From 277baff1a14c0eb57ef723d625446698a857884e Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 26 Nov 2014 08:15:59 +1100 Subject: Update to Minecraft 1.8 For more information please see http://www.spigotmc.org/ --- src/main/java/org/bukkit/Achievement.java | 1 + src/main/java/org/bukkit/GameMode.java | 9 +- src/main/java/org/bukkit/Material.java | 100 +++++++- src/main/java/org/bukkit/Statistic.java | 7 +- src/main/java/org/bukkit/WorldType.java | 4 +- src/main/java/org/bukkit/block/Banner.java | 77 ++++++ src/main/java/org/bukkit/block/banner/Pattern.java | 61 +++++ .../java/org/bukkit/block/banner/PatternType.java | 80 +++++++ .../bukkit/command/defaults/GameModeCommand.java | 4 +- src/main/java/org/bukkit/entity/ArmorStand.java | 261 +++++++++++++++++++++ src/main/java/org/bukkit/entity/CreatureType.java | 3 + src/main/java/org/bukkit/entity/Endermite.java | 4 + src/main/java/org/bukkit/entity/Entity.java | 45 ++++ src/main/java/org/bukkit/entity/EntityType.java | 4 + src/main/java/org/bukkit/entity/Guardian.java | 4 + src/main/java/org/bukkit/entity/LivingEntity.java | 45 ---- src/main/java/org/bukkit/entity/Rabbit.java | 4 + src/main/java/org/bukkit/entity/WaterMob.java | 2 +- .../bukkit/event/block/BlockPistonExtendEvent.java | 11 + .../org/bukkit/event/entity/EntityTargetEvent.java | 11 +- .../org/bukkit/event/inventory/InventoryType.java | 4 +- .../event/player/PlayerInteractAtEntityEvent.java | 22 ++ .../org/bukkit/inventory/EnchantingInventory.java | 14 ++ .../java/org/bukkit/inventory/meta/BannerMeta.java | 76 ++++++ src/main/java/org/bukkit/material/Banner.java | 232 ++++++++++++++++++ .../org/bukkit/plugin/java/JavaPluginLoader.java | 5 +- src/main/java/org/bukkit/potion/PotionType.java | 1 + src/main/java/org/bukkit/util/EulerAngle.java | 147 ++++++++++++ 28 files changed, 1181 insertions(+), 57 deletions(-) create mode 100644 src/main/java/org/bukkit/block/Banner.java create mode 100644 src/main/java/org/bukkit/block/banner/Pattern.java create mode 100644 src/main/java/org/bukkit/block/banner/PatternType.java create mode 100644 src/main/java/org/bukkit/entity/ArmorStand.java create mode 100644 src/main/java/org/bukkit/entity/Endermite.java create mode 100644 src/main/java/org/bukkit/entity/Guardian.java create mode 100644 src/main/java/org/bukkit/entity/Rabbit.java create mode 100644 src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java create mode 100644 src/main/java/org/bukkit/inventory/meta/BannerMeta.java create mode 100644 src/main/java/org/bukkit/material/Banner.java create mode 100644 src/main/java/org/bukkit/util/EulerAngle.java (limited to 'src/main') diff --git a/src/main/java/org/bukkit/Achievement.java b/src/main/java/org/bukkit/Achievement.java index 928b6d5d..ee874ee6 100644 --- a/src/main/java/org/bukkit/Achievement.java +++ b/src/main/java/org/bukkit/Achievement.java @@ -37,6 +37,7 @@ public enum Achievement { FULL_BEACON (KILL_WITHER), BREED_COW (KILL_COW), DIAMONDS_TO_YOU (GET_DIAMONDS), + OVERPOWERED (BUILD_BETTER_PICKAXE) ; private final Achievement parent; diff --git a/src/main/java/org/bukkit/GameMode.java b/src/main/java/org/bukkit/GameMode.java index f85ed0b2..803944ea 100644 --- a/src/main/java/org/bukkit/GameMode.java +++ b/src/main/java/org/bukkit/GameMode.java @@ -25,7 +25,14 @@ public enum GameMode { /** * Adventure mode cannot break blocks without the correct tools. */ - ADVENTURE(2); + ADVENTURE(2), + + /** + * Spectator mode cannot interact with the world in anyway and is + * invisible to normal players. This grants the player the + * ability to no-clip through the world. + */ + SPECTATOR(3); private final int value; private final static Map BY_ID = Maps.newHashMap(); diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index c45c1805..1702a79c 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -57,6 +57,7 @@ import org.bukkit.potion.Potion; import org.bukkit.util.Java15Compat; import com.google.common.collect.Maps; +import org.bukkit.material.Banner; /** * An enum of all material IDs accepted by the official server and client @@ -229,12 +230,39 @@ public enum Material { LOG_2(162), ACACIA_STAIRS(163, Stairs.class), DARK_OAK_STAIRS(164, Stairs.class), + SLIME_BLOCK(165), + BARRIER(166), + IRON_TRAPDOOR(167, TrapDoor.class), + PRISMARINE(168), + SEA_LANTERN(169), HAY_BLOCK(170), CARPET(171), HARD_CLAY(172), COAL_BLOCK(173), PACKED_ICE(174), DOUBLE_PLANT(175), + STANDING_BANNER(176, Banner.class), + WALL_BANNER(177, Banner.class), + DAYLIGHT_DETECTOR_INVERTED(178), + RED_SANDSTONE(179), + RED_SANDSTONE_STAIRS(180, Stairs.class), + DOUBLE_STONE_SLAB2(181), + STONE_SLAB2(182), + SPRUCE_FENCE_GATE(183), + BIRCH_FENCE_GATE(184), + JUNGLE_FENCE_GATE(185), + DARK_OAK_FENCE_GATE(186), + ACACIA_FENCE_GATE(187), + SPRUCE_FENCE(188), + BIRCH_FENCE(189), + JUNGLE_FENCE(190), + DARK_OAK_FENCE(191), + ACACIA_FENCE(192), + SPRUCE_DOOR(193), + BIRCH_DOOR(194), + JUNGLE_DOOR(195), + ACACIA_DOOR(196), + DARK_OAK_DOOR(197), // ----- Item Separator ----- IRON_SPADE(256, 1, 250), IRON_PICKAXE(257, 1, 250), @@ -304,13 +332,13 @@ public enum Material { PAINTING(321), GOLDEN_APPLE(322), SIGN(323, 16), - WOOD_DOOR(324, 1), + WOOD_DOOR(324, 64), BUCKET(325, 16), WATER_BUCKET(326, 1), LAVA_BUCKET(327, 1), MINECART(328, 1), SADDLE(329, 1), - IRON_DOOR(330, 1), + IRON_DOOR(330, 64), REDSTONE(331), SNOW_BALL(332, 16), BOAT(333, 1), @@ -395,12 +423,28 @@ public enum Material { QUARTZ(406), EXPLOSIVE_MINECART(407, 1), HOPPER_MINECART(408, 1), + PRISMARINE_SHARD(409), + PRISMARINE_CRYSTALS(410), + RABBIT(411), + COOKED_RABBIT(412), + RABBIT_STEW(413, 1), + RABBIT_FOOT(414), + RABBIT_HIDE(415), + ARMOR_STAND(416, 16), IRON_BARDING(417, 1), GOLD_BARDING(418, 1), DIAMOND_BARDING(419, 1), LEASH(420), NAME_TAG(421), COMMAND_MINECART(422, 1), + MUTTON(423), + COOKED_MUTTON(424), + BANNER(425, 16), + SPRUCE_DOOR_ITEM(427), + BIRCH_DOOR_ITEM(428), + JUNGLE_DOOR_ITEM(429), + ACACIA_DOOR_ITEM(430), + DARK_OAK_DOOR_ITEM(431), GOLD_RECORD(2256, 1), GREEN_RECORD(2257, 1), RECORD_3(2258, 1), @@ -558,6 +602,11 @@ public enum Material { case GOLDEN_APPLE: case ROTTEN_FLESH: case SPIDER_EYE: + case RABBIT: + case COOKED_RABBIT: + case RABBIT_STEW: + case MUTTON: + case COOKED_MUTTON: return true; default: return false; @@ -777,6 +826,25 @@ public enum Material { case ACACIA_STAIRS: case DARK_OAK_STAIRS: case PACKED_ICE: + case RED_SANDSTONE: + case SLIME_BLOCK: + case BARRIER: + case IRON_TRAPDOOR: + case PRISMARINE: + case SEA_LANTERN: + case DOUBLE_STONE_SLAB2: + case RED_SANDSTONE_STAIRS: + case STONE_SLAB2: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case ACACIA_FENCE_GATE: + case SPRUCE_FENCE: + case BIRCH_FENCE: + case JUNGLE_FENCE: + case DARK_OAK_FENCE: + case ACACIA_FENCE: return true; default: return false; @@ -837,6 +905,7 @@ public enum Material { case ACTIVATOR_RAIL: case CARPET: case DOUBLE_PLANT: + case DAYLIGHT_DETECTOR_INVERTED: return true; default: return false; @@ -889,6 +958,17 @@ public enum Material { case LOG_2: case ACACIA_STAIRS: case DARK_OAK_STAIRS: + case DOUBLE_PLANT: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case ACACIA_FENCE_GATE: + case SPRUCE_FENCE: + case BIRCH_FENCE: + case JUNGLE_FENCE: + case DARK_OAK_FENCE: + case ACACIA_FENCE: return true; default: return false; @@ -928,6 +1008,18 @@ public enum Material { case LOG_2: case CARPET: case DOUBLE_PLANT: + case DEAD_BUSH: + case FENCE_GATE: + case SPRUCE_FENCE_GATE: + case BIRCH_FENCE_GATE: + case JUNGLE_FENCE_GATE: + case DARK_OAK_FENCE_GATE: + case ACACIA_FENCE_GATE: + case SPRUCE_FENCE: + case BIRCH_FENCE: + case JUNGLE_FENCE: + case DARK_OAK_FENCE: + case ACACIA_FENCE: return true; default: return false; @@ -1009,6 +1101,10 @@ public enum Material { case COAL_BLOCK: case LOG_2: case PACKED_ICE: + case SLIME_BLOCK: + case BARRIER: + case PRISMARINE: + case RED_SANDSTONE: return true; default: return false; diff --git a/src/main/java/org/bukkit/Statistic.java b/src/main/java/org/bukkit/Statistic.java index 57df72ba..df8f80e5 100644 --- a/src/main/java/org/bukkit/Statistic.java +++ b/src/main/java/org/bukkit/Statistic.java @@ -27,12 +27,17 @@ public enum Statistic { BOAT_ONE_CM, PIG_ONE_CM, HORSE_ONE_CM, + SPRINT_ONE_CM, + CROUCH_ONE_CM, MINE_BLOCK(Type.BLOCK), USE_ITEM(Type.ITEM), BREAK_ITEM(Type.ITEM), CRAFT_ITEM(Type.ITEM), KILL_ENTITY(Type.ENTITY), - ENTITY_KILLED_BY(Type.ENTITY); + ENTITY_KILLED_BY(Type.ENTITY), + TIME_SINCE_DEATH, + TALKED_TO_VILLAGER, + TRADED_WITH_VILLAGER; private final Type type; diff --git a/src/main/java/org/bukkit/WorldType.java b/src/main/java/org/bukkit/WorldType.java index 201852df..20c8dda8 100644 --- a/src/main/java/org/bukkit/WorldType.java +++ b/src/main/java/org/bukkit/WorldType.java @@ -11,7 +11,9 @@ public enum WorldType { FLAT("FLAT"), VERSION_1_1("DEFAULT_1_1"), LARGE_BIOMES("LARGEBIOMES"), - AMPLIFIED("AMPLIFIED"); + AMPLIFIED("AMPLIFIED"), + CUSTOMIZED("CUSTOMIZED"), + DEBUG_ALL_BLOCK_STATES("DEBUG_ALL_BLOCK_STATES"); private final static Map BY_NAME = Maps.newHashMap(); private final String name; diff --git a/src/main/java/org/bukkit/block/Banner.java b/src/main/java/org/bukkit/block/Banner.java new file mode 100644 index 00000000..723b8836 --- /dev/null +++ b/src/main/java/org/bukkit/block/Banner.java @@ -0,0 +1,77 @@ +package org.bukkit.block; + +import org.bukkit.DyeColor; +import org.bukkit.block.banner.Pattern; + +import java.util.List; + +public interface Banner extends BlockState { + + /** + * Returns the base color for this banner + * + * @return the base color + */ + DyeColor getBaseColor(); + + /** + * Sets the base color for this banner + * + * @param color the base color + */ + void setBaseColor(DyeColor color); + + /** + * Returns a list of patterns on this banner + * + * @return the patterns + */ + List getPatterns(); + + /** + * Sets the patterns used on this banner + * + * @param patterns the new list of patterns + */ + void setPatterns(List patterns); + + /** + * Adds a new pattern on top of the existing + * patterns + * + * @param pattern the new pattern to add + */ + void addPattern(Pattern pattern); + + /** + * Returns the pattern at the specified index + * + * @param i the index + * @return the pattern + */ + Pattern getPattern(int i); + + /** + * Removes the pattern at the specified index + * + * @param i the index + * @return the removed pattern + */ + Pattern removePattern(int i); + + /** + * Sets the pattern at the specified index + * + * @param i the index + * @param pattern the new pattern + */ + void setPattern(int i, Pattern pattern); + + /** + * Returns the number of patterns on this + * banner + * + * @return the number of patterns + */ + int numberOfPatterns(); +} diff --git a/src/main/java/org/bukkit/block/banner/Pattern.java b/src/main/java/org/bukkit/block/banner/Pattern.java new file mode 100644 index 00000000..ba51c1fc --- /dev/null +++ b/src/main/java/org/bukkit/block/banner/Pattern.java @@ -0,0 +1,61 @@ +package org.bukkit.block.banner; + +import org.bukkit.DyeColor; +import org.bukkit.configuration.serialization.SerializableAs; + +@SerializableAs("Pattern") +public class Pattern { + + private final DyeColor color; + private final PatternType pattern; + + /** + * Creates a new pattern from the specified color and + * pattern type + * + * @param color the pattern color + * @param pattern the pattern type + */ + public Pattern(DyeColor color, PatternType pattern) { + this.color = color; + this.pattern = pattern; + } + + /** + * Returns the color of the pattern + * + * @return the color of the pattern + */ + public DyeColor getColor() { + return color; + } + + /** + * Returns the type of pattern + * + * @return the pattern type + */ + public PatternType getPattern() { + return pattern; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + (this.color != null ? this.color.hashCode() : 0); + hash = 97 * hash + (this.pattern != null ? this.pattern.hashCode() : 0); + return hash; + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Pattern other = (Pattern) obj; + return this.color == other.color && this.pattern == other.pattern; + } +} diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/java/org/bukkit/block/banner/PatternType.java new file mode 100644 index 00000000..25543b0b --- /dev/null +++ b/src/main/java/org/bukkit/block/banner/PatternType.java @@ -0,0 +1,80 @@ +package org.bukkit.block.banner; + +import java.util.HashMap; +import java.util.Map; + +public enum PatternType { + BASE("b"), + SQUARE_BOTTOM_LEFT("bl"), + SQUARE_BOTTOM_RIGHT("br"), + SQUARE_TOP_LEFT("tl"), + SQUARE_TOP_RIGHT("tr"), + STRIPE_BOTTOM("bs"), + STRIPE_TOP("ts"), + STRIPE_LEFT("ls"), + STRIPE_RIGHT("rs"), + STRIPE_CENTER("cs"), + STRIPE_MIDDLE("ms"), + STRIPE_DOWNRIGHT("drs"), + STRIPE_DOWNLEFT("dls"), + STRIPE_SMALL("ss"), + CROSS("cr"), + STRAIGHT_CROSS("sc"), + TRIANGLE_BOTTOM("bt"), + TRIANGLE_TOP("tt"), + TRIANGLES_BOTTOM("bts"), + TRIANGLES_TOP("tts"), + DIAGONAL_LEFT("ld"), + DIAGONAL_RIGHT("rd"), + DIAGONAL_LEFT_MIRROR("lud"), + DIAGONAL_RIGHT_MIRROR("rud"), + CIRCLE_MIDDLE("mc"), + RHOMBUS_MIDDLE("mr"), + HALF_VERTICAL("vh"), + HALF_HORIZONTAL("hh"), + HALF_VERTICAL_MIRROR("vhr"), + HALF_HORIZONTAL_MIRROR("hhb"), + BORDER("bo"), + CURLY_BORDER("cbo"), + CREEPER("cre"), + GRADIENT("gra"), + GRADIENT_UP("gru"), + BRICKS("bri"), + SKULL("sku"), + FLOWER("flo"), + MOJANG("moj"); + + private final String identifier; + private static final Map byString = new HashMap(); + + static { + for (PatternType p : values()) { + byString.put(p.identifier, p); + } + } + + private PatternType(String key) { + this.identifier = key; + } + + /** + * Returns the identifier used to represent + * this pattern type + * + * @return the pattern's identifier + */ + public String getIdentifier() { + return identifier; + } + + /** + * Returns the pattern type which matches the passed + * identifier or null if no matches are found + * + * @param identifier the identifier + * @return the matched pattern type or null + */ + public static PatternType getByIdentifier(String identifier) { + return byString.get(identifier); + } +} diff --git a/src/main/java/org/bukkit/command/defaults/GameModeCommand.java b/src/main/java/org/bukkit/command/defaults/GameModeCommand.java index c58f9067..471ccdfb 100644 --- a/src/main/java/org/bukkit/command/defaults/GameModeCommand.java +++ b/src/main/java/org/bukkit/command/defaults/GameModeCommand.java @@ -15,7 +15,7 @@ import org.bukkit.util.StringUtil; import com.google.common.collect.ImmutableList; public class GameModeCommand extends VanillaCommand { - private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival"); + private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", "spectator"); public GameModeCommand() { super("gamemode"); @@ -55,6 +55,8 @@ public class GameModeCommand extends VanillaCommand { mode = GameMode.CREATIVE; } else if (modeArg.equalsIgnoreCase("adventure") || modeArg.equalsIgnoreCase("a")) { mode = GameMode.ADVENTURE; + } else if (modeArg.equalsIgnoreCase("spectator") || modeArg.equalsIgnoreCase("sp")) { + mode = GameMode.SPECTATOR; } else { mode = GameMode.SURVIVAL; } diff --git a/src/main/java/org/bukkit/entity/ArmorStand.java b/src/main/java/org/bukkit/entity/ArmorStand.java new file mode 100644 index 00000000..b323e735 --- /dev/null +++ b/src/main/java/org/bukkit/entity/ArmorStand.java @@ -0,0 +1,261 @@ +package org.bukkit.entity; + +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.EulerAngle; + +public interface ArmorStand extends LivingEntity { + + /** + * Returns the item the armor stand is + * currently holding + * + * @return the held item + */ + ItemStack getItemInHand(); + + /** + * Sets the item the armor stand is currently + * holding + * + * @param item the item to hold + */ + void setItemInHand(ItemStack item); + + /** + * Returns the item currently being worn + * by the armor stand on its feet + * + * @return the worn item + */ + ItemStack getBoots(); + + /** + * Sets the item currently being worn + * by the armor stand on its feet + * + * @param item the item to wear + */ + void setBoots(ItemStack item); + + /** + * Returns the item currently being worn + * by the armor stand on its legs + * + * @return the worn item + */ + ItemStack getLeggings(); + + /** + * Sets the item currently being worn + * by the armor stand on its legs + * + * @param item the item to wear + */ + void setLeggings(ItemStack item); + + /** + * Returns the item currently being worn + * by the armor stand on its chest + * + * @return the worn item + */ + ItemStack getChestplate(); + + /** + * Sets the item currently being worn + * by the armor stand on its chest + * + * @param item the item to wear + */ + void setChestplate(ItemStack item); + + /** + * Returns the item currently being worn + * by the armor stand on its head + * + * @return the worn item + */ + ItemStack getHelmet(); + + /** + * Sets the item currently being worn + * by the armor stand on its head + * + * @param item the item to wear + */ + void setHelmet(ItemStack item); + + /** + * Returns the armor stand's body's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getBodyPose(); + + /** + * Sets the armor stand's body's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setBodyPose(EulerAngle pose); + + /** + * Returns the armor stand's left arm's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getLeftArmPose(); + + /** + * Sets the armor stand's left arm's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setLeftArmPose(EulerAngle pose); + + /** + * Returns the armor stand's right arm's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getRightArmPose(); + + /** + * Sets the armor stand's right arm's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setRightArmPose(EulerAngle pose); + + /** + * Returns the armor stand's left leg's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getLeftLegPose(); + + /** + * Sets the armor stand's left leg's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setLeftLegPose(EulerAngle pose); + + /** + * Returns the armor stand's right leg's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getRightLegPose(); + + /** + * Sets the armor stand's right leg's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setRightLegPose(EulerAngle pose); + + /** + * Returns the armor stand's head's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @return the current pose + */ + EulerAngle getHeadPose(); + + /** + * Sets the armor stand's head's + * current pose as a {@link org.bukkit.util.EulerAngle} + * + * @param pose the current pose + */ + void setHeadPose(EulerAngle pose); + + /** + * Returns whether the armor stand has + * a base plate + * + * @return whether it has a base plate + */ + boolean hasBasePlate(); + + /** + * Sets whether the armor stand has a + * base plate + * + * @param basePlate whether is has a base plate + */ + void setBasePlate(boolean basePlate); + + /** + * Returns whether gravity applies to + * this armor stand + * + * @return whether gravity applies + */ + boolean hasGravity(); + + /** + * Sets whether gravity applies to + * this armor stand + * + * @param gravity whether gravity should apply + */ + void setGravity(boolean gravity); + + /** + * Returns whether the armor stand should be + * visible or not + * + * @return whether the stand is visible or not + */ + boolean isVisible(); + + /** + * Sets whether the armor stand should be + * visible or not + * + * @param visible whether the stand is visible or not + */ + void setVisible(boolean visible); + + /** + * Returns whether this armor stand has arms + * + * @return whether this has arms or not + */ + boolean hasArms(); + + /** + * Sets whether this armor stand has arms + * + * @param arms whether this has arms or not + */ + void setArms(boolean arms); + + /** + * Returns whether this armor stand is scaled + * down + * + * @return whether this is scaled down + */ + boolean isSmall(); + + /** + * Sets whether this armor stand is scaled + * down + * + * @param small whether this is scaled down + */ + void setSmall(boolean small); +} diff --git a/src/main/java/org/bukkit/entity/CreatureType.java b/src/main/java/org/bukkit/entity/CreatureType.java index fd230933..48ff687a 100644 --- a/src/main/java/org/bukkit/entity/CreatureType.java +++ b/src/main/java/org/bukkit/entity/CreatureType.java @@ -26,6 +26,8 @@ public enum CreatureType { BLAZE("Blaze", Blaze.class, 61), MAGMA_CUBE("LavaSlime", MagmaCube.class, 62), ENDER_DRAGON("EnderDragon", EnderDragon.class, 63), + ENDERMITE("Endermite", Endermite.class, 67), + GUARDIAN("Guardian", Guardian.class, 68), PIG("Pig", Pig.class, 90), SHEEP("Sheep", Sheep.class, 91), COW("Cow", Cow.class, 92), @@ -34,6 +36,7 @@ public enum CreatureType { WOLF("Wolf", Wolf.class, 95), MUSHROOM_COW("MushroomCow", MushroomCow.class, 96), SNOWMAN("SnowMan", Snowman.class, 97), + RABBIT("Rabbit", Rabbit.class, 101), VILLAGER("Villager", Villager.class, 120); private String name; diff --git a/src/main/java/org/bukkit/entity/Endermite.java b/src/main/java/org/bukkit/entity/Endermite.java new file mode 100644 index 00000000..dc1fa542 --- /dev/null +++ b/src/main/java/org/bukkit/entity/Endermite.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface Endermite extends Monster { +} diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java index a60172df..39c35c05 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -295,4 +295,49 @@ public interface Entity extends Metadatable { * @return The current vehicle. */ public Entity getVehicle(); + + /** + * Sets a custom name on a mob. This name will be used in death messages + * and can be sent to the client as a nameplate over the mob. + *

