Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,21 @@ publishing {

tasks {
processResources {
val name = project.name
val description = project.description
val version = project.version.toString()
val commitHash = project.latestCommitHash()

filesMatching(listOf("plugin.yml")) {
expand(
"name" to project.name,
"description" to project.description,
"mainClass" to "dev.pgm.events.EventsPlugin",
"version" to project.version,
"commitHash" to project.latestCommitHash(),
"url" to "https://pgm.dev/"
mapOf(
"name" to name,
"description" to description,
"mainClass" to "dev.pgm.events.EventsPlugin",
"version" to version,
"commitHash" to commitHash,
"url" to "https://pgm.dev/"
)
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {
}

dependencies {
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:7.0.0.BETA4")
implementation("de.skuzzle.restrictimports:restrict-imports-gradle-plugin:2.6.0")
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.3.1")
implementation("com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:8.2.0")
implementation("de.skuzzle.restrictimports:de.skuzzle.restrictimports.gradle.plugin:3.0.0")
}
19 changes: 12 additions & 7 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,25 @@ repositories {
}

dependencies {
compileOnly("dev.pgm.paper:paper-api:1.8_1.21.1-SNAPSHOT")
api("org.jspecify:jspecify:1.0.0")
compileOnly("dev.pgm.paper:paper-api:1.8_1.21.10-SNAPSHOT")
compileOnly("tc.oc.pgm:core:0.16-SNAPSHOT")
compileOnly("net.md-5:bungeecord-chat:1.20-R0.2-deprecated+build.18")
compileOnly("net.kyori:adventure-api:4.26.1")
compileOnly("net.kyori:adventure-text-serializer-plain:4.26.1")
compileOnly("net.md-5:bungeecord-chat:1.21-R0.2")
compileOnly("org.incendo:cloud-annotations:2.0.0")
compileOnly("org.jetbrains:annotations:22.0.0")
compileOnly("org.jetbrains:annotations:26.0.2-1")
}

group = "dev.pgm"
version = "1.0.0-SNAPSHOT"
description = "Manage PvP tournament events"

tasks {
withType<JavaCompile>() {
withType<JavaCompile> {
options.encoding = "UTF-8"
}
withType<Javadoc>() {
withType<Javadoc> {
options.encoding = "UTF-8"
}
}
Expand All @@ -43,14 +46,16 @@ spotless {
ratchetFrom = "origin/master"
java {
removeUnusedImports()
palantirJavaFormat("2.47.0").style("GOOGLE").formatJavadoc(true)
trimTrailingWhitespace()
formatAnnotations()
palantirJavaFormat("2.85.0").style("GOOGLE").formatJavadoc(true)
}
}


restrictImports {
group {
reason = "Use org.jetbrains.annotations to add annotations"
reason = "Use org.jspecify.annotations to add annotations, or org.jetbrains.annotations if needed"
bannedImports = listOf("javax.annotation.**")
}
group {
Expand Down
11 changes: 4 additions & 7 deletions buildSrc/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import org.gradle.api.Project
import java.io.ByteArrayOutputStream


fun Project.latestCommitHash(): String {
return runGitCommand(listOf("rev-parse", "--short", "HEAD"))
}

fun Project.runGitCommand(args: List<String>): String {
val byteOut = ByteArrayOutputStream()
exec {
commandLine = listOf("git") + args
standardOutput = byteOut
}
return byteOut.toString(Charsets.UTF_8.name()).trim()
return providers.exec {
commandLine("git")
args(args)
}.standardOutput.asText.get().trim()
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.gradle.configuration-cache=true
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
12 changes: 4 additions & 8 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 93 additions & 0 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 17 additions & 20 deletions src/main/java/dev/pgm/events/api/teams/ConfigTeams.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ public List<? extends TournamentTeam> getTeams() {
private static List<TournamentTeam> parseTournamentTeams(File teamsFolder, File teamsFile) {
if (!teamsFolder.exists()) teamsFolder.mkdirs();

List<TournamentTeam> teamList = new ArrayList<TournamentTeam>();
List<TournamentTeam> teamList = new ArrayList<>();
for (File child :
teamsFolder.listFiles((file) -> file.getName().toLowerCase().endsWith(".yml"))) {
FileConfiguration config = YamlConfiguration.loadConfiguration(child);
String teamName = config.getString("name");
List<TournamentPlayer> players =
config.getStringList("players").stream()
.map(String::trim)
.map(UUID::fromString)
.map(x -> TournamentPlayer.create(x, true))
.collect(Collectors.toList());
List<TournamentPlayer> players = config.getStringList("players").stream()
.map(String::trim)
.map(UUID::fromString)
.map(x -> TournamentPlayer.create(x, true))
.collect(Collectors.toList());

teamList.add(TournamentTeam.create(teamName, players));
}
Expand All @@ -43,24 +42,22 @@ private static List<TournamentTeam> parseTournamentTeams(File teamsFolder, File
YamlConfiguration teamsConfig = YamlConfiguration.loadConfiguration(teamsFile);
for (Object object : teamsConfig.getList("teams")) {
if (!(object instanceof Map<?, ?>)) {
System.out.println(
"Invalid type in teams.yml ("
+ object.getClass().getName()
+ ": "
+ object.toString()
+ ")! Skipping...");
System.out.println("Invalid type in teams.yml ("
+ object.getClass().getName()
+ ": "
+ object
+ ")! Skipping...");
continue;
}

Map<Object, Object> team = (Map<Object, Object>) object;
String teamName = (String) team.get("name");
List<TournamentPlayer> players =
((List<String>) team.get("players"))
.stream()
.map(String::trim)
.map(UUID::fromString)
.map(x -> TournamentPlayer.create(x, true))
.collect(Collectors.toList());
List<TournamentPlayer> players = ((List<String>) team.get("players"))
.stream()
.map(String::trim)
.map(UUID::fromString)
.map(x -> TournamentPlayer.create(x, true))
.collect(Collectors.toList());

teamList.add(TournamentTeam.create(teamName, players));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import net.kyori.adventure.text.Component;
import net.kyori.adventure.util.ComponentMessageThrowable;
import org.jetbrains.annotations.Nullable;
import org.jspecify.annotations.Nullable;

public class CommandException extends RuntimeException implements ComponentMessageThrowable {

Expand Down
29 changes: 14 additions & 15 deletions src/main/java/dev/pgm/events/commands/TournamentAdminCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public void register(
for (TournamentPlayer player : team.getPlayers()) {
Player bukkit = Bukkit.getPlayer(player.getUUID());
MatchPlayer mp = matchManager.getPlayer(bukkit);
if (bukkit != null && Integration.isVanished(bukkit)) Integration.setVanished(mp, false, false);
if (bukkit != null && Integration.isVanished(bukkit))
Integration.setVanished(mp, false, false);
}

teamManager.addTeam(team);
Expand All @@ -65,13 +66,12 @@ public void register(
@CommandDescription("List all loaded teams")
@Permission("events.staff")
public void list(CommandSender sender, TournamentTeamRegistry registry) {
sender.sendMessage(
ChatColor.GOLD
+ "------- "
+ ChatColor.AQUA
+ "Registered Teams"
+ ChatColor.GOLD
+ " -------");
sender.sendMessage(ChatColor.GOLD
+ "------- "
+ ChatColor.AQUA
+ "Registered Teams"
+ ChatColor.GOLD
+ " -------");
for (TournamentTeam team : registry.getTeams())
sender.sendMessage(ChatColor.AQUA + "- " + team.getName());
sender.sendMessage(ChatColor.YELLOW + "Run /tourney info <team> to see player roster!");
Expand All @@ -87,13 +87,12 @@ public void info(
TournamentTeam team = registry.getTeam(name);
if (team == null) throw new CommandException("Team not found!");

sender.sendMessage(
ChatColor.GOLD
+ "------- "
+ ChatColor.AQUA
+ team.getName()
+ ChatColor.GOLD
+ " -------");
sender.sendMessage(ChatColor.GOLD
+ "------- "
+ ChatColor.AQUA
+ team.getName()
+ ChatColor.GOLD
+ " -------");
for (TournamentPlayer player : team.getPlayers()) {
String playerName =
player.getUUID().toString() + ChatColor.GRAY + " (player hasn't logged on)";
Expand Down
Loading