Update Update Bukkit to 1.7.2

By: mbax <matt@phozop.net>
This commit is contained in:
Bukkit/Spigot 2013-11-13 17:53:49 -07:00
parent 1945a3b7ea
commit aa66c8025a
19 changed files with 327 additions and 205 deletions

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.4-R2.1-SNAPSHOT</version>
<version>1.7.2-R0.1-SNAPSHOT</version>
<name>Bukkit</name>
<url>http://www.bukkit.org</url>

View File

@ -1,82 +1,48 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
/**
* Represents an achievement, which may be given to players
*/
public enum Achievement {
OPEN_INVENTORY(0),
MINE_WOOD(1),
BUILD_WORKBENCH(2),
BUILD_PICKAXE(3),
BUILD_FURNACE(4),
ACQUIRE_IRON(5),
BUILD_HOE(6),
MAKE_BREAD(7),
BAKE_CAKE(8),
BUILD_BETTER_PICKAXE(9),
COOK_FISH(10),
ON_A_RAIL(11),
BUILD_SWORD(12),
KILL_ENEMY(13),
KILL_COW(14),
FLY_PIG(15),
SNIPE_SKELETON(16),
GET_DIAMONDS(17),
NETHER_PORTAL(18),
GHAST_RETURN(19),
GET_BLAZE_ROD(20),
BREW_POTION(21),
END_PORTAL(22),
THE_END(23),
ENCHANTMENTS(24),
OVERKILL(25),
BOOKCASE(26);
OPEN_INVENTORY,
MINE_WOOD,
BUILD_WORKBENCH,
BUILD_PICKAXE,
BUILD_FURNACE,
ACQUIRE_IRON,
BUILD_HOE,
MAKE_BREAD,
BAKE_CAKE,
BUILD_BETTER_PICKAXE,
COOK_FISH,
ON_A_RAIL,
BUILD_SWORD,
KILL_ENEMY,
KILL_COW,
FLY_PIG,
SNIPE_SKELETON,
GET_DIAMONDS,
NETHER_PORTAL,
GHAST_RETURN,
GET_BLAZE_ROD,
BREW_POTION,
END_PORTAL,
THE_END,
ENCHANTMENTS,
OVERKILL,
BOOKCASE,
BREED_COW,
SPAWN_WITHER,
KILL_WITHER,
FULL_BEACON,
EXPLORE_ALL_BIOMES,
DIAMONDS_TO_YOU,
;
/**
* The offset used to distinguish Achievements and Statistics
* @deprecated Magic value
*/
@Deprecated
public final static int STATISTIC_OFFSET = 0x500000;
private final static Map<Integer, Achievement> BY_ID = Maps.newHashMap();
private final int id;
private Achievement(int id) {
this.id = STATISTIC_OFFSET + id;
}
/**
* Gets the ID for this achievement.
* <p>
* Note that this is offset using {@link #STATISTIC_OFFSET}
*
* @return ID of this achievement
* @deprecated Magic value
*/
@Deprecated
public int getId() {
return id;
}
/**
* Gets the achievement associated with the given ID.
* <p>
* Note that the ID must already be offset using {@link #STATISTIC_OFFSET}
*
* @param id ID of the achievement to return
* @return Achievement with the given ID
* @deprecated Magic value
*/
@Deprecated
public static Achievement getById(int id) {
return BY_ID.get(id);
}
static {
for (Achievement achievement : values()) {
BY_ID.put(achievement.id, achievement);
}
}
}

View File

@ -1,5 +1,6 @@
package org.bukkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Iterator;
import java.util.List;
@ -25,6 +26,7 @@ import org.bukkit.plugin.ServicesManager;
import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.util.CachedServerIcon;
import com.avaje.ebean.config.ServerConfig;
import org.bukkit.inventory.ItemFactory;
@ -654,4 +656,25 @@ public final class Bukkit {
public static ScoreboardManager getScoreboardManager() {
return server.getScoreboardManager();
}
/**
* @see Server#getServerIcon()
*/
public static CachedServerIcon getServerIcon() {
return server.getServerIcon();
}
/**
* @see Server#loadServerIcon(File)()
*/
public static CachedServerIcon loadServerIcon(File file) throws Exception {
return server.loadServerIcon(file);
}
/**
* @see Server#loadServerIcon(BufferedImage)
*/
public static CachedServerIcon loadServerIcon(BufferedImage image) throws Exception {
return server.loadServerIcon(image);
}
}

View File

@ -157,7 +157,9 @@ public enum Material {
CAKE_BLOCK(92, 64, Cake.class),
DIODE_BLOCK_OFF(93, Diode.class),
DIODE_BLOCK_ON(94, Diode.class),
@Deprecated
LOCKED_CHEST(95),
STAINED_GLASS(95),
TRAP_DOOR(96, TrapDoor.class),
MONSTER_EGGS(97, MonsterEggs.class),
SMOOTH_BRICK(98, SmoothBrick.class),
@ -222,10 +224,17 @@ public enum Material {
ACTIVATOR_RAIL(157, PoweredRail.class),
DROPPER(158, Dispenser.class),
STAINED_CLAY(159),
STAINED_GLASS_PANE(160),
LEAVES_2(161),
LOG_2(162),
ACACIA_STAIRS(163),
DARK_OAK_STAIRS(164),
HAY_BLOCK(170),
CARPET(171),
HARD_CLAY(172),
COAL_BLOCK(173),
PACKED_ICE(174),
DOUBLE_PLANT(175),
// ----- Item Separator -----
IRON_SPADE(256, 1, 250),
IRON_PICKAXE(257, 1, 250),
@ -364,7 +373,7 @@ public enum Material {
EXP_BOTTLE(384, 64),
FIREBALL(385, 64),
BOOK_AND_QUILL(386, 1),
WRITTEN_BOOK(387, 1),
WRITTEN_BOOK(387, 16),
EMERALD(388, 64),
ITEM_FRAME(389),
FLOWER_POT_ITEM(390),
@ -391,6 +400,7 @@ public enum Material {
DIAMOND_BARDING(419, 1),
LEASH(420),
NAME_TAG(421),
COMMAND_MINECART(422, 1),
GOLD_RECORD(2256, 1),
GREEN_RECORD(2257, 1),
RECORD_3(2258, 1),
@ -706,6 +716,7 @@ public enum Material {
case JACK_O_LANTERN:
case CAKE_BLOCK:
case LOCKED_CHEST:
case STAINED_GLASS:
case TRAP_DOOR:
case MONSTER_EGGS:
case SMOOTH_BRICK:
@ -756,6 +767,12 @@ public enum Material {
case HAY_BLOCK:
case HARD_CLAY:
case COAL_BLOCK:
case STAINED_GLASS_PANE:
case LEAVES_2:
case LOG_2:
case ACACIA_STAIRS:
case DARK_OAK_STAIRS:
case PACKED_ICE:
return true;
default:
return false;
@ -815,6 +832,7 @@ public enum Material {
case REDSTONE_COMPARATOR_ON:
case ACTIVATOR_RAIL:
case CARPET:
case DOUBLE_PLANT:
return true;
default:
return false;
@ -850,7 +868,6 @@ public enum Material {
case WOOD_PLATE:
case JUKEBOX:
case FENCE:
case LOCKED_CHEST:
case TRAP_DOOR:
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
@ -864,6 +881,10 @@ public enum Material {
case TRAPPED_CHEST:
case DAYLIGHT_DETECTOR:
case CARPET:
case LEAVES_2:
case LOG_2:
case ACACIA_STAIRS:
case DARK_OAK_STAIRS:
return true;
default:
return false;
@ -885,6 +906,8 @@ public enum Material {
case LEAVES:
case LONG_GRASS:
case WOOL:
case YELLOW_FLOWER:
case RED_ROSE:
case TNT:
case BOOKSHELF:
case WOOD_STAIRS:
@ -897,6 +920,10 @@ public enum Material {
case JUNGLE_WOOD_STAIRS:
case HAY_BLOCK:
case COAL_BLOCK:
case LEAVES_2:
case LOG_2:
case CARPET:
case DOUBLE_PLANT:
return true;
default:
return false;
@ -954,7 +981,6 @@ public enum Material {
case NETHERRACK:
case SOUL_SAND:
case JACK_O_LANTERN:
case LOCKED_CHEST:
case MONSTER_EGGS:
case SMOOTH_BRICK:
case HUGE_MUSHROOM_1:
@ -977,6 +1003,8 @@ public enum Material {
case HAY_BLOCK:
case HARD_CLAY:
case COAL_BLOCK:
case LOG_2:
case PACKED_ICE:
return true;
default:
return false;

View File

@ -1,5 +1,6 @@
package org.bukkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Iterator;
import java.util.List;
@ -15,6 +16,7 @@ import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.help.HelpMap;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
@ -27,6 +29,7 @@ import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.plugin.messaging.PluginMessageRecipient;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scoreboard.ScoreboardManager;
import org.bukkit.util.CachedServerIcon;
import com.avaje.ebean.config.ServerConfig;
import org.bukkit.inventory.ItemFactory;
@ -709,4 +712,44 @@ public interface Server extends PluginMessageRecipient {
* @return the scoreboard manager or null if no worlds are loaded.
*/
ScoreboardManager getScoreboardManager();
/**
* Gets an instance of the server's default server-icon.
*
* @return the default server-icon; null values may be used by the
* implementation to indicate no defined icon, but this behavior is
* not guaranteed
*/
CachedServerIcon getServerIcon();
/**
* Loads an image from a file, and returns a cached image for the
* specific server-icon.
* <p>
* Size and type are implementation defined. An incompatible file is
* guaranteed to throw an implementation-defined {@link Exception}.
*
* @param file the file to load the from
* @throws IllegalArgumentException if image is null
* @throws Exception if the image does not meet current server
* server-icon specifications
* @return a cached server-icon that can be used for a {@link
* ServerListPingEvent#setServerIcon(CachedServerIcon)}
*/
CachedServerIcon loadServerIcon(File file) throws IllegalArgumentException, Exception;
/**
* Creates a cached server-icon for the specific image.
* <p>
* Size and type are implementation defined. An incompatible file is
* guaranteed to throw an implementation-defined {@link Exception}.
*
* @param image the image to use
* @throws IllegalArgumentException if image is null
* @throws Exception if the image does not meet current server
* server-icon specifications
* @return a cached server-icon that can be used for a {@link
* ServerListPingEvent#setServerIcon(CachedServerIcon)}
*/
CachedServerIcon loadServerIcon(BufferedImage image) throws IllegalArgumentException, Exception;
}

View File

@ -1,53 +1,35 @@
package org.bukkit;
import java.util.Map;
import com.google.common.collect.Maps;
/**
* Represents a countable statistic, which is collected by the client
*/
public enum Statistic {
DAMAGE_DEALT(2020),
DAMAGE_TAKEN(2021),
DEATHS(2022),
MOB_KILLS(2023),
PLAYER_KILLS(2024),
FISH_CAUGHT(2025),
MINE_BLOCK(16777216, true),
USE_ITEM(6908288, false),
BREAK_ITEM(16973824, true);
DAMAGE_DEALT,
DAMAGE_TAKEN,
DEATHS,
MOB_KILLS,
PLAYER_KILLS,
FISH_CAUGHT,
MINE_BLOCK(true),
USE_ITEM(false),
BREAK_ITEM(true);
private final static Map<Integer, Statistic> BY_ID = Maps.newHashMap();
private final int id;
private final boolean isSubstat;
private final boolean isBlock;
private Statistic(int id) {
this(id, false, false);
private Statistic() {
this(false, false);
}
private Statistic(int id, boolean isBlock) {
this(id, true, isBlock);
private Statistic(boolean isBlock) {
this(true, isBlock);
}
private Statistic(int id, boolean isSubstat, boolean isBlock) {
this.id = id;
private Statistic(boolean isSubstat, boolean isBlock) {
this.isSubstat = isSubstat;
this.isBlock = isBlock;
}
/**
* Gets the ID for this statistic.
*
* @return ID of this statistic
* @deprecated Magic value
*/
@Deprecated
public int getId() {
return id;
}
/**
* Checks if this is a substatistic.
* <p>
@ -67,22 +49,4 @@ public enum Statistic {
public boolean isBlock() {
return isSubstat && isBlock;
}
/**
* Gets the statistic associated with the given ID.
*
* @param id ID of the statistic to return
* @return statistic with the given ID
* @deprecated Magic value
*/
@Deprecated
public static Statistic getById(int id) {
return BY_ID.get(id);
}
static {
for (Statistic statistic : values()) {
BY_ID.put(statistic.id, statistic);
}
}
}

View File

@ -24,7 +24,16 @@ public enum TreeSpecies {
/**
* Represents jungle trees.
*/
JUNGLE(0x3);
JUNGLE(0x3),
/**
* Represents acacia trees.
*/
ACACIA(0x4),
/**
* Represents dark oak trees.
*/
DARK_OAK(0x5),
;
private final byte data;
private final static Map<Byte, TreeSpecies> BY_DATA = Maps.newHashMap();

View File

@ -49,4 +49,12 @@ public enum TreeType {
* Swamp tree (regular with vines on the side)
*/
SWAMP,
/**
* Acacia tree.
*/
ACACIA,
/**
* Dark Oak tree.
*/
DARK_OAK,
}

View File

@ -10,7 +10,8 @@ public enum WorldType {
NORMAL("DEFAULT"),
FLAT("FLAT"),
VERSION_1_1("DEFAULT_1_1"),
LARGE_BIOMES("LARGEBIOMES");
LARGE_BIOMES("LARGEBIOMES"),
AMPLIFIED("AMPLIFIED");
private final static Map<String, WorldType> BY_NAME = Maps.newHashMap();
private final String name;

View File

@ -26,5 +26,43 @@ public enum Biome {
TAIGA_HILLS,
SMALL_MOUNTAINS,
JUNGLE,
JUNGLE_HILLS
JUNGLE_HILLS,
JUNGLE_EDGE,
DEEP_OCEAN,
STONE_BEACH,
COLD_BEACH,
BIRCH_FOREST,
BIRCH_FOREST_HILLS,
ROOFED_FOREST,
COLD_TAIGA,
COLD_TAIGA_HILLS,
MEGA_TAIGA,
MEGA_TAIGA_HILLS,
EXTREME_HILLS_PLUS,
SAVANNA,
SAVANNA_PLATEAU,
MESA,
MESA_PLATEAU_FOREST,
MESA_PLATEAU,
SUNFLOWER_PLAINS,
DESERT_MOUNTAINS,
FLOWER_FOREST,
TAIGA_MOUNTAINS,
SWAMPLAND_MOUNTAINS,
ICE_PLAINS_SPIKES,
JUNGLE_MOUNTAINS,
JUNGLE_EDGE_MOUNTAINS,
COLD_TAIGA_MOUNTAINS,
SAVANNA_MOUNTAINS,
SAVANNA_PLATEAU_MOUNTAINS,
MESA_BRYCE,
MESA_PLATEAU_FOREST_MOUNTAINS,
MESA_PLATEAU_MOUNTAINS,
BIRCH_FOREST_MOUNTAINS,
BIRCH_FOREST_HILLS_MOUNTAINS,
ROOFED_FOREST_MOUNTAINS,
MEGA_SPRUCE_TAIGA,
EXTREME_HILLS_MOUNTAINS,
EXTREME_HILLS_PLUS_MOUNTAINS,
MEGA_SPRUCE_TAIGA_HILLS,
}

View File

@ -1,40 +1,40 @@
package org.bukkit.block;
public interface CommandBlock extends BlockState {
/**
* Gets the command that this CommandBlock will run when powered.
* This will never return null. If the CommandBlock does not have a
* command, an empty String will be returned instead.
*
* @return Command that this CommandBlock will run when powered.
*/
public String getCommand();
/**
* Sets the command that this CommandBlock will run when powered.
* Setting the command to null is the same as setting it to an empty
* String.
*
* @param command Command that this CommandBlock will run when powered.
*/
public void setCommand(String command);
/**
* Gets the name of this CommandBlock. The name is used with commands
* that this CommandBlock executes. This name will never be null, and
* by default is "@".
*
* @return Name of this CommandBlock.
*/
public String getName();
/**
* Sets the name of this CommandBlock. The name is used with commands
* that this CommandBlock executes. Setting the name to null is the
* same as setting it to "@".
*
* @param name New name for this CommandBlock.
*/
public void setName(String name);
}
package org.bukkit.block;
public interface CommandBlock extends BlockState {
/**
* Gets the command that this CommandBlock will run when powered.
* This will never return null. If the CommandBlock does not have a
* command, an empty String will be returned instead.
*
* @return Command that this CommandBlock will run when powered.
*/
public String getCommand();
/**
* Sets the command that this CommandBlock will run when powered.
* Setting the command to null is the same as setting it to an empty
* String.
*
* @param command Command that this CommandBlock will run when powered.
*/
public void setCommand(String command);
/**
* Gets the name of this CommandBlock. The name is used with commands
* that this CommandBlock executes. This name will never be null, and
* by default is "@".
*
* @return Name of this CommandBlock.
*/
public String getName();
/**
* Sets the name of this CommandBlock. The name is used with commands
* that this CommandBlock executes. Setting the name to null is the
* same as setting it to "@".
*
* @param name New name for this CommandBlock.
*/
public void setName(String name);
}

View File

@ -3,6 +3,7 @@ package org.bukkit.entity;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.minecart.CommandMinecart;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
import org.bukkit.entity.minecart.RideableMinecart;
@ -80,6 +81,10 @@ public enum EntityType {
*/
FALLING_BLOCK("FallingSand", FallingBlock.class, 21, false),
FIREWORK("FireworksRocketEntity", Firework.class, 22, false),
/**
* @see CommandMinecart
*/
MINECART_COMMAND("MinecartCommandBlock", CommandMinecart.class, 40),
/**
* A placed boat.
*/

View File

@ -0,0 +1,36 @@
package org.bukkit.entity.minecart;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Minecart;
public interface CommandMinecart extends Minecart, CommandSender {
/**
* Gets the command that this CommandMinecart will run when activated.
* This will never return null. If the CommandMinecart does not have a
* command, an empty String will be returned instead.
*
* @return Command that this CommandMinecart will run when powered.
*/
public String getCommand();
/**
* Sets the command that this CommandMinecart will run when activated.
* Setting the command to null is the same as setting it to an empty
* String.
*
* @param command Command that this CommandMinecart will run when
* activated.
*/
public void setCommand(String command);
/**
* Sets the name of this CommandMinecart. The name is used with commands
* that this CommandMinecart executes. Setting the name to null is the
* same as setting it to "@".
*
* @param name New name for this CommandMinecart.
*/
public void setName(String name);
}

View File

@ -3,6 +3,7 @@ package org.bukkit.event.server;
import java.net.InetAddress;
import org.bukkit.event.HandlerList;
import org.bukkit.util.CachedServerIcon;
/**
* Called when a server list ping is coming in.
@ -75,6 +76,20 @@ public class ServerListPingEvent extends ServerEvent {
this.maxPlayers = maxPlayers;
}
/**
* Sets the server-icon sent to the client.
*
* @param icon the icon to send to the client
* @throws IllegalArgumentException if the {@link CachedServerIcon} is
* not created by the caller of this event; null may be accepted for
* some implementations
* @throws UnsupportedOperationException if the caller of this event does
* not support setting the server icon
*/
public void setServerIcon(CachedServerIcon icon) throws IllegalArgumentException, UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@Override
public HandlerList getHandlers() {
return handlers;

View File

@ -12,6 +12,7 @@ public enum PotionType {
STRENGTH(9, PotionEffectType.INCREASE_DAMAGE, 2),
SLOWNESS(10, PotionEffectType.SLOW, 1),
INSTANT_DAMAGE(12, PotionEffectType.HARM, 2),
WATER_BREATHING(13, PotionEffectType.WATER_BREATHING, 1),
INVISIBILITY(14, PotionEffectType.INVISIBILITY, 1),
;

View File

@ -0,0 +1,15 @@
package org.bukkit.util;
import org.bukkit.Server;
import org.bukkit.event.server.ServerListPingEvent;
/**
* This is a cached version of a server-icon. It's internal representation
* and implementation is undefined.
*
* @see Server#getServerIcon()
* @see Server#loadServerIcon(java.awt.image.BufferedImage)
* @see Server#loadServerIcon(java.io.File)
* @see ServerListPingEvent#setServerIcon(CachedServerIcon)
*/
public interface CachedServerIcon {}

View File

@ -1,21 +0,0 @@
package org.bukkit;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class AchievementTest {
@Test
public void getById() {
for (Achievement achievement : Achievement.values()) {
assertThat(Achievement.getById(achievement.getId()), is(achievement));
}
}
@Test
public void getByOffset() {
assertThat(Achievement.getById(Achievement.STATISTIC_OFFSET), is(Achievement.values()[0]));
}
}

View File

@ -15,8 +15,11 @@ public class MaterialTest {
}
@Test
public void getById() {
public void getById() throws Throwable {
for (Material material : Material.values()) {
if (material.getClass().getField(material.name()).getAnnotation(Deprecated.class) != null) {
continue;
}
assertThat(Material.getMaterial(material.getId()), is(material));
}
}
@ -56,8 +59,11 @@ public class MaterialTest {
}
@Test
public void matchMaterialById() {
public void matchMaterialById() throws Throwable {
for (Material material : Material.values()) {
if (material.getClass().getField(material.name()).getAnnotation(Deprecated.class) != null) {
continue;
}
assertThat(Material.matchMaterial(String.valueOf(material.getId())), is(material));
}
}

View File

@ -1,15 +0,0 @@
package org.bukkit;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
public class StatisticTest {
@Test
public void getById() {
for (Statistic statistic : Statistic.values()) {
assertThat(Statistic.getById(statistic.getId()), is(statistic));
}
}
}