+ * Setting the name to null or an empty string will clear it. + *

+ * This value has no effect on players, they will always use their real + * name. + * + * @param name the name to set + */ + public void setCustomName(String name); + + /** + * Gets the custom name on a mob. If there is no name this method will + * return null. + *

+ * This value has no effect on players, they will always use their real + * name. + * + * @return name of the mob or null + */ + public String getCustomName(); + + /** + * Sets whether or not to display the mob's custom name client side. The + * name will be displayed above the mob similarly to a player. + *

+ * This value has no effect on players, they will always display their + * name. + * + * @param flag custom name or not + */ + public void setCustomNameVisible(boolean flag); + + /** + * Gets whether or not the mob's custom name is displayed client side. + *

+ * This value has no effect on players, they will always display their + * name. + * + * @return if the custom name is displayed + */ + public boolean isCustomNameVisible(); } diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java index 39ecb130..2a69367d 100644 --- a/src/main/java/org/bukkit/entity/EntityType.java +++ b/src/main/java/org/bukkit/entity/EntityType.java @@ -81,6 +81,7 @@ public enum EntityType { */ FALLING_BLOCK("FallingSand", FallingBlock.class, 21, false), FIREWORK("FireworksRocketEntity", Firework.class, 22, false), + ARMOR_STAND("ArmorStand", ArmorStand.class, 30, false), /** * @see CommandMinecart */ @@ -130,6 +131,8 @@ public enum EntityType { WITHER("WitherBoss", Wither.class, 64), BAT("Bat", Bat.class, 65), WITCH("Witch", Witch.class, 66), + ENDERMITE("Endermite", Endermite.class, 67), + GUARDIAN("Guardian", Guardian.class, 68), PIG("Pig", Pig.class, 90), SHEEP("Sheep", Sheep.class, 91), COW("Cow", Cow.class, 92), @@ -141,6 +144,7 @@ public enum EntityType { OCELOT("Ozelot", Ocelot.class, 98), IRON_GOLEM("VillagerGolem", IronGolem.class, 99), HORSE("EntityHorse", Horse.class, 100), + RABBIT("Rabbit", Rabbit.class, 101), VILLAGER("Villager", Villager.class, 120), ENDER_CRYSTAL("EnderCrystal", EnderCrystal.class, 200), // These don't have an entity ID in nms.EntityTypes. diff --git a/src/main/java/org/bukkit/entity/Guardian.java b/src/main/java/org/bukkit/entity/Guardian.java new file mode 100644 index 00000000..2b2f496b --- /dev/null +++ b/src/main/java/org/bukkit/entity/Guardian.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface Guardian extends Monster { +} diff --git a/src/main/java/org/bukkit/entity/LivingEntity.java b/src/main/java/org/bukkit/entity/LivingEntity.java index 6c8b4f86..5e2a41ae 100644 --- a/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/src/main/java/org/bukkit/entity/LivingEntity.java @@ -320,51 +320,6 @@ public interface LivingEntity extends Entity, Damageable, ProjectileSource { */ public boolean getCanPickupItems(); - /** - * Sets a custom name on a mob. This name will be used in death messages - * and can be sent to the client as a nameplate over the mob. - *

- * Setting the name to null or an empty string will clear it. - *

- * This value has no effect on players, they will always use their real - * name. - * - * @param name the name to set - */ - public void setCustomName(String name); - - /** - * Gets the custom name on a mob. If there is no name this method will - * return null. - *

- * This value has no effect on players, they will always use their real - * name. - * - * @return name of the mob or null - */ - public String getCustomName(); - - /** - * Sets whether or not to display the mob's custom name client side. The - * name will be displayed above the mob similarly to a player. - *

- * This value has no effect on players, they will always display their - * name. - * - * @param flag custom name or not - */ - public void setCustomNameVisible(boolean flag); - - /** - * Gets whether or not the mob's custom name is displayed client side. - *

- * This value has no effect on players, they will always display their - * name. - * - * @return if the custom name is displayed - */ - public boolean isCustomNameVisible(); - /** * Returns whether the entity is currently leashed. * diff --git a/src/main/java/org/bukkit/entity/Rabbit.java b/src/main/java/org/bukkit/entity/Rabbit.java new file mode 100644 index 00000000..7c3e3daa --- /dev/null +++ b/src/main/java/org/bukkit/entity/Rabbit.java @@ -0,0 +1,4 @@ +package org.bukkit.entity; + +public interface Rabbit extends Animals { +} diff --git a/src/main/java/org/bukkit/entity/WaterMob.java b/src/main/java/org/bukkit/entity/WaterMob.java index 62b4e89d..3e89ca0c 100644 --- a/src/main/java/org/bukkit/entity/WaterMob.java +++ b/src/main/java/org/bukkit/entity/WaterMob.java @@ -3,4 +3,4 @@ package org.bukkit.entity; /** * Represents a Water Mob */ -public interface WaterMob extends Creature {} +public interface WaterMob extends LivingEntity {} diff --git a/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java b/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java index 1058b8b8..682ce60a 100644 --- a/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java +++ b/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java @@ -16,17 +16,28 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { private final int length; private List blocks; + @Deprecated public BlockPistonExtendEvent(final Block block, final int length, final BlockFace direction) { super(block, direction); this.length = length; } + public BlockPistonExtendEvent(final Block block, final List blocks, final BlockFace direction) { + super(block, direction); + + this.length = blocks.size(); + this.blocks = blocks; + } + /** * Get the amount of blocks which will be moved while extending. * * @return the amount of moving blocks + * @deprecated slime blocks make the value of this method + * inaccurate due to blocks being pushed at the side */ + @Deprecated public int getLength() { return this.length; } diff --git a/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index 1f7af4db..cf672513 100644 --- a/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -136,6 +136,15 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { /** * For custom calls to the event. */ - CUSTOM + CUSTOM, + /** + * When the entity doesn't have a target, so it attacks the nearest + * entity + */ + CLOSEST_ENTITY, + /** + * A currently unknown reason for the entity changing target. + */ + UNKNOWN; } } diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java index b83580a4..c36e0467 100644 --- a/src/main/java/org/bukkit/event/inventory/InventoryType.java +++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java @@ -30,10 +30,10 @@ public enum InventoryType { */ CRAFTING(5,"Crafting"), /** - * An enchantment table inventory, with one CRAFTING slot and three + * An enchantment table inventory, with two CRAFTING slots and three * enchanting buttons. */ - ENCHANTING(1,"Enchanting"), + ENCHANTING(2,"Enchanting"), /** * A brewing stand inventory, with one FUEL slot and three CRAFTING slots. */ diff --git a/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java b/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java new file mode 100644 index 00000000..db5678ee --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java @@ -0,0 +1,22 @@ +package org.bukkit.event.player; + +import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; +import org.bukkit.util.Vector; + +/** + * Represents an event that is called when a player right clicks an entity + * with a location on the entity the was clicked. + */ +public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent { + private final Vector position; + + public PlayerInteractAtEntityEvent(Player who, Entity clickedEntity, Vector position) { + super(who, clickedEntity); + this.position = position; + } + + public Vector getClickedPosition() { + return position.clone(); + } +} diff --git a/src/main/java/org/bukkit/inventory/EnchantingInventory.java b/src/main/java/org/bukkit/inventory/EnchantingInventory.java index 74a863e1..6551a16a 100644 --- a/src/main/java/org/bukkit/inventory/EnchantingInventory.java +++ b/src/main/java/org/bukkit/inventory/EnchantingInventory.java @@ -18,4 +18,18 @@ public interface EnchantingInventory extends Inventory { * @return The current item. */ ItemStack getItem(); + + /** + * Set the secondary item being used for the enchant. + * + * @param item The new item + */ + void setSecondary(ItemStack item); + + /** + * Get the secondary item being used for the enchant. + * + * @return The second item + */ + ItemStack getSecondary(); } diff --git a/src/main/java/org/bukkit/inventory/meta/BannerMeta.java b/src/main/java/org/bukkit/inventory/meta/BannerMeta.java new file mode 100644 index 00000000..6bf33c59 --- /dev/null +++ b/src/main/java/org/bukkit/inventory/meta/BannerMeta.java @@ -0,0 +1,76 @@ +package org.bukkit.inventory.meta; + +import java.util.List; +import org.bukkit.DyeColor; +import org.bukkit.block.banner.Pattern; + +public interface BannerMeta extends ItemMeta { + + /** + * Returns the base color for this banner + * + * @return the base color + */ + DyeColor getBaseColor(); + + /** + * Sets the base color for this banner + * + * @param color the base color + */ + void setBaseColor(DyeColor color); + + /** + * Returns a list of patterns on this banner + * + * @return the patterns + */ + List getPatterns(); + + /** + * Sets the patterns used on this banner + * + * @param patterns the new list of patterns + */ + void setPatterns(List patterns); + + /** + * Adds a new pattern on top of the existing + * patterns + * + * @param pattern the new pattern to add + */ + void addPattern(Pattern pattern); + + /** + * Returns the pattern at the specified index + * + * @param i the index + * @return the pattern + */ + Pattern getPattern(int i); + + /** + * Removes the pattern at the specified index + * + * @param i the index + * @return the removed pattern + */ + Pattern removePattern(int i); + + /** + * Sets the pattern at the specified index + * + * @param i the index + * @param pattern the new pattern + */ + void setPattern(int i, Pattern pattern); + + /** + * Returns the number of patterns on this + * banner + * + * @return the number of patterns + */ + int numberOfPatterns(); +} diff --git a/src/main/java/org/bukkit/material/Banner.java b/src/main/java/org/bukkit/material/Banner.java new file mode 100644 index 00000000..e5a9d1c8 --- /dev/null +++ b/src/main/java/org/bukkit/material/Banner.java @@ -0,0 +1,232 @@ +package org.bukkit.material; + +import org.bukkit.Material; +import org.bukkit.block.BlockFace; + +public class Banner extends MaterialData implements Attachable { + + public Banner() { + super(Material.BANNER); + } + + public Banner(Material type) { + super(type); + } + + /** + * + * @deprecated Magic value + */ + @Deprecated + public Banner(int type) { + super(type); + } + + /** + * + * @deprecated Magic value + */ + @Deprecated + public Banner(Material type, byte data) { + super(type, data); + } + + /** + * + * @deprecated Magic value + */ + @Deprecated + public Banner(int type, byte data) { + super(type, data); + } + + public boolean isWallBanner() { + return getItemType() == Material.WALL_BANNER; + } + + public BlockFace getAttachedFace() { + if (isWallBanner()) { + byte data = getData(); + + switch (data) { + case 0x2: + return BlockFace.SOUTH; + + case 0x3: + return BlockFace.NORTH; + + case 0x4: + return BlockFace.EAST; + + case 0x5: + return BlockFace.WEST; + } + + return null; + } else { + return BlockFace.DOWN; + } + } + + public BlockFace getFacing() { + byte data = getData(); + + if (!isWallBanner()) { + switch (data) { + case 0x0: + return BlockFace.SOUTH; + + case 0x1: + return BlockFace.SOUTH_SOUTH_WEST; + + case 0x2: + return BlockFace.SOUTH_WEST; + + case 0x3: + return BlockFace.WEST_SOUTH_WEST; + + case 0x4: + return BlockFace.WEST; + + case 0x5: + return BlockFace.WEST_NORTH_WEST; + + case 0x6: + return BlockFace.NORTH_WEST; + + case 0x7: + return BlockFace.NORTH_NORTH_WEST; + + case 0x8: + return BlockFace.NORTH; + + case 0x9: + return BlockFace.NORTH_NORTH_EAST; + + case 0xA: + return BlockFace.NORTH_EAST; + + case 0xB: + return BlockFace.EAST_NORTH_EAST; + + case 0xC: + return BlockFace.EAST; + + case 0xD: + return BlockFace.EAST_SOUTH_EAST; + + case 0xE: + return BlockFace.SOUTH_EAST; + + case 0xF: + return BlockFace.SOUTH_SOUTH_EAST; + } + + return null; + } else { + return getAttachedFace().getOppositeFace(); + } + } + + public void setFacingDirection(BlockFace face) { + byte data; + + if (isWallBanner()) { + switch (face) { + case NORTH: + data = 0x2; + break; + + case SOUTH: + data = 0x3; + break; + + case WEST: + data = 0x4; + break; + + case EAST: + default: + data = 0x5; + } + } else { + switch (face) { + case SOUTH: + data = 0x0; + break; + + case SOUTH_SOUTH_WEST: + data = 0x1; + break; + + case SOUTH_WEST: + data = 0x2; + break; + + case WEST_SOUTH_WEST: + data = 0x3; + break; + + case WEST: + data = 0x4; + break; + + case WEST_NORTH_WEST: + data = 0x5; + break; + + case NORTH_WEST: + data = 0x6; + break; + + case NORTH_NORTH_WEST: + data = 0x7; + break; + + case NORTH: + data = 0x8; + break; + + case NORTH_NORTH_EAST: + data = 0x9; + break; + + case NORTH_EAST: + data = 0xA; + break; + + case EAST_NORTH_EAST: + data = 0xB; + break; + + case EAST: + data = 0xC; + break; + + case EAST_SOUTH_EAST: + data = 0xD; + break; + + case SOUTH_SOUTH_EAST: + data = 0xF; + break; + + case SOUTH_EAST: + default: + data = 0xE; + } + } + + setData(data); + } + + @Override + public String toString() { + return super.toString() + " facing " + getFacing(); + } + + @Override + public Banner clone() { + return (Banner) super.clone(); + } +} diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index b178c0d1..fb0bfba5 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -232,11 +232,12 @@ public final class JavaPluginLoader implements PluginLoader { Set methods; try { Method[] publicMethods = listener.getClass().getMethods(); - methods = new HashSet(publicMethods.length, Float.MAX_VALUE); + Method[] privateMethods = listener.getClass().getDeclaredMethods(); + methods = new HashSet(publicMethods.length + privateMethods.length, 1.0f); for (Method method : publicMethods) { methods.add(method); } - for (Method method : listener.getClass().getDeclaredMethods()) { + for (Method method : privateMethods) { methods.add(method); } } catch (NoClassDefFoundError e) { diff --git a/src/main/java/org/bukkit/potion/PotionType.java b/src/main/java/org/bukkit/potion/PotionType.java index a02b6a81..b9949d96 100644 --- a/src/main/java/org/bukkit/potion/PotionType.java +++ b/src/main/java/org/bukkit/potion/PotionType.java @@ -14,6 +14,7 @@ public enum PotionType { INSTANT_DAMAGE(12, PotionEffectType.HARM, 2), WATER_BREATHING(13, PotionEffectType.WATER_BREATHING, 1), INVISIBILITY(14, PotionEffectType.INVISIBILITY, 1), + JUMP(15, PotionEffectType.JUMP, 2) ; private final int damageValue, maxLevel; diff --git a/src/main/java/org/bukkit/util/EulerAngle.java b/src/main/java/org/bukkit/util/EulerAngle.java new file mode 100644 index 00000000..7778710c --- /dev/null +++ b/src/main/java/org/bukkit/util/EulerAngle.java @@ -0,0 +1,147 @@ +package org.bukkit.util; + +/** + * EulerAngle is used to represent 3 angles, one for each + * axis (x, y, z). The angles are in radians + */ +public class EulerAngle { + + /** + * A EulerAngle with every axis set to 0 + */ + public static final EulerAngle ZERO = new EulerAngle(0, 0, 0); + + private final double x; + private final double y; + private final double z; + + /** + * Creates a EularAngle with each axis set to the + * passed angle in radians + * + * @param x the angle for the x axis in radians + * @param y the angle for the x axis in radians + * @param z the angle for the x axis in radians + */ + public EulerAngle(double x, double y, double z) { + this.x = x; + this.y = y; + this.z = z; + } + + /** + * Returns the angle on the x axis in radians + * + * @return the angle in radians + */ + public double getX() { + return x; + } + + /** + * Returns the angle on the y axis in radians + * + * @return the angle in radians + */ + public double getY() { + return y; + } + + /** + * Returns the angle on the z axis in radians + * + * @return the angle in radians + */ + public double getZ() { + return z; + } + + /** + * Return a EulerAngle which is the result of changing + * the x axis to the passed angle + * + * @param x the angle in radians + * @return the resultant EulerAngle + */ + public EulerAngle setX(double x) { + return new EulerAngle(x, y, z); + } + + /** + * Return a EulerAngle which is the result of changing + * the y axis to the passed angle + * + * @param y the angle in radians + * @return the resultant EulerAngle + */ + public EulerAngle setY(double y) { + return new EulerAngle(x, y, z); + } + + /** + * Return a EulerAngle which is the result of changing + * the z axis to the passed angle + * + * @param z the angle in radians + * @return the resultant EulerAngle + */ + public EulerAngle setZ(double z) { + return new EulerAngle(x, y, z); + } + + /** + * Creates a new EulerAngle which is the result of adding + * the x, y, z components to this EulerAngle + * + * @param x the angle to add to the x axis in radians + * @param y the angle to add to the y axis in radians + * @param z the angle to add to the z axis in radians + * @return the resultant EulerAngle + */ + public EulerAngle add(double x, double y, double z) { + return new EulerAngle( + this.x + x, + this.y + y, + this.z + z + ); + } + + /** + * Creates a new EulerAngle which is the result of subtracting + * the x, y, z components to this EulerAngle + * + * @param x the angle to subtract to the x axis in radians + * @param y the angle to subtract to the y axis in radians + * @param z the angle to subtract to the z axis in radians + * @return the resultant EulerAngle + */ + public EulerAngle subtract(double x, double y, double z) { + return add(-x, -y, -z); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + EulerAngle that = (EulerAngle) o; + + return Double.compare(that.x, x) == 0 + && Double.compare(that.y, y) == 0 + && Double.compare(that.z, z) == 0; + + } + + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(x); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(y); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(z); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + return result; + } +} -- cgit v1.2.3