mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-10 17:41:48 +01:00
Use "legacy-aware" utility class for Material types.
Introduces the Materials utility class, which works much like the static MACreature registration process, but for certain material types. Instead of storing everything in a stringly typed map, certain Material values are stored as constants. Right now it's just the `OAK_SIGN`/`SIGN` pair for the autogeneration in MAUtils, and chances are we can throw it out at some point in the near future, but at least now there's room for more materials, should the need arise.
This commit is contained in:
parent
b49920fc38
commit
b4cd509eff
@ -5,6 +5,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||
import com.garbagemule.MobArena.region.ArenaRegion;
|
||||
import com.garbagemule.MobArena.things.InvalidThingInputString;
|
||||
import com.garbagemule.MobArena.things.ThingPicker;
|
||||
import com.garbagemule.MobArena.util.Materials;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -274,7 +275,7 @@ public class MAUtils
|
||||
// Place the hippie signs
|
||||
//Iterator<String> iterator = am.getClasses().iterator();
|
||||
Iterator<ArenaClass> iterator = am.getClasses().values().iterator();
|
||||
Rotatable signData = (Rotatable) Material.OAK_SIGN.createBlockData();
|
||||
Rotatable signData = (Rotatable) Materials.SIGN.createBlockData();
|
||||
signData.setRotation(BlockFace.NORTH);
|
||||
for (int i = lx1+2; i <= lx2-2; i++) // Signs
|
||||
{
|
||||
|
22
src/main/java/com/garbagemule/MobArena/util/Materials.java
Normal file
22
src/main/java/com/garbagemule/MobArena/util/Materials.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.garbagemule.MobArena.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Materials {
|
||||
|
||||
public static final Material SIGN = resolve("OAK_SIGN", "SIGN");
|
||||
|
||||
private static Material resolve(String... names) {
|
||||
for (String name : names) {
|
||||
try {
|
||||
return Material.valueOf(name);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Swallow
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Unknown material: " + Arrays.toString(names));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user