diff options
author | md_5 <git@md-5.net> | 2018-07-15 15:00:35 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-07-15 15:00:35 +1000 |
commit | 72cf620d474ca21b5369b61136e286101f2f635a (patch) | |
tree | 8217d7f3f2413f06bf5e21e8aa7ec674e19a29e1 /src | |
parent | 421c1728c81e2f729dff88da2ac96535d2b8e5e8 (diff) | |
download | craftbukkit-72cf620d474ca21b5369b61136e286101f2f635a.tar craftbukkit-72cf620d474ca21b5369b61136e286101f2f635a.tar.gz craftbukkit-72cf620d474ca21b5369b61136e286101f2f635a.tar.lz craftbukkit-72cf620d474ca21b5369b61136e286101f2f635a.tar.xz craftbukkit-72cf620d474ca21b5369b61136e286101f2f635a.zip |
SPIGOT-4002: Fix usage of default: statements in 1.13 plugins compiled w/ Eclipse
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/util/Commodore.java | 3 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index aefba149..cc877f0a 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -196,6 +196,9 @@ public class Commodore case "values": super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/util/CraftLegacy", "modern_" + name, desc, itf ); return; + case "ordinal": + super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftLegacy", "modern_" + name, "(Lorg/bukkit/Material;)I", false ); + return; } } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java index 5965e82c..4ecba728 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java @@ -221,6 +221,15 @@ public class CraftLegacy { return Arrays.copyOfRange(values, 0, Material.LEGACY_AIR.ordinal()); } + public static int modern_ordinal(Material material) { + if (material.isLegacy()) { + // SPIGOT-4002: Fix for eclipse compiler manually compiling in default statements to lookupswitch + throw new NoSuchFieldError("Legacy field ordinal: " + material); + } + + return material.ordinal(); + } + static { SPAWN_EGGS.put(EntityType.BAT, Material.BAT_SPAWN_EGG); SPAWN_EGGS.put(EntityType.BLAZE, Material.BLAZE_SPAWN_EGG); |