Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 12:30:06 +01:00
SPIGOT-5536: Material.values() causes legacy data init
Dieser Commit ist enthalten in:
Ursprung
a81f6ed397
Commit
a0e88fb362
@ -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() {
|
||||
//
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren