Skip to content

Commit

Permalink
Remove enum compatibility option
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Jul 18, 2024
1 parent 15cb355 commit 65dd605
Show file tree
Hide file tree
Showing 26 changed files with 122 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ index 10ce6b9f748b69283e03454e9b1ed0b7df379a17..002449e66f83a419afa8357d2e719267
@Override
public B get(NamespacedKey namespacedKey) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 856de462a5a92d00896b5454244014eae2cdbf24..10f99b75406176bc11947dde53d94a714d8d28e0 100644
index 856de462a5a92d00896b5454244014eae2cdbf24..a29f4992f7927d0f241962f972dd13ce77094d97 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -281,7 +281,7 @@ public final class CraftServer implements Server {
Expand All @@ -851,7 +851,15 @@ index 856de462a5a92d00896b5454244014eae2cdbf24..10f99b75406176bc11947dde53d94a71
private YamlConfiguration configuration;
private YamlConfiguration commandsConfiguration;
private final Yaml yaml = new Yaml(new SafeConstructor(new LoaderOptions()));
@@ -2729,7 +2729,7 @@ public final class CraftServer implements Server {
@@ -428,6 +428,7 @@ public final class CraftServer implements Server {
}

private void loadCompatibilities() {
+ if (true) return; // Paper - Big nope
ConfigurationSection compatibilities = this.configuration.getConfigurationSection("settings.compatibility");
if (compatibilities == null) {
this.activeCompatibilities = Collections.emptySet();
@@ -2729,7 +2730,7 @@ public final class CraftServer implements Server {

@Override
public <T extends Keyed> Registry<T> getRegistry(Class<T> aClass) {
Expand Down Expand Up @@ -884,6 +892,47 @@ index 1f58b92c17d28e14621e8dc28042a5368f1f4a1f..ef80e6b4dff557daaab1b9fde4d8d401

// PatternType
private static final FieldRenameData PATTERN_TYPE_DATA = FieldRenameData.Builder.newBuilder()
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
index eeaa9787c7e04e7155b93aa8d83bd073e8dc209e..07e3ff72a186165734da56cb0a60138b7b77dc5a 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -189,20 +189,10 @@ public class Commodore {

public static byte[] convert(byte[] b, final String pluginName, final ApiVersion pluginVersion, final Set<String> activeCompatibilities) {
final boolean modern = pluginVersion.isNewerThanOrSameAs(ApiVersion.FLATTENING);
- final boolean enumCompatibility = pluginVersion.isOlderThanOrSameAs(ApiVersion.getOrCreateVersion("1.20.6")) && activeCompatibilities.contains("enum-compatibility-mode");
ClassReader cr = new ClassReader(b);
ClassWriter cw = new ClassWriter(0); // TODO 2024-06-22: Open PR to ASM to included interface in handle hash

- List<String> methodEnumSignatures = Commodore.getMethodSignatures(b);
- Multimap<String, String> enumLessToEnum = HashMultimap.create();
- for (String method : methodEnumSignatures) {
- enumLessToEnum.put(method.replace("Ljava/lang/Enum;", "Ljava/lang/Object;"), method);
- }
-
ClassVisitor visitor = cw;
- if (enumCompatibility) {
- visitor = new LimitedClassRemapper(cw, new SimpleRemapper(Commodore.ENUM_RENAMES));
- }

cr.accept(new ClassRemapper(new ClassVisitor(Opcodes.ASM9, io.papermc.paper.pluginremap.reflect.ReflectionRemapper.visitor(visitor)) { // Paper
final Set<RerouteMethodData> rerouteMethodData = new HashSet<>();
@@ -268,15 +258,6 @@ public class Commodore {

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- if (enumCompatibility && (access & Opcodes.ACC_SYNTHETIC) != 0 && (access & Opcodes.ACC_BRIDGE) != 0 && desc.contains("Ljava/lang/Object;")) {
- // SPIGOT-7820: Do not use object method if enum method is present
- // The object method does only redirect to the enum method
- Collection<String> result = enumLessToEnum.get(desc.replace("Ljava/lang/Enum;", "Ljava/lang/Object;") + " " + name);
- if (result.size() == 2) {
- name = name + "_BUKKIT_UNUSED";
- }
- }
-
return new MethodVisitor(this.api, super.visitMethod(access, name, desc, signature, exceptions)) {
// Paper start - Plugin rewrites
@Override
diff --git a/src/main/resources/META-INF/services/io.papermc.paper.registry.RegistryAccess b/src/main/resources/META-INF/services/io.papermc.paper.registry.RegistryAccess
new file mode 100644
index 0000000000000000000000000000000000000000..8a083d45004f82fc9c51c219fb20f34624adb501
Expand All @@ -892,17 +941,19 @@ index 0000000000000000000000000000000000000000..8a083d45004f82fc9c51c219fb20f346
@@ -0,0 +1 @@
+io.papermc.paper.registry.PaperRegistryAccess
diff --git a/src/main/resources/configurations/bukkit.yml b/src/main/resources/configurations/bukkit.yml
index 543e37737bc6fdca23ed9ed0606805d345515a5a..818a1d2e152e45a28aa5b0d1acd0e6dc300d9054 100644
index 543e37737bc6fdca23ed9ed0606805d345515a5a..eef7c125b2689f29cae5464659eacdf33f5695b2 100644
--- a/src/main/resources/configurations/bukkit.yml
+++ b/src/main/resources/configurations/bukkit.yml
@@ -24,7 +24,6 @@ settings:
@@ -23,9 +23,6 @@ settings:
shutdown-message: Server closed
minimum-api: none
use-map-color-cache: true
compatibility:
- compatibility:
- allow-old-keys-in-registry: false
enum-compatibility-mode: false
- enum-compatibility-mode: false
spawn-limits:
monsters: 70
animals: 10
diff --git a/src/test/java/io/papermc/paper/registry/LegacyRegistryIdentifierTest.java b/src/test/java/io/papermc/paper/registry/LegacyRegistryIdentifierTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..b9d00e65639521eecd44bd2be3e012264c3785f5
Expand Down
8 changes: 4 additions & 4 deletions patches/server/0504-Expand-world-key-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ index 1963e826548c5a8859c50f57654784c3aef50e44..04a39cb6c13c26e2cb1d73a9da98df5d
// Paper end
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 10f99b75406176bc11947dde53d94a714d8d28e0..e826af8b23b5850f7a9164d088bce936cc082f4a 100644
index a29f4992f7927d0f241962f972dd13ce77094d97..f83eb7fd5c9b368ba0bf9e07a568d69c6566a5af 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1180,9 +1180,15 @@ public final class CraftServer implements Server {
@@ -1181,9 +1181,15 @@ public final class CraftServer implements Server {
File folder = new File(this.getWorldContainer(), name);
World world = this.getWorld(name);

Expand All @@ -41,7 +41,7 @@ index 10f99b75406176bc11947dde53d94a714d8d28e0..e826af8b23b5850f7a9164d088bce936

if (folder.exists()) {
Preconditions.checkArgument(folder.isDirectory(), "File (%s) exists and isn't a folder", name);
@@ -1308,7 +1314,7 @@ public final class CraftServer implements Server {
@@ -1309,7 +1315,7 @@ public final class CraftServer implements Server {
} else if (name.equals(levelName + "_the_end")) {
worldKey = net.minecraft.world.level.Level.END;
} else {
Expand All @@ -50,7 +50,7 @@ index 10f99b75406176bc11947dde53d94a714d8d28e0..e826af8b23b5850f7a9164d088bce936
}

// If set to not keep spawn in memory (changed from default) then adjust rule accordingly
@@ -1404,6 +1410,15 @@ public final class CraftServer implements Server {
@@ -1405,6 +1411,15 @@ public final class CraftServer implements Server {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0533-Add-basic-Datapack-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ index 0000000000000000000000000000000000000000..cf4374493c11057451a62a655514415c
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e826af8b23b5850f7a9164d088bce936cc082f4a..e0bb97be1a1f082ec647f92271b2b7f8071a49f4 100644
index f83eb7fd5c9b368ba0bf9e07a568d69c6566a5af..691ad3df67ff32528ac18c2927e96c91db25741e 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -305,6 +305,7 @@ public final class CraftServer implements Server {
Expand All @@ -111,7 +111,7 @@ index e826af8b23b5850f7a9164d088bce936cc082f4a..e0bb97be1a1f082ec647f92271b2b7f8
}

public boolean getCommandBlockOverride(String command) {
@@ -3008,5 +3010,11 @@ public final class CraftServer implements Server {
@@ -3009,5 +3011,11 @@ public final class CraftServer implements Server {
public com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return mobGoals;
}
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0590-Add-more-advancement-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ index 8ca86852319d7463f60832bc98b825b0b4325995..62ada73302c6b3ce3fb2dcc8c31a1d9c

private final DisplayInfo handle;
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
index eeaa9787c7e04e7155b93aa8d83bd073e8dc209e..ca099f7c94d19890eabf3eaf03e93c0383374d1a 100644
index 07e3ff72a186165734da56cb0a60138b7b77dc5a..376520f5136dca50a3f35a42bd1f19091df36dfd 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -452,6 +452,11 @@ public class Commodore {
@@ -433,6 +433,11 @@ public class Commodore {
super.visitMethodInsn(opcode, owner, name, "()Lcom/destroystokyo/paper/profile/PlayerProfile;", itf);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0591-Add-ItemFactory-getSpawnEgg-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ index eabb8b42b890224dd19b879ff276e9908674310d..803a19063c03627dbea79cb1c395ae35
+ // Paper end - old getSpawnEgg API
}
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
index ca099f7c94d19890eabf3eaf03e93c0383374d1a..f379ea0f7b42492dd0bf23202e5f417b2981aea9 100644
index 376520f5136dca50a3f35a42bd1f19091df36dfd..0103dcc3f34e07c540e7db0f9bf32c358ccef8f2 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -459,6 +459,15 @@ public class Commodore {
@@ -440,6 +440,15 @@ public class Commodore {
}
// Paper end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,10 @@ index 58ea6a1f95a09c22125a8262b1b221004ebce0e4..ea6533c1ac218aa075da3401807a06fc
BlockPos blockposition = NaturalSpawner.getRandomPosWithin(world, chunk);

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b788be6e8610d8f5ad4c082bcb6d211dbb46ecdd..fb804ddfe3c1927a36da365a7ba8d3826f61305a 100644
index c57428b235f7bc0444ba0024d05c7c15b5e74fc4..9707b24da58fdc56732d6372038055e8676e9e0d 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2328,6 +2328,11 @@ public final class CraftServer implements Server {
@@ -2329,6 +2329,11 @@ public final class CraftServer implements Server {

@Override
public int getSpawnLimit(SpawnCategory spawnCategory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ index 6ad7c34513034c87059f8a0790aea3231dd0d2a9..188b1844ca6ee5a97f7a588121255417
biomeProvider = gen.getDefaultBiomeProvider(worldInfo);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index fb804ddfe3c1927a36da365a7ba8d3826f61305a..935feb8a3beb410702e416eb7c4d21d023fbfc2f 100644
index 9707b24da58fdc56732d6372038055e8676e9e0d..05dbcff299d42dc05e3a8db0265fb607197731e7 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1305,7 +1305,7 @@ public final class CraftServer implements Server {
@@ -1306,7 +1306,7 @@ public final class CraftServer implements Server {
List<CustomSpawner> list = ImmutableList.of(new PhantomSpawner(), new PatrolSpawner(), new CatSpawner(), new VillageSiege(), new WanderingTraderSpawner(worlddata));
LevelStem worlddimension = iregistry.get(actualDimension);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ index 0000000000000000000000000000000000000000..e3a5f1ec376319bdfda87fa27ae217bf
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 935feb8a3beb410702e416eb7c4d21d023fbfc2f..df2117fabddeddd923831de4cbef798e330eb0c7 100644
index 05dbcff299d42dc05e3a8db0265fb607197731e7..e56894f16c49085c2de819334f6d0591c0ee8313 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2159,6 +2159,13 @@ public final class CraftServer implements Server {
@@ -2160,6 +2160,13 @@ public final class CraftServer implements Server {
return this.console.console;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Add missing Validate calls to CraftServer#getSpawnLimit
Copies appropriate checks from CraftWorld#getSpawnLimit

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index df2117fabddeddd923831de4cbef798e330eb0c7..1da887485d858df839cd9c04129fec6a0074f695 100644
index e56894f16c49085c2de819334f6d0591c0ee8313..4baa784788dba2e3bbb83ed59e003d07646abfc5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2336,6 +2336,8 @@ public final class CraftServer implements Server {
@@ -2337,6 +2337,8 @@ public final class CraftServer implements Server {
@Override
public int getSpawnLimit(SpawnCategory spawnCategory) {
// Paper start - Add mobcaps commands
Expand Down
6 changes: 3 additions & 3 deletions patches/server/0666-Add-GameEvent-tags.patch
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ index 0000000000000000000000000000000000000000..e7d9fd2702a1ce96596580fff8f5ee4f
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 1da887485d858df839cd9c04129fec6a0074f695..64e5cbb77db1f510647dc6cf83bac9e641e6f8cf 100644
index 4baa784788dba2e3bbb83ed59e003d07646abfc5..2cf3e1082e7d88d5450b44e99becc9db2c14a4d4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2685,6 +2685,15 @@ public final class CraftServer implements Server {
@@ -2686,6 +2686,15 @@ public final class CraftServer implements Server {
return (org.bukkit.Tag<T>) new CraftEntityTag(BuiltInRegistries.ENTITY_TYPE, entityTagKey);
}
}
Expand All @@ -65,7 +65,7 @@ index 1da887485d858df839cd9c04129fec6a0074f695..64e5cbb77db1f510647dc6cf83bac9e6
default -> throw new IllegalArgumentException();
}

@@ -2717,6 +2726,13 @@ public final class CraftServer implements Server {
@@ -2718,6 +2727,13 @@ public final class CraftServer implements Server {
net.minecraft.core.Registry<EntityType<?>> entityTags = BuiltInRegistries.ENTITY_TYPE;
return entityTags.getTags().map(pair -> (org.bukkit.Tag<T>) new CraftEntityTag(entityTags, pair.getFirst())).collect(ImmutableList.toImmutableList());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ index aa1fbbe55e3dc8fd6bbf021806c66686f8de3d9a..04286e907ff14cc8c45dbfc6ab12f520

if (worlddata.getCustomBossEvents() != null) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 64e5cbb77db1f510647dc6cf83bac9e641e6f8cf..9a0283d028f1e7035c3954449defe80ff62f6e9a 100644
index 2cf3e1082e7d88d5450b44e99becc9db2c14a4d4..6f6d4a82c350864a60f084eb341d59cf025cde77 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1331,10 +1331,11 @@ public final class CraftServer implements Server {
@@ -1332,10 +1332,11 @@ public final class CraftServer implements Server {
return null;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0673-Custom-Potion-Mixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ index c8f9972ad1c2330908cc840d426f29c20b242ca8..a2fafef89d5354e2cb02f56728109099
}

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 9a0283d028f1e7035c3954449defe80ff62f6e9a..f27961e61c797b5a36999949d14ee6f8ae311986 100644
index 6f6d4a82c350864a60f084eb341d59cf025cde77..ee6bdc985e8396e873bfd5c1f1d0046e2e830784 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -308,6 +308,7 @@ public final class CraftServer implements Server {
Expand All @@ -301,7 +301,7 @@ index 9a0283d028f1e7035c3954449defe80ff62f6e9a..f27961e61c797b5a36999949d14ee6f8
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
}

@@ -3048,5 +3050,9 @@ public final class CraftServer implements Server {
@@ -3049,5 +3051,9 @@ public final class CraftServer implements Server {
return datapackManager;
}

Expand Down
4 changes: 2 additions & 2 deletions patches/server/0684-Fix-saving-in-unloadWorld.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Fix saving in unloadWorld
Change savingDisabled to false to ensure ServerLevel's saving logic gets called when unloadWorld is called with save = true

diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index f27961e61c797b5a36999949d14ee6f8ae311986..adc8d512bd27bb13fa4896f1930aca70fe16607d 100644
index ee6bdc985e8396e873bfd5c1f1d0046e2e830784..d80691928310059ab9d834ebf050c0214fbdd8bc 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1380,7 +1380,7 @@ public final class CraftServer implements Server {
@@ -1381,7 +1381,7 @@ public final class CraftServer implements Server {

try {
if (save) {
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0696-WorldCreator-keepSpawnLoaded.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ Subject: [PATCH] WorldCreator#keepSpawnLoaded


diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index adc8d512bd27bb13fa4896f1930aca70fe16607d..7f34f198335cf025fbfa4b647f2cee4a548844f8 100644
index d80691928310059ab9d834ebf050c0214fbdd8bc..c5f736ad83c0296c3291ad71278598eb00db436c 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1323,7 +1323,7 @@ public final class CraftServer implements Server {
@@ -1324,7 +1324,7 @@ public final class CraftServer implements Server {
}

// If set to not keep spawn in memory (changed from default) then adjust rule accordingly
Expand Down
Loading

0 comments on commit 65dd605

Please sign in to comment.