Skip to content
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
name: Setup Java
uses: actions/setup-java@v4
with:
java-version: 21
java-version: 25
distribution: temurin
# Configures gradle with caching
- name: Setup Gradle
Expand Down
4 changes: 2 additions & 2 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:com.gradleup.shadow.gradle.plugin:9.3.1")
implementation("com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:8.2.1")
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.5.1")
implementation("com.diffplug.gradle.spotless:com.diffplug.gradle.spotless.gradle.plugin:8.8.0")
implementation("de.skuzzle.restrictimports:de.skuzzle.restrictimports.gradle.plugin:3.0.0")
}
35 changes: 23 additions & 12 deletions buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(25)
}
}

Expand All @@ -17,32 +17,43 @@ repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots/") // Snapshots
maven("https://repo.viaversion.com/") // ViaVersion
maven("https://repo.pgm.fyi/snapshots") // SportPaper & other PGM-specific stuff
maven("https://jitpack.io") // MinusKube SmartsInv fix for shift click
maven("https://repo.codemc.io/repository/maven-releases/") // PacketEvents
exclusiveContent {
forRepository {
maven("https://jitpack.io")
}
filter {
includeGroup("com.github.OvercastCommunity.adventure-platform")
includeGroup("com.github.MinusKube")
}
}
}

dependencies {
api("org.jdom:jdom2:2.0.6.1")
api("net.kyori:adventure-api:4.26.1")
api("net.kyori:adventure-text-serializer-plain:4.26.1")
api("net.kyori:adventure-platform-bukkit:4.4.1")
api("net.kyori:adventure-api:5.2.0")
api("net.kyori:adventure-text-serializer-plain:5.2.0")
// adventure-platform fork supporting Adventure 5.x
// https://github.com/OvercastCommunity/adventure-platform
api("com.github.OvercastCommunity.adventure-platform:adventure-platform-bukkit:b4bfb8a6b4")
api("org.incendo:cloud-core:2.0.0")
api("org.incendo:cloud-annotations:2.0.0")
api("org.incendo:cloud-paper:2.0.0-beta.14")
api("org.incendo:cloud-minecraft-extras:2.0.0-beta.14")
api("org.incendo:cloud-paper:2.0.0-beta.17")
api("org.incendo:cloud-minecraft-extras:2.0.0-beta.17")
api("me.lucko:commodore:2.2")
api("fr.mrmicky:fastboard:2.1.5")
api("fr.mrmicky:fastboard:2.2.0")
// Latest SmartInvs commit
api("com.github.MinusKube:SmartInvs:9c9dbbe") { isTransitive = false }
api("org.eclipse.jgit:org.eclipse.jgit:7.5.0.202512021534-r") { isTransitive = false }
api("org.eclipse.jgit:org.eclipse.jgit:7.7.0.202606012155-r") { isTransitive = false }
api("net.objecthunter:exp4j:0.4.9-pgm")
api("org.reflections:reflections:0.10.2")

// Annotations
api("org.jspecify:jspecify:1.0.0")
compileOnly("org.jetbrains:annotations:26.0.2-1")
compileOnly("org.jetbrains:annotations:26.1.0")

// Optional runtime dependencies
compileOnly("com.github.retrooper:packetevents-spigot:2.12.0")
compileOnly("com.github.retrooper:packetevents-spigot:2.13.0")
compileOnly("com.viaversion:viaversion-api:5.0.0")

// Paper and SportPaper include these (or equivalents)
Expand Down Expand Up @@ -71,7 +82,7 @@ spotless {
removeUnusedImports()
trimTrailingWhitespace()
formatAnnotations()
palantirJavaFormat("2.87.0").style("GOOGLE").formatJavadoc(true)
palantirJavaFormat("2.96.0").style("GOOGLE").formatJavadoc(true)
}
}

Expand Down
7 changes: 4 additions & 3 deletions buildSrc/src/main/kotlin/extensions.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import org.gradle.api.Project
import org.gradle.api.provider.Provider


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

fun Project.runGitCommand(args: List<String>): String {
fun Project.runGitCommand(args: List<String>): Provider<String> {
return providers.exec {
commandLine("git")
args(args)
}.standardOutput.asText.get().trim()
}.standardOutput.asText.map { it.trim() }
}
8 changes: 5 additions & 3 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

dependencies {
compileOnly("dev.pgm.paper:paper-api:1.8_1.21.11-SNAPSHOT")
compileOnly("dev.pgm.paper:paper-api:1.8_26.2-SNAPSHOT")

implementation(project(":util"))
runtimeOnly(project(":platform-sportpaper")) { exclude("*") }
Expand Down Expand Up @@ -86,15 +86,17 @@ tasks {
val version = project.version.toString()
val commitHash = project.latestCommitHash()

inputs.property("commitHash", commitHash)

filesMatching(listOf("plugin.yml", "paper-plugin.yml")) {
expand(
mapOf(
"name" to name,
"description" to description,
"apiVersion" to "1.21.11",
"apiVersion" to "26.2",
"mainClass" to "tc.oc.pgm.PGMPlugin",
"version" to version,
"commitHash" to commitHash,
"commitHash" to commitHash.get(),
"url" to "https://pgm.dev/"
)
)
Expand Down
15 changes: 3 additions & 12 deletions core/src/main/java/tc/oc/pgm/PGMPlugin.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tc.oc.pgm;

import static tc.oc.pgm.util.bukkit.MiscUtils.MISC_UTILS;

import com.google.common.collect.Lists;
import fr.minuskube.inv.InventoryManager;
import java.io.File;
Expand Down Expand Up @@ -67,8 +69,6 @@
import tc.oc.pgm.rotation.MapPoolManager;
import tc.oc.pgm.rotation.RandomMapOrder;
import tc.oc.pgm.tablist.MatchTabManager;
import tc.oc.pgm.util.FileUtils;
import tc.oc.pgm.util.bukkit.ViaUtils;
import tc.oc.pgm.util.chunk.NullChunkGenerator;
import tc.oc.pgm.util.concurrent.BukkitExecutorService;
import tc.oc.pgm.util.listener.AfkTracker;
Expand Down Expand Up @@ -133,8 +133,6 @@ public void onEnable() {
getLogger().log(Level.SEVERE, "Failed to initialize PGM platform", t);
getServer().getPluginManager().disablePlugin(this);
}
// Fix before any audiences have the chance of creating
if (Platform.isLegacy()) ViaUtils.removeViaChatFacet();

Permissions.registerAll();

Expand Down Expand Up @@ -212,14 +210,7 @@ public void onEnable() {
config.getGroups().isEmpty() ? null : new ConfigDecorationProvider());

// Sometimes match folders need to be cleaned up if the server previously crashed
final File[] worldDirs = getServer().getWorldContainer().listFiles();
if (worldDirs != null) {
for (File dir : worldDirs) {
if (dir.isDirectory() && Match.isMatchWorld(dir.getName())) {
FileUtils.delete(dir);
}
}
}
MISC_UTILS.cleanupWorldFiles();

matchManager = new MatchManagerImpl(logger);

Expand Down
20 changes: 14 additions & 6 deletions core/src/main/java/tc/oc/pgm/action/actions/MessageAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import net.kyori.adventure.title.Title;
import org.jspecify.annotations.NonNull;
import org.jspecify.annotations.Nullable;
import tc.oc.pgm.action.replacements.Replacement;
import tc.oc.pgm.filters.Filterable;
Expand Down Expand Up @@ -71,18 +72,25 @@ private Component replaceClickEvents(
Component component, Function<MatchResult, String> replacer) {
var click = component.clickEvent();
if (click != null && click.payload() instanceof ClickEvent.Payload.Text payload) {
var matcher = PATTERN.matcher(payload.value());
var result = new StringBuilder();
while (matcher.find()) matcher.appendReplacement(result, replacer.apply(matcher));
matcher.appendTail(result);
var resultPayload = ClickEvent.Payload.string(result.toString());
component = component.clickEvent(ClickEvent.clickEvent(click.action(), resultPayload));
component = component.clickEvent(replaceEvent(click, payload, replacer));
}
var children = new ArrayList<>(component.children());
children.replaceAll(child -> replaceClickEvents(child, replacer));
return component.children(children);
}

private @NonNull ClickEvent replaceEvent(
ClickEvent click,
ClickEvent.Payload.@NonNull Text payload,
Function<MatchResult, String> replacer) {
var matcher = PATTERN.matcher(payload.value());
var result = new StringBuilder();
while (matcher.find()) matcher.appendReplacement(result, replacer.apply(matcher));
matcher.appendTail(result);
var resultPayload = ClickEvent.Payload.string(result.toString());
return ClickEvent.clickEvent(click.action(), resultPayload);
}

private Title replace(Title title, T scope) {
if (replacements == null) return title;
return Title.title(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -144,13 +145,14 @@ class Beam {

ItemStack wool =
new ItemBuilder().material(Materials.WOOL).color(flag.getDyeColor()).build();
this.base = ENTITIES.fakeArmorStand(wool);
this.legacyBase = ENTITIES.fakeWitherSkull();
World world = match.getWorld();
this.base = ENTITIES.fakeArmorStand(wool, world);
this.legacyBase = ENTITIES.fakeWitherSkull(world);
this.segments = range(
0, 64) // ~100 blocks is the height which the particles appear to be reasonably
// visible (similar amount to amount closest to the flag), we limit this to 64 blocks
// to reduce load on the client
.mapToObj(i -> ENTITIES.fakeArmorStand(wool))
.mapToObj(_ -> ENTITIES.fakeArmorStand(wool, match.getWorld()))
.collect(Collectors.toList());
}

Expand Down
5 changes: 3 additions & 2 deletions core/src/main/java/tc/oc/pgm/match/MatchImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static tc.oc.pgm.util.Assert.assertNotNull;
import static tc.oc.pgm.util.Assert.assertTrue;
import static tc.oc.pgm.util.bukkit.MiscUtils.MISC_UTILS;
import static tc.oc.pgm.util.nms.NMSHacks.NMS_HACKS;

import com.google.common.collect.ImmutableList;
Expand Down Expand Up @@ -946,8 +947,8 @@ public void destroy() {
Level.SEVERE, "Unable to unload world " + worldName + " (this can cause memory leaks!)");
}

final File oldMatchFolder = new File(PGM.get().getServer().getWorldContainer(), worldName);
if (oldMatchFolder.exists()) {
final File oldMatchFolder = MISC_UTILS.getWorldFolder(worldName);
if (oldMatchFolder != null && oldMatchFolder.exists()) {
FileUtils.delete(oldMatchFolder);
}
}
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/tc/oc/pgm/match/MatchPlayerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@
import tc.oc.pgm.util.bukkit.ViaUtils;
import tc.oc.pgm.util.listener.AfkTracker;
import tc.oc.pgm.util.named.NameStyle;
import tc.oc.pgm.util.nms.packets.FakeEntity;

public class MatchPlayerImpl implements MatchPlayer, Comparable<MatchPlayer> {

// TODO: Probably should be moved to a better location
private static final int FROZEN_VEHICLE_ENTITY_ID = NMS_HACKS.allocateEntityId();

private static final String DEATH_KEY = "isDead";
private static final MetadataValue DEATH_VALUE = new FixedMetadataValue(PGM.get(), true);

Expand All @@ -80,6 +78,7 @@ public class MatchPlayerImpl implements MatchPlayer, Comparable<MatchPlayer> {
private final AtomicBoolean visible;
private final AtomicBoolean protocolReady;
private final AtomicInteger protocolVersion;
private final FakeEntity frozenVehicle;
private final AfkTracker.Activity activity;
private long lastKitTick = 0;

Expand All @@ -96,6 +95,7 @@ public MatchPlayerImpl(Match match, Player player) {
this.visible = new AtomicBoolean(false);
this.protocolReady = new AtomicBoolean(ViaUtils.isReady(player));
this.protocolVersion = new AtomicInteger(ViaUtils.getProtocolVersion(player));
this.frozenVehicle = ENTITIES.fakeFreezeEntity(player, this::isLegacy);
this.activity = PGM.get().getAfkTracker().getActivity(player);
}

Expand Down Expand Up @@ -335,10 +335,10 @@ public void setFrozen(boolean yes) {
if (bukkit == null) return;

if (yes) {
ENTITIES.spawnFreezeEntity(bukkit, FROZEN_VEHICLE_ENTITY_ID, isLegacy()).send(bukkit);
ENTITIES.entityMount(bukkit.getEntityId(), FROZEN_VEHICLE_ENTITY_ID).send(bukkit);
frozenVehicle.spawn(bukkit.getLocation()).send(bukkit);
frozenVehicle.ride(bukkit.getEntityId()).send(bukkit);
} else {
ENTITIES.destroyEntitiesPacket(FROZEN_VEHICLE_ENTITY_ID).send(bukkit);
frozenVehicle.destroy().send(bukkit);
}
resetInteraction();
}
Expand Down Expand Up @@ -453,7 +453,7 @@ public void tick(Match match, Tick tick) {
// If the player right-clicks on another vehicle while frozen, the client will
// eject them from the freeze entity unconditionally, so we have to spam them
// with these packets to keep them on it.
ENTITIES.entityMount(bukkit.getEntityId(), FROZEN_VEHICLE_ENTITY_ID).send(bukkit);
frozenVehicle.ride(bukkit.getEntityId()).send(bukkit);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onSlimeSplit(CreatureSpawnEvent event) {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSlimeSplit(SlimeSplitEvent event) {
if (event.getCount() > 0 && resolveEntity(event.getEntity()) != null) {
splitter = new WeakReference<>(event.getEntity());
splitter = new WeakReference<>((Slime) event.getEntity());
}
}
}
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.configuration-cache=true
# https://github.com/diffplug/spotless/issues/2850
org.gradle.configuration-cache=false
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions gradlew

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

4 changes: 2 additions & 2 deletions platform/platform-modern/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id("buildlogic.java-conventions")
id("io.papermc.paperweight.userdev") version "2.0.0-beta.19"
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21"
}

dependencies {
implementation(project(":core"))
implementation(project(":util"))
paperweight.paperDevBundle("1.21.11-R0.1-SNAPSHOT")
paperweight.paperDevBundle("26.2.build.+")
}
paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION
Loading
Loading