SPIGOT-5536: Material.values() causes legacy data init

Dieser Commit ist enthalten in:
md_5 2020-01-23 08:53:36 +11:00
Ursprung a81f6ed397
Commit a0e88fb362
4 geänderte Dateien mit 18 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -248,20 +248,6 @@ public final class CraftLegacy {
return name(material);
}
public static Material[] modern_values() {
Material[] values = Material.values();
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();
}
public static void init() {
//
}

Datei anzeigen

@ -243,10 +243,10 @@ public class Commodore
switch ( name )
{
case "values":
super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/legacy/CraftLegacy", "modern_" + name, desc, itf );
super.visitMethodInsn( opcode, "org/bukkit/craftbukkit/util/CraftLegacy", "modern_" + name, desc, itf );
return;
case "ordinal":
super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/legacy/CraftLegacy", "modern_" + name, "(Lorg/bukkit/Material;)I", false );
super.visitMethodInsn( Opcodes.INVOKESTATIC, "org/bukkit/craftbukkit/util/CraftLegacy", "modern_" + name, "(Lorg/bukkit/Material;)I", false );
return;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package org.bukkit.craftbukkit.util;
import java.util.Arrays;
import org.bukkit.Material;
import org.bukkit.material.MaterialData;
@ -24,4 +25,18 @@ public final class CraftLegacy {
public static Material fromLegacy(MaterialData materialData) {
return org.bukkit.craftbukkit.legacy.CraftLegacy.fromLegacy(materialData);
}
public static Material[] modern_values() {
Material[] values = Material.values();
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();
}
}

Datei anzeigen

@ -99,7 +99,7 @@ public class LegacyTest extends AbstractTestingBase {
Assert.assertTrue("Must iterate only legacy materials", material.isLegacy());
}
for (Material material : CraftLegacy.modern_values()) {
for (Material material : org.bukkit.craftbukkit.util.CraftLegacy.modern_values()) {
Assert.assertFalse("Must iterate only modern materials", material.isLegacy());
}
}