New materials, changed material names per style guidelines + correct names

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-13 23:33:10 +00:00
parent 0a677497d4
commit 2fab54ae7b
2 changed files with 224 additions and 174 deletions

View file

@ -1,199 +1,249 @@
package org.bukkit; package org.bukkit;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.material.MaterialData;
/** /**
* An enum of all material IDs accepted by the official server + client * An enum of all material IDs accepted by the official server + client
*/ */
public enum Material { public enum Material {
Air(0), AIR(0),
Stone(1), STONE(1),
Grass(2), GRASS(2),
Dirt(3), DIRT(3),
Cobblestone(4), COBBLESTONE(4),
Wood(5), WOOD(5),
Sapling(6), SAPLING(6),
Bedrock(7), BEDROCK(7),
Water(8), WATER(8),
StationaryWater(9), STATIONARY_WATER(9),
Lava(10), LAVA(10),
StationaryLava(11), STATIONARY_LAVA(11),
Sand(12), SAND(12),
Gravel(13), GRAVEL(13),
GoldOre(14), GOLD_ORE(14),
IronOre(15), IRON_ORE(15),
CoalOre(16), COAL_ORE(16),
Log(17), LOG(17),
Leaves(18), LEAVES(18),
Sponge(19), SPONGE(19),
Glass(20), GLASS(20),
Cloth(35), LAPIS_ORE(21),
YellowFlower(37), LAPIS_BLOCK(22),
RedRose(38), DISPENSER(23),
BrownMushroom(39), SANDSTONE(24),
RedMushroom(40), NOTE_BLOCK(25),
GoldBlock(41), CLOTH(35),
IronBlock(42), YELLOW_FLOWER(37),
DoubleStep(43), RED_ROSE(38),
Step(44), BROWN_MUSHROOM(39),
Brick(45), RED_MUSHROOM(40),
GOLD_BLOCK(41),
IRON_BLOCK(42),
DOUBLE_STEP(43),
STEP(44),
BRICK(45),
TNT(46), TNT(46),
BookShelf(47), BOOKSHELF(47),
MossyCobblestone(48), MOSSY_COBBLESTONE(48),
Obsidian(49), OBSIDIAN(49),
Torch(50), TORCH(50),
Fire(51), FIRE(51),
MobSpawner(52), MOB_SPAWNER(52),
WoodStairs(53), WOOD_STAIRS(53),
Chest(54), CHEST(54),
RedstoneWire(55), REDSTONE_WIRE(55),
DiamondOre(56), DIAMOND_ORE(56),
DiamondBlock(57), DIAMOND_BLOCK(57),
Workbench(58), WORKBENCH(58),
Crops(59), CROPS(59),
Soil(60), SOIL(60),
Furnace(61), FURNACE(61),
BurningFurnace(62), BURNING_FURNACE(62),
SignPost(63), SIGN_POST(63),
WoodenDoor(64), WOODEN_DOOR(64),
Ladder(65), LADDER(65),
Rails(66), RAILS(66),
CobblestoneStairs(67), COBBLESTONE_STAIRS(67),
WallSign(68), WALL_SIGN(68),
Lever(69), LEVER(69),
StonePlate(70), STONE_PLATE(70),
IronDoorBlock(71), IRON_DOOR_BLOCK(71),
WoodPlate(72), WOOD_PLATE(72),
RedstoneOre(73), REDSTONE_ORE(73),
GlowingRedstoneOre(74), GLOWING_REDSTONE_ORE(74),
RedstoneTorchOff(75), REDSTONE_TORCH_OFF(75),
RedstoneTorchOn(76), REDSTONE_TORCH_ON(76),
StoneButton(77), STONE_BUTTON(77),
Snow(78), SNOW(78),
Ice(79), ICE(79),
SnowBlock(80), SNOW_BLOCK(80),
Cactus(81), CACTUS(81),
Clay(82), CLAY(82),
ReedBlock(83), SUGAR_CANE_BLOCK(83),
Jukebox(84), JUKEBOX(84),
Fence(85), FENCE(85),
Pumpkin(86), PUMPKIN(86),
Netherstone(87), NETHERRACK(87),
SlowSand(88), SOUL_SAND(88),
LightStone(89), GLOWSTONE(89),
Portal(90), PORTAL(90),
JackOLantern(91), JACK_O_LANTERN(91),
IronSpade(256), CAKE_BLOCK(92),
IronPickaxe(257), IRON_SPADE(256),
IronAxe(258), IRON_PICKAXE(257),
FlintAndSteel(259), IRON_AXE(258),
Apple(260), FLINT_AND_STEEL(259),
Bow(261), APPLE(260),
Arrow(262), BOW(261),
Coal(263), ARROW(262),
Diamond(264), COAL(263),
IronIngot(265), DIAMOND(264),
GoldIngot(266), IRON_INGOT(265),
IronSword(267), GOLD_INGOT(266),
WoodSword(268), IRON_SWORD(267),
WoodSpade(269), WOOD_SWORD(268),
WoodPickaxe(270), WOOD_SPADE(269),
WoodAxe(271), WOOD_PICKAXE(270),
StoneSword(272), WOOD_AXE(271),
StoneSpade(273), STONE_SWORD(272),
StonePickaxe(274), STONE_SPADE(273),
StoneAxe(275), STONE_PICKAXE(274),
DiamondSword(276), STONE_AXE(275),
DiamondSpade(277), DIAMOND_SWORD(276),
DiamondPickaxe(278), DIAMOND_SPADE(277),
DiamondAxe(279), DIAMOND_PICKAXE(278),
Stick(280), DIAMOND_AXE(279),
Bowl(281), STICK(280),
MushroomSoup(282), BOWL(281),
GoldSword(283), MUSHROOM_SOUP(282),
GoldSpade(284), GOLD_SWORD(283),
GoldPickaxe(285), GOLD_SPADE(284),
GoldAxe(286), GOLD_PICKAXE(285),
String(287), GOLD_AXE(286),
Feather(288), STRING(287),
Gunpowder(289), FEATHER(288),
WoodHoe(290), SULPHUR(289),
StoneHoe(291), WOOD_HOE(290),
IronHoe(292), STONE_HOE(291),
DiamondHoe(293), IRON_HOE(292),
GoldHoe(294), DIAMOND_HOE(293),
Seeds(295), GOLD_HOE(294),
Wheat(296), SEEDS(295),
Bread(297), WHEAT(296),
LeatherHelmet(298), BREAD(297),
LeatherChestplate(299), LEATHER_HELMET(298),
LeatherLeggings(300), LEATHER_CHESTPLATE(299),
LeatherBoots(301), LEATHER_LEGGINGS(300),
ChainmailHelmet(302), LEATHER_BOOTS(301),
ChainmailChestplate(303), CHAINMAIL_HELMET(302),
ChainmailLeggings(304), CHAINMAIL_CHESTPLATE(303),
ChainmailBoots(305), CHAINMAIL_LEGGINGS(304),
IronHelmet(306), CHAINMAIL_BOOTS(305),
IronChestplate(307), IRON_HELMET(306),
IronLeggings(308), IRON_CHESTPLATE(307),
IronBoots(309), IRON_LEGGINGS(308),
DiamondHelmet(310), IRON_BOOTS(309),
DiamondChestplate(311), DIAMOND_HELMET(310),
DiamondLeggings(312), DIAMOND_CHESTPLATE(311),
DiamondBoots(313), DIAMOND_LEGGINGS(312),
GoldHelmet(314), DIAMOND_BOOTS(313),
GoldChestplate(315), GOLD_HELMET(314),
GoldLeggings(316), GOLD_CHESTPLATE(315),
GoldBoots(317), GOLD_LEGGINGS(316),
Flint(318), GOLD_BOOTS(317),
Pork(319), FLINT(318),
GrilledPork(320), PORK(319),
Painting(321), GRILLED_PORK(320),
GoldenApple(322), PAINTING(321),
Sign(323), GOLDEN_APPLE(322),
WoodDoor(324), SIGN(323),
Bucket(325), WOOD_DOOR(324),
WaterBucket(326), BUCKET(325),
LavaBucket(327), WATER_BUCKET(326),
Minecart(328), LAVA_BUCKET(327),
Saddle(329), MINECART(328),
IronDoor(330), SADDLE(329),
RedStone(331), IRON_DOOR(330),
SnowBall(332), REDSTONE(331),
Boat(333), SNOW_BALL(332),
Leather(334), BOAT(333),
MilkBucket(335), LEATHER(334),
ClayBrick(336), MILK_BUCKET(335),
ClayBall(337), CLAY_BRICK(336),
Reed(338), CLAY_BALL(337),
Paper(339), SUGAR_CANE(338),
Book(340), PAPER(339),
SlimeBall(341), BOOK(340),
StorageMinecart(342), SLIME_BALL(341),
PoweredMinecart(343), STORAGE_MINECART(342),
Egg(344), POWERED_MINECART(343),
Compass(345), EGG(344),
FishingRod(346), COMPASS(345),
Watch(347), FISHING_ROD(346),
LightstoneDust(348), WATCH(347),
RawFish(349), GLOWSTONE_DUST(348),
CookedFish(350), RAW_FISH(349),
GoldRecord(2256), COOKED_FISH(350),
GreenRecord(2257); INK_SACK(351),
BONE(352),
SUGAR(353),
CAKE(354),
GOLD_RECORD(2256),
GREEN_RECORD(2257);
private final int id; private final int id;
private final Class<MaterialData> data;
private static final Map<Integer, Material> lookupId = new HashMap<Integer, Material>(); private static final Map<Integer, Material> lookupId = new HashMap<Integer, Material>();
private static final Map<String, Material> lookupName = new HashMap<String, Material>(); private static final Map<String, Material> lookupName = new HashMap<String, Material>();
private Material(final int id) { private Material(final int id) {
this(id, null);
}
private Material(final int id, final Class<MaterialData> data) {
this.id = id; this.id = id;
this.data = data;
} }
public int getID() { public int getID() {
return id; return id;
} }
public Class<MaterialData> getData() {
return data;
}
public MaterialData getNewData(final byte raw) {
if (data == null) {
return null;
}
try {
Constructor<MaterialData> ctor = data.getConstructor(int.class, byte.class);
return ctor.newInstance(id, raw);
} catch (InstantiationException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
} catch (InvocationTargetException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchMethodException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityException ex) {
Logger.getLogger(Material.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
public boolean isBlock() { public boolean isBlock() {
return id < 256; return id < 256;
} }

View file

@ -66,7 +66,7 @@ public class PlayerItemEvent extends PlayerEvent implements Cancellable {
* @return Material the material of the item used * @return Material the material of the item used
*/ */
public Material getMaterial() { public Material getMaterial() {
if (this.item == null) return Material.Air; if (this.item == null) return Material.AIR;
return item.getType(); return item.getType();
} }