Paper/src/main/java/org/bukkit/craftbukkit/CraftArt.java
Wesley Wolfe 1c14586c49 Add CraftArt mappings for Wither. Fixes BUKKIT-2667.
The static assertions are not normally evaluated in the JVM, and failed
to fail when the enums went from size 25 to size 26. This meant missing
values would not be detected at runtime and instead return null,
compounding problems later. The switches should never evaluate to null
so will instead throw runtime assertion errors.

Additional unit tests were added to detect new paintings and assure they
have proper, unique mappings. The test checks both that a mapping
exists, is not null, and does not duplicate another mapping.
2012-11-01 03:06:47 -05:00

75 Zeilen
2.9 KiB
Java

package org.bukkit.craftbukkit;
import net.minecraft.server.EnumArt;
import org.bukkit.Art;
// Safety class, will break if either side changes
public class CraftArt {
public static Art NotchToBukkit(EnumArt art) {
switch (art) {
case KEBAB: return Art.KEBAB;
case AZTEC: return Art.AZTEC;
case ALBAN: return Art.ALBAN;
case AZTEC2: return Art.AZTEC2;
case BOMB: return Art.BOMB;
case PLANT: return Art.PLANT;
case WASTELAND: return Art.WASTELAND;
case POOL: return Art.POOL;
case COURBET: return Art.COURBET;
case SEA: return Art.SEA;
case SUNSET: return Art.SUNSET;
case CREEBET: return Art.CREEBET;
case WANDERER: return Art.WANDERER;
case GRAHAM: return Art.GRAHAM;
case MATCH: return Art.MATCH;
case BUST: return Art.BUST;
case STAGE: return Art.STAGE;
case VOID: return Art.VOID;
case SKULL_AND_ROSES: return Art.SKULL_AND_ROSES;
case FIGHTERS: return Art.FIGHTERS;
case POINTER: return Art.POINTER;
case PIGSCENE: return Art.PIGSCENE;
case BURNINGSKULL: return Art.BURNINGSKULL;
case SKELETON: return Art.SKELETON;
case DONKEYKONG: return Art.DONKEYKONG;
case WITHER: return Art.WITHER;
default:
throw new AssertionError(art);
}
}
public static EnumArt BukkitToNotch(Art art) {
switch (art) {
case KEBAB: return EnumArt.KEBAB;
case AZTEC: return EnumArt.AZTEC;
case ALBAN: return EnumArt.ALBAN;
case AZTEC2: return EnumArt.AZTEC2;
case BOMB: return EnumArt.BOMB;
case PLANT: return EnumArt.PLANT;
case WASTELAND: return EnumArt.WASTELAND;
case POOL: return EnumArt.POOL;
case COURBET: return EnumArt.COURBET;
case SEA: return EnumArt.SEA;
case SUNSET: return EnumArt.SUNSET;
case CREEBET: return EnumArt.CREEBET;
case WANDERER: return EnumArt.WANDERER;
case GRAHAM: return EnumArt.GRAHAM;
case MATCH: return EnumArt.MATCH;
case BUST: return EnumArt.BUST;
case STAGE: return EnumArt.STAGE;
case VOID: return EnumArt.VOID;
case SKULL_AND_ROSES: return EnumArt.SKULL_AND_ROSES;
case FIGHTERS: return EnumArt.FIGHTERS;
case POINTER: return EnumArt.POINTER;
case PIGSCENE: return EnumArt.PIGSCENE;
case BURNINGSKULL: return EnumArt.BURNINGSKULL;
case SKELETON: return EnumArt.SKELETON;
case DONKEYKONG: return EnumArt.DONKEYKONG;
case WITHER: return EnumArt.WITHER;
default:
throw new AssertionError(art);
}
}
}