Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ThomasGaubert/1557998 to your computer and use it in GitHub Desktop.
Save ThomasGaubert/1557998 to your computer and use it in GitHub Desktop.
ModLoaderMP Bukkit Diff
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
new file mode 100755
index 0000000..699d5ea
--- /dev/null
+++ b/src/main/java/org/bukkit/Material.java
@@ -0,0 +1,617 @@
+package org.bukkit;
+
+import java.lang.reflect.*;
+import java.util.*;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.bukkit.material.*;
+
+/**
+ * An enum of all material ids accepted by the official server + client
+ */
+public enum Material {
+ AIR(0),
+ STONE(1),
+ GRASS(2),
+ DIRT(3),
+ COBBLESTONE(4),
+ WOOD(5),
+ SAPLING(6, Tree.class),
+ BEDROCK(7),
+ WATER(8, MaterialData.class),
+ STATIONARY_WATER(9, MaterialData.class),
+ LAVA(10, MaterialData.class),
+ STATIONARY_LAVA(11, MaterialData.class),
+ SAND(12),
+ GRAVEL(13),
+ GOLD_ORE(14),
+ IRON_ORE(15),
+ COAL_ORE(16),
+ LOG(17, Tree.class),
+ LEAVES(18, Tree.class),
+ SPONGE(19),
+ GLASS(20),
+ LAPIS_ORE(21),
+ LAPIS_BLOCK(22),
+ DISPENSER(23, Dispenser.class),
+ SANDSTONE(24),
+ NOTE_BLOCK(25),
+ BED_BLOCK(26, Bed.class),
+ POWERED_RAIL(27, PoweredRail.class),
+ DETECTOR_RAIL(28, DetectorRail.class),
+ PISTON_STICKY_BASE(29, PistonBaseMaterial.class),
+ WEB(30),
+ LONG_GRASS(31, LongGrass.class),
+ DEAD_BUSH(32),
+ PISTON_BASE(33, PistonBaseMaterial.class),
+ PISTON_EXTENSION(34, PistonExtensionMaterial.class),
+ WOOL(35, Wool.class),
+ PISTON_MOVING_PIECE(36),
+ YELLOW_FLOWER(37),
+ RED_ROSE(38),
+ BROWN_MUSHROOM(39),
+ RED_MUSHROOM(40),
+ GOLD_BLOCK(41),
+ IRON_BLOCK(42),
+ DOUBLE_STEP(43, Step.class),
+ STEP(44, Step.class),
+ BRICK(45),
+ TNT(46),
+ BOOKSHELF(47),
+ MOSSY_COBBLESTONE(48),
+ OBSIDIAN(49),
+ TORCH(50, Torch.class),
+ FIRE(51),
+ MOB_SPAWNER(52),
+ WOOD_STAIRS(53, Stairs.class),
+ CHEST(54),
+ REDSTONE_WIRE(55, RedstoneWire.class),
+ DIAMOND_ORE(56),
+ DIAMOND_BLOCK(57),
+ WORKBENCH(58),
+ CROPS(59, Crops.class),
+ SOIL(60, MaterialData.class),
+ FURNACE(61, Furnace.class),
+ BURNING_FURNACE(62, Furnace.class),
+ SIGN_POST(63, 1, Sign.class),
+ WOODEN_DOOR(64, Door.class),
+ LADDER(65, Ladder.class),
+ RAILS(66, Rails.class),
+ COBBLESTONE_STAIRS(67, Stairs.class),
+ WALL_SIGN(68, 1, Sign.class),
+ LEVER(69, Lever.class),
+ STONE_PLATE(70, PressurePlate.class),
+ IRON_DOOR_BLOCK(71, Door.class),
+ WOOD_PLATE(72, PressurePlate.class),
+ REDSTONE_ORE(73),
+ GLOWING_REDSTONE_ORE(74),
+ REDSTONE_TORCH_OFF(75, RedstoneTorch.class),
+ REDSTONE_TORCH_ON(76, RedstoneTorch.class),
+ STONE_BUTTON(77, Button.class),
+ SNOW(78),
+ ICE(79),
+ SNOW_BLOCK(80),
+ CACTUS(81, MaterialData.class),
+ CLAY(82),
+ SUGAR_CANE_BLOCK(83, MaterialData.class),
+ JUKEBOX(84),
+ FENCE(85),
+ PUMPKIN(86, Pumpkin.class),
+ NETHERRACK(87),
+ SOUL_SAND(88),
+ GLOWSTONE(89),
+ PORTAL(90),
+ JACK_O_LANTERN(91, Pumpkin.class),
+ CAKE_BLOCK(92, 1, Cake.class),
+ DIODE_BLOCK_OFF(93, Diode.class),
+ DIODE_BLOCK_ON(94, Diode.class),
+ LOCKED_CHEST(95),
+ TRAP_DOOR(96, TrapDoor.class),
+ MONSTER_EGGS(97, MonsterEggs.class),
+ SMOOTH_BRICK(98, SmoothBrick.class),
+ HUGE_MUSHROOM_1(99),
+ HUGE_MUSHROOM_2(100),
+ IRON_FENCE(101),
+ THIN_GLASS(102),
+ MELON_BLOCK(103),
+ PUMPKIN_STEM(104),
+ MELON_STEM(105),
+ VINE(106),
+ FENCE_GATE(107),
+ BRICK_STAIRS(108),
+ SMOOTH_STAIRS(109),
+ MYCEL(110),
+ WATER_LILY(111),
+ NETHER_BRICK(112),
+ NETHER_FENCE(113),
+ NETHER_BRICK_STAIRS(114),
+ NETHER_WARTS(115),
+ ENCHANTMENT_TABLE(116),
+ BREWING_STAND(117),
+ CAULDRON(118),
+ ENDER_PORTAL(119),
+ ENDER_PORTAL_FRAME(120),
+ ENDER_STONE(121),
+ DRAGON_EGG(122),
+ // ----- Item Separator -----
+ IRON_SPADE(256, 1, 250),
+ IRON_PICKAXE(257, 1, 250),
+ IRON_AXE(258, 1, 250),
+ FLINT_AND_STEEL(259, 1, 64),
+ APPLE(260),
+ BOW(261, 1, 384),
+ ARROW(262),
+ COAL(263, Coal.class),
+ DIAMOND(264),
+ IRON_INGOT(265),
+ GOLD_INGOT(266),
+ IRON_SWORD(267, 1, 250),
+ WOOD_SWORD(268, 1, 59),
+ WOOD_SPADE(269, 1, 59),
+ WOOD_PICKAXE(270, 1, 59),
+ WOOD_AXE(271, 1, 59),
+ STONE_SWORD(272, 1, 131),
+ STONE_SPADE(273, 1, 131),
+ STONE_PICKAXE(274, 1, 131),
+ STONE_AXE(275, 1, 131),
+ DIAMOND_SWORD(276, 1, 1561),
+ DIAMOND_SPADE(277, 1, 1561),
+ DIAMOND_PICKAXE(278, 1, 1561),
+ DIAMOND_AXE(279, 1, 1561),
+ STICK(280),
+ BOWL(281),
+ MUSHROOM_SOUP(282, 1),
+ GOLD_SWORD(283, 1, 32),
+ GOLD_SPADE(284, 1, 32),
+ GOLD_PICKAXE(285, 1, 32),
+ GOLD_AXE(286, 1, 32),
+ STRING(287),
+ FEATHER(288),
+ SULPHUR(289),
+ WOOD_HOE(290, 1, 59),
+ STONE_HOE(291, 1, 131),
+ IRON_HOE(292, 1, 250),
+ DIAMOND_HOE(293, 1, 1561),
+ GOLD_HOE(294, 1, 32),
+ SEEDS(295),
+ WHEAT(296),
+ BREAD(297),
+ LEATHER_HELMET(298, 1, 33),
+ LEATHER_CHESTPLATE(299, 1, 47),
+ LEATHER_LEGGINGS(300, 1, 45),
+ LEATHER_BOOTS(301, 1, 39),
+ CHAINMAIL_HELMET(302, 1, 66),
+ CHAINMAIL_CHESTPLATE(303, 1, 95),
+ CHAINMAIL_LEGGINGS(304, 1, 91),
+ CHAINMAIL_BOOTS(305, 1, 78),
+ IRON_HELMET(306, 1, 135),
+ IRON_CHESTPLATE(307, 1, 191),
+ IRON_LEGGINGS(308, 1, 183),
+ IRON_BOOTS(309, 1, 159),
+ DIAMOND_HELMET(310, 1, 271),
+ DIAMOND_CHESTPLATE(311, 1, 383),
+ DIAMOND_LEGGINGS(312, 1, 367),
+ DIAMOND_BOOTS(313, 1, 319),
+ GOLD_HELMET(314, 1, 67),
+ GOLD_CHESTPLATE(315, 1, 95),
+ GOLD_LEGGINGS(316, 1, 91),
+ GOLD_BOOTS(317, 1, 79),
+ FLINT(318),
+ PORK(319),
+ GRILLED_PORK(320),
+ PAINTING(321),
+ GOLDEN_APPLE(322),
+ SIGN(323, 1),
+ WOOD_DOOR(324, 1),
+ BUCKET(325, 1),
+ WATER_BUCKET(326, 1),
+ LAVA_BUCKET(327, 1),
+ MINECART(328, 1),
+ SADDLE(329, 1),
+ IRON_DOOR(330, 1),
+ REDSTONE(331),
+ SNOW_BALL(332, 16),
+ BOAT(333, 1),
+ LEATHER(334),
+ MILK_BUCKET(335, 1),
+ CLAY_BRICK(336),
+ CLAY_BALL(337),
+ SUGAR_CANE(338),
+ PAPER(339),
+ BOOK(340),
+ SLIME_BALL(341),
+ STORAGE_MINECART(342, 1),
+ POWERED_MINECART(343, 1),
+ EGG(344, 16),
+ COMPASS(345),
+ FISHING_ROD(346, 1, 64),
+ WATCH(347),
+ GLOWSTONE_DUST(348),
+ RAW_FISH(349),
+ COOKED_FISH(350),
+ INK_SACK(351, Dye.class),
+ BONE(352),
+ SUGAR(353),
+ CAKE(354, 1),
+ BED(355, 1),
+ DIODE(356),
+ COOKIE(357),
+ MAP(358, 1, MaterialData.class),
+ SHEARS(359, 1, 238),
+ MELON(360),
+ PUMPKIN_SEEDS(361),
+ MELON_SEEDS(362),
+ RAW_BEEF(363),
+ COOKED_BEEF(364),
+ RAW_CHICKEN(365),
+ COOKED_CHICKEN(366),
+ ROTTEN_FLESH(367),
+ ENDER_PEARL(368),
+ BLAZE_ROD(369),
+ GHAST_TEAR(370),
+ GOLD_NUGGET(371),
+ NETHER_STALK(372),
+ POTION(373),
+ GLASS_BOTTLE(374),
+ SPIDER_EYE(375),
+ FERMENTED_SPIDER_EYE(376),
+ BLAZE_POWDER(377),
+ MAGMA_CREAM(378),
+ BREWING_STAND_ITEM(379),
+ CAULDRON_ITEM(380),
+ EYE_OF_ENDER(381),
+ SPECKLED_MELON(382),
+ GOLD_RECORD(2256, 1),
+ GREEN_RECORD(2257, 1),
+ RECORD_3(2258, 1),
+ RECORD_4(2259, 1),
+ RECORD_5(2260, 1),
+ RECORD_6(2261, 1),
+ RECORD_7(2262, 1),
+ RECORD_8(2263, 1),
+ RECORD_9(2264, 1),
+ RECORD_10(2265, 1),
+ RECORD_11(2266, 1);
+
+ private final int id;
+ private final Class<? extends MaterialData> data;
+ private static Map<Integer, Material> lookupId = new HashMap<Integer, Material>();
+ private static Map<String, Material> lookupName = new HashMap<String, Material>();
+ private final int maxStack;
+ private final short durability;
+
+ private Material(final int id) {
+ this(id, 64);
+ }
+
+ private Material(final int id, final int stack) {
+ this(id, stack, null);
+ }
+
+ private Material(final int id, final int stack, final int durability) {
+ this(id, stack, durability, null);
+ }
+
+ private Material(final int id, final Class<? extends MaterialData> data) {
+ this(id, 64, data);
+ }
+
+ private Material(final int id, final int stack, final Class<? extends MaterialData> data) {
+ this(id, stack, -1, data);
+ }
+
+ private Material(final int id, final int stack, final int durability, final Class<? extends MaterialData> data) {
+ this.id = id;
+ this.durability = (short) durability;
+ this.maxStack = stack;
+ this.data = data;
+ }
+
+ /**
+ * Gets the item ID or block ID of this Material
+ *
+ * @return ID of this material
+ */
+ public int getId() {
+ return id;
+ }
+
+ /**
+ * Gets the maximum amount of this material that can be held in a stack
+ *
+ * @return Maximum stack size for this material
+ */
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+
+ /**
+ * Gets the maximum durability of this material
+ *
+ * @return Maximum durability for this material
+ */
+ public short getMaxDurability() {
+ return durability;
+ }
+
+ /**
+ * Gets the MaterialData class associated with this Material
+ *
+ * @return MaterialData associated with this Material
+ */
+ public Class<? extends MaterialData> getData() {
+ return (data == null) ? MaterialData.class : data;
+ }
+
+ /**
+ * Constructs a new MaterialData relevant for this Material, with the given
+ * initial data
+ *
+ * @param raw Initial data to construct the MaterialData with
+ * @return New MaterialData with the given data
+ */
+ public MaterialData getNewData(final byte raw) {
+ if (data == null) {
+ return new MaterialData(id, raw);
+ }
+
+ try {
+ Constructor<? extends 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;
+ }
+
+ /**
+ * Checks if this Material is a placable block
+ *
+ * @return true if this material is a block
+ */
+ public boolean isBlock() {
+ return id < 256;
+ }
+
+ /**
+ * Checks if this Material is edible.
+ *
+ * @return true if this Material is edible.
+ */
+ public boolean isEdible() {
+ return equals(Material.BREAD)
+ || equals(Material.COOKIE)
+ || equals(Material.MELON)
+ || equals(Material.MUSHROOM_SOUP)
+ || equals(Material.RAW_CHICKEN)
+ || equals(Material.COOKED_CHICKEN)
+ || equals(Material.RAW_BEEF)
+ || equals(Material.COOKED_BEEF)
+ || equals(Material.RAW_FISH)
+ || equals(Material.COOKED_FISH)
+ || equals(Material.PORK)
+ || equals(Material.GRILLED_PORK)
+ || equals(Material.APPLE)
+ || equals(Material.GOLDEN_APPLE)
+ || equals(Material.ROTTEN_FLESH)
+ || equals(Material.SPIDER_EYE);
+ }
+
+ /**
+ * Attempts to get the Material with the given ID
+ *
+ * @param id ID of the material to get
+ * @return Material if found, or null
+ */
+ public static Material getMaterial(final int id) {
+ return lookupId.get(id);
+ }
+
+ /**
+ * Attempts to get the Material with the given name.
+ * This is a normal lookup, names must be the precise name they are given
+ * in the enum.
+ *
+ * @param name Name of the material to get
+ * @return Material if found, or null
+ */
+ public static Material getMaterial(final String name) {
+ return lookupName.get(name);
+ }
+
+ /**
+ * Attempts to match the Material with the given name.
+ * This is a match lookup; names will be converted to uppercase, then stripped
+ * of special characters in an attempt to format it like the enum
+ *
+ * @param name Name of the material to get
+ * @return Material if found, or null
+ */
+ public static Material matchMaterial(final String name) {
+ Material result = null;
+
+ try {
+ result = getMaterial(Integer.parseInt(name));
+ } catch (NumberFormatException ex) {}
+
+ if (result == null) {
+ String filtered = name.toUpperCase();
+
+ filtered = filtered.replaceAll("\\s+", "_").replaceAll("\\W", "");
+ result = lookupName.get(filtered);
+ }
+
+ return result;
+ }
+
+ /* Mae start - Updated with code from Forge. */
+ public static void addMaterial(int id) {
+ addMaterial(id, "X" + String.valueOf(id));
+ }
+
+ public static void addMaterial(int id, String name) {
+ if (!lookupId.containsKey(Integer.valueOf(id))) {
+ System.out.println("Adding Material: " + id + ":" + name);
+ Material material = addEnum(Material.class, name,
+ new Class[] { int.class },
+ new Object[]{ id });
+ lookupId.put(id, material);
+ lookupName.put(name, material);
+
+ String material_name = name.toUpperCase().trim();
+ material_name = material_name.replaceAll("\\s+", "_").replaceAll("\\W", "");
+ lookupName.put(material_name, material);
+ }
+ }
+
+ public static void setMaterialName(int id, String name) {
+ String material_name = name.toUpperCase().trim();
+ material_name = material_name.replaceAll("\\s+", "_").replaceAll("\\W", "");
+
+ if(!lookupId.containsKey(Integer.valueOf(id))) {
+ System.out.println("Adding material " + id + " name: " + name);
+ addMaterial(id, material_name);
+ } else {
+ System.out.println("Aliasing material " + id + " name: " + name);
+ Material material = getMaterial(id);
+ lookupName.put(name, material);
+ lookupName.put(material_name, material);
+ }
+ }
+
+ /*
+ * Everything below this is found at the site below, and updated to be able to compile in Eclipse/Java 1.6+
+ * Also modified for use in decompiled code.
+ * Found at: http://niceideas.ch/roller2/badtrash/entry/java_create_enum_instances_dynamically
+ */
+ private static Object reflectionFactory = null;
+ private static Method newConstructorAccessor = null;
+ private static Method newInstance = null;
+ private static Method newFieldAccessor = null;
+ private static Method fieldAccessorSet = null;
+ private static boolean isSetup = false;
+
+ private static void setup()
+ {
+ if (isSetup)
+ {
+ return;
+ }
+ try {
+ Method getReflectionFactory = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("getReflectionFactory");
+ reflectionFactory = getReflectionFactory.invoke(null);
+ newConstructorAccessor = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("newConstructorAccessor", Constructor.class);
+ newInstance = Class.forName("sun.reflect.ConstructorAccessor").getDeclaredMethod("newInstance", Object[].class);
+ newFieldAccessor = Class.forName("sun.reflect.ReflectionFactory").getDeclaredMethod("newFieldAccessor", Field.class, boolean.class);
+ fieldAccessorSet = Class.forName("sun.reflect.FieldAccessor").getDeclaredMethod("set", Object.class, Object.class);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ isSetup = true;
+ }
+
+ private static Object getConstructorAccessor(Class<?> enumClass, Class<?>[] additionalParameterTypes) throws Exception {
+ Class<?>[] parameterTypes = null;
+
+ parameterTypes = new Class[additionalParameterTypes.length + 2];
+ parameterTypes[0] = String.class;
+ parameterTypes[1] = int.class;
+ System.arraycopy(additionalParameterTypes, 0, parameterTypes, 2, additionalParameterTypes.length);
+
+ return newConstructorAccessor.invoke(reflectionFactory, enumClass.getDeclaredConstructor(parameterTypes));
+ }
+
+ private static <T extends Enum<?>> T makeEnum(Class<T> enumClass, String value, int ordinal, Class<?>[] additionalTypes, Object[] additionalValues) throws Exception {
+ Object[] parms = null;
+
+ parms = new Object[additionalValues.length + 2];
+ parms[0] = value;
+ parms[1] = Integer.valueOf(ordinal);
+ System.arraycopy(additionalValues, 0, parms, 2, additionalValues.length);
+
+ return enumClass.cast(newInstance.invoke(getConstructorAccessor(enumClass, additionalTypes), new Object[]{parms}));
+ }
+
+ private static void setFailsafeFieldValue(Field field, Object target, Object value) throws Exception {
+ field.setAccessible(true);
+ Field modifiersField = Field.class.getDeclaredField("modifiers");
+ modifiersField.setAccessible(true);
+ modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);
+ Object fieldAccessor = newFieldAccessor.invoke(reflectionFactory, field, false);
+ fieldAccessorSet.invoke(fieldAccessor, target, value);
+ }
+
+ private static void blankField(Class<?> enumClass, String fieldName) throws Exception {
+ for (Field field : Class.class.getDeclaredFields()) {
+ if (field.getName().contains(fieldName)) {
+ field.setAccessible(true);
+ setFailsafeFieldValue(field, enumClass, null);
+ break;
+ }
+ }
+ }
+
+ private static void cleanEnumCache(Class<?> enumClass) throws Exception {
+ blankField(enumClass, "enumConstantDirectory");
+ blankField(enumClass, "enumConstants");
+ }
+
+ @SuppressWarnings("unchecked")
+ public static <T extends Enum<?>> T addEnum(Class<T> enumType, String enumName, Class<?>[] paramTypes, Object[] paramValues) {
+ if (!isSetup) setup();
+ Field valuesField = null;
+ Field[] fields = enumType.getDeclaredFields();
+ int flags = Modifier.PRIVATE | Modifier.STATIC | Modifier.FINAL | 0x1000 /*SYNTHETIC*/;
+ String valueType = String.format("[L%s;", enumType.getName()/*.replace('.', '/')*/);
+
+ for (Field field : fields) {
+ if ((field.getModifiers() & flags) == flags &&
+ field.getType().getName().equals(valueType))
+ {
+ valuesField = field;
+ break;
+ }
+ }
+ valuesField.setAccessible(true);
+
+ try {
+ T[] previousValues = (T[])valuesField.get(enumType);
+ List<T> values = new ArrayList<T>(Arrays.asList(previousValues));
+ T newValue = (T)makeEnum(enumType, enumName, values.size(), paramTypes, paramValues);
+ values.add(newValue);
+ setFailsafeFieldValue(valuesField, null, values.toArray((T[]) Array.newInstance(enumType, 0)));
+ cleanEnumCache(enumType);
+
+ return newValue;
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+ // Mae end
+
+ static {
+ for (Material material : values()) {
+ lookupId.put(material.getId(), material);
+ lookupName.put(material.name(), material);
+ }
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6e237be..002324f 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -55,6 +55,7 @@ import net.minecraft.server.WorldMap;
import net.minecraft.server.WorldMapCollection;
import net.minecraft.server.WorldNBTStorage;
import net.minecraft.server.WorldSettings;
+import net.minecraft.server.ModLoaderMp;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -379,6 +380,13 @@ public final class CraftServer implements Server {
return true;
}
+ // liar beg
+ /* FIXME
+ if (ModLoaderMp.handleCommand(commandLine, "", sender, null)) {
+ return true;
+ } */
+ // liar end
+
sender.sendMessage("Unknown command. Type \"help\" for help.");
return false;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
index 8701d4b..8fd7f3d 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java
@@ -17,7 +17,7 @@ import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
-public abstract class CraftEntity implements org.bukkit.entity.Entity {
+public class CraftEntity implements org.bukkit.entity.Entity {
private static final Map<String, CraftPlayer> players = new MapMaker().softValues().makeMap();
protected final CraftServer server;
protected Entity entity;
@@ -129,8 +129,10 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
}
else if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); }
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
-
- throw new IllegalArgumentException("Unknown entity");
+ // liar start - workaround
+ /* throw new IllegalArgumentException("Unknown entity"); */
+ return new CraftEntity(server, entity);
+ // liar end
}
public Location getLocation() {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 17438f7..91e9940 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -65,7 +65,7 @@ public class CraftEventFactory {
int spawnSize = Bukkit.getServer().getSpawnRadius();
if (spawnSize <= 0) return true;
- if (player.isOp()) return true;
+ if (player != null && player.isOp()) return true;
ChunkCoordinates chunkcoordinates = worldServer.getSpawn();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment