mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-21 07:50:52 +01:00
Update CraftBukkit to Minecraft 1.7.2
By: mbax <matt@phozop.net>
This commit is contained in:
parent
5961c3b788
commit
5783df9d13
63 changed files with 1137 additions and 429 deletions
|
@ -4,7 +4,7 @@
|
|||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.6.4-R2.1-SNAPSHOT</version>
|
||||
<version>1.7.2-R0.1-SNAPSHOT</version>
|
||||
<name>CraftBukkit</name>
|
||||
<url>http://www.bukkit.org</url>
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<api.version>unknown</api.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
<minecraft.version>1.6.4</minecraft.version>
|
||||
<minecraft_version>1_6_R3</minecraft_version>
|
||||
<minecraft.version>1.7.2</minecraft.version>
|
||||
<minecraft_version>1_7_R1</minecraft_version>
|
||||
<buildtag.prefix>git-Bukkit-</buildtag.prefix>
|
||||
<buildtag.suffix></buildtag.suffix>
|
||||
</properties>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import org.bukkit.Achievement;
|
||||
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
public class CraftAchievement {
|
||||
private static final BiMap<String, Achievement> achievements;
|
||||
static {
|
||||
ImmutableMap<String, Achievement> specialCases = ImmutableMap.<String, Achievement>builder()
|
||||
.put("achievement.buildWorkBench", Achievement.BUILD_WORKBENCH)
|
||||
.put("achievement.diamonds", Achievement.GET_DIAMONDS)
|
||||
.put("achievement.portal", Achievement.NETHER_PORTAL)
|
||||
.put("achievement.ghast", Achievement.GHAST_RETURN)
|
||||
.put("achievement.theEnd", Achievement.END_PORTAL)
|
||||
.put("achievement.theEnd2", Achievement.THE_END)
|
||||
.put("achievement.blazeRod", Achievement.GET_BLAZE_ROD)
|
||||
.put("achievement.potion", Achievement.BREW_POTION)
|
||||
.build();
|
||||
|
||||
ImmutableBiMap.Builder<String, Achievement> builder = ImmutableBiMap.<String, Achievement>builder();
|
||||
for (Achievement achievement : Achievement.values()) {
|
||||
if (specialCases.values().contains(achievement)) {
|
||||
continue;
|
||||
}
|
||||
builder.put("achievement."+CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, achievement.name()), achievement);
|
||||
}
|
||||
|
||||
builder.putAll(specialCases);
|
||||
|
||||
achievements = builder.build();
|
||||
}
|
||||
|
||||
public static String getAchievementName(Achievement material) {
|
||||
return achievements.inverse().get(material);
|
||||
}
|
||||
|
||||
public static Achievement getAchievement(String name) {
|
||||
return achievements.get(name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
|
||||
public class CraftBlockChangeDelegate {
|
||||
private final BlockChangeDelegate delegate;
|
||||
|
||||
public CraftBlockChangeDelegate(BlockChangeDelegate delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public BlockChangeDelegate getDelegate() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
public Block getType(int x, int y, int z) {
|
||||
return Block.e(this.delegate.getTypeId(x, y, z));
|
||||
}
|
||||
|
||||
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
|
||||
delegate.setRawTypeIdAndData(x, y, z, Block.b(block), data);
|
||||
}
|
||||
|
||||
public boolean isEmpty(int x, int y, int z) {
|
||||
return delegate.isEmpty(x, y, z);
|
||||
}
|
||||
}
|
|
@ -33,8 +33,8 @@ public class CraftChunk implements Chunk {
|
|||
}
|
||||
|
||||
worldServer = (WorldServer) getHandle().world;
|
||||
x = getHandle().x;
|
||||
z = getHandle().z;
|
||||
x = getHandle().locX;
|
||||
z = getHandle().locZ;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
@ -114,7 +114,7 @@ public class CraftChunk implements Chunk {
|
|||
}
|
||||
|
||||
ChunkPosition position = (ChunkPosition) obj;
|
||||
entities[index++] = worldServer.getWorld().getBlockAt(position.x + (chunk.x << 4), position.y, position.z + (chunk.z << 4)).getState();
|
||||
entities[index++] = worldServer.getWorld().getBlockAt(position.x + (chunk.locX << 4), position.y, position.z + (chunk.locZ << 4)).getState();
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ public class CraftChunk implements Chunk {
|
|||
if (includeBiomeTempRain) {
|
||||
biomeTemp = new double[256];
|
||||
biomeRain = new double[256];
|
||||
float[] dat = wcm.getTemperatures(null, getX() << 4, getZ() << 4, 16, 16);
|
||||
float[] dat = getTemperatures(wcm, getX() << 4, getZ() << 4);
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biomeTemp[i] = dat[i];
|
||||
|
@ -264,7 +264,7 @@ public class CraftChunk implements Chunk {
|
|||
if (includeBiomeTempRain) {
|
||||
biomeTemp = new double[256];
|
||||
biomeRain = new double[256];
|
||||
float[] dat = wcm.getTemperatures(null, x << 4, z << 4, 16, 16);
|
||||
float[] dat = getTemperatures(wcm, x << 4, z << 4);
|
||||
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biomeTemp[i] = dat[i];
|
||||
|
@ -297,6 +297,23 @@ public class CraftChunk implements Chunk {
|
|||
return new CraftChunkSnapshot(x, z, world.getName(), world.getFullTime(), blockIDs, blockData, skyLight, emitLight, empty, new int[256], biome, biomeTemp, biomeRain);
|
||||
}
|
||||
|
||||
private static float[] getTemperatures(WorldChunkManager chunkmanager, int chunkX, int chunkZ) {
|
||||
BiomeBase[] biomes = chunkmanager.getBiomes(null, chunkX, chunkZ, 16, 16);
|
||||
float[] temps = new float[biomes.length];
|
||||
|
||||
for (int i = 0; i < biomes.length; i++) {
|
||||
float temp = biomes[i].temperature; // Vanilla of olde: ((int) biomes[i].temperature * 65536.0F) / 65536.0F
|
||||
|
||||
if (temp > 1F) {
|
||||
temp = 1F;
|
||||
}
|
||||
|
||||
temps[i] = temp;
|
||||
}
|
||||
|
||||
return temps;
|
||||
}
|
||||
|
||||
static {
|
||||
Arrays.fill(emptySkyLight, (byte) 0xFF);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public class CraftCrashReport implements Callable {
|
||||
public class CraftCrashReport implements Callable<Object> {
|
||||
|
||||
public Object call() throws Exception {
|
||||
StringWriter value = new StringWriter();
|
||||
|
|
|
@ -144,7 +144,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
|
||||
if (result != null) {
|
||||
if (!result.hasKey("bukkit")) {
|
||||
result.setCompound("bukkit", new NBTTagCompound());
|
||||
result.set("bukkit", new NBTTagCompound());
|
||||
}
|
||||
result = result.getCompound("bukkit");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.bukkit.craftbukkit;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
|
@ -18,6 +19,8 @@ import java.util.UUID;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.server.BanEntry;
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.Convertable;
|
||||
|
@ -28,11 +31,12 @@ import net.minecraft.server.DedicatedServer;
|
|||
import net.minecraft.server.Enchantment;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EntityTracker;
|
||||
import net.minecraft.server.EnumDifficulty;
|
||||
import net.minecraft.server.EnumGamemode;
|
||||
import net.minecraft.server.ExceptionWorldConflict;
|
||||
import net.minecraft.server.Items;
|
||||
import net.minecraft.server.PlayerList;
|
||||
import net.minecraft.server.RecipesFurnace;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.PropertyManager;
|
||||
|
@ -41,11 +45,16 @@ import net.minecraft.server.ServerNBTManager;
|
|||
import net.minecraft.server.WorldLoaderServer;
|
||||
import net.minecraft.server.WorldManager;
|
||||
import net.minecraft.server.WorldMap;
|
||||
import net.minecraft.server.WorldMapCollection;
|
||||
import net.minecraft.server.PersistentCollection;
|
||||
import net.minecraft.server.WorldNBTStorage;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.WorldSettings;
|
||||
import net.minecraft.server.WorldType;
|
||||
import net.minecraft.util.com.google.common.base.Charsets;
|
||||
import net.minecraft.util.io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.util.io.netty.buffer.ByteBufOutputStream;
|
||||
import net.minecraft.util.io.netty.buffer.Unpooled;
|
||||
import net.minecraft.util.io.netty.handler.codec.base64.Base64;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -83,7 +92,9 @@ import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
|||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager;
|
||||
import org.bukkit.craftbukkit.updater.AutoUpdater;
|
||||
import org.bukkit.craftbukkit.updater.BukkitDLUpdaterService;
|
||||
import org.bukkit.craftbukkit.util.CraftIconCache;
|
||||
import org.bukkit.craftbukkit.util.DatFileFilter;
|
||||
import org.bukkit.craftbukkit.util.Log4jConverter;
|
||||
import org.bukkit.craftbukkit.util.Versioning;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
@ -164,6 +175,8 @@ public final class CraftServer implements Server {
|
|||
public CraftScoreboardManager scoreboardManager;
|
||||
public boolean playerCommandState;
|
||||
private boolean printSaveWarning;
|
||||
private Logger logger;
|
||||
private CraftIconCache icon;
|
||||
|
||||
private final class BooleanWrapper {
|
||||
private boolean value = true;
|
||||
|
@ -175,6 +188,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public CraftServer(MinecraftServer console, PlayerList playerList) {
|
||||
this.logger = Log4jConverter.createLogger();
|
||||
this.console = console;
|
||||
this.playerList = (DedicatedPlayerList) playerList;
|
||||
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
|
||||
|
@ -208,6 +222,7 @@ public final class CraftServer implements Server {
|
|||
warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
|
||||
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
|
||||
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
|
||||
loadIcon();
|
||||
|
||||
updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel"));
|
||||
updater.setEnabled(configuration.getBoolean("auto-updater.enabled"));
|
||||
|
@ -540,13 +555,13 @@ public final class CraftServer implements Server {
|
|||
|
||||
public void reload() {
|
||||
configuration = YamlConfiguration.loadConfiguration(getConfigFile());
|
||||
PropertyManager config = new PropertyManager(console.options, console.getLogger());
|
||||
PropertyManager config = new PropertyManager(console.options);
|
||||
|
||||
((DedicatedServer) console).propertyManager = config;
|
||||
|
||||
boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals());
|
||||
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty > 0);
|
||||
int difficulty = config.getInt("difficulty", console.worlds.get(0).difficulty);
|
||||
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty != EnumDifficulty.PEACEFUL);
|
||||
EnumDifficulty difficulty = EnumDifficulty.a(config.getInt("difficulty", console.worlds.get(0).difficulty.ordinal()));
|
||||
|
||||
online.value = config.getBoolean("online-mode", console.getOnlineMode());
|
||||
console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals()));
|
||||
|
@ -562,6 +577,7 @@ public final class CraftServer implements Server {
|
|||
console.autosavePeriod = configuration.getInt("ticks-per.autosave");
|
||||
chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
|
||||
chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");
|
||||
loadIcon();
|
||||
|
||||
playerList.getIPBans().load();
|
||||
playerList.getNameBans().load();
|
||||
|
@ -615,6 +631,18 @@ public final class CraftServer implements Server {
|
|||
enablePlugins(PluginLoadOrder.POSTWORLD);
|
||||
}
|
||||
|
||||
private void loadIcon() {
|
||||
icon = new CraftIconCache(null);
|
||||
try {
|
||||
final File file = new File(new File("."), "server-icon.png");
|
||||
if (file.isFile()) {
|
||||
icon = loadServerIcon0(file);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, "Couldn't load server icon", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "finally" })
|
||||
private void loadCustomPermissions() {
|
||||
File file = new File(configuration.getString("settings.permissions-file"));
|
||||
|
@ -724,7 +752,7 @@ public final class CraftServer implements Server {
|
|||
} while(used);
|
||||
boolean hardcore = false;
|
||||
|
||||
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGamemode.a(getDefaultGameMode().getValue()), generateStructures, hardcore, type), console.methodProfiler, console.getLogger(), creator.environment(), generator);
|
||||
WorldServer internal = new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), name, dimension, new WorldSettings(creator.seed(), EnumGamemode.a(getDefaultGameMode().getValue()), generateStructures, hardcore, type), console.methodProfiler, creator.environment(), generator);
|
||||
|
||||
if (!(worlds.containsKey(name.toLowerCase()))) {
|
||||
return null;
|
||||
|
@ -734,7 +762,7 @@ public final class CraftServer implements Server {
|
|||
|
||||
internal.tracker = new EntityTracker(internal);
|
||||
internal.addIWorldAccess(new WorldManager(console, internal));
|
||||
internal.difficulty = 1;
|
||||
internal.difficulty = EnumDifficulty.EASY;
|
||||
internal.setSpawnFlags(true, true);
|
||||
console.worlds.add(internal);
|
||||
|
||||
|
@ -849,7 +877,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public Logger getLogger() {
|
||||
return console.getLogger().getLogger();
|
||||
return logger;
|
||||
}
|
||||
|
||||
public ConsoleReader getReader() {
|
||||
|
@ -1037,7 +1065,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public CraftMapView getMap(short id) {
|
||||
WorldMapCollection collection = console.worlds.get(0).worldMaps;
|
||||
PersistentCollection collection = console.worlds.get(0).worldMaps;
|
||||
WorldMap worldmap = (WorldMap) collection.get(WorldMap.class, "map_" + id);
|
||||
if (worldmap == null) {
|
||||
return null;
|
||||
|
@ -1048,8 +1076,8 @@ public final class CraftServer implements Server {
|
|||
public CraftMapView createMap(World world) {
|
||||
Validate.notNull(world, "World cannot be null");
|
||||
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Item.MAP, 1, -1);
|
||||
WorldMap worldmap = Item.MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1, -1);
|
||||
WorldMap worldmap = Items.MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
|
||||
return worldmap.mapView;
|
||||
}
|
||||
|
||||
|
@ -1388,4 +1416,39 @@ public final class CraftServer implements Server {
|
|||
this.printSaveWarning = true;
|
||||
getLogger().log(Level.WARNING, "A manual (plugin-induced) save has been detected while server is configured to auto-save. This may affect performance.", warningState == WarningState.ON ? new Throwable() : null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftIconCache getServerIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftIconCache loadServerIcon(File file) throws Exception {
|
||||
Validate.notNull(file, "File cannot be null");
|
||||
if (!file.isFile()) {
|
||||
throw new IllegalArgumentException(file + " is not a file");
|
||||
}
|
||||
return loadServerIcon0(file);
|
||||
}
|
||||
|
||||
static CraftIconCache loadServerIcon0(File file) throws Exception {
|
||||
return loadServerIcon0(ImageIO.read(file));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftIconCache loadServerIcon(BufferedImage image) throws Exception {
|
||||
Validate.notNull(image, "Image cannot be null");
|
||||
return loadServerIcon0(image);
|
||||
}
|
||||
|
||||
static CraftIconCache loadServerIcon0(BufferedImage image) throws Exception {
|
||||
ByteBuf bytebuf = Unpooled.buffer();
|
||||
|
||||
Validate.isTrue(image.getWidth() == 64, "Must be 64 pixels wide");
|
||||
Validate.isTrue(image.getHeight() == 64, "Must be 64 pixels high");
|
||||
ImageIO.write(image, "PNG", new ByteBufOutputStream(bytebuf));
|
||||
ByteBuf bytebuf1 = Base64.encode(bytebuf);
|
||||
|
||||
return new CraftIconCache("data:image/png;base64," + bytebuf1.toString(Charsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -361,7 +361,7 @@ public class CraftWorld implements World {
|
|||
gen = new WorldGenBigTree(true);
|
||||
break;
|
||||
case BIRCH:
|
||||
gen = new WorldGenForest(true);
|
||||
gen = new WorldGenForest(true, false);
|
||||
break;
|
||||
case REDWOOD:
|
||||
gen = new WorldGenTaiga2(true);
|
||||
|
@ -370,7 +370,7 @@ public class CraftWorld implements World {
|
|||
gen = new WorldGenTaiga1();
|
||||
break;
|
||||
case JUNGLE:
|
||||
gen = new WorldGenMegaTree(true, 10 + rand.nextInt(20), 3, 3);
|
||||
gen = new WorldGenMegaTree(true, rand.nextBoolean());
|
||||
break;
|
||||
case SMALL_JUNGLE:
|
||||
gen = new WorldGenTrees(true, 4 + rand.nextInt(7), 3, 3, false);
|
||||
|
@ -387,13 +387,19 @@ public class CraftWorld implements World {
|
|||
case SWAMP:
|
||||
gen = new WorldGenSwampTree();
|
||||
break;
|
||||
case ACACIA:
|
||||
gen = new WorldGenAcaciaTree(true);
|
||||
break;
|
||||
case DARK_OAK:
|
||||
gen = new WorldGenForestTree(true);
|
||||
break;
|
||||
case TREE:
|
||||
default:
|
||||
gen = new WorldGenTrees(true);
|
||||
break;
|
||||
}
|
||||
|
||||
return gen.generate(delegate, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return gen.generate(new CraftBlockChangeDelegate(delegate), rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
|
||||
|
@ -442,7 +448,7 @@ public class CraftWorld implements World {
|
|||
CraftPlayer cp = (CraftPlayer) p;
|
||||
if (cp.getHandle().playerConnection == null) continue;
|
||||
|
||||
cp.getHandle().playerConnection.sendPacket(new Packet4UpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().world.getGameRules().getBoolean("doDaylightCycle")));
|
||||
cp.getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime(), cp.getHandle().world.getGameRules().getBoolean("doDaylightCycle")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -663,11 +669,11 @@ public class CraftWorld implements World {
|
|||
}
|
||||
|
||||
public void setDifficulty(Difficulty difficulty) {
|
||||
this.getHandle().difficulty = difficulty.getValue();
|
||||
this.getHandle().difficulty = EnumDifficulty.a(difficulty.getValue());
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty() {
|
||||
return Difficulty.getByValue(this.getHandle().difficulty);
|
||||
return Difficulty.getByValue(this.getHandle().difficulty.ordinal());
|
||||
}
|
||||
|
||||
public BlockMetadataStore getBlockMetadata() {
|
||||
|
@ -773,7 +779,7 @@ public class CraftWorld implements World {
|
|||
Validate.notNull(effect, "Effect cannot be null");
|
||||
Validate.notNull(location.getWorld(), "World cannot be null");
|
||||
int packetData = effect.getId();
|
||||
Packet61WorldEvent packet = new Packet61WorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false);
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false);
|
||||
int distance;
|
||||
radius *= radius;
|
||||
|
||||
|
@ -801,8 +807,8 @@ public class CraftWorld implements World {
|
|||
double y = location.getBlockY() + 0.5;
|
||||
double z = location.getBlockZ() + 0.5;
|
||||
|
||||
EntityFallingBlock entity = new EntityFallingBlock(world, x, y, z, material.getId(), data);
|
||||
entity.c = 1; // ticksLived
|
||||
EntityFallingBlock entity = new EntityFallingBlock(world, x, y, z, net.minecraft.server.Block.e(material.getId()), data);
|
||||
entity.b = 1; // ticksLived
|
||||
|
||||
world.addEntity(entity, SpawnReason.CUSTOM);
|
||||
return (FallingBlock) entity.getBukkitEntity();
|
||||
|
@ -836,7 +842,7 @@ public class CraftWorld implements World {
|
|||
int type = world.getTypeId((int) x, (int) y, (int) z);
|
||||
int data = world.getData((int) x, (int) y, (int) z);
|
||||
|
||||
entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, type, data);
|
||||
entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.e(type), data);
|
||||
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
||||
if (Snowball.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntitySnowball(world, x, y, z);
|
||||
|
@ -996,7 +1002,7 @@ public class CraftWorld implements World {
|
|||
entity = new EntityItemFrame(world, (int) x, (int) y, (int) z, dir);
|
||||
} else if (LeashHitch.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityLeash(world, (int) x, (int) y, (int) z);
|
||||
entity.p = true;
|
||||
entity.o = true;
|
||||
}
|
||||
|
||||
if (entity != null && !((EntityHanging) entity).survives()) {
|
||||
|
@ -1255,17 +1261,17 @@ public class CraftWorld implements World {
|
|||
ChunkProviderServer cps = world.chunkProviderServer;
|
||||
for (net.minecraft.server.Chunk chunk : cps.chunks.values()) {
|
||||
// If in use, skip it
|
||||
if (isChunkInUse(chunk.x, chunk.z)) {
|
||||
if (isChunkInUse(chunk.locX, chunk.locZ)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Already unloading?
|
||||
if (cps.unloadQueue.contains(chunk.x, chunk.z)) {
|
||||
if (cps.unloadQueue.contains(chunk.locX, chunk.locZ)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add unload request
|
||||
cps.queueUnload(chunk.x, chunk.z);
|
||||
cps.queueUnload(chunk.locX, chunk.locZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.bukkit.craftbukkit;
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class LoggerOutputStream extends ByteArrayOutputStream {
|
||||
private final String separator = System.getProperty("line.separator");
|
||||
|
@ -24,7 +24,7 @@ public class LoggerOutputStream extends ByteArrayOutputStream {
|
|||
super.reset();
|
||||
|
||||
if ((record.length() > 0) && (!record.equals(separator))) {
|
||||
logger.logp(level, "", "", record);
|
||||
logger.log(level, record);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ import java.util.List;
|
|||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.BlockRedstoneWire;
|
||||
import net.minecraft.server.Direction;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.EnumSkyBlock;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
|
||||
|
@ -23,6 +24,7 @@ import org.bukkit.block.BlockState;
|
|||
import org.bukkit.block.PistonMoveReaction;
|
||||
import org.bukkit.craftbukkit.CraftChunk;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
@ -43,6 +45,14 @@ public class CraftBlock implements Block {
|
|||
this.chunk = chunk;
|
||||
}
|
||||
|
||||
private net.minecraft.server.Block getNMSBlock() {
|
||||
return CraftMagicNumbers.getBlock(this); // TODO: UPDATE THIS
|
||||
}
|
||||
|
||||
private static net.minecraft.server.Block getNMSBlock(int type) {
|
||||
return CraftMagicNumbers.getBlock(type);
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return chunk.getWorld();
|
||||
}
|
||||
|
@ -105,22 +115,18 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
|
||||
public boolean setTypeId(final int type) {
|
||||
return chunk.getHandle().world.setTypeIdAndData(x, y, z, type, getData(), 3);
|
||||
return setTypeId(type, true);
|
||||
}
|
||||
|
||||
public boolean setTypeId(final int type, final boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
return setTypeId(type);
|
||||
} else {
|
||||
return chunk.getHandle().world.setTypeIdAndData(x, y, z, type, getData(), 2);
|
||||
}
|
||||
return setTypeIdAndData(type, getData(), applyPhysics);
|
||||
}
|
||||
|
||||
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
return chunk.getHandle().world.setTypeIdAndData(x, y, z, type, data, 3);
|
||||
return chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 3);
|
||||
} else {
|
||||
boolean success = chunk.getHandle().world.setTypeIdAndData(x, y, z, type, data, 2);
|
||||
boolean success = chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 2);
|
||||
if (success) {
|
||||
chunk.getHandle().world.notify(x, y, z);
|
||||
}
|
||||
|
@ -132,8 +138,10 @@ public class CraftBlock implements Block {
|
|||
return Material.getMaterial(getTypeId());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getTypeId() {
|
||||
return chunk.getHandle().getTypeId(this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
return CraftMagicNumbers.getId(chunk.getHandle().getType(this.x & 0xF, this.y & 0xFF, this.z & 0xF));
|
||||
}
|
||||
|
||||
public byte getLightLevel() {
|
||||
|
@ -342,7 +350,7 @@ public class CraftBlock implements Block {
|
|||
|
||||
public int getBlockPower(BlockFace face) {
|
||||
int power = 0;
|
||||
BlockRedstoneWire wire = net.minecraft.server.Block.REDSTONE_WIRE;
|
||||
BlockRedstoneWire wire = Blocks.REDSTONE_WIRE;
|
||||
net.minecraft.server.World world = chunk.getHandle().world;
|
||||
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(x, y - 1, z, 0)) power = wire.getPower(world, x, y - 1, z, power);
|
||||
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(x, y + 1, z, 1)) power = wire.getPower(world, x, y + 1, z, power);
|
||||
|
@ -366,22 +374,22 @@ public class CraftBlock implements Block {
|
|||
}
|
||||
|
||||
public PistonMoveReaction getPistonMoveReaction() {
|
||||
return PistonMoveReaction.getById(net.minecraft.server.Block.byId[this.getTypeId()].material.getPushReaction());
|
||||
return PistonMoveReaction.getById(getNMSBlock().getMaterial().getPushReaction());
|
||||
}
|
||||
|
||||
private boolean itemCausesDrops(ItemStack item) {
|
||||
net.minecraft.server.Block block = net.minecraft.server.Block.byId[this.getTypeId()];
|
||||
net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.byId[item.getTypeId()] : null;
|
||||
return block != null && (block.material.isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block)));
|
||||
net.minecraft.server.Block block = this.getNMSBlock();
|
||||
net.minecraft.server.Item itemType = item != null ? net.minecraft.server.Item.d(item.getTypeId()) : null;
|
||||
return block != null && (block.getMaterial().isAlwaysDestroyable() || (itemType != null && itemType.canDestroySpecialBlock(block)));
|
||||
}
|
||||
|
||||
public boolean breakNaturally() {
|
||||
// Order matters here, need to drop before setting to air so skulls can get their data
|
||||
net.minecraft.server.Block block = net.minecraft.server.Block.byId[this.getTypeId()];
|
||||
net.minecraft.server.Block block = this.getNMSBlock();
|
||||
byte data = getData();
|
||||
boolean result = false;
|
||||
|
||||
if (block != null) {
|
||||
if (block != null && block != Blocks.AIR) {
|
||||
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
|
||||
result = true;
|
||||
}
|
||||
|
@ -401,16 +409,16 @@ public class CraftBlock implements Block {
|
|||
public Collection<ItemStack> getDrops() {
|
||||
List<ItemStack> drops = new ArrayList<ItemStack>();
|
||||
|
||||
net.minecraft.server.Block block = net.minecraft.server.Block.byId[this.getTypeId()];
|
||||
if (block != null) {
|
||||
net.minecraft.server.Block block = this.getNMSBlock();
|
||||
if (block != Blocks.AIR) {
|
||||
byte data = getData();
|
||||
// based on nms.Block.dropNaturally
|
||||
int count = block.getDropCount(0, chunk.getHandle().world.random);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
int item = block.getDropType(data, chunk.getHandle().world.random, 0);
|
||||
if (item > 0) {
|
||||
Item item = block.getDropType(data, chunk.getHandle().world.random, 0);
|
||||
if (item != null) {
|
||||
// Skulls are special, their data is based on the tile entity
|
||||
if (net.minecraft.server.Block.SKULL.id == this.getTypeId()) {
|
||||
if (Blocks.SKULL == block) {
|
||||
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().world, x, y, z));
|
||||
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().world.getTileEntity(x, y, z);
|
||||
|
||||
|
@ -421,7 +429,7 @@ public class CraftBlock implements Block {
|
|||
|
||||
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
|
||||
} else {
|
||||
drops.add(new ItemStack(item, 1, (short) block.getDropData(data)));
|
||||
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -439,18 +447,18 @@ public class CraftBlock implements Block {
|
|||
|
||||
/* Build biome index based lookup table for BiomeBase to Biome mapping */
|
||||
static {
|
||||
BIOME_MAPPING = new Biome[BiomeBase.biomes.length];
|
||||
BIOME_MAPPING = new Biome[BiomeBase.n().length];
|
||||
BIOMEBASE_MAPPING = new BiomeBase[Biome.values().length];
|
||||
BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND;
|
||||
BIOME_MAPPING[BiomeBase.OCEAN.id] = Biome.OCEAN;
|
||||
BIOME_MAPPING[BiomeBase.PLAINS.id] = Biome.PLAINS;
|
||||
BIOME_MAPPING[BiomeBase.DESERT.id] = Biome.DESERT;
|
||||
BIOME_MAPPING[BiomeBase.EXTREME_HILLS.id] = Biome.EXTREME_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.FOREST.id] = Biome.FOREST;
|
||||
BIOME_MAPPING[BiomeBase.TAIGA.id] = Biome.TAIGA;
|
||||
BIOME_MAPPING[BiomeBase.DESERT.id] = Biome.DESERT;
|
||||
BIOME_MAPPING[BiomeBase.PLAINS.id] = Biome.PLAINS;
|
||||
BIOME_MAPPING[BiomeBase.SWAMPLAND.id] = Biome.SWAMPLAND;
|
||||
BIOME_MAPPING[BiomeBase.RIVER.id] = Biome.RIVER;
|
||||
BIOME_MAPPING[BiomeBase.HELL.id] = Biome.HELL;
|
||||
BIOME_MAPPING[BiomeBase.SKY.id] = Biome.SKY;
|
||||
BIOME_MAPPING[BiomeBase.RIVER.id] = Biome.RIVER;
|
||||
BIOME_MAPPING[BiomeBase.EXTREME_HILLS.id] = Biome.EXTREME_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.OCEAN.id] = Biome.OCEAN;
|
||||
BIOME_MAPPING[BiomeBase.FROZEN_OCEAN.id] = Biome.FROZEN_OCEAN;
|
||||
BIOME_MAPPING[BiomeBase.FROZEN_RIVER.id] = Biome.FROZEN_RIVER;
|
||||
BIOME_MAPPING[BiomeBase.ICE_PLAINS.id] = Biome.ICE_PLAINS;
|
||||
|
@ -464,14 +472,55 @@ public class CraftBlock implements Block {
|
|||
BIOME_MAPPING[BiomeBase.SMALL_MOUNTAINS.id] = Biome.SMALL_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.JUNGLE.id] = Biome.JUNGLE;
|
||||
BIOME_MAPPING[BiomeBase.JUNGLE_HILLS.id] = Biome.JUNGLE_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.JUNGLE_EDGE.id] = Biome.JUNGLE_EDGE;
|
||||
BIOME_MAPPING[BiomeBase.DEEP_OCEAN.id] = Biome.DEEP_OCEAN;
|
||||
BIOME_MAPPING[BiomeBase.STONE_BEACH.id] = Biome.STONE_BEACH;
|
||||
BIOME_MAPPING[BiomeBase.COLD_BEACH.id] = Biome.COLD_BEACH;
|
||||
BIOME_MAPPING[BiomeBase.BIRCH_FOREST.id] = Biome.BIRCH_FOREST;
|
||||
BIOME_MAPPING[BiomeBase.BIRCH_FOREST_HILLS.id] = Biome.BIRCH_FOREST_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.ROOFED_FOREST.id] = Biome.ROOFED_FOREST;
|
||||
BIOME_MAPPING[BiomeBase.COLD_TAIGA.id] = Biome.COLD_TAIGA;
|
||||
BIOME_MAPPING[BiomeBase.COLD_TAIGA_HILLS.id] = Biome.COLD_TAIGA_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.MEGA_TAIGA.id] = Biome.MEGA_TAIGA;
|
||||
BIOME_MAPPING[BiomeBase.MEGA_TAIGA_HILLS.id] = Biome.MEGA_TAIGA_HILLS;
|
||||
BIOME_MAPPING[BiomeBase.EXTREME_HILLS_PLUS.id] = Biome.EXTREME_HILLS_PLUS;
|
||||
BIOME_MAPPING[BiomeBase.SAVANNA.id] = Biome.SAVANNA;
|
||||
BIOME_MAPPING[BiomeBase.SAVANNA_PLATEAU.id] = Biome.SAVANNA_PLATEAU;
|
||||
BIOME_MAPPING[BiomeBase.MESA.id] = Biome.MESA;
|
||||
BIOME_MAPPING[BiomeBase.MESA_PLATEAU_F.id] = Biome.MESA_PLATEAU_FOREST;
|
||||
BIOME_MAPPING[BiomeBase.MESA_PLATEAU.id] = Biome.MESA_PLATEAU;
|
||||
|
||||
// Extended Biomes
|
||||
BIOME_MAPPING[BiomeBase.PLAINS.id + 128] = Biome.SUNFLOWER_PLAINS;
|
||||
BIOME_MAPPING[BiomeBase.DESERT.id + 128] = Biome.DESERT_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.FOREST.id + 128] = Biome.FLOWER_FOREST;
|
||||
BIOME_MAPPING[BiomeBase.TAIGA.id + 128] = Biome.TAIGA_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.SWAMPLAND.id + 128] = Biome.SWAMPLAND_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.ICE_PLAINS.id + 128] = Biome.ICE_PLAINS_SPIKES;
|
||||
BIOME_MAPPING[BiomeBase.JUNGLE.id + 128] = Biome.JUNGLE_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.JUNGLE_EDGE.id + 128] = Biome.JUNGLE_EDGE_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.COLD_TAIGA.id + 128] = Biome.COLD_TAIGA_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.SAVANNA.id + 128] = Biome.SAVANNA_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.SAVANNA_PLATEAU.id + 128] = Biome.SAVANNA_PLATEAU_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.MESA.id + 128] = Biome.MESA_BRYCE;
|
||||
BIOME_MAPPING[BiomeBase.MESA_PLATEAU_F.id + 128] = Biome.MESA_PLATEAU_FOREST_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.MESA_PLATEAU.id + 128] = Biome.MESA_PLATEAU_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.BIRCH_FOREST.id + 128] = Biome.BIRCH_FOREST_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.BIRCH_FOREST_HILLS.id + 128] = Biome.BIRCH_FOREST_HILLS_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.ROOFED_FOREST.id + 128] = Biome.ROOFED_FOREST_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.MEGA_TAIGA.id + 128] = Biome.MEGA_SPRUCE_TAIGA;
|
||||
BIOME_MAPPING[BiomeBase.EXTREME_HILLS.id + 128] = Biome.EXTREME_HILLS_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.EXTREME_HILLS_PLUS.id + 128] = Biome.EXTREME_HILLS_PLUS_MOUNTAINS;
|
||||
BIOME_MAPPING[BiomeBase.MEGA_TAIGA_HILLS.id + 128] = Biome.MEGA_SPRUCE_TAIGA_HILLS;
|
||||
|
||||
/* Sanity check - we should have a record for each record in the BiomeBase.a table */
|
||||
/* Helps avoid missed biomes when we upgrade bukkit to new code with new biomes */
|
||||
for (int i = 0; i < BIOME_MAPPING.length; i++) {
|
||||
if ((BiomeBase.biomes[i] != null) && (BIOME_MAPPING[i] == null)) {
|
||||
throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + "]");
|
||||
if ((BiomeBase.getBiome(i) != null) && (BIOME_MAPPING[i] == null)) {
|
||||
throw new IllegalArgumentException("Missing Biome mapping for BiomeBase[" + i + ", " + BiomeBase.getBiome(i) + "]");
|
||||
}
|
||||
if (BIOME_MAPPING[i] != null) { /* Build reverse mapping for setBiome */
|
||||
BIOMEBASE_MAPPING[BIOME_MAPPING[i].ordinal()] = BiomeBase.biomes[i];
|
||||
BIOMEBASE_MAPPING[BIOME_MAPPING[i].ordinal()] = BiomeBase.getBiome(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityChest;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
|
|
@ -1,48 +1,48 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityCommand;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
|
||||
private final TileEntityCommand commandBlock;
|
||||
private String command;
|
||||
private String name;
|
||||
|
||||
public CraftCommandBlock(Block block) {
|
||||
super(block);
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
commandBlock = (TileEntityCommand) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
command = commandBlock.b;
|
||||
name = commandBlock.getName();
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command != null ? command : "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name != null ? name : "@";
|
||||
}
|
||||
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
commandBlock.a(command);
|
||||
commandBlock.b(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.TileEntityCommand;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CommandBlock;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftCommandBlock extends CraftBlockState implements CommandBlock {
|
||||
private final TileEntityCommand commandBlock;
|
||||
private String command;
|
||||
private String name;
|
||||
|
||||
public CraftCommandBlock(Block block) {
|
||||
super(block);
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
commandBlock = (TileEntityCommand) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
command = commandBlock.a().e;
|
||||
name = commandBlock.a().getName();
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command != null ? command : "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name != null ? name : "@";
|
||||
}
|
||||
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
commandBlock.a().a(command);
|
||||
commandBlock.a().b(name);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.Random;
|
||||
import net.minecraft.server.BlockDispenser;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDispenser;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -29,7 +29,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
|||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
BlockDispenser dispense = (BlockDispenser) net.minecraft.server.Block.DISPENSER;
|
||||
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDropper;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDropper;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
@ -29,7 +30,7 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
|||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
BlockDropper drop = (BlockDropper) net.minecraft.server.Block.DROPPER;
|
||||
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
|
||||
|
||||
drop.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.TileEntityRecordPlayer;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Jukebox;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.TileEntityRecordPlayer;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
private final CraftWorld world;
|
||||
|
@ -22,20 +22,22 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
|||
jukebox = (TileEntityRecordPlayer) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getPlaying() {
|
||||
ItemStack record = jukebox.getRecord();
|
||||
if (record == null) {
|
||||
return Material.AIR;
|
||||
}
|
||||
return Material.getMaterial(record.id);
|
||||
return CraftMagicNumbers.getMaterial(record.getItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlaying(Material record) {
|
||||
if (record == null || Item.byId[record.getId()] == null) {
|
||||
if (record == null || CraftMagicNumbers.getItem(record) == null) {
|
||||
record = Material.AIR;
|
||||
jukebox.setRecord(null);
|
||||
} else {
|
||||
jukebox.setRecord(new ItemStack(Item.byId[record.getId()], 1));
|
||||
jukebox.setRecord(new ItemStack(CraftMagicNumbers.getItem(record), 1));
|
||||
}
|
||||
jukebox.update();
|
||||
if (record == Material.AIR) {
|
||||
|
@ -52,7 +54,7 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
|||
|
||||
public boolean eject() {
|
||||
boolean result = isPlaying();
|
||||
((BlockJukeBox) net.minecraft.server.Block.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ());
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.bukkit.Note;
|
|||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.NoteBlock;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
private final CraftWorld world;
|
||||
|
@ -47,22 +48,24 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean play(byte instrument, byte note) {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument, note);
|
||||
world.getHandle().playNote(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument, note);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean play(Instrument instrument, Note note) {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playNote(getX(), getY(), getZ(), block.getTypeId(), instrument.getType(), note.getId());
|
||||
world.getHandle().playNote(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -45,7 +45,7 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
|
|||
}
|
||||
|
||||
queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
|
||||
chunk.n = queuedChunk.provider.world.getTime();
|
||||
chunk.p = queuedChunk.provider.world.getTime();
|
||||
queuedChunk.provider.chunks.put(queuedChunk.coords, chunk);
|
||||
chunk.addEntities();
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.server.TileEntityCommand;
|
||||
import net.minecraft.server.TileEntityCommandListener;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
|
||||
|
@ -8,15 +9,15 @@ import org.bukkit.command.BlockCommandSender;
|
|||
* Represents input from a command block
|
||||
*/
|
||||
public class CraftBlockCommandSender extends ServerCommandSender implements BlockCommandSender {
|
||||
private final TileEntityCommand commandBlock;
|
||||
private final TileEntityCommandListener commandBlock;
|
||||
|
||||
public CraftBlockCommandSender(TileEntityCommand commandBlock) {
|
||||
public CraftBlockCommandSender(TileEntityCommandListener commandBlockListenerAbstract) {
|
||||
super();
|
||||
this.commandBlock = commandBlock;
|
||||
this.commandBlock = commandBlockListenerAbstract;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.x, commandBlock.y, commandBlock.z);
|
||||
return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().x, commandBlock.getChunkCoordinates().y, commandBlock.getChunkCoordinates().z);
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.server.ChatMessage;
|
||||
import net.minecraft.server.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
|
||||
|
@ -9,24 +8,29 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
|||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
RemoteControlCommandListener.instance.sendMessage(ChatMessage.d(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
RemoteControlCommandListener.instance.sendMessage(message + "\n"); // Send a newline after each message, to preserve formatting.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages) {
|
||||
for (String message : messages) {
|
||||
sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Rcon";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of remote controller.");
|
||||
}
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import net.minecraft.server.ChatMessage;
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.LocaleLanguage;
|
||||
import net.minecraft.server.World;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class ServerCommandListener implements ICommandListener {
|
||||
private final CommandSender commandSender;
|
||||
private final String prefix;
|
||||
|
||||
public ServerCommandListener(CommandSender commandSender) {
|
||||
this.commandSender = commandSender;
|
||||
String[] parts = commandSender.getClass().getName().split("\\.");
|
||||
this.prefix = parts[parts.length - 1];
|
||||
}
|
||||
|
||||
public void sendMessage(ChatMessage chatmessage) {
|
||||
this.commandSender.sendMessage(chatmessage.toString());
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return commandSender;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
try {
|
||||
Method getName = commandSender.getClass().getMethod("getName");
|
||||
|
||||
return (String) getName.invoke(commandSender);
|
||||
} catch (Exception e) {}
|
||||
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public boolean a(int i, String s) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public ChunkCoordinates b() {
|
||||
return new ChunkCoordinates(0, 0, 0);
|
||||
}
|
||||
|
||||
public World f_() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -11,7 +11,6 @@ import net.minecraft.server.EntityEnderDragon;
|
|||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.ComplexEntityPart;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftEnderDragon extends CraftComplexLivingEntity implements EnderDragon {
|
||||
|
|
|
@ -2,8 +2,8 @@ package org.bukkit.craftbukkit.entity;
|
|||
|
||||
import net.minecraft.server.EntityEnderman;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Enderman;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
@ -14,11 +14,11 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
|||
}
|
||||
|
||||
public MaterialData getCarriedMaterial() {
|
||||
return Material.getMaterial(getHandle().getCarriedId()).getNewData((byte) getHandle().getCarriedData());
|
||||
return CraftMagicNumbers.getMaterial(getHandle().getCarried()).getNewData((byte) getHandle().getCarriedData());
|
||||
}
|
||||
|
||||
public void setCarriedMaterial(MaterialData data) {
|
||||
getHandle().setCarriedId(data.getItemTypeId());
|
||||
getHandle().setCarried(CraftMagicNumbers.getBlock(data.getItemTypeId()));
|
||||
getHandle().setCarriedData(data.getData());
|
||||
}
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
else if (entity instanceof EntityMinecartHopper) { return new CraftMinecartHopper(server, (EntityMinecartHopper) entity); }
|
||||
else if (entity instanceof EntityMinecartMobSpawner) { return new CraftMinecartMobSpawner(server, (EntityMinecartMobSpawner) entity); }
|
||||
else if (entity instanceof EntityMinecartRideable) { return new CraftMinecartRideable(server, (EntityMinecartRideable) entity); }
|
||||
else if (entity instanceof EntityMinecartCommandBlock) { return new CraftMinecartCommand(server, (EntityMinecartCommandBlock) entity); }
|
||||
} else if (entity instanceof EntityHanging) {
|
||||
if (entity instanceof EntityPainting) { return new CraftPainting(server, (EntityPainting) entity); }
|
||||
else if (entity instanceof EntityItemFrame) { return new CraftItemFrame(server, (EntityItemFrame) entity); }
|
||||
|
@ -230,7 +231,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entity.id;
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
public int getFireTicks() {
|
||||
|
|
|
@ -4,6 +4,7 @@ import net.minecraft.server.EntityFallingBlock;
|
|||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingSand;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
|||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return getHandle().id;
|
||||
return CraftMagicNumbers.getId(getHandle().id);
|
||||
}
|
||||
|
||||
public byte getBlockData() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFireworks;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.Items;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
@ -25,7 +25,7 @@ public class CraftFirework extends CraftEntity implements Firework {
|
|||
ItemStack item = getHandle().getDataWatcher().getItemStack(FIREWORK_ITEM_INDEX);
|
||||
|
||||
if (item == null) {
|
||||
item = new ItemStack(Item.FIREWORKS);
|
||||
item = new ItemStack(Items.FIREWORKS);
|
||||
getHandle().getDataWatcher().watch(FIREWORK_ITEM_INDEX, item);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import net.minecraft.server.Container;
|
|||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityMinecartHopper;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.Packet100OpenWindow;
|
||||
import net.minecraft.server.Packet101CloseWindow;
|
||||
import net.minecraft.server.PacketPlayInCloseWindow;
|
||||
import net.minecraft.server.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.TileEntityBrewingStand;
|
||||
import net.minecraft.server.TileEntityDispenser;
|
||||
import net.minecraft.server.TileEntityFurnace;
|
||||
|
@ -249,7 +249,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
String title = container.getBukkitView().getTitle();
|
||||
int size = container.getBukkitView().getTopInventory().getSize();
|
||||
|
||||
player.playerConnection.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size, true));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, true));
|
||||
getHandle().activeContainer = container;
|
||||
getHandle().activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
if (((EntityPlayer) getHandle()).playerConnection == null) return;
|
||||
if (getHandle().activeContainer != getHandle().defaultContainer) {
|
||||
// fire INVENTORY_CLOSE if one already open
|
||||
((EntityPlayer)getHandle()).playerConnection.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
|
||||
((EntityPlayer)getHandle()).playerConnection.a(new PacketPlayInCloseWindow(getHandle().activeContainer.windowId));
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer) getHandle();
|
||||
Container container;
|
||||
|
@ -314,7 +314,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
int windowType = CraftContainer.getNotchInventoryType(type);
|
||||
String title = inventory.getTitle();
|
||||
int size = inventory.getTopInventory().getSize();
|
||||
player.playerConnection.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size, false));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, false));
|
||||
player.activeContainer = container;
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
|
|
@ -274,7 +274,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
}
|
||||
|
||||
public void removePotionEffect(PotionEffectType type) {
|
||||
getHandle().k(type.getId()); // Should be removeEffect.
|
||||
getHandle().m(type.getId()); // Should be removeEffect.
|
||||
}
|
||||
|
||||
public Collection<PotionEffect> getActivePotionEffects() {
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.EntityMinecartCommandBlock;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.minecart.CommandMinecart;
|
||||
import org.bukkit.permissions.PermissibleBase;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class CraftMinecartCommand extends CraftMinecart implements CommandMinecart {
|
||||
private final PermissibleBase perm = new PermissibleBase(this);
|
||||
|
||||
public CraftMinecartCommand(CraftServer server, EntityMinecartCommandBlock entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommand() {
|
||||
return ((EntityMinecartCommandBlock) getHandle()).e().e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommand(String command) {
|
||||
((EntityMinecartCommandBlock) getHandle()).e().a(command != null ? command : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
((EntityMinecartCommandBlock) getHandle()).e().b(name != null ? name : "@");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.MINECART_COMMAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ((EntityMinecartCommandBlock) getHandle()).e().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOp(boolean value) {
|
||||
throw new UnsupportedOperationException("Cannot change operator status of a minecart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String name) {
|
||||
return perm.isPermissionSet(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(Permission perm) {
|
||||
return this.perm.isPermissionSet(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String name) {
|
||||
return perm.hasPermission(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(Permission perm) {
|
||||
return this.perm.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
|
||||
return perm.addAttachment(plugin, name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin) {
|
||||
return perm.addAttachment(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
|
||||
return perm.addAttachment(plugin, name, value, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
|
||||
return perm.addAttachment(plugin, ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttachment(PermissionAttachment attachment) {
|
||||
perm.removeAttachment(attachment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissions() {
|
||||
perm.recalculatePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
|
||||
return perm.getEffectivePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer() {
|
||||
return Bukkit.getServer();
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ import org.bukkit.craftbukkit.CraftWorld;
|
|||
import org.bukkit.craftbukkit.map.CraftMapView;
|
||||
import org.bukkit.craftbukkit.map.RenderData;
|
||||
import org.bukkit.craftbukkit.scoreboard.CraftScoreboard;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
|
@ -129,36 +131,45 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String message) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.sendPacket(new Packet3Chat(ChatMessage.d(message)));
|
||||
for (IChatBaseComponent component : CraftChatMessage.fromString(message)) {
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutChat(component));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
if (!conversationTracker.isConversingModaly()) {
|
||||
this.sendRawMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] messages) {
|
||||
for (String message : messages) {
|
||||
sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return getHandle().displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(final String name) {
|
||||
getHandle().displayName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerListName() {
|
||||
return getHandle().listName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name) {
|
||||
String oldName = getHandle().listName;
|
||||
|
||||
|
@ -184,8 +195,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
getHandle().listName = name;
|
||||
|
||||
// Change the name on the client side
|
||||
Packet201PlayerInfo oldpacket = new Packet201PlayerInfo(oldName, false, 9999);
|
||||
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
|
||||
PacketPlayOutPlayerInfo oldpacket = new PacketPlayOutPlayerInfo(oldName, false, 9999);
|
||||
PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(name, true, getHandle().ping);
|
||||
for (int i = 0; i < server.getHandle().players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
|
||||
if (entityplayer.playerConnection == null) continue;
|
||||
|
@ -217,47 +228,89 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return nameEquals && idEquals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickPlayer(String message) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location loc) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
// Do not directly assign here, from the packethandler we'll assign it.
|
||||
getHandle().playerConnection.sendPacket(new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCompassTarget() {
|
||||
return getHandle().compassTarget;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String msg) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().playerConnection.chat(msg, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCommand(String command) {
|
||||
return server.dispatchCommand(this, command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playNote(Location loc, byte instrument, byte note) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
|
||||
String instrumentName = null;
|
||||
switch (instrument) {
|
||||
case 0:
|
||||
instrumentName = "harp";
|
||||
break;
|
||||
case 1:
|
||||
instrumentName = "bd";
|
||||
break;
|
||||
case 2:
|
||||
instrumentName = "snare";
|
||||
break;
|
||||
case 3:
|
||||
instrumentName = "hat";
|
||||
break;
|
||||
case 4:
|
||||
instrumentName = "bassattack";
|
||||
break;
|
||||
}
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playNote(Location loc, Instrument instrument, Note note) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
|
||||
String instrumentName = null;
|
||||
switch (instrument.ordinal()) {
|
||||
case 0:
|
||||
instrumentName = "harp";
|
||||
break;
|
||||
case 1:
|
||||
instrumentName = "bd";
|
||||
break;
|
||||
case 2:
|
||||
instrumentName = "snare";
|
||||
break;
|
||||
case 3:
|
||||
instrumentName = "hat";
|
||||
break;
|
||||
case 4:
|
||||
instrumentName = "bassattack";
|
||||
break;
|
||||
}
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("note."+instrumentName, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), 3.0f, note.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
if (sound == null) {
|
||||
return;
|
||||
|
@ -265,6 +318,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
playSound(loc, CraftSound.getSound(sound), volume, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Location loc, String sound, float volume, float pitch) {
|
||||
if (loc == null || sound == null || getHandle().playerConnection == null) return;
|
||||
|
||||
|
@ -272,18 +326,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
double y = loc.getBlockY() + 0.5;
|
||||
double z = loc.getBlockZ() + 0.5;
|
||||
|
||||
Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect(sound, x, y, z, volume, pitch);
|
||||
PacketPlayOutNamedSoundEffect packet = new PacketPlayOutNamedSoundEffect(sound, x, y, z, volume, pitch);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playEffect(Location loc, Effect effect, int data) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int packetData = effect.getId();
|
||||
Packet61WorldEvent packet = new Packet61WorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(Location loc, Effect effect, T data) {
|
||||
if (data != null) {
|
||||
Validate.isTrue(data.getClass().equals(effect.getData()), "Wrong kind of data for this effect!");
|
||||
|
@ -295,20 +351,23 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
playEffect(loc, effect, datavalue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockChange(Location loc, Material material, byte data) {
|
||||
sendBlockChange(loc, material.getId(), data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBlockChange(Location loc, int material, byte data) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
Packet53BlockChange packet = new Packet53BlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
|
||||
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
|
||||
|
||||
packet.material = material;
|
||||
packet.block = CraftMagicNumbers.getBlock(material);
|
||||
packet.data = data;
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) {
|
||||
if (getHandle().playerConnection == null) return false;
|
||||
|
||||
|
@ -342,6 +401,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
throw new NotImplementedException("Chunk changes do not yet work"); // TODO: Chunk changes.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView map) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
|
@ -352,7 +412,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
for (int y = 0; y < 128; ++y) {
|
||||
bytes[y + 3] = data.buffer[y * 128 + x];
|
||||
}
|
||||
Packet131ItemData packet = new Packet131ItemData((short) Material.MAP.getId(), map.getId(), bytes);
|
||||
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), bytes);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +425,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (entity.playerConnection == null || entity.playerConnection.disconnected) {
|
||||
if (entity.playerConnection == null || entity.playerConnection.isDisconnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -408,125 +468,125 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSneaking(boolean sneak) {
|
||||
getHandle().setSneaking(sneak);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking() {
|
||||
return getHandle().isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting() {
|
||||
return getHandle().isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean sprinting) {
|
||||
getHandle().setSprinting(sprinting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData() {
|
||||
server.getHandle().playerFileData.load(getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
server.getHandle().playerFileData.save(getHandle());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void updateInventory() {
|
||||
getHandle().updateInventory(getHandle().activeContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSleepingIgnored(boolean isSleeping) {
|
||||
getHandle().fauxSleeping = isSleeping;
|
||||
((CraftWorld) getWorld()).getHandle().checkSleepStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSleepingIgnored() {
|
||||
return getHandle().fauxSleeping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void awardAchievement(Achievement achievement) {
|
||||
sendStatistic(achievement.getId(), 1);
|
||||
// TODO - non-functional as of ID purge
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic statistic) {
|
||||
incrementStatistic(statistic, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic statistic, int amount) {
|
||||
sendStatistic(statistic.getId(), amount);
|
||||
// TODO - non-functional as of ID purge
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic statistic, Material material) {
|
||||
incrementStatistic(statistic, material, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void incrementStatistic(Statistic statistic, Material material, int amount) {
|
||||
if (!statistic.isSubstatistic()) {
|
||||
throw new IllegalArgumentException("Given statistic is not a substatistic");
|
||||
}
|
||||
if (statistic.isBlock() != material.isBlock()) {
|
||||
throw new IllegalArgumentException("Given material is not valid for this substatistic");
|
||||
}
|
||||
|
||||
int mat = material.getId();
|
||||
|
||||
if (!material.isBlock()) {
|
||||
mat -= 255;
|
||||
}
|
||||
|
||||
sendStatistic(statistic.getId() + mat, amount);
|
||||
}
|
||||
|
||||
private void sendStatistic(int id, int amount) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
while (amount > Byte.MAX_VALUE) {
|
||||
sendStatistic(id, Byte.MAX_VALUE);
|
||||
amount -= Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
getHandle().playerConnection.sendPacket(new Packet200Statistic(id, amount));
|
||||
// TODO - non-functional as of ID purge
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerTime(long time, boolean relative) {
|
||||
getHandle().timeOffset = time;
|
||||
getHandle().relativeTime = relative;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTimeOffset() {
|
||||
return getHandle().timeOffset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPlayerTime() {
|
||||
return getHandle().getPlayerTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerTimeRelative() {
|
||||
return getHandle().relativeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerTime() {
|
||||
setPlayerTime(0, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerWeather(WeatherType type) {
|
||||
getHandle().setPlayerWeather(type, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WeatherType getPlayerWeather() {
|
||||
return getHandle().getPlayerWeather();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetPlayerWeather() {
|
||||
getHandle().resetPlayerWeather();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned() {
|
||||
return server.getHandle().getNameBans().isBanned(getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean value) {
|
||||
if (value) {
|
||||
BanEntry entry = new BanEntry(getName().toLowerCase());
|
||||
|
@ -538,10 +598,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
server.getHandle().getNameBans().save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted() {
|
||||
return server.getHandle().getWhitelisted().contains(getName().toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean value) {
|
||||
if (value) {
|
||||
server.getHandle().addWhitelist(getName().toLowerCase());
|
||||
|
@ -566,7 +628,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
getHandle().playerInteractManager.setGameMode(EnumGamemode.a(mode.getValue()));
|
||||
getHandle().playerConnection.sendPacket(new Packet70Bed(3, mode.getValue()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,13 +731,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
//remove this player from the hidden player's EntityTrackerEntry
|
||||
EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
||||
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
||||
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.id);
|
||||
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId());
|
||||
if (entry != null) {
|
||||
entry.clear(getHandle());
|
||||
}
|
||||
|
||||
//remove the hidden player from this player user list
|
||||
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), false, 9999));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), false, 9999));
|
||||
}
|
||||
|
||||
public void showPlayer(Player player) {
|
||||
|
@ -687,12 +749,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
EntityTracker tracker = ((WorldServer) entity.world).tracker;
|
||||
EntityPlayer other = ((CraftPlayer) player).getHandle();
|
||||
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.id);
|
||||
EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.getId());
|
||||
if (entry != null && !entry.trackedPlayers.contains(getHandle())) {
|
||||
entry.updatePlayer(getHandle());
|
||||
}
|
||||
|
||||
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), true, getHandle().ping));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), true, getHandle().ping));
|
||||
}
|
||||
|
||||
public boolean canSee(Player player) {
|
||||
|
@ -772,7 +834,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
public void setExtraData(NBTTagCompound nbttagcompound) {
|
||||
if (!nbttagcompound.hasKey("bukkit")) {
|
||||
nbttagcompound.setCompound("bukkit", new NBTTagCompound());
|
||||
nbttagcompound.set("bukkit", new NBTTagCompound());
|
||||
}
|
||||
|
||||
NBTTagCompound data = nbttagcompound.getCompound("bukkit");
|
||||
|
@ -811,10 +873,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
if (channels.contains(channel)) {
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.tag = channel;
|
||||
packet.length = message.length;
|
||||
packet.data = message;
|
||||
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, message);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
@ -825,7 +884,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
byte[] message = (url + "\0" + "16").getBytes();
|
||||
Validate.isTrue(message.length <= Messenger.MAX_MESSAGE_SIZE, "Texture pack URL is too long");
|
||||
|
||||
getHandle().playerConnection.sendPacket(new Packet250CustomPayload("MC|TPack", message));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("MC|TPack", message));
|
||||
}
|
||||
|
||||
public void addChannel(String channel) {
|
||||
|
@ -849,9 +908,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
Set<String> listening = server.getMessenger().getIncomingChannels();
|
||||
|
||||
if (!listening.isEmpty()) {
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
|
||||
packet.tag = "REGISTER";
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
|
||||
for (String channel : listening) {
|
||||
|
@ -863,10 +919,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
}
|
||||
|
||||
packet.data = stream.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", stream.toByteArray()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1056,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
if (playerConnection == null) {
|
||||
throw new IllegalStateException("Cannot set scoreboard yet");
|
||||
}
|
||||
if (playerConnection.disconnected) {
|
||||
if (playerConnection.isDisconnected()) {
|
||||
throw new IllegalStateException("Cannot set scoreboard for invalid CraftPlayer");
|
||||
}
|
||||
|
||||
|
@ -1045,14 +1098,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void updateScaledHealth() {
|
||||
AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().aX();
|
||||
AttributeMapServer attributemapserver = (AttributeMapServer) getHandle().bc();
|
||||
Set set = attributemapserver.b();
|
||||
|
||||
injectScaledMaxHealth(set, true);
|
||||
|
||||
getHandle().getDataWatcher().watch(6, (float) getScaledHealth());
|
||||
getHandle().playerConnection.sendPacket(new Packet8UpdateHealth(getScaledHealth(), getHandle().getFoodData().a(), getHandle().getFoodData().e()));
|
||||
getHandle().playerConnection.sendPacket(new Packet44UpdateAttributes(getHandle().id, set));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().a(), getHandle().getFoodData().e()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateAttributes(getHandle().getId(), set));
|
||||
|
||||
set.clear();
|
||||
getHandle().maxHealthCache = getMaxHealth();
|
||||
|
@ -1070,6 +1123,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
collection.add(new AttributeModifiable(getHandle().aX(), (new AttributeRanged("generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
|
||||
collection.add(new AttributeModifiable(getHandle().bc(), (new AttributeRanged("generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,10 +21,10 @@ import net.minecraft.server.EntityPotion;
|
|||
import net.minecraft.server.Explosion;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.InventoryCrafting;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.Packet101CloseWindow;
|
||||
import net.minecraft.server.Packet103SetSlot;
|
||||
import net.minecraft.server.Items;
|
||||
import net.minecraft.server.PacketPlayInCloseWindow;
|
||||
import net.minecraft.server.PacketPlayOutSetSlot;
|
||||
import net.minecraft.server.Slot;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
@ -44,6 +44,7 @@ import org.bukkit.craftbukkit.entity.CraftPlayer;
|
|||
import org.bukkit.craftbukkit.inventory.CraftInventoryCrafting;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.util.CraftDamageSource;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Horse;
|
||||
|
@ -118,7 +119,7 @@ public class CraftEventFactory {
|
|||
* Bucket methods
|
||||
*/
|
||||
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand) {
|
||||
return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, Item.BUCKET);
|
||||
return (PlayerBucketEmptyEvent) getPlayerBucketEvent(false, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, Items.BUCKET);
|
||||
}
|
||||
|
||||
public static PlayerBucketFillEvent callPlayerBucketFillEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) {
|
||||
|
@ -128,7 +129,7 @@ public class CraftEventFactory {
|
|||
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
|
||||
Material bucket = Material.getMaterial(itemstack.id);
|
||||
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
|
||||
|
||||
CraftWorld craftWorld = (CraftWorld) player.getWorld();
|
||||
CraftServer craftServer = (CraftServer) player.getServer();
|
||||
|
@ -294,18 +295,18 @@ public class CraftEventFactory {
|
|||
/**
|
||||
* BlockFadeEvent
|
||||
*/
|
||||
public static BlockFadeEvent callBlockFadeEvent(Block block, int type) {
|
||||
public static BlockFadeEvent callBlockFadeEvent(Block block, net.minecraft.server.Block type) {
|
||||
BlockState state = block.getState();
|
||||
state.setTypeId(type);
|
||||
state.setTypeId(net.minecraft.server.Block.b(type));
|
||||
|
||||
BlockFadeEvent event = new BlockFadeEvent(block, state);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void handleBlockSpreadEvent(Block block, Block source, int type, int data) {
|
||||
public static void handleBlockSpreadEvent(Block block, Block source, net.minecraft.server.Block type, int data) {
|
||||
BlockState state = block.getState();
|
||||
state.setTypeId(type);
|
||||
state.setTypeId(net.minecraft.server.Block.b(type));
|
||||
state.setRawData((byte) data);
|
||||
|
||||
BlockSpreadEvent event = new BlockSpreadEvent(block, source, state);
|
||||
|
@ -323,13 +324,13 @@ public class CraftEventFactory {
|
|||
public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
|
||||
CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
|
||||
org.bukkit.World world = entity.getWorld();
|
||||
CraftWorld world = (CraftWorld) entity.getWorld();
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
victim.expToDrop = event.getDroppedExp();
|
||||
|
||||
for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
|
||||
if (stack == null || stack.getType() == Material.AIR) continue;
|
||||
if (stack == null || stack.getType() == Material.AIR || stack.getAmount() == 0) continue;
|
||||
|
||||
world.dropItemNaturally(entity.getLocation(), stack);
|
||||
}
|
||||
|
@ -465,10 +466,10 @@ public class CraftEventFactory {
|
|||
return event;
|
||||
}
|
||||
|
||||
public static void handleBlockGrowEvent(World world, int x, int y, int z, int type, int data) {
|
||||
public static void handleBlockGrowEvent(World world, int x, int y, int z, net.minecraft.server.Block type, int data) {
|
||||
Block block = world.getWorld().getBlockAt(x, y, z);
|
||||
CraftBlockState state = (CraftBlockState) block.getState();
|
||||
state.setTypeId(type);
|
||||
state.setTypeId(net.minecraft.server.Block.b(type));
|
||||
state.setRawData((byte) data);
|
||||
|
||||
BlockGrowEvent event = new BlockGrowEvent(block, state);
|
||||
|
@ -505,15 +506,24 @@ public class CraftEventFactory {
|
|||
return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0);
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, int type, int data) {
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, Block block, Material material, boolean cancelled) {
|
||||
return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, 0, cancelled);
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(Entity entity, int x, int y, int z, net.minecraft.server.Block type, int data) {
|
||||
Block block = entity.world.getWorld().getBlockAt(x, y, z);
|
||||
Material material = Material.getMaterial(type);
|
||||
Material material = CraftMagicNumbers.getMaterial(type);
|
||||
|
||||
return callEntityChangeBlockEvent(entity.getBukkitEntity(), block, material, data);
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data) {
|
||||
return callEntityChangeBlockEvent(entity, block, material, data, false);
|
||||
}
|
||||
|
||||
public static EntityChangeBlockEvent callEntityChangeBlockEvent(org.bukkit.entity.Entity entity, Block block, Material material, int data, boolean cancelled) {
|
||||
EntityChangeBlockEvent event = new EntityChangeBlockEvent(entity, block, material, (byte) data);
|
||||
event.setCancelled(cancelled);
|
||||
entity.getServer().getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
@ -548,7 +558,7 @@ public class CraftEventFactory {
|
|||
|
||||
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
|
||||
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
|
||||
player.playerConnection.handleContainerClose(new Packet101CloseWindow(player.activeContainer.windowId));
|
||||
player.playerConnection.a(new PacketPlayInCloseWindow(player.activeContainer.windowId));
|
||||
}
|
||||
|
||||
CraftServer server = player.world.getServer();
|
||||
|
@ -686,22 +696,22 @@ public class CraftEventFactory {
|
|||
public static void handleEditBookEvent(EntityPlayer player, ItemStack newBookItem) {
|
||||
int itemInHandIndex = player.inventory.itemInHandIndex;
|
||||
|
||||
PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), player.inventory.itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(player.inventory.getItemInHand()), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.id == Item.WRITTEN_BOOK.id);
|
||||
PlayerEditBookEvent editBookEvent = new PlayerEditBookEvent(player.getBukkitEntity(), player.inventory.itemInHandIndex, (BookMeta) CraftItemStack.getItemMeta(player.inventory.getItemInHand()), (BookMeta) CraftItemStack.getItemMeta(newBookItem), newBookItem.getItem() == Items.WRITTEN_BOOK);
|
||||
player.world.getServer().getPluginManager().callEvent(editBookEvent);
|
||||
ItemStack itemInHand = player.inventory.getItem(itemInHandIndex);
|
||||
|
||||
// If they've got the same item in their hand, it'll need to be updated.
|
||||
if (itemInHand.id == Item.BOOK_AND_QUILL.id) {
|
||||
if (itemInHand.getItem() == Items.BOOK_AND_QUILL) {
|
||||
if (!editBookEvent.isCancelled()) {
|
||||
CraftItemStack.setItemMeta(itemInHand, editBookEvent.getNewBookMeta());
|
||||
if (editBookEvent.isSigning()) {
|
||||
itemInHand.id = Item.WRITTEN_BOOK.id;
|
||||
itemInHand.setItem(Items.WRITTEN_BOOK);
|
||||
}
|
||||
}
|
||||
|
||||
// Client will have updated its idea of the book item; we need to overwrite that
|
||||
Slot slot = player.activeContainer.a((IInventory) player.inventory, itemInHandIndex);
|
||||
player.playerConnection.sendPacket(new Packet103SetSlot(player.activeContainer.windowId, slot.g, itemInHand));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutSetSlot(player.activeContainer.windowId, slot.rawSlotIndex, itemInHand));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.inventory.InventoryView;
|
|||
import net.minecraft.server.Container;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.Packet100OpenWindow;
|
||||
import net.minecraft.server.PacketPlayOutOpenWindow;
|
||||
import net.minecraft.server.Slot;
|
||||
|
||||
public class CraftContainer extends Container {
|
||||
|
@ -85,7 +85,7 @@ public class CraftContainer extends Container {
|
|||
setupSlots(top, bottom);
|
||||
}
|
||||
int size = getSize();
|
||||
player.getHandle().playerConnection.sendPacket(new Packet100OpenWindow(this.windowId, type, cachedTitle, size, true));
|
||||
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
|
||||
player.updateInventory();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.inventory;
|
|||
|
||||
import net.minecraft.server.RecipesFurnace;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.FurnaceRecipe;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
@ -20,6 +21,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
|
|||
public void addToCraftingManager() {
|
||||
ItemStack result = this.getResult();
|
||||
ItemStack input = this.getInput();
|
||||
RecipesFurnace.getInstance().registerRecipe(input.getTypeId(), CraftItemStack.asNMSCopy(result), 0.1f);
|
||||
RecipesFurnace.getInstance().registerRecipe(CraftMagicNumbers.getBlock(input.getTypeId()), CraftItemStack.asNMSCopy(result), 0.1f);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
|
||||
public String getName() {
|
||||
return getInventory().getName();
|
||||
return getInventory().getInventoryName();
|
||||
}
|
||||
|
||||
public ItemStack getItem(int index) {
|
||||
|
@ -421,7 +421,7 @@ public class CraftInventory implements Inventory {
|
|||
}
|
||||
|
||||
public String getTitle() {
|
||||
return inventory.getName();
|
||||
return inventory.getInventoryName();
|
||||
}
|
||||
|
||||
public InventoryType getType() {
|
||||
|
|
|
@ -97,7 +97,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
public String getInventoryName() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
return type;
|
||||
}
|
||||
|
||||
public void g() {}
|
||||
public void l_() {}
|
||||
|
||||
public InventoryHolder getOwner() {
|
||||
return owner;
|
||||
|
@ -143,7 +143,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
|||
|
||||
public void startOpen() {}
|
||||
|
||||
public boolean c() {
|
||||
public boolean k_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.Packet16BlockItemSwitch;
|
||||
import net.minecraft.server.PacketPlayOutHeldItemSlot;
|
||||
import net.minecraft.server.PlayerInventory;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
@ -39,7 +39,7 @@ public class CraftInventoryPlayer extends CraftInventory implements org.bukkit.i
|
|||
public void setHeldItemSlot(int slot) {
|
||||
Validate.isTrue(slot >= 0 && slot < PlayerInventory.getHotbarSize(), "Slot is not between 0 and 8 inclusive");
|
||||
this.getInventory().itemInHandIndex = slot;
|
||||
((CraftPlayer) this.getHolder()).getHandle().playerConnection.sendPacket(new Packet16BlockItemSwitch(slot));
|
||||
((CraftPlayer) this.getHolder()).getHandle().playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(slot));
|
||||
}
|
||||
|
||||
public ItemStack getHelmet() {
|
||||
|
|
|
@ -53,7 +53,7 @@ public class CraftInventoryView extends InventoryView {
|
|||
if (slot != -999) {
|
||||
container.getSlot(slot).set(stack);
|
||||
} else {
|
||||
player.getHandle().drop(stack);
|
||||
player.getHandle().drop(stack, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,12 +7,14 @@ import static org.bukkit.craftbukkit.inventory.CraftMetaItem.ENCHANTMENTS_LVL;
|
|||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.EnchantmentManager;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
@ -30,7 +32,14 @@ public final class CraftItemStack extends ItemStack {
|
|||
if (original == null || original.getTypeId() <= 0) {
|
||||
return null;
|
||||
}
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(original.getTypeId(), original.getAmount(), original.getDurability());
|
||||
|
||||
Item item = CraftMagicNumbers.getItem(original.getType());
|
||||
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(item, original.getAmount(), original.getDurability());
|
||||
if (original.hasItemMeta()) {
|
||||
setItemMeta(stack, original.getItemMeta());
|
||||
}
|
||||
|
@ -50,7 +59,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
if (original == null) {
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
ItemStack stack = new ItemStack(original.id, original.count, (short) original.getData());
|
||||
ItemStack stack = new ItemStack(CraftMagicNumbers.getMaterial(original.getItem()), original.count, (short) original.getData());
|
||||
if (hasItemMeta(original)) {
|
||||
stack.setItemMeta(getItemMeta(original));
|
||||
}
|
||||
|
@ -69,12 +78,12 @@ public final class CraftItemStack extends ItemStack {
|
|||
return new CraftItemStack(original);
|
||||
}
|
||||
|
||||
public static CraftItemStack asNewCraftStack(net.minecraft.server.Item item) {
|
||||
public static CraftItemStack asNewCraftStack(Item item) {
|
||||
return asNewCraftStack(item, 1);
|
||||
}
|
||||
|
||||
public static CraftItemStack asNewCraftStack(net.minecraft.server.Item item, int amount) {
|
||||
return new CraftItemStack(item.id, amount, (short) 0, null);
|
||||
public static CraftItemStack asNewCraftStack(Item item, int amount) {
|
||||
return new CraftItemStack(CraftMagicNumbers.getMaterial(item), amount, (short) 0, null);
|
||||
}
|
||||
|
||||
net.minecraft.server.ItemStack handle;
|
||||
|
@ -90,16 +99,21 @@ public final class CraftItemStack extends ItemStack {
|
|||
this(item.getTypeId(), item.getAmount(), item.getDurability(), item.hasItemMeta() ? item.getItemMeta() : null);
|
||||
}
|
||||
|
||||
private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
|
||||
setTypeId(typeId);
|
||||
private CraftItemStack(Material type, int amount, short durability, ItemMeta itemMeta) {
|
||||
setType(type);
|
||||
setAmount(amount);
|
||||
setDurability(durability);
|
||||
setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
private CraftItemStack(int typeId, int amount, short durability, ItemMeta itemMeta) {
|
||||
this(Material.getMaterial(typeId), amount, durability, itemMeta);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTypeId() {
|
||||
return handle != null ? handle.id : 0;
|
||||
return handle != null ? CraftMagicNumbers.getId(handle.getItem()) : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,10 +122,12 @@ public final class CraftItemStack extends ItemStack {
|
|||
return;
|
||||
} else if (type == 0) {
|
||||
handle = null;
|
||||
} else if (CraftMagicNumbers.getItem(type) == null) { // :(
|
||||
handle = null;
|
||||
} else if (handle == null) {
|
||||
handle = new net.minecraft.server.ItemStack(type, 1, 0);
|
||||
handle = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(type), 1, 0);
|
||||
} else {
|
||||
handle.id = type;
|
||||
handle.setItem(CraftMagicNumbers.getItem(type));
|
||||
if (hasItemMeta()) {
|
||||
// This will create the appropriate item meta, which will contain all the data we intend to keep
|
||||
setItemMeta(handle, getItemMeta(handle));
|
||||
|
@ -168,7 +184,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
NBTTagList list = getEnchantmentList(handle);
|
||||
if (list == null) {
|
||||
list = new NBTTagList(ENCHANTMENTS.NBT);
|
||||
list = new NBTTagList();
|
||||
handle.tag.set(ENCHANTMENTS.NBT, list);
|
||||
}
|
||||
int size = list.size();
|
||||
|
@ -193,7 +209,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
|
||||
if (item.tag == null) {
|
||||
item.setTag(new NBTTagCompound("tag"));
|
||||
item.setTag(new NBTTagCompound());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -247,7 +263,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
|
||||
// This is workaround for not having an index removal
|
||||
listCopy = new NBTTagList(ENCHANTMENTS.NBT);
|
||||
listCopy = new NBTTagList();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i != index) {
|
||||
listCopy.add(list.get(i));
|
||||
|
@ -264,13 +280,14 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
|
||||
static Map<Enchantment, Integer> getEnchantments(net.minecraft.server.ItemStack item) {
|
||||
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
|
||||
NBTTagList list = (item == null) ? null : item.getEnchantments();
|
||||
NBTTagList list = (item != null && item.hasEnchantments()) ? item.getEnchantments() : null;
|
||||
|
||||
if (list == null) {
|
||||
return result.build();
|
||||
if (list == null || list.size() == 0) {
|
||||
return ImmutableMap.of();
|
||||
}
|
||||
|
||||
ImmutableMap.Builder<Enchantment, Integer> result = ImmutableMap.builder();
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
int id = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_ID.NBT);
|
||||
int level = 0xffff & ((NBTTagCompound) list.get(i)).getShort(ENCHANTMENTS_LVL.NBT);
|
||||
|
@ -282,7 +299,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
|
||||
static NBTTagList getEnchantmentList(net.minecraft.server.ItemStack item) {
|
||||
return item == null ? null : item.getEnchantments();
|
||||
return (item != null && item.hasEnchantments()) ? item.getEnchantments() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -330,7 +347,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
}
|
||||
|
||||
static Material getType(net.minecraft.server.ItemStack item) {
|
||||
Material material = Material.getMaterial(item == null ? 0 : item.id);
|
||||
Material material = Material.getMaterial(item == null ? 0 : CraftMagicNumbers.getId(item.getItem()));
|
||||
return material == null ? Material.AIR : material;
|
||||
}
|
||||
|
||||
|
@ -351,7 +368,7 @@ public final class CraftItemStack extends ItemStack {
|
|||
return false;
|
||||
}
|
||||
|
||||
NBTTagCompound tag = new NBTTagCompound("tag");
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
item.setTag(tag);
|
||||
|
||||
((CraftMetaItem) itemMeta).applyToItem(tag);
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Map;
|
|||
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import net.minecraft.server.NBTTagString;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
|
@ -54,11 +53,11 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
}
|
||||
|
||||
if (tag.hasKey(BOOK_PAGES.NBT)) {
|
||||
NBTTagList pages = tag.getList(BOOK_PAGES.NBT);
|
||||
NBTTagList pages = tag.getList(BOOK_PAGES.NBT, 8);
|
||||
String[] pageArray = new String[pages.size()];
|
||||
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
String page = ((NBTTagString) pages.get(i)).data;
|
||||
String page = pages.f(i);
|
||||
pageArray[i] = page;
|
||||
}
|
||||
|
||||
|
@ -90,7 +89,7 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
|||
}
|
||||
|
||||
if (hasPages()) {
|
||||
itemData.set(BOOK_PAGES.NBT, createStringList(pages, BOOK_PAGES));
|
||||
itemData.set(BOOK_PAGES.NBT, createStringList(pages));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
return;
|
||||
}
|
||||
|
||||
NBTTagList fireworkEffects = fireworks.getList(EXPLOSIONS.NBT);
|
||||
NBTTagList fireworkEffects = fireworks.getList(EXPLOSIONS.NBT, 10);
|
||||
List<FireworkEffect> effects = this.effects = new ArrayList<FireworkEffect>(fireworkEffects.size());
|
||||
|
||||
for (int i = 0; i < fireworkEffects.size(); i++) {
|
||||
|
@ -209,10 +209,10 @@ class CraftMetaFirework extends CraftMetaItem implements FireworkMeta {
|
|||
}
|
||||
|
||||
NBTTagCompound fireworks = itemTag.getCompound(FIREWORKS.NBT);
|
||||
itemTag.setCompound(FIREWORKS.NBT, fireworks);
|
||||
itemTag.set(FIREWORKS.NBT, fireworks);
|
||||
|
||||
if (hasEffects()) {
|
||||
NBTTagList effects = new NBTTagList(EXPLOSIONS.NBT);
|
||||
NBTTagList effects = new NBTTagList();
|
||||
for (FireworkEffect effect : this.effects) {
|
||||
effects.add(getExplosion(effect));
|
||||
}
|
||||
|
|
|
@ -231,11 +231,11 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
}
|
||||
|
||||
if (display.hasKey(LORE.NBT)) {
|
||||
NBTTagList list = display.getList(LORE.NBT);
|
||||
NBTTagList list = display.getList(LORE.NBT, 8);
|
||||
lore = new ArrayList<String>(list.size());
|
||||
|
||||
for (int index = 0; index < list.size(); index++) {
|
||||
String line = ((NBTTagString) list.get(index)).data;
|
||||
String line = list.f(index);
|
||||
lore.add(line);
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
|
||||
if (tag.get(ATTRIBUTES.NBT) instanceof NBTTagList) {
|
||||
NBTTagList save = null;
|
||||
NBTTagList nbttaglist = tag.getList(ATTRIBUTES.NBT);
|
||||
NBTTagList nbttaglist = tag.getList(ATTRIBUTES.NBT, 10);
|
||||
|
||||
for (int i = 0; i < nbttaglist.size(); ++i) {
|
||||
if (!(nbttaglist.get(i) instanceof NBTTagCompound)) {
|
||||
|
@ -278,7 +278,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
}
|
||||
|
||||
if (save == null) {
|
||||
save = new NBTTagList(ATTRIBUTES.NBT);
|
||||
save = new NBTTagList();
|
||||
}
|
||||
|
||||
NBTTagCompound entry = new NBTTagCompound();
|
||||
|
@ -302,7 +302,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
return null;
|
||||
}
|
||||
|
||||
NBTTagList ench = tag.getList(key.NBT);
|
||||
NBTTagList ench = tag.getList(key.NBT, 10);
|
||||
Map<Enchantment, Integer> enchantments = new HashMap<Enchantment, Integer>(ench.size());
|
||||
|
||||
for (int i = 0; i < ench.size(); i++) {
|
||||
|
@ -354,11 +354,11 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
@Overridden
|
||||
void applyToItem(NBTTagCompound itemTag) {
|
||||
if (hasDisplayName()) {
|
||||
setDisplayTag(itemTag, NAME.NBT, new NBTTagString(NAME.NBT, displayName));
|
||||
setDisplayTag(itemTag, NAME.NBT, new NBTTagString(displayName));
|
||||
}
|
||||
|
||||
if (hasLore()) {
|
||||
setDisplayTag(itemTag, LORE.NBT, createStringList(lore, LORE));
|
||||
setDisplayTag(itemTag, LORE.NBT, createStringList(lore));
|
||||
}
|
||||
|
||||
applyEnchantments(enchantments, itemTag, ENCHANTMENTS);
|
||||
|
@ -372,14 +372,14 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
}
|
||||
}
|
||||
|
||||
static NBTTagList createStringList(List<String> list, ItemMetaKey key) {
|
||||
static NBTTagList createStringList(List<String> list) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
NBTTagList tagList = new NBTTagList(key.NBT);
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
for (String value : list) {
|
||||
tagList.add(new NBTTagString("", value));
|
||||
tagList.add(new NBTTagString(value));
|
||||
}
|
||||
|
||||
return tagList;
|
||||
|
@ -390,7 +390,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
return;
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList(key.NBT);
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
NBTTagCompound subtag = new NBTTagCompound();
|
||||
|
@ -408,7 +408,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||
final NBTTagCompound display = tag.getCompound(DISPLAY.NBT);
|
||||
|
||||
if (!tag.hasKey(DISPLAY.NBT)) {
|
||||
tag.setCompound(DISPLAY.NBT, display);
|
||||
tag.set(DISPLAY.NBT, display);
|
||||
}
|
||||
|
||||
display.set(key, value);
|
||||
|
|
|
@ -51,7 +51,7 @@ class CraftMetaLeatherArmor extends CraftMetaItem implements LeatherArmorMeta {
|
|||
super.applyToItem(itemTag);
|
||||
|
||||
if (hasColor()) {
|
||||
setDisplayTag(itemTag, COLOR.NBT, new NBTTagInt(COLOR.NBT, color.asRGB()));
|
||||
setDisplayTag(itemTag, COLOR.NBT, new NBTTagInt(color.asRGB()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,13 +44,13 @@ class CraftMetaPotion extends CraftMetaItem implements PotionMeta {
|
|||
super(tag);
|
||||
|
||||
if (tag.hasKey(POTION_EFFECTS.NBT)) {
|
||||
NBTTagList list = tag.getList(POTION_EFFECTS.NBT);
|
||||
NBTTagList list = tag.getList(POTION_EFFECTS.NBT, 10);
|
||||
int length = list.size();
|
||||
if (length > 0) {
|
||||
customEffects = new ArrayList<PotionEffect>(length);
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
NBTTagCompound effect = (NBTTagCompound) list.get(i);
|
||||
NBTTagCompound effect = list.get(i);
|
||||
PotionEffectType type = PotionEffectType.getById(effect.getByte(ID.NBT));
|
||||
int amp = effect.getByte(AMPLIFIER.NBT);
|
||||
int duration = effect.getInt(DURATION.NBT);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Map;
|
|||
import net.minecraft.server.CraftingManager;
|
||||
import net.minecraft.server.ShapedRecipes;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
|
@ -56,7 +57,7 @@ public class CraftShapedRecipe extends ShapedRecipe implements CraftRecipe {
|
|||
i++;
|
||||
int id = mdata.getTypeId();
|
||||
short dmg = mdata.getDurability();
|
||||
data[i] = new net.minecraft.server.ItemStack(id, 1, dmg);
|
||||
data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
|
||||
i++;
|
||||
}
|
||||
CraftingManager.getInstance().registerShapedRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import net.minecraft.server.CraftingManager;
|
||||
import net.minecraft.server.ShapelessRecipes;
|
||||
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapelessRecipe;
|
||||
|
||||
|
@ -39,7 +40,7 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe
|
|||
for (ItemStack mdata : ingred) {
|
||||
int id = mdata.getTypeId();
|
||||
short dmg = mdata.getDurability();
|
||||
data[i] = new net.minecraft.server.ItemStack(id, 1, dmg);
|
||||
data[i] = new net.minecraft.server.ItemStack(CraftMagicNumbers.getItem(id), 1, dmg);
|
||||
i++;
|
||||
}
|
||||
CraftingManager.getInstance().registerShapelessRecipe(CraftItemStack.asNMSCopy(this.getResult()), data);
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.bukkit.craftbukkit.inventory;
|
|||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Recipe;
|
||||
|
||||
import net.minecraft.server.CraftingManager;
|
||||
|
@ -11,7 +10,7 @@ import net.minecraft.server.RecipesFurnace;
|
|||
|
||||
public class RecipeIterator implements Iterator<Recipe> {
|
||||
private final Iterator<IRecipe> recipes;
|
||||
private final Iterator<Integer> smelting;
|
||||
private final Iterator<net.minecraft.server.ItemStack> smelting;
|
||||
private Iterator<?> removeFrom = null;
|
||||
|
||||
public RecipeIterator() {
|
||||
|
@ -33,10 +32,10 @@ public class RecipeIterator implements Iterator<Recipe> {
|
|||
return recipes.next().toBukkitRecipe();
|
||||
} else {
|
||||
removeFrom = smelting;
|
||||
int id = smelting.next();
|
||||
CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(id));
|
||||
net.minecraft.server.ItemStack item = smelting.next();
|
||||
CraftItemStack stack = CraftItemStack.asCraftMirror(RecipesFurnace.getInstance().getResult(item));
|
||||
|
||||
return new CraftFurnaceRecipe(stack, new ItemStack(id, 1, (short) -1));
|
||||
return new CraftFurnaceRecipe(stack, CraftItemStack.asCraftMirror(item));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import java.util.Map;
|
|||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.IScoreboardCriteria;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.Packet206SetScoreboardObjective;
|
||||
import net.minecraft.server.Packet209SetScoreboardTeam;
|
||||
import net.minecraft.server.PacketPlayOutScoreboardObjective;
|
||||
import net.minecraft.server.PacketPlayOutScoreboardTeam;
|
||||
import net.minecraft.server.Scoreboard;
|
||||
import net.minecraft.server.ScoreboardObjective;
|
||||
import net.minecraft.server.ScoreboardScore;
|
||||
|
@ -77,7 +77,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
|
|||
for (int i = 0; i < 3; ++i) {
|
||||
ScoreboardObjective scoreboardobjective = oldboard.getObjectiveForSlot(i);
|
||||
if (scoreboardobjective != null && !removed.contains(scoreboardobjective)) {
|
||||
entityplayer.playerConnection.sendPacket(new Packet206SetScoreboardObjective(scoreboardobjective, 1));
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardObjective(scoreboardobjective, 1));
|
||||
removed.add(scoreboardobjective);
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ public final class CraftScoreboardManager implements ScoreboardManager {
|
|||
Iterator<?> iterator = oldboard.getTeams().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
ScoreboardTeam scoreboardteam = (ScoreboardTeam) iterator.next();
|
||||
entityplayer.playerConnection.sendPacket(new Packet209SetScoreboardTeam(scoreboardteam, 1));
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutScoreboardTeam(scoreboardteam, 1));
|
||||
}
|
||||
|
||||
// The above is the reverse of the below method.
|
||||
|
|
|
@ -112,7 +112,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
|||
Validate.notNull(player, "OfflinePlayer cannot be null");
|
||||
CraftScoreboard scoreboard = checkState();
|
||||
|
||||
scoreboard.board.addPlayerToTeam(player.getName(), team);
|
||||
scoreboard.board.addPlayerToTeam(player.getName(), team.getName());
|
||||
}
|
||||
|
||||
public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException {
|
||||
|
|
|
@ -13,6 +13,8 @@ import java.util.Date;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitDLUpdaterService {
|
||||
private static final String API_PREFIX_ARTIFACT = "/api/1.0/downloads/projects/craftbukkit/view/";
|
||||
private static final String API_PREFIX_CHANNEL = "/api/1.0/downloads/channels/";
|
||||
|
@ -27,9 +29,9 @@ public class BukkitDLUpdaterService {
|
|||
try {
|
||||
return fetchArtifact(slug);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -60,9 +62,9 @@ public class BukkitDLUpdaterService {
|
|||
try {
|
||||
return fetchChannel(slug);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(BukkitDLUpdaterService.class.getName()).log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -2,6 +2,9 @@ package org.bukkit.craftbukkit.util;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
|
@ -18,12 +21,28 @@ public class BlockStateListPopulator {
|
|||
this.list = list;
|
||||
}
|
||||
|
||||
public void setTypeAndData(int x, int y, int z, Block block, int data, int light) {
|
||||
BlockState state = world.getBlockAt(x, y, z).getState();
|
||||
state.setTypeId(Block.b(block));
|
||||
state.setRawData((byte) data);
|
||||
list.add(state);
|
||||
}
|
||||
public void setTypeId(int x, int y, int z, int type) {
|
||||
BlockState state = world.getBlockAt(x, y, z).getState();
|
||||
state.setTypeId(type);
|
||||
list.add(state);
|
||||
}
|
||||
|
||||
public void setTypeUpdate(int x, int y, int z, Block block) {
|
||||
this.setType(x, y, z, block);
|
||||
}
|
||||
|
||||
public void setType(int x, int y, int z, Block block) {
|
||||
BlockState state = world.getBlockAt(x, y, z).getState();
|
||||
state.setTypeId(Block.b(block));
|
||||
list.add(state);
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
for (BlockState state : list) {
|
||||
state.update(true);
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.ChatModifier;
|
||||
import net.minecraft.server.EnumChatFormat;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
|
||||
public final class CraftChatMessage {
|
||||
private static class FromString {
|
||||
private static final Map<Character, EnumChatFormat> formatMap;
|
||||
|
||||
static {
|
||||
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
|
||||
for (EnumChatFormat format : EnumChatFormat.values()) {
|
||||
builder.put(format.getChar(), format);
|
||||
}
|
||||
formatMap = builder.build();
|
||||
}
|
||||
|
||||
private final List<IChatBaseComponent> list = new ArrayList<IChatBaseComponent>();
|
||||
private IChatBaseComponent currentChatComponent = new ChatComponentText("");
|
||||
private ChatModifier modifier = new ChatModifier();
|
||||
private StringBuilder builder = new StringBuilder();
|
||||
private final IChatBaseComponent[] output;
|
||||
|
||||
private FromString(String message) {
|
||||
if (message == null) {
|
||||
output = new IChatBaseComponent[] { new ChatComponentText("") };
|
||||
return;
|
||||
}
|
||||
|
||||
EnumChatFormat format = null;
|
||||
|
||||
for (int i = 0; i < message.length(); i++) {
|
||||
char currentChar = message.charAt(i);
|
||||
if (currentChar == '\u00A7' && (i < (message.length() - 1)) && (format = formatMap.get(message.charAt(i + 1))) != null) {
|
||||
if (builder.length() > 0) {
|
||||
appendNewComponent();
|
||||
}
|
||||
|
||||
if (format == EnumChatFormat.RESET) {
|
||||
modifier = new ChatModifier();
|
||||
} else if (format.isFormat()) {
|
||||
switch (format) {
|
||||
case BOLD:
|
||||
modifier.setBold(Boolean.TRUE);
|
||||
break;
|
||||
case ITALIC:
|
||||
modifier.setItalic(Boolean.TRUE);
|
||||
break;
|
||||
case STRIKETHROUGH:
|
||||
modifier.setStrikethrough(Boolean.TRUE);
|
||||
break;
|
||||
case UNDERLINE:
|
||||
modifier.setUnderline(Boolean.TRUE);
|
||||
break;
|
||||
case RANDOM:
|
||||
modifier.setRandom(Boolean.TRUE);
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError("Unexpected message format");
|
||||
}
|
||||
} else { // Color resets formatting
|
||||
modifier = new ChatModifier().setColor(format);
|
||||
}
|
||||
i++;
|
||||
} else if (currentChar == '\n') {
|
||||
if (builder.length() > 0) {
|
||||
finishComponent();
|
||||
}
|
||||
} else {
|
||||
builder.append(currentChar);
|
||||
}
|
||||
}
|
||||
|
||||
if (builder.length() > 0) {
|
||||
finishComponent();
|
||||
}
|
||||
|
||||
if (list.isEmpty()) {
|
||||
list.add(new ChatComponentText(""));
|
||||
}
|
||||
|
||||
output = list.toArray(new IChatBaseComponent[0]);
|
||||
}
|
||||
|
||||
private void appendNewComponent() {
|
||||
IChatBaseComponent addition = new ChatComponentText(builder.toString()).setChatModifier(modifier);
|
||||
builder = new StringBuilder();
|
||||
modifier = modifier.clone();
|
||||
currentChatComponent = currentChatComponent.a(addition);
|
||||
}
|
||||
|
||||
private void finishComponent() {
|
||||
appendNewComponent();
|
||||
list.add(currentChatComponent);
|
||||
currentChatComponent = new ChatComponentText("");
|
||||
}
|
||||
|
||||
private IChatBaseComponent[] getOutput() {
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
public static IChatBaseComponent[] fromString(String message) {
|
||||
return new FromString(message).getOutput();
|
||||
}
|
||||
|
||||
private CraftChatMessage() {
|
||||
}
|
||||
}
|
|
@ -9,17 +9,17 @@ public final class CraftDamageSource extends DamageSource {
|
|||
|
||||
// Check ignoresArmor
|
||||
if (original.ignoresArmor()) {
|
||||
newSource.j();
|
||||
newSource.k();
|
||||
}
|
||||
|
||||
// Check magic
|
||||
if (original.q()) {
|
||||
newSource.r();
|
||||
if (original.s()) {
|
||||
newSource.t();
|
||||
}
|
||||
|
||||
// Check fire
|
||||
if (original.c()) {
|
||||
newSource.l();
|
||||
newSource.n();
|
||||
}
|
||||
|
||||
return newSource;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import org.bukkit.util.CachedServerIcon;
|
||||
|
||||
public class CraftIconCache implements CachedServerIcon {
|
||||
public final String value;
|
||||
|
||||
public CraftIconCache(final String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.Item;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public final class CraftMagicNumbers {
|
||||
private CraftMagicNumbers() {}
|
||||
|
||||
public static Block getBlock(org.bukkit.block.Block block) {
|
||||
return getBlock(block.getType());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// A bad method for bad magic.
|
||||
public static Block getBlock(int id) {
|
||||
return getBlock(Material.getMaterial(id));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// A bad method for bad magic.
|
||||
public static int getId(Block block) {
|
||||
return Block.b(block);
|
||||
}
|
||||
|
||||
public static Material getMaterial(Block block) {
|
||||
return Material.getMaterial(Block.b(block));
|
||||
}
|
||||
|
||||
public static Item getItem(Material material) {
|
||||
// TODO: Don't use ID
|
||||
Item item = Item.d(material.getId());
|
||||
return item;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// A bad method for bad magic.
|
||||
public static Item getItem(int id) {
|
||||
return Item.d(id);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
// A bad method for bad magic.
|
||||
public static int getId(Item item) {
|
||||
return Item.b(item);
|
||||
}
|
||||
|
||||
public static Material getMaterial(Item item) {
|
||||
// TODO: Don't use ID
|
||||
Material material = Material.getMaterial(Item.b(item));
|
||||
|
||||
if (material == null) {
|
||||
return Material.AIR;
|
||||
}
|
||||
|
||||
return material;
|
||||
}
|
||||
|
||||
public static Block getBlock(Material material) {
|
||||
// TODO: Don't use ID
|
||||
Block block = Block.e(material.getId());
|
||||
|
||||
if (block == null) {
|
||||
return Blocks.AIR;
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Log4jConverter {
|
||||
|
||||
private static final Map<Level, org.apache.logging.log4j.Level> JULTOLOG4J = new HashMap<Level, org.apache.logging.log4j.Level>();
|
||||
private static final Map<org.apache.logging.log4j.Level, Level> LOG4JTOJUL = new EnumMap<org.apache.logging.log4j.Level, Level>(org.apache.logging.log4j.Level.class);
|
||||
static {
|
||||
JULTOLOG4J.put(Level.ALL, org.apache.logging.log4j.Level.ALL);
|
||||
JULTOLOG4J.put(Level.FINEST, org.apache.logging.log4j.Level.TRACE);
|
||||
JULTOLOG4J.put(Level.FINER, org.apache.logging.log4j.Level.TRACE);
|
||||
JULTOLOG4J.put(Level.FINE, org.apache.logging.log4j.Level.TRACE);
|
||||
JULTOLOG4J.put(Level.INFO, org.apache.logging.log4j.Level.INFO);
|
||||
JULTOLOG4J.put(Level.CONFIG, org.apache.logging.log4j.Level.INFO);
|
||||
JULTOLOG4J.put(Level.WARNING, org.apache.logging.log4j.Level.WARN);
|
||||
JULTOLOG4J.put(Level.SEVERE, org.apache.logging.log4j.Level.ERROR);
|
||||
JULTOLOG4J.put(Level.OFF, org.apache.logging.log4j.Level.OFF);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.ALL, Level.ALL);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.TRACE, Level.FINE);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.INFO, Level.INFO);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.DEBUG, Level.INFO);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.WARN, Level.WARNING);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.ERROR, Level.SEVERE);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.FATAL, Level.SEVERE);
|
||||
LOG4JTOJUL.put(org.apache.logging.log4j.Level.OFF, Level.OFF);
|
||||
}
|
||||
|
||||
public static org.apache.logging.log4j.Level getLog4jLevel(Level level) {
|
||||
org.apache.logging.log4j.Level log4jLevel = JULTOLOG4J.get(level);
|
||||
return log4jLevel == null ? org.apache.logging.log4j.Level.INFO : log4jLevel;
|
||||
}
|
||||
|
||||
public static Level getJULLevel(org.apache.logging.log4j.Level level) {
|
||||
return LOG4JTOJUL.get(level);
|
||||
}
|
||||
|
||||
public static Logger createLogger() {
|
||||
final Logger logger = Logger.getLogger("Minecraft");
|
||||
// Grab a logger. It doesn't really matter which, so long as it is within net.minecraft.server.
|
||||
final org.apache.logging.log4j.core.Logger log4j = (org.apache.logging.log4j.core.Logger) org.apache.logging.log4j.LogManager.getLogger("net.minecraft.server.DedicatedServer");
|
||||
logger.setUseParentHandlers(false);
|
||||
// Add a handler to our Bukkit Logger so that messages logged to it are sent to log4j.
|
||||
Handler log4jHandler = new Handler() {
|
||||
@Override
|
||||
public void close() throws SecurityException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
log4j.log(Log4jConverter.getLog4jLevel(record.getLevel()), record.getMessage());
|
||||
|
||||
}
|
||||
};
|
||||
logger.addHandler(log4jHandler);
|
||||
return logger;
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.ConsoleHandler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jline.console.ConsoleReader;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
|
||||
public class TerminalConsoleHandler extends ConsoleHandler {
|
||||
private final ConsoleReader reader;
|
||||
|
||||
public TerminalConsoleHandler(ConsoleReader reader) {
|
||||
super();
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void flush() {
|
||||
try {
|
||||
if (Main.useJline) {
|
||||
reader.print(ConsoleReader.RESET_LINE + "");
|
||||
reader.flush();
|
||||
super.flush();
|
||||
try {
|
||||
reader.drawLine();
|
||||
} catch (Throwable ex) {
|
||||
reader.getCursorBuffer().clear();
|
||||
}
|
||||
reader.flush();
|
||||
} else {
|
||||
super.flush();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(TerminalConsoleHandler.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import jline.console.ConsoleReader;
|
||||
import net.minecraft.util.com.mojang.util.QueueLogAppender;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
|
||||
public class TerminalConsoleWriterThread implements Runnable {
|
||||
final private ConsoleReader reader;
|
||||
final private OutputStream output;
|
||||
|
||||
public TerminalConsoleWriterThread(OutputStream output, ConsoleReader reader) {
|
||||
this.output = output;
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
String message;
|
||||
|
||||
// Using name from log4j config in vanilla jar
|
||||
while (true) {
|
||||
message = QueueLogAppender.getNextLogEvent("ServerGuiConsole");
|
||||
if (message == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
if (Main.useJline) {
|
||||
reader.print(ConsoleReader.RESET_LINE + "");
|
||||
reader.flush();
|
||||
output.write(message.getBytes());
|
||||
output.flush();
|
||||
|
||||
try {
|
||||
reader.drawLine();
|
||||
} catch (Throwable ex) {
|
||||
reader.getCursorBuffer().clear();
|
||||
}
|
||||
reader.flush();
|
||||
} else {
|
||||
output.write(message.getBytes());
|
||||
output.flush();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(TerminalConsoleWriterThread.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,6 @@ import java.util.NoSuchElementException;
|
|||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
|
||||
public final class WeakCollection<T> implements Collection<T> {
|
||||
static final Object NO_VALUE = new Object();
|
||||
private final Collection<WeakReference<T>> collection;
|
||||
|
|
|
@ -7,26 +7,26 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.AchievementList;
|
||||
import net.minecraft.server.Statistic;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftAchievement;
|
||||
import org.bukkit.support.AbstractTestingBase;
|
||||
import org.bukkit.support.Util;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
public class AchievementTest {
|
||||
public class AchievementTest extends AbstractTestingBase {
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void verifyMapping() throws Throwable {
|
||||
List<Achievement> achievements = Lists.newArrayList(Achievement.values());
|
||||
|
||||
for (net.minecraft.server.Achievement statistic : (List<net.minecraft.server.Achievement>) AchievementList.e) {
|
||||
int id = statistic.e;
|
||||
String name = statistic.e;
|
||||
|
||||
String name = Util.getInternalState(Statistic.class, statistic, "a");
|
||||
String message = String.format("org.bukkit.Achievement is missing id: %d named: '%s'", id - Achievement.STATISTIC_OFFSET, name);
|
||||
String message = String.format("org.bukkit.Achievement is missing: '%s'", name);
|
||||
|
||||
Achievement subject = Achievement.getById(id);
|
||||
Achievement subject = CraftAchievement.getAchievement(name);
|
||||
assertNotNull(message, subject);
|
||||
|
||||
assertTrue(name, achievements.remove(subject));
|
||||
|
|
|
@ -12,6 +12,8 @@ import org.bukkit.support.AbstractTestingBase;
|
|||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Iterator;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
public class MaterialTest extends AbstractTestingBase {
|
||||
|
||||
|
@ -19,14 +21,21 @@ public class MaterialTest extends AbstractTestingBase {
|
|||
public void verifyMapping() {
|
||||
Map<Integer, Material> materials = Maps.newHashMap();
|
||||
for (Material material : Material.values()) {
|
||||
if (INVALIDATED_MATERIALS.contains(material)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
materials.put(material.getId(), material);
|
||||
}
|
||||
materials.remove(0); // Purge air.
|
||||
|
||||
for (Item item : Item.byId) {
|
||||
Iterator<Item> items = Item.REGISTRY.iterator();
|
||||
|
||||
while (items.hasNext()) {
|
||||
Item item = items.next();
|
||||
if (item == null) continue;
|
||||
|
||||
int id = item.id;
|
||||
int id = CraftMagicNumbers.getId(item);
|
||||
String name = item.getName();
|
||||
|
||||
Material material = materials.remove(id);
|
||||
|
|
|
@ -5,12 +5,11 @@ import static org.hamcrest.Matchers.*;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.BlockFalling;
|
||||
import net.minecraft.server.BlockFire;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.ItemFood;
|
||||
import net.minecraft.server.ItemRecord;
|
||||
import net.minecraft.server.BlockSand;
|
||||
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -24,6 +23,8 @@ import org.junit.runners.Parameterized.Parameter;
|
|||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.server.Blocks;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
public class PerMaterialTest extends AbstractTestingBase {
|
||||
|
@ -31,13 +32,17 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
|
||||
@BeforeClass
|
||||
public static void getFireValues() {
|
||||
fireValues = Util.getInternalState(BlockFire.class, Block.FIRE, "a");
|
||||
fireValues = Util.getInternalState(BlockFire.class, Blocks.FIRE, "a");
|
||||
}
|
||||
|
||||
@Parameters(name= "{index}: {0}")
|
||||
public static List<Object[]> data() {
|
||||
List<Object[]> list = Lists.newArrayList();
|
||||
for (Material material : Material.values()) {
|
||||
if (INVALIDATED_MATERIALS.contains(material)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(new Object[] {material});
|
||||
}
|
||||
return list;
|
||||
|
@ -50,7 +55,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
if (material == Material.AIR) {
|
||||
assertFalse(material.isSolid());
|
||||
} else if (material.isBlock()) {
|
||||
assertThat(material.isSolid(), is(Block.byId[material.getId()].material.isSolid()));
|
||||
assertThat(material.isSolid(), is(CraftMagicNumbers.getBlock(material).getMaterial().isSolid()));
|
||||
} else {
|
||||
assertFalse(material.isSolid());
|
||||
}
|
||||
|
@ -58,20 +63,21 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
|
||||
@Test
|
||||
public void isEdible() {
|
||||
assertThat(material.isEdible(), is(Item.byId[material.getId()] instanceof ItemFood));
|
||||
assertThat(material.isEdible(), is(CraftMagicNumbers.getItem(material) instanceof ItemFood));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isRecord() {
|
||||
assertThat(material.isRecord(), is(Item.byId[material.getId()] instanceof ItemRecord));
|
||||
assertThat(material.isRecord(), is(CraftMagicNumbers.getItem(material) instanceof ItemRecord));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void maxDurability() {
|
||||
if (material == Material.AIR) {
|
||||
assertThat((int) material.getMaxDurability(), is(0));
|
||||
} else {
|
||||
assertThat((int) material.getMaxDurability(), is(Item.byId[material.getId()].getMaxDurability()));
|
||||
} else if (material.isBlock()){
|
||||
Item item = CraftMagicNumbers.getItem(material);
|
||||
assertThat((int) material.getMaxDurability(), is(item.getMaxDurability()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +91,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
assertThat(bukkit.getMaxStackSize(), is(MAX_AIR_STACK));
|
||||
assertThat(craft.getMaxStackSize(), is(MAX_AIR_STACK));
|
||||
} else {
|
||||
assertThat(material.getMaxStackSize(), is(Item.byId[material.getId()].getMaxStackSize()));
|
||||
assertThat(material.getMaxStackSize(), is(CraftMagicNumbers.getItem(material).getMaxStackSize()));
|
||||
assertThat(bukkit.getMaxStackSize(), is(material.getMaxStackSize()));
|
||||
assertThat(craft.getMaxStackSize(), is(material.getMaxStackSize()));
|
||||
}
|
||||
|
@ -96,7 +102,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
if (material == Material.AIR) {
|
||||
assertTrue(material.isTransparent());
|
||||
} else if (material.isBlock()) {
|
||||
assertThat(material.isTransparent(), is(not(Block.byId[material.getId()].material.blocksLight())));
|
||||
assertThat(material.isTransparent(), is(not(CraftMagicNumbers.getBlock(material).getMaterial().blocksLight())));
|
||||
} else {
|
||||
assertFalse(material.isTransparent());
|
||||
}
|
||||
|
@ -105,7 +111,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
@Test
|
||||
public void isFlammable() {
|
||||
if (material != Material.AIR && material.isBlock()) {
|
||||
assertThat(material.isFlammable(), is(Block.byId[material.getId()].material.isBurnable()));
|
||||
assertThat(material.isFlammable(), is(CraftMagicNumbers.getBlock(material).getMaterial().isBurnable()));
|
||||
} else {
|
||||
assertFalse(material.isFlammable());
|
||||
}
|
||||
|
@ -123,7 +129,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
@Test
|
||||
public void isOccluding() {
|
||||
if (material.isBlock()) {
|
||||
assertThat(material.isOccluding(), is(Block.l(material.getId())));
|
||||
assertThat(material.isOccluding(), is(CraftMagicNumbers.getBlock(material).r()));
|
||||
} else {
|
||||
assertFalse(material.isOccluding());
|
||||
}
|
||||
|
@ -132,7 +138,7 @@ public class PerMaterialTest extends AbstractTestingBase {
|
|||
@Test
|
||||
public void hasGravity() {
|
||||
if (material.isBlock()) {
|
||||
assertThat(material.hasGravity(), is(Block.byId[material.getId()] instanceof BlockSand));
|
||||
assertThat(material.hasGravity(), is(CraftMagicNumbers.getBlock(material) instanceof BlockFalling));
|
||||
} else {
|
||||
assertFalse(material.hasGravity());
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import static org.hamcrest.Matchers.*;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFactory;
|
||||
|
@ -21,7 +22,20 @@ import org.junit.runners.Parameterized.Parameters;
|
|||
public class FactoryItemMaterialTest extends AbstractTestingBase {
|
||||
static final ItemFactory factory = CraftItemFactory.instance();
|
||||
static final StringBuilder buffer = new StringBuilder();
|
||||
static final Material[] materials = Material.values();
|
||||
static final Material[] materials;
|
||||
|
||||
static {
|
||||
Material[] local_materials = Material.values();
|
||||
List<Material> list = new ArrayList<Material>(local_materials.length);
|
||||
for (Material material : local_materials) {
|
||||
if (INVALIDATED_MATERIALS.contains(material)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(material);
|
||||
}
|
||||
materials = list.toArray(new Material[list.size()]);
|
||||
}
|
||||
|
||||
static String name(Enum<?> from, Enum<?> to) {
|
||||
if (from.getClass() == to.getClass()) {
|
||||
|
|
|
@ -13,7 +13,7 @@ public class NMSCraftItemStackTest extends AbstractTestingBase {
|
|||
|
||||
@Test
|
||||
public void testCloneEnchantedItem() throws Exception {
|
||||
net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Item.POTION);
|
||||
net.minecraft.server.ItemStack nmsItemStack = new net.minecraft.server.ItemStack(net.minecraft.server.Items.POTION);
|
||||
nmsItemStack.addEnchantment(Enchantment.DAMAGE_ALL, 1);
|
||||
ItemStack itemStack = CraftItemStack.asCraftMirror(nmsItemStack);
|
||||
ItemStack clone = itemStack.clone();
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.bukkit.support;
|
||||
|
||||
import net.minecraft.server.StatisticList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.DispenserRegistry;
|
||||
import org.bukkit.Material;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/**
|
||||
|
@ -13,10 +15,11 @@ import org.junit.BeforeClass;
|
|||
* extend this class to solve it.
|
||||
*/
|
||||
public abstract class AbstractTestingBase {
|
||||
public static final List<Material> INVALIDATED_MATERIALS = ImmutableList.<Material>builder().add(Material.BREWING_STAND, Material.BED_BLOCK, Material.NETHER_WARTS, Material.CAULDRON, Material.FLOWER_POT, Material.CROPS, Material.SUGAR_CANE_BLOCK, Material.CAKE_BLOCK, Material.SKULL, Material.PISTON_EXTENSION, Material.PISTON_MOVING_PIECE, Material.GLOWING_REDSTONE_ORE, Material.DIODE_BLOCK_ON, Material.PUMPKIN_STEM, Material.SIGN_POST, Material.REDSTONE_COMPARATOR_ON, Material.TRIPWIRE, Material.REDSTONE_LAMP_ON, Material.MELON_STEM, Material.REDSTONE_TORCH_OFF, Material.REDSTONE_COMPARATOR_OFF, Material.REDSTONE_WIRE, Material.WALL_SIGN, Material.DIODE_BLOCK_OFF, Material.IRON_DOOR_BLOCK, Material.WOODEN_DOOR).add(Material.LOCKED_CHEST).build();
|
||||
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
StatisticList.a();
|
||||
DispenserRegistry.b();
|
||||
DummyServer.setup();
|
||||
DummyPotions.setup();
|
||||
DummyEnchantments.setup();
|
||||
|
|
Loading…
Add table
Reference in a new issue