Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/ By: Thinkofdeath <thinkofdeath@spigotmc.org>
This commit is contained in:
@@ -11,7 +11,7 @@ public class CraftArt {
|
||||
case KEBAB: return Art.KEBAB;
|
||||
case AZTEC: return Art.AZTEC;
|
||||
case ALBAN: return Art.ALBAN;
|
||||
case AZTEC2: return Art.AZTEC2;
|
||||
case AZTEC_2: return Art.AZTEC2;
|
||||
case BOMB: return Art.BOMB;
|
||||
case PLANT: return Art.PLANT;
|
||||
case WASTELAND: return Art.WASTELAND;
|
||||
@@ -30,9 +30,9 @@ public class CraftArt {
|
||||
case FIGHTERS: return Art.FIGHTERS;
|
||||
case POINTER: return Art.POINTER;
|
||||
case PIGSCENE: return Art.PIGSCENE;
|
||||
case BURNINGSKULL: return Art.BURNINGSKULL;
|
||||
case BURNING_SKULL: return Art.BURNINGSKULL;
|
||||
case SKELETON: return Art.SKELETON;
|
||||
case DONKEYKONG: return Art.DONKEYKONG;
|
||||
case DONKEY_KONG: return Art.DONKEYKONG;
|
||||
case WITHER: return Art.WITHER;
|
||||
default:
|
||||
throw new AssertionError(art);
|
||||
@@ -44,7 +44,7 @@ public class CraftArt {
|
||||
case KEBAB: return EnumArt.KEBAB;
|
||||
case AZTEC: return EnumArt.AZTEC;
|
||||
case ALBAN: return EnumArt.ALBAN;
|
||||
case AZTEC2: return EnumArt.AZTEC2;
|
||||
case AZTEC2: return EnumArt.AZTEC_2;
|
||||
case BOMB: return EnumArt.BOMB;
|
||||
case PLANT: return EnumArt.PLANT;
|
||||
case WASTELAND: return EnumArt.WASTELAND;
|
||||
@@ -63,9 +63,9 @@ public class CraftArt {
|
||||
case FIGHTERS: return EnumArt.FIGHTERS;
|
||||
case POINTER: return EnumArt.POINTER;
|
||||
case PIGSCENE: return EnumArt.PIGSCENE;
|
||||
case BURNINGSKULL: return EnumArt.BURNINGSKULL;
|
||||
case BURNINGSKULL: return EnumArt.BURNING_SKULL;
|
||||
case SKELETON: return EnumArt.SKELETON;
|
||||
case DONKEYKONG: return EnumArt.DONKEYKONG;
|
||||
case DONKEYKONG: return EnumArt.DONKEY_KONG;
|
||||
case WITHER: return EnumArt.WITHER;
|
||||
default:
|
||||
throw new AssertionError(art);
|
||||
|
||||
@@ -3,12 +3,7 @@ package org.bukkit.craftbukkit;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Arrays;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.ChunkSection;
|
||||
import net.minecraft.server.EmptyChunk;
|
||||
import net.minecraft.server.WorldChunkManager;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@@ -91,6 +86,7 @@ public class CraftChunk implements Chunk {
|
||||
Entity[] entities = new Entity[count];
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
|
||||
for (Object obj : chunk.entitySlices[i].toArray()) {
|
||||
if (!(obj instanceof net.minecraft.server.Entity)) {
|
||||
continue;
|
||||
@@ -106,15 +102,16 @@ public class CraftChunk implements Chunk {
|
||||
public BlockState[] getTileEntities() {
|
||||
int index = 0;
|
||||
net.minecraft.server.Chunk chunk = getHandle();
|
||||
|
||||
BlockState[] entities = new BlockState[chunk.tileEntities.size()];
|
||||
|
||||
for (Object obj : chunk.tileEntities.keySet().toArray()) {
|
||||
if (!(obj instanceof ChunkPosition)) {
|
||||
if (!(obj instanceof BlockPosition)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ChunkPosition position = (ChunkPosition) obj;
|
||||
entities[index++] = worldServer.getWorld().getBlockAt(position.x + (chunk.locX << 4), position.y, position.z + (chunk.locZ << 4)).getState();
|
||||
BlockPosition position = (BlockPosition) obj;
|
||||
entities[index++] = worldServer.getWorld().getBlockAt(position.getX() + (chunk.locX << 4), position.getY(), position.getZ() + (chunk.locZ << 4)).getState();
|
||||
}
|
||||
return entities;
|
||||
}
|
||||
@@ -158,49 +155,40 @@ public class CraftChunk implements Chunk {
|
||||
boolean[] sectionEmpty = new boolean[cs.length];
|
||||
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
if (cs[i] == null) { /* Section is empty? */
|
||||
if (cs[i] == null) { // Section is empty?
|
||||
sectionBlockIDs[i] = emptyBlockIDs;
|
||||
sectionBlockData[i] = emptyData;
|
||||
sectionSkyLights[i] = emptySkyLight;
|
||||
sectionEmitLights[i] = emptyData;
|
||||
sectionEmpty[i] = true;
|
||||
} else { /* Not empty */
|
||||
} else { // Not empty
|
||||
short[] blockids = new short[4096];
|
||||
byte[] baseids = cs[i].getIdArray();
|
||||
char[] baseids = cs[i].getIdArray();
|
||||
byte[] dataValues = sectionBlockData[i] = new byte[2048];
|
||||
|
||||
/* Copy base IDs */
|
||||
// Copy base IDs
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
blockids[j] = (short) (baseids[j] & 0xFF);
|
||||
}
|
||||
|
||||
if (cs[i].getExtendedIdArray() != null) { /* If we've got extended IDs */
|
||||
byte[] extids = cs[i].getExtendedIdArray().a;
|
||||
|
||||
for (int j = 0; j < 2048; j++) {
|
||||
short b = (short) (extids[j] & 0xFF);
|
||||
|
||||
if (b == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
blockids[j<<1] |= (b & 0x0F) << 8;
|
||||
blockids[(j<<1)+1] |= (b & 0xF0) << 4;
|
||||
IBlockData blockData = net.minecraft.server.Block.getByCombinedId(baseids[j]);
|
||||
blockids[j] = (short) net.minecraft.server.Block.getId(blockData.getBlock());
|
||||
int data = blockData.getBlock().toLegacyData(blockData);
|
||||
int jj = j >> 1;
|
||||
if ((j & 1) == 0) {
|
||||
dataValues[jj] = (byte) ((dataValues[jj] & 0xF0) | (data & 0xF));
|
||||
} else {
|
||||
dataValues[jj] = (byte) ((dataValues[jj] & 0xF) | ((data & 0xF) << 4));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sectionBlockIDs[i] = blockids;
|
||||
|
||||
/* Get block data nibbles */
|
||||
sectionBlockData[i] = new byte[2048];
|
||||
System.arraycopy(cs[i].getDataArray().a, 0, sectionBlockData[i], 0, 2048);
|
||||
|
||||
if (cs[i].getSkyLightArray() == null) {
|
||||
sectionSkyLights[i] = emptyData;
|
||||
} else {
|
||||
sectionSkyLights[i] = new byte[2048];
|
||||
System.arraycopy(cs[i].getSkyLightArray().a, 0, sectionSkyLights[i], 0, 2048);
|
||||
System.arraycopy(cs[i].getSkyLightArray().a(), 0, sectionSkyLights[i], 0, 2048);
|
||||
}
|
||||
sectionEmitLights[i] = new byte[2048];
|
||||
System.arraycopy(cs[i].getEmittedLightArray().a, 0, sectionEmitLights[i], 0, 2048);
|
||||
System.arraycopy(cs[i].getEmittedLightArray().a(), 0, sectionEmitLights[i], 0, 2048);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +209,7 @@ public class CraftChunk implements Chunk {
|
||||
if (includeBiome) {
|
||||
biome = new BiomeBase[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biome[i] = chunk.getBiome(i & 0xF, i >> 4, wcm);
|
||||
biome[i] = chunk.getBiome(new BlockPosition(i & 0xF, 0, i >> 4), wcm);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +245,7 @@ public class CraftChunk implements Chunk {
|
||||
if (includeBiome) {
|
||||
biome = new BiomeBase[256];
|
||||
for (int i = 0; i < 256; i++) {
|
||||
biome[i] = world.getHandle().getBiome((x << 4) + (i & 0xF), (z << 4) + (i >> 4));
|
||||
biome[i] = world.getHandle().getBiome(new BlockPosition((x << 4) + (i & 0xF), 0, (z << 4) + (i >> 4)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -10,7 +11,6 @@ import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.WorldNBTStorage;
|
||||
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.GameProfileBanEntry;
|
||||
import net.minecraft.server.GameProfileBanList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -8,12 +8,12 @@ import net.minecraft.server.GameProfileBanEntry;
|
||||
import net.minecraft.server.GameProfileBanList;
|
||||
import net.minecraft.server.JsonListEntry;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
public class CraftProfileBanList implements org.bukkit.BanList {
|
||||
private final GameProfileBanList list;
|
||||
|
||||
@@ -23,83 +23,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.CommandAchievement;
|
||||
import net.minecraft.server.CommandBan;
|
||||
import net.minecraft.server.CommandBanIp;
|
||||
import net.minecraft.server.CommandBanList;
|
||||
import net.minecraft.server.CommandClear;
|
||||
import net.minecraft.server.CommandDeop;
|
||||
import net.minecraft.server.CommandDifficulty;
|
||||
import net.minecraft.server.CommandEffect;
|
||||
import net.minecraft.server.CommandEnchant;
|
||||
import net.minecraft.server.CommandGamemode;
|
||||
import net.minecraft.server.CommandGamemodeDefault;
|
||||
import net.minecraft.server.CommandGamerule;
|
||||
import net.minecraft.server.CommandGive;
|
||||
import net.minecraft.server.CommandHelp;
|
||||
import net.minecraft.server.CommandIdleTimeout;
|
||||
import net.minecraft.server.CommandKick;
|
||||
import net.minecraft.server.CommandKill;
|
||||
import net.minecraft.server.CommandList;
|
||||
import net.minecraft.server.CommandMe;
|
||||
import net.minecraft.server.CommandNetstat;
|
||||
import net.minecraft.server.CommandOp;
|
||||
import net.minecraft.server.CommandPardon;
|
||||
import net.minecraft.server.CommandPardonIP;
|
||||
import net.minecraft.server.CommandPlaySound;
|
||||
import net.minecraft.server.CommandSay;
|
||||
import net.minecraft.server.CommandScoreboard;
|
||||
import net.minecraft.server.CommandSeed;
|
||||
import net.minecraft.server.CommandSetBlock;
|
||||
import net.minecraft.server.CommandSetWorldSpawn;
|
||||
import net.minecraft.server.CommandSpawnpoint;
|
||||
import net.minecraft.server.CommandSpreadPlayers;
|
||||
import net.minecraft.server.CommandSummon;
|
||||
import net.minecraft.server.CommandTell;
|
||||
import net.minecraft.server.CommandTellRaw;
|
||||
import net.minecraft.server.CommandTestFor;
|
||||
import net.minecraft.server.CommandTestForBlock;
|
||||
import net.minecraft.server.CommandTime;
|
||||
import net.minecraft.server.CommandToggleDownfall;
|
||||
import net.minecraft.server.CommandTp;
|
||||
import net.minecraft.server.CommandWeather;
|
||||
import net.minecraft.server.CommandWhitelist;
|
||||
import net.minecraft.server.CommandXp;
|
||||
import net.minecraft.server.Convertable;
|
||||
import net.minecraft.server.ConvertProgressUpdater;
|
||||
import net.minecraft.server.CraftingManager;
|
||||
import net.minecraft.server.DedicatedPlayerList;
|
||||
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.JsonListEntry;
|
||||
import net.minecraft.server.PlayerList;
|
||||
import net.minecraft.server.RecipesFurnace;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.PropertyManager;
|
||||
import net.minecraft.server.ServerCommand;
|
||||
import net.minecraft.server.ServerNBTManager;
|
||||
import net.minecraft.server.WorldLoaderServer;
|
||||
import net.minecraft.server.WorldManager;
|
||||
import net.minecraft.server.WorldMap;
|
||||
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.com.mojang.authlib.GameProfile;
|
||||
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 net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.BanList;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -139,8 +63,6 @@ import org.bukkit.craftbukkit.metadata.WorldMetadataStore;
|
||||
import org.bukkit.craftbukkit.potion.CraftPotionBrewer;
|
||||
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.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.util.DatFileFilter;
|
||||
@@ -186,8 +108,16 @@ import com.avaje.ebean.config.DataSourceConfig;
|
||||
import com.avaje.ebean.config.ServerConfig;
|
||||
import com.avaje.ebean.config.dbplatform.SQLitePlatform;
|
||||
import com.avaje.ebeaninternal.server.lib.sql.TransactionIsolation;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufOutputStream;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.base64.Base64;
|
||||
|
||||
import jline.console.ConsoleReader;
|
||||
|
||||
@@ -210,7 +140,6 @@ public final class CraftServer implements Server {
|
||||
private YamlConfiguration commandsConfiguration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
private final Map<UUID, OfflinePlayer> offlinePlayers = new MapMaker().softValues().makeMap();
|
||||
private final AutoUpdater updater;
|
||||
private final EntityMetadataStore entityMetadata = new EntityMetadataStore();
|
||||
private final PlayerMetadataStore playerMetadata = new PlayerMetadataStore();
|
||||
private final WorldMetadataStore worldMetadata = new WorldMetadataStore();
|
||||
@@ -244,7 +173,7 @@ public final class CraftServer implements Server {
|
||||
public CraftServer(MinecraftServer console, PlayerList playerList) {
|
||||
this.console = console;
|
||||
this.playerList = (DedicatedPlayerList) playerList;
|
||||
this.playerView = Collections.unmodifiableList(net.minecraft.util.com.google.common.collect.Lists.transform(playerList.players, new net.minecraft.util.com.google.common.base.Function<EntityPlayer, CraftPlayer>() {
|
||||
this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, new Function<EntityPlayer, CraftPlayer>() {
|
||||
@Override
|
||||
public CraftPlayer apply(EntityPlayer player) {
|
||||
return player.getBukkitEntity();
|
||||
@@ -316,13 +245,6 @@ public final class CraftServer implements Server {
|
||||
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"));
|
||||
updater.setSuggestChannels(configuration.getBoolean("auto-updater.suggest-channels"));
|
||||
updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
|
||||
updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
|
||||
updater.check(serverVersion);
|
||||
|
||||
loadPlugins();
|
||||
enablePlugins(PluginLoadOrder.STARTUP);
|
||||
}
|
||||
@@ -405,49 +327,10 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
private void setVanillaCommands() {
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandAchievement(), "/achievement give <stat_name> [player]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBan(), "/ban <playername> [reason]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBanIp(), "/ban-ip <ip-address|playername>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandBanList(), "/banlist [ips]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandClear(), "/clear <playername> [item] [metadata]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamemodeDefault(), "/defaultgamemode <mode>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandDeop(), "/deop <playername>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandDifficulty(), "/difficulty <new difficulty>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandEffect(), "/effect <player> <effect|clear> [seconds] [amplifier]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandEnchant(), "/enchant <playername> <enchantment ID> [enchantment level]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamemode(), "/gamemode <mode> [player]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGamerule(), "/gamerule <rulename> [true|false]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandGive(), "/give <playername> <item> [amount] [metadata] [dataTag]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandHelp(), "/help [page|commandname]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandIdleTimeout(), "/setidletimeout <Minutes until kick>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandKick(), "/kick <playername> [reason]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandKill(), "/kill [playername]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandList(), "/list"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandMe(), "/me <actiontext>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandOp(), "/op <playername>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPardon(), "/pardon <playername>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPardonIP(), "/pardon-ip <ip-address>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandPlaySound(), "/playsound <sound> <playername> [x] [y] [z] [volume] [pitch] [minimumVolume]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSay(), "/say <message>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandScoreboard(), "/scoreboard"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSeed(), "/seed"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSetBlock(), "/setblock <x> <y> <z> <tilename> [datavalue] [oldblockHandling] [dataTag]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSetWorldSpawn(), "/setworldspawn [x] [y] [z]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSpawnpoint(), "/spawnpoint <playername> [x] [y] [z]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSpreadPlayers(), "/spreadplayers <x> <z> [spreadDistance] [maxRange] [respectTeams] <playernames>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandSummon(), "/summon <EntityName> [x] [y] [z] [dataTag]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTp(), "/tp [player] <target>\n/tp [player] <x> <y> <z>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTell(), "/tell <playername> <message>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTellRaw(), "/tellraw <playername> <raw message>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTestFor(), "/testfor <playername | selector> [dataTag]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTestForBlock(), "/testforblock <x> <y> <z> <tilename> [datavalue] [dataTag]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandTime(), "/time set <value>\n/time add <value>"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandToggleDownfall(), "/toggledownfall"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandWeather(), "/weather <clear/rain/thunder> [duration in seconds]"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandWhitelist(), "/whitelist (add|remove) <player>\n/whitelist (on|off|list|reload)"));
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandXp(), "/xp <amount> [player]\n/xp <amount>L [player]"));
|
||||
// This is what is in the lang file, I swear.
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper(new CommandNetstat(), "/list"));
|
||||
Map<String, ICommand> commands = new CommandDispatcher().getCommands();
|
||||
for (ICommand cmd : commands.values()) {
|
||||
commandMap.register("minecraft", new VanillaCommandWrapper((CommandAbstract) cmd, LocaleI18n.get(cmd.getUsage(null))));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadPlugin(Plugin plugin) {
|
||||
@@ -550,7 +433,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
public Player getPlayer(final EntityPlayer entity) {
|
||||
return entity.playerConnection.getPlayer();
|
||||
return entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -759,12 +642,12 @@ public final class CraftServer implements Server {
|
||||
((DedicatedServer) console).propertyManager = config;
|
||||
|
||||
boolean animals = config.getBoolean("spawn-animals", console.getSpawnAnimals());
|
||||
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty != EnumDifficulty.PEACEFUL);
|
||||
EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.worlds.get(0).difficulty.ordinal()));
|
||||
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).getDifficulty() != EnumDifficulty.PEACEFUL);
|
||||
EnumDifficulty difficulty = EnumDifficulty.getById(config.getInt("difficulty", console.worlds.get(0).getDifficulty().ordinal()));
|
||||
|
||||
online.value = config.getBoolean("online-mode", console.getOnlineMode());
|
||||
console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals()));
|
||||
console.setPvP(config.getBoolean("pvp", console.getPvP()));
|
||||
console.setPVP(config.getBoolean("pvp", console.getPVP()));
|
||||
console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight()));
|
||||
console.setMotd(config.getString("motd", console.getMotd()));
|
||||
monsterSpawn = configuration.getInt("spawn-limits.monsters");
|
||||
@@ -790,7 +673,7 @@ public final class CraftServer implements Server {
|
||||
}
|
||||
|
||||
for (WorldServer world : console.worlds) {
|
||||
world.difficulty = difficulty;
|
||||
world.worldData.setDifficulty(difficulty);
|
||||
world.setSpawnFlags(monsters, animals);
|
||||
if (this.getTicksPerAnimalSpawns() < 0) {
|
||||
world.ticksPerAnimalSpawns = 400;
|
||||
@@ -961,7 +844,8 @@ 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.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type), console.methodProfiler, creator.environment(), generator);
|
||||
WorldData worlddata = new WorldData(new WorldSettings(creator.seed(), EnumGamemode.getById(getDefaultGameMode().getValue()), generateStructures, hardcore, type), name);
|
||||
WorldServer internal = (WorldServer) new WorldServer(console, new ServerNBTManager(getWorldContainer(), name, true), worlddata, dimension, console.methodProfiler, creator.environment(), generator).b();
|
||||
|
||||
if (!(worlds.containsKey(name.toLowerCase()))) {
|
||||
return null;
|
||||
@@ -971,7 +855,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
internal.tracker = new EntityTracker(internal);
|
||||
internal.addIWorldAccess(new WorldManager(console, internal));
|
||||
internal.difficulty = EnumDifficulty.EASY;
|
||||
internal.worldData.setDifficulty(EnumDifficulty.EASY);
|
||||
internal.setSpawnFlags(true, true);
|
||||
console.worlds.add(internal);
|
||||
|
||||
@@ -1001,8 +885,8 @@ public final class CraftServer implements Server {
|
||||
i = l;
|
||||
}
|
||||
|
||||
ChunkCoordinates chunkcoordinates = internal.getSpawn();
|
||||
internal.chunkProviderServer.getChunkAt(chunkcoordinates.x + j >> 4, chunkcoordinates.z + k >> 4);
|
||||
BlockPosition chunkcoordinates = internal.getSpawn();
|
||||
internal.chunkProviderServer.getChunkAt(chunkcoordinates.getX() + j >> 4, chunkcoordinates.getZ() + k >> 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1055,7 +939,6 @@ public final class CraftServer implements Server {
|
||||
|
||||
worlds.remove(world.getName().toLowerCase());
|
||||
console.worlds.remove(console.worlds.indexOf(handle));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1312,7 +1195,7 @@ public final class CraftServer implements Server {
|
||||
Validate.notNull(world, "World cannot be null");
|
||||
|
||||
net.minecraft.server.ItemStack stack = new net.minecraft.server.ItemStack(Items.MAP, 1, -1);
|
||||
WorldMap worldmap = Items.MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
|
||||
WorldMap worldmap = Items.FILLED_MAP.getSavedMap(stack, ((CraftWorld) world).getHandle());
|
||||
return worldmap.mapView;
|
||||
}
|
||||
|
||||
@@ -1415,7 +1298,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
for (JsonListEntry entry : playerList.getProfileBans().getValues()) {
|
||||
result.add(getOfflinePlayer((GameProfile) entry.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -1497,27 +1380,6 @@ public final class CraftServer implements Server {
|
||||
return worldMetadata;
|
||||
}
|
||||
|
||||
public void detectListNameConflict(EntityPlayer entityPlayer) {
|
||||
// Collisions will make for invisible people
|
||||
for (int i = 0; i < getHandle().players.size(); ++i) {
|
||||
EntityPlayer testEntityPlayer = (EntityPlayer) getHandle().players.get(i);
|
||||
|
||||
// We have a problem!
|
||||
if (testEntityPlayer != entityPlayer && testEntityPlayer.listName.equals(entityPlayer.listName)) {
|
||||
String oldName = entityPlayer.listName;
|
||||
int spaceLeft = 16 - oldName.length();
|
||||
|
||||
if (spaceLeft <= 1) { // We also hit the list name length limit!
|
||||
entityPlayer.listName = oldName.subSequence(0, oldName.length() - 2 - spaceLeft) + String.valueOf(System.currentTimeMillis() % 99);
|
||||
} else {
|
||||
entityPlayer.listName = oldName + String.valueOf(System.currentTimeMillis() % 99);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getWorldContainer() {
|
||||
if (this.getServer().universe != null) {
|
||||
@@ -1575,16 +1437,6 @@ public final class CraftServer implements Server {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void onPlayerJoin(Player player) {
|
||||
if ((updater.isEnabled()) && (updater.getCurrent() != null) && (player.hasPermission(Server.BROADCAST_CHANNEL_ADMINISTRATIVE))) {
|
||||
if ((updater.getCurrent().isBroken()) && (updater.getOnBroken().contains(AutoUpdater.WARN_OPERATORS))) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "The version of CraftBukkit that this server is running is known to be broken. Please consider updating to the latest version at dl.bukkit.org.");
|
||||
} else if ((updater.isUpdateAvailable()) && (updater.getOnUpdate().contains(AutoUpdater.WARN_OPERATORS))) {
|
||||
player.sendMessage(ChatColor.DARK_PURPLE + "The version of CraftBukkit that this server is running is out of date. Please consider updating to the latest version at dl.bukkit.org.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory createInventory(InventoryHolder owner, InventoryType type) {
|
||||
// TODO: Create the appropriate type, rather than Custom?
|
||||
|
||||
@@ -13,6 +13,9 @@ import com.google.common.base.CaseFormat;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableBiMap;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
|
||||
public class CraftStatistic {
|
||||
private static final BiMap<String, org.bukkit.Statistic> statistics;
|
||||
@@ -131,12 +134,19 @@ public class CraftStatistic {
|
||||
|
||||
public static Material getMaterialFromStatistic(net.minecraft.server.Statistic statistic) {
|
||||
String statisticString = statistic.name;
|
||||
int id;
|
||||
String val = statisticString.substring(statisticString.lastIndexOf(".") + 1);
|
||||
Item item = (Item) Item.REGISTRY.get(new MinecraftKey(val));
|
||||
if (item != null) {
|
||||
return Material.getMaterial(Item.getId(item));
|
||||
}
|
||||
Block block = (Block) Block.REGISTRY.get(new MinecraftKey(val));
|
||||
if (block != null) {
|
||||
return Material.getMaterial(Block.getId(block));
|
||||
}
|
||||
try {
|
||||
id = Integer.valueOf(statisticString.substring(statisticString.lastIndexOf(".") + 1));
|
||||
return Material.getMaterial(Integer.parseInt(val));
|
||||
} catch (NumberFormatException e) {
|
||||
return null;
|
||||
}
|
||||
return Material.getMaterial(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.bukkit.craftbukkit;
|
||||
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.PortalTravelAgent;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
@@ -22,6 +22,7 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location findOrCreate(Location target) {
|
||||
WorldServer worldServer = ((CraftWorld) target.getWorld()).getHandle();
|
||||
boolean before = worldServer.chunkProviderServer.forceChunkLoad;
|
||||
@@ -40,39 +41,47 @@ public class CraftTravelAgent extends PortalTravelAgent implements TravelAgent {
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location findPortal(Location location) {
|
||||
PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent();
|
||||
ChunkCoordinates found = pta.findPortal(location.getX(), location.getY(), location.getZ(), this.getSearchRadius());
|
||||
return found != null ? new Location(location.getWorld(), found.x, found.y, found.z, location.getYaw(), location.getPitch()) : null;
|
||||
BlockPosition found = pta.findPortal(location.getX(), location.getY(), location.getZ(), this.getSearchRadius());
|
||||
return found != null ? new Location(location.getWorld(), found.getX(), found.getY(), found.getZ(), location.getYaw(), location.getPitch()) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createPortal(Location location) {
|
||||
PortalTravelAgent pta = ((CraftWorld) location.getWorld()).getHandle().getTravelAgent();
|
||||
return pta.createPortal(location.getX(), location.getY(), location.getZ(), this.getCreationRadius());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TravelAgent setSearchRadius(int radius) {
|
||||
this.searchRadius = radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSearchRadius() {
|
||||
return this.searchRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TravelAgent setCreationRadius(int radius) {
|
||||
this.creationRadius = radius < 2 ? 0 : radius;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCreationRadius() {
|
||||
return this.creationRadius;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getCanCreatePortal() {
|
||||
return this.canCreatePortal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCanCreatePortal(boolean create) {
|
||||
this.canCreatePortal = create;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public int getBlockTypeIdAt(int x, int y, int z) {
|
||||
return world.getTypeId(x, y, z);
|
||||
return CraftMagicNumbers.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
|
||||
}
|
||||
|
||||
public int getHighestBlockYAt(int x, int z) {
|
||||
@@ -94,18 +94,18 @@ public class CraftWorld implements World {
|
||||
loadChunk(x >> 4, z >> 4);
|
||||
}
|
||||
|
||||
return world.getHighestBlockYAt(x, z);
|
||||
return world.getHighestBlockYAt(new BlockPosition(x, 0, z)).getY();
|
||||
}
|
||||
|
||||
public Location getSpawnLocation() {
|
||||
ChunkCoordinates spawn = world.getSpawn();
|
||||
return new Location(this, spawn.x, spawn.y, spawn.z);
|
||||
BlockPosition spawn = world.getSpawn();
|
||||
return new Location(this, spawn.getX(), spawn.getY(), spawn.getZ());
|
||||
}
|
||||
|
||||
public boolean setSpawnLocation(int x, int y, int z) {
|
||||
try {
|
||||
Location previousLocation = getSpawnLocation();
|
||||
world.worldData.setSpawn(x, y, z);
|
||||
world.worldData.setSpawn(new BlockPosition(x, y, z));
|
||||
|
||||
// Notify anyone who's listening.
|
||||
SpawnChangeEvent event = new SpawnChangeEvent(this, previousLocation);
|
||||
@@ -227,9 +227,9 @@ public class CraftWorld implements World {
|
||||
// This flags 65 blocks distributed across all the sections of the chunk, so that everything is sent, including biomes
|
||||
int height = getMaxHeight() / 16;
|
||||
for (int idx = 0; idx < 64; idx++) {
|
||||
world.notify(px + (idx / height), ((idx % height) * 16), pz);
|
||||
world.notify(new BlockPosition(px + (idx / height), ((idx % height) * 16), pz));
|
||||
}
|
||||
world.notify(px + 15, (height * 16) - 1, pz + 15);
|
||||
world.notify(new BlockPosition(px + 15, (height * 16) - 1, pz + 15));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ public class CraftWorld implements World {
|
||||
break;
|
||||
}
|
||||
|
||||
return gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
return gen.generate(world, rand, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
|
||||
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
|
||||
@@ -421,13 +421,14 @@ public class CraftWorld implements World {
|
||||
int x = blockstate.getX();
|
||||
int y = blockstate.getY();
|
||||
int z = blockstate.getZ();
|
||||
net.minecraft.server.Block oldBlock = world.getType(x, y, z);
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
net.minecraft.server.Block oldBlock = world.getType(position).getBlock();
|
||||
int typeId = blockstate.getTypeId();
|
||||
int data = blockstate.getRawData();
|
||||
int flag = ((CraftBlockState)blockstate).getFlag();
|
||||
delegate.setTypeIdAndData(x, y, z, typeId, data);
|
||||
net.minecraft.server.Block newBlock = world.getType(x, y, z);
|
||||
world.notifyAndUpdatePhysics(x, y, z, null, oldBlock, newBlock, flag);
|
||||
net.minecraft.server.Block newBlock = world.getType(position).getBlock();
|
||||
world.notifyAndUpdatePhysics(position, null, oldBlock, newBlock, flag);
|
||||
}
|
||||
world.capturedBlockStates.clear();
|
||||
return true;
|
||||
@@ -438,7 +439,7 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public TileEntity getTileEntityAt(final int x, final int y, final int z) {
|
||||
return world.getTileEntity(x, y, z);
|
||||
return world.getTileEntity(new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -551,27 +552,27 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public Biome getBiome(int x, int z) {
|
||||
return CraftBlock.biomeBaseToBiome(this.world.getBiome(x, z));
|
||||
return CraftBlock.biomeBaseToBiome(this.world.getBiome(new BlockPosition(x, 0, z)));
|
||||
}
|
||||
|
||||
public void setBiome(int x, int z, Biome bio) {
|
||||
BiomeBase bb = CraftBlock.biomeToBiomeBase(bio);
|
||||
if (this.world.isLoaded(x, 0, z)) {
|
||||
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(x, z);
|
||||
if (this.world.isLoaded(new BlockPosition(x, 0, z))) {
|
||||
net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(new BlockPosition(x, 0, z));
|
||||
|
||||
if (chunk != null) {
|
||||
byte[] biomevals = chunk.m();
|
||||
byte[] biomevals = chunk.getBiomeIndex();
|
||||
biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getTemperature(int x, int z) {
|
||||
return this.world.getBiome(x, z).temperature;
|
||||
return this.world.getBiome(new BlockPosition(x, 0, z)).temperature;
|
||||
}
|
||||
|
||||
public double getHumidity(int x, int z) {
|
||||
return this.world.getBiome(x, z).humidity;
|
||||
return this.world.getBiome(new BlockPosition(x, 0, z)).humidity;
|
||||
}
|
||||
|
||||
public List<Entity> getEntities() {
|
||||
@@ -704,11 +705,11 @@ public class CraftWorld implements World {
|
||||
}
|
||||
|
||||
public void setDifficulty(Difficulty difficulty) {
|
||||
this.getHandle().difficulty = EnumDifficulty.getById(difficulty.getValue());
|
||||
this.getHandle().worldData.setDifficulty(EnumDifficulty.getById(difficulty.getValue()));
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty() {
|
||||
return Difficulty.getByValue(this.getHandle().difficulty.ordinal());
|
||||
return Difficulty.getByValue(this.getHandle().getDifficulty().ordinal());
|
||||
}
|
||||
|
||||
public BlockMetadataStore getBlockMetadata() {
|
||||
@@ -814,7 +815,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();
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, location.getBlockX(), location.getBlockY(), location.getBlockZ(), data, false);
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), data, false);
|
||||
int distance;
|
||||
radius *= radius;
|
||||
|
||||
@@ -842,7 +843,7 @@ 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, net.minecraft.server.Block.getById(material.getId()), data);
|
||||
EntityFallingBlock entity = new EntityFallingBlock(world, x, y, z, net.minecraft.server.Block.getById(material.getId()).fromLegacyData(data));
|
||||
entity.ticksLived = 1;
|
||||
|
||||
world.addEntity(entity, SpawnReason.CUSTOM);
|
||||
@@ -874,10 +875,11 @@ public class CraftWorld implements World {
|
||||
x = location.getBlockX();
|
||||
y = location.getBlockY();
|
||||
z = location.getBlockZ();
|
||||
int type = world.getTypeId((int) x, (int) y, (int) z);
|
||||
int data = world.getData((int) x, (int) y, (int) z);
|
||||
IBlockData blockData = world.getType(new BlockPosition(x, y, z));
|
||||
int type = CraftMagicNumbers.getId(blockData.getBlock());
|
||||
int data = blockData.getBlock().toLegacyData(blockData);
|
||||
|
||||
entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.getById(type), data);
|
||||
entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, net.minecraft.server.Block.getById(type).fromLegacyData(data));
|
||||
} else if (Projectile.class.isAssignableFrom(clazz)) {
|
||||
if (Snowball.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntitySnowball(world, x, y, z);
|
||||
@@ -890,7 +892,7 @@ public class CraftWorld implements World {
|
||||
entity = new EntityThrownExpBottle(world);
|
||||
entity.setPositionRotation(x, y, z, 0, 0);
|
||||
} else if (EnderPearl.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityEnderPearl(world);
|
||||
entity = new EntityEnderPearl(world, null);
|
||||
entity.setPositionRotation(x, y, z, 0, 0);
|
||||
} else if (ThrownPotion.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityPotion(world, x, y, z, CraftItemStack.asNMSCopy(new ItemStack(org.bukkit.Material.POTION, 1)));
|
||||
@@ -1000,6 +1002,14 @@ public class CraftWorld implements World {
|
||||
if (Bat.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityBat(world);
|
||||
}
|
||||
} else if (Rabbit.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityRabbit(world);
|
||||
} else if (Endermite.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityEndermite(world);
|
||||
} else if (Guardian.class.isAssignableFrom(clazz)){
|
||||
entity = new EntityGuardian(world);
|
||||
} else if (ArmorStand.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityArmorStand(world, x, y, z);
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
@@ -1017,29 +1027,29 @@ public class CraftWorld implements World {
|
||||
} else if (block.getRelative(BlockFace.SOUTH).getTypeId() == 0) {
|
||||
face = BlockFace.SOUTH;
|
||||
}
|
||||
int dir;
|
||||
EnumDirection dir;
|
||||
switch (face) {
|
||||
case SOUTH:
|
||||
default:
|
||||
dir = 0;
|
||||
dir = EnumDirection.SOUTH;
|
||||
break;
|
||||
case WEST:
|
||||
dir = 1;
|
||||
dir = EnumDirection.WEST;
|
||||
break;
|
||||
case NORTH:
|
||||
dir = 2;
|
||||
dir = EnumDirection.NORTH;
|
||||
break;
|
||||
case EAST:
|
||||
dir = 3;
|
||||
dir = EnumDirection.EAST;
|
||||
break;
|
||||
}
|
||||
|
||||
if (Painting.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityPainting(world, (int) x, (int) y, (int) z, dir);
|
||||
entity = new EntityPainting(world, new BlockPosition((int) x, (int) y, (int) z), dir);
|
||||
} else if (ItemFrame.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityItemFrame(world, (int) x, (int) y, (int) z, dir);
|
||||
entity = new EntityItemFrame(world, new BlockPosition((int) x, (int) y, (int) z), dir);
|
||||
} else if (LeashHitch.class.isAssignableFrom(clazz)) {
|
||||
entity = new EntityLeash(world, (int) x, (int) y, (int) z);
|
||||
entity = new EntityLeash(world, new BlockPosition((int) x, (int) y, (int) z));
|
||||
entity.attachedToPlayer = true;
|
||||
}
|
||||
|
||||
@@ -1062,7 +1072,7 @@ public class CraftWorld implements World {
|
||||
|
||||
if (entity != null) {
|
||||
if (entity instanceof EntityInsentient) {
|
||||
((EntityInsentient) entity).prepare((GroupDataEntity) null);
|
||||
((EntityInsentient) entity).prepare(getHandle().E(new BlockPosition(entity)), (GroupDataEntity) null);
|
||||
}
|
||||
|
||||
world.addEntity(entity, reason);
|
||||
@@ -1103,9 +1113,9 @@ public class CraftWorld implements World {
|
||||
public void setKeepSpawnInMemory(boolean keepLoaded) {
|
||||
world.keepSpawnInMemory = keepLoaded;
|
||||
// Grab the worlds spawn chunk
|
||||
ChunkCoordinates chunkcoordinates = this.world.getSpawn();
|
||||
int chunkCoordX = chunkcoordinates.x >> 4;
|
||||
int chunkCoordZ = chunkcoordinates.z >> 4;
|
||||
BlockPosition chunkcoordinates = this.world.getSpawn();
|
||||
int chunkCoordX = chunkcoordinates.getX() >> 4;
|
||||
int chunkCoordZ = chunkcoordinates.getZ() >> 4;
|
||||
// Cycle through the 25x25 Chunks around it to load/unload the chunks.
|
||||
for (int x = -12; x <= 12; x++) {
|
||||
for (int z = -12; z <= 12; z++) {
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import net.minecraft.server.TileEntityBanner;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.block.Banner;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
public class CraftBanner extends CraftBlockState implements Banner {
|
||||
|
||||
private final TileEntityBanner banner;
|
||||
private DyeColor base;
|
||||
private List<Pattern> patterns = new ArrayList<Pattern>();
|
||||
|
||||
public CraftBanner(final Block block) {
|
||||
super(block);
|
||||
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
banner = (TileEntityBanner) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
|
||||
base = DyeColor.getByDyeData((byte) banner.color);
|
||||
|
||||
if (banner.patterns != null) {
|
||||
for (int i = 0; i < banner.patterns.size(); i++) {
|
||||
NBTTagCompound p = (NBTTagCompound) banner.patterns.get(i);
|
||||
patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInt("Color")), PatternType.getByIdentifier(p.getString("Pattern"))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getBaseColor() {
|
||||
return this.base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseColor(DyeColor color) {
|
||||
this.base = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pattern> getPatterns() {
|
||||
return new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPatterns(List<Pattern> patterns) {
|
||||
this.patterns = new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPattern(Pattern pattern) {
|
||||
this.patterns.add(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getPattern(int i) {
|
||||
return this.patterns.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern removePattern(int i) {
|
||||
return this.patterns.remove(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(int i, Pattern pattern) {
|
||||
this.patterns.set(i, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numberOfPatterns() {
|
||||
return patterns.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean force, boolean applyPhysics) {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
banner.color = base.getDyeData();
|
||||
|
||||
NBTTagList newPatterns = new NBTTagList();
|
||||
|
||||
for (Pattern p : patterns) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInt("Color", p.getColor().getDyeData());
|
||||
compound.setString("Pattern", p.getPattern().getIdentifier());
|
||||
newPatterns.add(compound);
|
||||
}
|
||||
|
||||
banner.patterns = newPatterns;
|
||||
|
||||
banner.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.BlockCocoa;
|
||||
import net.minecraft.server.BlockRedstoneWire;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.EnumSkyBlock;
|
||||
import net.minecraft.server.GameProfileSerializer;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@@ -97,19 +89,27 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public void setData(final byte data) {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 3);
|
||||
setData(data, 3);
|
||||
}
|
||||
|
||||
public void setData(final byte data, boolean applyPhysics) {
|
||||
if (applyPhysics) {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 3);
|
||||
setData(data, 3);
|
||||
} else {
|
||||
chunk.getHandle().world.setData(x, y, z, data, 2);
|
||||
setData(data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
private void setData(final byte data, int flag) {
|
||||
net.minecraft.server.World world = chunk.getHandle().getWorld();
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
IBlockData blockData = world.getType(position);
|
||||
world.setTypeAndData(position, blockData.getBlock().fromLegacyData(data), flag);
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return (byte) chunk.getHandle().getData(this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
IBlockData blockData = chunk.getHandle().getBlockData(new BlockPosition(x, y, z));
|
||||
return (byte) blockData.getBlock().toLegacyData(blockData);
|
||||
}
|
||||
|
||||
public void setType(final Material type) {
|
||||
@@ -125,12 +125,14 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean setTypeIdAndData(final int type, final byte data, final boolean applyPhysics) {
|
||||
IBlockData blockData = getNMSBlock(type).fromLegacyData(data);
|
||||
BlockPosition position = new BlockPosition(x, y, z);
|
||||
if (applyPhysics) {
|
||||
return chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 3);
|
||||
return chunk.getHandle().getWorld().setTypeAndData(position, blockData, 3);
|
||||
} else {
|
||||
boolean success = chunk.getHandle().world.setTypeAndData(x, y, z, getNMSBlock(type), data, 2);
|
||||
boolean success = chunk.getHandle().getWorld().setTypeAndData(position, blockData, 2);
|
||||
if (success) {
|
||||
chunk.getHandle().world.notify(x, y, z);
|
||||
chunk.getHandle().getWorld().notify(position);
|
||||
}
|
||||
return success;
|
||||
}
|
||||
@@ -143,19 +145,19 @@ public class CraftBlock implements Block {
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getTypeId() {
|
||||
return CraftMagicNumbers.getId(chunk.getHandle().getType(this.x & 0xF, this.y & 0xFF, this.z & 0xF));
|
||||
return CraftMagicNumbers.getId(chunk.getHandle().getType(new BlockPosition(this.x, this.y, this.z)));
|
||||
}
|
||||
|
||||
public byte getLightLevel() {
|
||||
return (byte) chunk.getHandle().world.getLightLevel(this.x, this.y, this.z);
|
||||
return (byte) chunk.getHandle().getWorld().getLightLevel(new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
public byte getLightFromSky() {
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.SKY, this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.SKY, new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
public byte getLightFromBlocks() {
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.BLOCK, this.x & 0xF, this.y & 0xFF, this.z & 0xF);
|
||||
return (byte) chunk.getHandle().getBrightness(EnumSkyBlock.BLOCK, new BlockPosition(this.x, this.y, this.z));
|
||||
}
|
||||
|
||||
|
||||
@@ -199,47 +201,42 @@ public class CraftBlock implements Block {
|
||||
return "CraftBlock{" + "chunk=" + chunk + ",x=" + x + ",y=" + y + ",z=" + z + ",type=" + getType() + ",data=" + getData() + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Notch uses a 0-5 to mean DOWN, UP, NORTH, SOUTH, WEST, EAST
|
||||
* in that order all over. This method is convenience to convert for us.
|
||||
*
|
||||
* @return BlockFace the BlockFace represented by this number
|
||||
*/
|
||||
public static BlockFace notchToBlockFace(int notch) {
|
||||
public static BlockFace notchToBlockFace(EnumDirection notch) {
|
||||
if (notch == null) return BlockFace.SELF;
|
||||
switch (notch) {
|
||||
case 0:
|
||||
case DOWN:
|
||||
return BlockFace.DOWN;
|
||||
case 1:
|
||||
case UP:
|
||||
return BlockFace.UP;
|
||||
case 2:
|
||||
case NORTH:
|
||||
return BlockFace.NORTH;
|
||||
case 3:
|
||||
case SOUTH:
|
||||
return BlockFace.SOUTH;
|
||||
case 4:
|
||||
case WEST:
|
||||
return BlockFace.WEST;
|
||||
case 5:
|
||||
case EAST:
|
||||
return BlockFace.EAST;
|
||||
default:
|
||||
return BlockFace.SELF;
|
||||
}
|
||||
}
|
||||
|
||||
public static int blockFaceToNotch(BlockFace face) {
|
||||
public static EnumDirection blockFaceToNotch(BlockFace face) {
|
||||
switch (face) {
|
||||
case DOWN:
|
||||
return 0;
|
||||
return EnumDirection.DOWN;
|
||||
case UP:
|
||||
return 1;
|
||||
return EnumDirection.UP;
|
||||
case NORTH:
|
||||
return 2;
|
||||
return EnumDirection.NORTH;
|
||||
case SOUTH:
|
||||
return 3;
|
||||
return EnumDirection.SOUTH;
|
||||
case WEST:
|
||||
return 4;
|
||||
return EnumDirection.WEST;
|
||||
case EAST:
|
||||
return 5;
|
||||
return EnumDirection.EAST;
|
||||
default:
|
||||
return 7; // Good as anything here, but technically invalid
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +274,9 @@ public class CraftBlock implements Block {
|
||||
return new CraftCommandBlock(this);
|
||||
case BEACON:
|
||||
return new CraftBeacon(this);
|
||||
case BANNER:
|
||||
case WALL_BANNER:
|
||||
return new CraftBanner(this);
|
||||
default:
|
||||
return new CraftBlockState(this);
|
||||
}
|
||||
@@ -314,11 +314,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean isBlockPowered() {
|
||||
return chunk.getHandle().world.getBlockPower(x, y, z) > 0;
|
||||
return chunk.getHandle().getWorld().getBlockPower(new BlockPosition(x, y, z)) > 0;
|
||||
}
|
||||
|
||||
public boolean isBlockIndirectlyPowered() {
|
||||
return chunk.getHandle().world.isBlockIndirectlyPowered(x, y, z);
|
||||
return chunk.getHandle().getWorld().isBlockIndirectlyPowered(new BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -336,11 +336,11 @@ public class CraftBlock implements Block {
|
||||
}
|
||||
|
||||
public boolean isBlockFacePowered(BlockFace face) {
|
||||
return chunk.getHandle().world.isBlockFacePowered(x, y, z, blockFaceToNotch(face));
|
||||
return chunk.getHandle().getWorld().isBlockFacePowered(new BlockPosition(x, y, z), blockFaceToNotch(face));
|
||||
}
|
||||
|
||||
public boolean isBlockFaceIndirectlyPowered(BlockFace face) {
|
||||
int power = chunk.getHandle().world.getBlockFacePower(x, y, z, blockFaceToNotch(face));
|
||||
int power = chunk.getHandle().getWorld().getBlockFacePower(new BlockPosition(x, y, z), blockFaceToNotch(face));
|
||||
|
||||
Block relative = getRelative(face);
|
||||
if (relative.getType() == Material.REDSTONE_WIRE) {
|
||||
@@ -353,13 +353,13 @@ public class CraftBlock implements Block {
|
||||
public int getBlockPower(BlockFace face) {
|
||||
int power = 0;
|
||||
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);
|
||||
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(x + 1, y, z, 2)) power = wire.getPower(world, x + 1, y, z, power);
|
||||
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(x - 1, y, z, 3)) power = wire.getPower(world, x - 1, y, z, power);
|
||||
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z - 1, 4)) power = wire.getPower(world, x, y, z - 1, power);
|
||||
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(x, y, z + 1, 5)) power = wire.getPower(world, x, y, z - 1, power);
|
||||
net.minecraft.server.World world = chunk.getHandle().getWorld();
|
||||
if ((face == BlockFace.DOWN || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y - 1, z), EnumDirection.DOWN)) power = wire.getPower(world, new BlockPosition(x, y - 1, z), power);
|
||||
if ((face == BlockFace.UP || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y + 1, z), EnumDirection.UP)) power = wire.getPower(world, new BlockPosition(x, y + 1, z), power);
|
||||
if ((face == BlockFace.EAST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x + 1, y, z), EnumDirection.EAST)) power = wire.getPower(world, new BlockPosition(x + 1, y, z), power);
|
||||
if ((face == BlockFace.WEST || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x - 1, y, z), EnumDirection.WEST)) power = wire.getPower(world, new BlockPosition(x - 1, y, z), power);
|
||||
if ((face == BlockFace.NORTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z - 1), EnumDirection.NORTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power);
|
||||
if ((face == BlockFace.SOUTH || face == BlockFace.SELF) && world.isBlockFacePowered(new BlockPosition(x, y, z + 1), EnumDirection.SOUTH)) power = wire.getPower(world, new BlockPosition(x, y, z - 1), power);
|
||||
return power > 0 ? power : (face == BlockFace.SELF ? isBlockIndirectlyPowered() : isBlockFaceIndirectlyPowered(face)) ? 15 : 0;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ public class CraftBlock implements Block {
|
||||
boolean result = false;
|
||||
|
||||
if (block != null && block != Blocks.AIR) {
|
||||
block.dropNaturally(chunk.getHandle().world, x, y, z, data, 1.0F, 0);
|
||||
block.dropNaturally(chunk.getHandle().getWorld(), new BlockPosition(x, y, z), block.fromLegacyData(data), 1.0F, 0);
|
||||
result = true;
|
||||
}
|
||||
|
||||
@@ -415,14 +415,14 @@ public class CraftBlock implements Block {
|
||||
if (block != Blocks.AIR) {
|
||||
byte data = getData();
|
||||
// based on nms.Block.dropNaturally
|
||||
int count = block.getDropCount(0, chunk.getHandle().world.random);
|
||||
int count = block.getDropCount(0, chunk.getHandle().getWorld().random);
|
||||
for (int i = 0; i < count; ++i) {
|
||||
Item item = block.getDropType(data, chunk.getHandle().world.random, 0);
|
||||
Item item = block.getDropType(block.fromLegacyData(data), chunk.getHandle().getWorld().random, 0);
|
||||
if (item != null) {
|
||||
// Skulls are special, their data is based on the tile entity
|
||||
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);
|
||||
net.minecraft.server.ItemStack nmsStack = new net.minecraft.server.ItemStack(item, 1, block.getDropData(chunk.getHandle().getWorld(), new BlockPosition(x, y, z)));
|
||||
TileEntitySkull tileentityskull = (TileEntitySkull) chunk.getHandle().getWorld().getTileEntity(new BlockPosition(x, y, z));
|
||||
|
||||
if (tileentityskull.getSkullType() == 3 && tileentityskull.getGameProfile() != null) {
|
||||
nmsStack.setTag(new NBTTagCompound());
|
||||
@@ -435,12 +435,13 @@ public class CraftBlock implements Block {
|
||||
drops.add(CraftItemStack.asBukkitCopy(nmsStack));
|
||||
// We don't want to drop cocoa blocks, we want to drop cocoa beans.
|
||||
} else if (Blocks.COCOA == block) {
|
||||
int dropAmount = (BlockCocoa.c(data) >= 2 ? 3 : 1);
|
||||
int age = (Integer) block.fromLegacyData(data).get(BlockCocoa.AGE);
|
||||
int dropAmount = (age >= 2 ? 3 : 1);
|
||||
for (int j = 0; j < dropAmount; ++j) {
|
||||
drops.add(new ItemStack(Material.INK_SACK, 1, (short) 3));
|
||||
}
|
||||
} else {
|
||||
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(data)));
|
||||
drops.add(new ItemStack(org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(item), 1, (short) block.getDropData(block.fromLegacyData(data))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -147,7 +148,7 @@ public class CraftBlockState implements BlockState {
|
||||
}
|
||||
|
||||
block.setData(getRawData(), applyPhysics);
|
||||
world.getHandle().notify(x, y, z);
|
||||
world.getHandle().notify(new BlockPosition(x, y, z));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.TileEntityChest;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@@ -41,19 +42,19 @@ public class CraftChest extends CraftBlockState implements Chest {
|
||||
}
|
||||
|
||||
if (world.getBlockTypeIdAt(x - 1, y, z) == id) {
|
||||
CraftInventory left = new CraftInventory((TileEntityChest)world.getHandle().getTileEntity(x - 1, y, z));
|
||||
CraftInventory left = new CraftInventory((TileEntityChest)world.getHandle().getTileEntity(new BlockPosition(x - 1, y, z)));
|
||||
inventory = new CraftInventoryDoubleChest(left, inventory);
|
||||
}
|
||||
if (world.getBlockTypeIdAt(x + 1, y, z) == id) {
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x + 1, y, z));
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x + 1, y, z)));
|
||||
inventory = new CraftInventoryDoubleChest(inventory, right);
|
||||
}
|
||||
if (world.getBlockTypeIdAt(x, y, z - 1) == id) {
|
||||
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x, y, z - 1));
|
||||
CraftInventory left = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z - 1)));
|
||||
inventory = new CraftInventoryDoubleChest(left, inventory);
|
||||
}
|
||||
if (world.getBlockTypeIdAt(x, y, z + 1) == id) {
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(x, y, z + 1));
|
||||
CraftInventory right = new CraftInventory((TileEntityChest) world.getHandle().getTileEntity(new BlockPosition(x, y, z + 1)));
|
||||
inventory = new CraftInventoryDoubleChest(inventory, right);
|
||||
}
|
||||
return inventory;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDispenser;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDispenser;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class CraftDispenser extends CraftBlockState implements Dispenser {
|
||||
if (block.getType() == Material.DISPENSER) {
|
||||
BlockDispenser dispense = (BlockDispenser) Blocks.DISPENSER;
|
||||
|
||||
dispense.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
dispense.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockDropper;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.TileEntityDropper;
|
||||
|
||||
@@ -32,7 +33,7 @@ public class CraftDropper extends CraftBlockState implements Dropper {
|
||||
if (block.getType() == Material.DROPPER) {
|
||||
BlockDropper drop = (BlockDropper) Blocks.DROPPER;
|
||||
|
||||
drop.dispense(world.getHandle(), getX(), getY(), getZ());
|
||||
drop.dispense(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockJukeBox;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.ItemStack;
|
||||
import net.minecraft.server.TileEntityRecordPlayer;
|
||||
import net.minecraft.server.*;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -41,9 +38,13 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
}
|
||||
jukebox.update();
|
||||
if (record == Material.AIR) {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 0, 3);
|
||||
world.getHandle().setTypeAndData(new BlockPosition(getX(), getY(), getZ()),
|
||||
Blocks.JUKEBOX.getBlockData()
|
||||
.set(BlockJukeBox.HAS_RECORD, false), 3);
|
||||
} else {
|
||||
world.getHandle().setData(getX(), getY(), getZ(), 1, 3);
|
||||
world.getHandle().setTypeAndData(new BlockPosition(getX(), getY(), getZ()),
|
||||
Blocks.JUKEBOX.getBlockData()
|
||||
.set(BlockJukeBox.HAS_RECORD, true), 3);
|
||||
}
|
||||
world.playEffect(getLocation(), Effect.RECORD_PLAY, record.getId());
|
||||
}
|
||||
@@ -54,7 +55,7 @@ public class CraftJukebox extends CraftBlockState implements Jukebox {
|
||||
|
||||
public boolean eject() {
|
||||
boolean result = isPlaying();
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), getX(), getY(), getZ());
|
||||
((BlockJukeBox) Blocks.JUKEBOX).dropRecord(world.getHandle(), new BlockPosition(getX(), getY(), getZ()), null);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.TileEntityNote;
|
||||
|
||||
import org.bukkit.Instrument;
|
||||
@@ -41,7 +42,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
note.play(world.getHandle(), getX(), getY(), getZ());
|
||||
note.play(world.getHandle(), new BlockPosition(getX(), getY(), getZ()));
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -53,7 +54,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playBlockAction(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument, note);
|
||||
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument, note);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -65,7 +66,7 @@ public class CraftNoteBlock extends CraftBlockState implements NoteBlock {
|
||||
Block block = getBlock();
|
||||
|
||||
if (block.getType() == Material.NOTE_BLOCK) {
|
||||
world.getHandle().playBlockAction(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
|
||||
world.getHandle().playBlockAction(new BlockPosition(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
import net.minecraft.server.TileEntitySign;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
public class CraftSign extends CraftBlockState implements Sign {
|
||||
private final TileEntitySign sign;
|
||||
@@ -15,7 +18,7 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
CraftWorld world = (CraftWorld) block.getWorld();
|
||||
sign = (TileEntitySign) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
lines = new String[sign.lines.length];
|
||||
System.arraycopy(sign.lines, 0, lines, 0, lines.length);
|
||||
System.arraycopy(revertComponents(sign.lines), 0, lines, 0, lines.length);
|
||||
}
|
||||
|
||||
public String[] getLines() {
|
||||
@@ -35,24 +38,37 @@ public class CraftSign extends CraftBlockState implements Sign {
|
||||
boolean result = super.update(force, applyPhysics);
|
||||
|
||||
if (result) {
|
||||
sign.lines = sanitizeLines(lines);
|
||||
IChatBaseComponent[] newLines = sanitizeLines(lines);
|
||||
System.arraycopy(newLines, 0, sign.lines, 0, 4);
|
||||
sign.update();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String[] sanitizeLines(String[] lines) {
|
||||
String[] astring = new String[4];
|
||||
public static IChatBaseComponent[] sanitizeLines(String[] lines) {
|
||||
IChatBaseComponent[] components = new IChatBaseComponent[4];
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (i < lines.length && lines[i] != null) {
|
||||
astring[i] = lines[i];
|
||||
components[i] = CraftChatMessage.fromString(lines[i])[0];
|
||||
} else {
|
||||
astring[i] = "";
|
||||
components[i] = new ChatComponentText("");
|
||||
}
|
||||
}
|
||||
|
||||
return TileEntitySign.sanitizeLines(astring);
|
||||
return components;
|
||||
}
|
||||
|
||||
public static String[] revertComponents(IChatBaseComponent[] components) {
|
||||
String[] lines = new String[components.length];
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
lines[i] = revertComponent(components[i]);
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static String revertComponent(IChatBaseComponent component) {
|
||||
return CraftChatMessage.fromComponent(component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.bukkit.craftbukkit.block;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.TileEntitySkull;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.bukkit.SkullType;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -24,7 +24,7 @@ public class CraftSkull extends CraftBlockState implements Skull {
|
||||
skull = (TileEntitySkull) world.getTileEntityAt(getX(), getY(), getZ());
|
||||
profile = skull.getGameProfile();
|
||||
skullType = getSkullType(skull.getSkullType());
|
||||
rotation = (byte) skull.getRotation();
|
||||
rotation = (byte) skull.rotation;
|
||||
}
|
||||
|
||||
static SkullType getSkullType(int id) {
|
||||
|
||||
@@ -35,17 +35,17 @@ class ChunkIOProvider implements AsynchronousExecutor.CallBackProvider<QueuedChu
|
||||
}
|
||||
|
||||
queuedChunk.loader.loadEntities(chunk, queuedChunk.compound.getCompound("Level"), queuedChunk.world);
|
||||
chunk.lastSaved = queuedChunk.provider.world.getTime();
|
||||
chunk.setLastSaved(queuedChunk.provider.world.getTime());
|
||||
queuedChunk.provider.chunks.put(LongHash.toLong(queuedChunk.x, queuedChunk.z), chunk);
|
||||
chunk.addEntities();
|
||||
|
||||
if (queuedChunk.provider.chunkProvider != null) {
|
||||
queuedChunk.provider.chunkProvider.recreateStructures(queuedChunk.x, queuedChunk.z);
|
||||
queuedChunk.provider.chunkProvider.recreateStructures(chunk, queuedChunk.x, queuedChunk.z);
|
||||
}
|
||||
|
||||
Server server = queuedChunk.provider.world.getServer();
|
||||
if (server != null) {
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
|
||||
server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(chunk.bukkitChunk, false));
|
||||
}
|
||||
|
||||
// Update neighbor counts
|
||||
|
||||
@@ -18,7 +18,7 @@ public class CraftBlockCommandSender extends ServerCommandSender implements Bloc
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().x, commandBlock.getChunkCoordinates().y, commandBlock.getChunkCoordinates().z);
|
||||
return commandBlock.getWorld().getWorld().getBlockAt(commandBlock.getChunkCoordinates().getX(), commandBlock.getChunkCoordinates().getY(), commandBlock.getChunkCoordinates().getZ());
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import net.minecraft.server.RemoteControlCommandListener;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
|
||||
@@ -10,7 +11,7 @@ public class CraftRemoteConsoleCommandSender extends ServerCommandSender impleme
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
RemoteControlCommandListener.instance.sendMessage(message + "\n"); // Send a newline after each message, to preserve formatting.
|
||||
RemoteControlCommandListener.getInstance().sendMessage(new ChatComponentText(message + "\n")); // Send a newline after each message, to preserve formatting.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,22 +1,9 @@
|
||||
package org.bukkit.craftbukkit.command;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.ChatMessage;
|
||||
import net.minecraft.server.CommandAbstract;
|
||||
import net.minecraft.server.CommandBlockListenerAbstract;
|
||||
import net.minecraft.server.CommandException;
|
||||
import net.minecraft.server.EntityMinecartCommandBlock;
|
||||
import net.minecraft.server.EntityMinecartCommandBlockListener;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EnumChatFormat;
|
||||
import net.minecraft.server.ExceptionUsage;
|
||||
import net.minecraft.server.ICommandListener;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerSelector;
|
||||
import net.minecraft.server.RemoteControlCommandListener;
|
||||
import net.minecraft.server.TileEntityCommandListener;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.logging.log4j.Level;
|
||||
@@ -58,6 +45,9 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
MinecraftServer.getServer().worldServer = new WorldServer[]{(WorldServer) icommandlistener.getWorld()};
|
||||
try {
|
||||
vanillaCommand.execute(icommandlistener, args);
|
||||
// PAIL fake throws
|
||||
if (false) throw new ExceptionUsage(null, null);
|
||||
if (false) throw new CommandException(null, null);
|
||||
} catch (ExceptionUsage exceptionusage) {
|
||||
ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] {new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())});
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
@@ -77,7 +67,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
Validate.notNull(sender, "Sender cannot be null");
|
||||
Validate.notNull(args, "Arguments cannot be null");
|
||||
Validate.notNull(alias, "Alias cannot be null");
|
||||
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args);
|
||||
return (List<String>) vanillaCommand.tabComplete(getListener(sender), args, new BlockPosition(0, 0, 0));
|
||||
}
|
||||
|
||||
public final int dispatchVanillaCommandBlock(CommandBlockListenerAbstract icommandlistener, String s) {
|
||||
@@ -97,26 +87,35 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
try {
|
||||
if (vanillaCommand.canUse(icommandlistener)) {
|
||||
if (i > -1) {
|
||||
EntityPlayer aentityplayer[] = PlayerSelector.getPlayers(icommandlistener, as[i]);
|
||||
List<Entity> list = ((List<Entity>)PlayerSelector.getPlayers(icommandlistener, as[i], Entity.class));
|
||||
String s2 = as[i];
|
||||
EntityPlayer aentityplayer1[] = aentityplayer;
|
||||
int k = aentityplayer1.length;
|
||||
for (int l = 0; l < k;l++) {
|
||||
EntityPlayer entityplayer = aentityplayer1[l];
|
||||
as[i] = entityplayer.getName();
|
||||
|
||||
icommandlistener.a(EnumCommandResult.AFFECTED_ENTITIES, list.size());
|
||||
Iterator<Entity> iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = iterator.next();
|
||||
|
||||
try {
|
||||
as[i] = entity.getUniqueID().toString();
|
||||
vanillaCommand.execute(icommandlistener, as);
|
||||
j++;
|
||||
continue;
|
||||
} catch (CommandException commandexception1) {
|
||||
ChatMessage chatmessage4 = new ChatMessage(commandexception1.getMessage(), commandexception1.getArgs());
|
||||
chatmessage4.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage4);
|
||||
}
|
||||
// PAIL fake throws
|
||||
if (false) throw new ExceptionUsage(null, null);
|
||||
if (false) throw new CommandException(null, null);
|
||||
} catch (ExceptionUsage exceptionusage) {
|
||||
ChatMessage chatmessage = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs())});
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage);
|
||||
} catch (CommandException commandexception) {
|
||||
ChatMessage chatmessage = new ChatMessage(commandexception.getMessage(), commandexception.getArgs());
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage);
|
||||
}
|
||||
}
|
||||
|
||||
as[i] = s2;
|
||||
} else {
|
||||
icommandlistener.a(EnumCommandResult.AFFECTED_ENTITIES, 1);
|
||||
vanillaCommand.execute(icommandlistener, as);
|
||||
j++;
|
||||
}
|
||||
@@ -125,6 +124,10 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
chatmessage.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
icommandlistener.sendMessage(chatmessage);
|
||||
}
|
||||
// PAIL start: fix compile error
|
||||
if (false) throw new ExceptionUsage(null, null);
|
||||
if (false) throw new CommandException(null, null);
|
||||
// PAIL end
|
||||
} catch (ExceptionUsage exceptionusage) {
|
||||
ChatMessage chatmessage1 = new ChatMessage("commands.generic.usage", new Object[] { new ChatMessage(exceptionusage.getMessage(), exceptionusage.getArgs()) });
|
||||
chatmessage1.getChatModifier().setColor(EnumChatFormat.RED);
|
||||
@@ -139,16 +142,17 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
icommandlistener.sendMessage(chatmessage3);
|
||||
if(icommandlistener instanceof TileEntityCommandListener) {
|
||||
TileEntityCommandListener listener = (TileEntityCommandListener) icommandlistener;
|
||||
MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().x, listener.getChunkCoordinates().y, listener.getChunkCoordinates().z), throwable);
|
||||
MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), throwable);
|
||||
} else if (icommandlistener instanceof EntityMinecartCommandBlockListener) {
|
||||
EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) icommandlistener;
|
||||
MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().x, listener.getChunkCoordinates().y, listener.getChunkCoordinates().z), throwable);
|
||||
MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getChunkCoordinates().getX(), listener.getChunkCoordinates().getY(), listener.getChunkCoordinates().getZ()), throwable);
|
||||
} else {
|
||||
MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), throwable);
|
||||
}
|
||||
} finally {
|
||||
MinecraftServer.getServer().worldServer = prev;
|
||||
}
|
||||
icommandlistener.a(EnumCommandResult.SUCCESS_COUNT, j);
|
||||
return j;
|
||||
}
|
||||
|
||||
@@ -163,7 +167,7 @@ public final class VanillaCommandWrapper extends VanillaCommand {
|
||||
return ((EntityMinecartCommandBlock) ((CraftMinecartCommand) sender).getHandle()).getCommandBlock();
|
||||
}
|
||||
if (sender instanceof RemoteConsoleCommandSender) {
|
||||
return RemoteControlCommandListener.instance;
|
||||
return RemoteControlCommandListener.getInstance();
|
||||
}
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
return ((CraftServer) sender.getServer()).getServer();
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityArmorStand;
|
||||
import net.minecraft.server.Vector3f;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
public class CraftArmorStand extends CraftLivingEntity implements ArmorStand {
|
||||
|
||||
private static final int HAND = 0;
|
||||
private static final int FEET = 1;
|
||||
private static final int LEGS = 2;
|
||||
private static final int CHEST = 3;
|
||||
private static final int HEAD = 4;
|
||||
|
||||
public CraftArmorStand(CraftServer server, EntityArmorStand entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftArmorStand";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ARMOR_STAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityArmorStand getHandle() {
|
||||
return (EntityArmorStand) super.getHandle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(HAND));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack item) {
|
||||
getHandle().setEquipment(HAND, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(FEET));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoots(ItemStack item) {
|
||||
getHandle().setEquipment(FEET, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(LEGS));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggings(ItemStack item) {
|
||||
getHandle().setEquipment(LEGS, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(CHEST));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplate(ItemStack item) {
|
||||
getHandle().setEquipment(CHEST, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
return CraftItemStack.asBukkitCopy(getHandle().getEquipment(HEAD));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmet(ItemStack item) {
|
||||
getHandle().setEquipment(HEAD, CraftItemStack.asNMSCopy(item));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getBodyPose() {
|
||||
return fromNMS(getHandle().bodyPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBodyPose(EulerAngle pose) {
|
||||
getHandle().setBodyPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getLeftArmPose() {
|
||||
return fromNMS(getHandle().leftArmPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftArmPose(EulerAngle pose) {
|
||||
getHandle().setLeftArmPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getRightArmPose() {
|
||||
return fromNMS(getHandle().rightArmPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightArmPose(EulerAngle pose) {
|
||||
getHandle().setRightArmPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getLeftLegPose() {
|
||||
return fromNMS(getHandle().leftLegPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeftLegPose(EulerAngle pose) {
|
||||
getHandle().setLeftLegPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getRightLegPose() {
|
||||
return fromNMS(getHandle().rightLegPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRightLegPose(EulerAngle pose) {
|
||||
getHandle().setRightLegPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EulerAngle getHeadPose() {
|
||||
return fromNMS(getHandle().headPose);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeadPose(EulerAngle pose) {
|
||||
getHandle().setHeadPose(toNMS(pose));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasBasePlate() {
|
||||
return !getHandle().hasBasePlate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBasePlate(boolean basePlate) {
|
||||
getHandle().setBasePlate(!basePlate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity() {
|
||||
return !getHandle().hasGravity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGravity(boolean gravity) {
|
||||
getHandle().setGravity(!gravity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return !getHandle().isInvisible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean visible) {
|
||||
getHandle().setInvisible(!visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasArms() {
|
||||
return getHandle().hasArms();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArms(boolean arms) {
|
||||
getHandle().setArms(arms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSmall() {
|
||||
return getHandle().isSmall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSmall(boolean small) {
|
||||
getHandle().setSmall(small);
|
||||
}
|
||||
|
||||
private static EulerAngle fromNMS(Vector3f old) {
|
||||
return new EulerAngle(
|
||||
Math.toRadians(old.getX()),
|
||||
Math.toRadians(old.getY()),
|
||||
Math.toRadians(old.getZ())
|
||||
);
|
||||
}
|
||||
|
||||
private static Vector3f toNMS(EulerAngle old) {
|
||||
return new Vector3f(
|
||||
(float) Math.toDegrees(old.getX()),
|
||||
(float) Math.toDegrees(old.getY()),
|
||||
(float) Math.toDegrees(old.getZ())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ public class CraftArrow extends AbstractProjectile implements Arrow {
|
||||
}
|
||||
|
||||
public ProjectileSource getShooter() {
|
||||
return getHandle().projectileSource;
|
||||
return getHandle().projectileSource;
|
||||
}
|
||||
|
||||
public void setShooter(ProjectileSource shooter) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityCreature;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@@ -14,20 +13,16 @@ public class CraftCreature extends CraftLivingEntity implements Creature {
|
||||
public void setTarget(LivingEntity target) {
|
||||
EntityCreature entity = getHandle();
|
||||
if (target == null) {
|
||||
entity.target = null;
|
||||
entity.setGoalTarget(null);
|
||||
entity.setGoalTarget(null, null, false);
|
||||
} else if (target instanceof CraftLivingEntity) {
|
||||
entity.target = ((CraftLivingEntity) target).getHandle();
|
||||
entity.pathEntity = entity.world.findPath(entity, entity.target, 16.0F, true, false, false, true);
|
||||
entity.setGoalTarget(((CraftLivingEntity) target).getHandle());
|
||||
entity.setGoalTarget(((CraftLivingEntity) target).getHandle(), null, false);
|
||||
}
|
||||
}
|
||||
|
||||
public CraftLivingEntity getTarget() {
|
||||
if (getHandle().target == null) return null;
|
||||
if (!(getHandle().target instanceof EntityLiving)) return null;
|
||||
if (getHandle().getGoalTarget() == null) return null;
|
||||
|
||||
return (CraftLivingEntity) getHandle().target.getBukkitEntity();
|
||||
return (CraftLivingEntity) getHandle().getGoalTarget().getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityEnderman;
|
||||
|
||||
import net.minecraft.server.IBlockData;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
import org.bukkit.entity.Enderman;
|
||||
@@ -14,12 +15,12 @@ public class CraftEnderman extends CraftMonster implements Enderman {
|
||||
}
|
||||
|
||||
public MaterialData getCarriedMaterial() {
|
||||
return CraftMagicNumbers.getMaterial(getHandle().getCarried()).getNewData((byte) getHandle().getCarriedData());
|
||||
IBlockData blockData = getHandle().getCarried();
|
||||
return CraftMagicNumbers.getMaterial(blockData.getBlock()).getNewData((byte) blockData.getBlock().toLegacyData(blockData));
|
||||
}
|
||||
|
||||
public void setCarriedMaterial(MaterialData data) {
|
||||
getHandle().setCarried(CraftMagicNumbers.getBlock(data.getItemTypeId()));
|
||||
getHandle().setCarriedData(data.getData());
|
||||
getHandle().setCarried(CraftMagicNumbers.getBlock(data.getItemTypeId()).fromLegacyData(data.getData()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityEndermite;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Endermite;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public class CraftEndermite extends CraftMonster implements Endermite {
|
||||
|
||||
public CraftEndermite(CraftServer server, EntityEndermite entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftEndermite";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.ENDERMITE;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityPlayer) { return new CraftPlayer(server, (EntityPlayer) entity); }
|
||||
else { return new CraftHumanEntity(server, (EntityHuman) entity); }
|
||||
}
|
||||
// Water Animals
|
||||
else if (entity instanceof EntityWaterAnimal) {
|
||||
if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); }
|
||||
else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityCreature) {
|
||||
// Animals
|
||||
if (entity instanceof EntityAnimal) {
|
||||
@@ -52,6 +57,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
else if (entity instanceof EntitySheep) { return new CraftSheep(server, (EntitySheep) entity); }
|
||||
else if (entity instanceof EntityHorse) { return new CraftHorse(server, (EntityHorse) entity); }
|
||||
else if (entity instanceof EntityRabbit) { return new CraftRabbit(server, (EntityRabbit) entity); }
|
||||
else { return new CraftAnimals(server, (EntityAnimal) entity); }
|
||||
}
|
||||
// Monsters
|
||||
@@ -72,14 +78,11 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityCaveSpider) { return new CraftCaveSpider(server, (EntityCaveSpider) entity); }
|
||||
else { return new CraftSpider(server, (EntitySpider) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityEndermite) { return new CraftEndermite(server, (EntityEndermite) entity); }
|
||||
else if (entity instanceof EntityGuardian) { return new CraftGuardian(server, (EntityGuardian) entity); }
|
||||
|
||||
else { return new CraftMonster(server, (EntityMonster) entity); }
|
||||
}
|
||||
// Water Animals
|
||||
else if (entity instanceof EntityWaterAnimal) {
|
||||
if (entity instanceof EntitySquid) { return new CraftSquid(server, (EntitySquid) entity); }
|
||||
else { return new CraftWaterMob(server, (EntityWaterAnimal) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityGolem) {
|
||||
if (entity instanceof EntitySnowman) { return new CraftSnowman(server, (EntitySnowman) entity); }
|
||||
else if (entity instanceof EntityIronGolem) { return new CraftIronGolem(server, (EntityIronGolem) entity); }
|
||||
@@ -105,6 +108,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
if (entity instanceof EntityBat) { return new CraftBat(server, (EntityBat) entity); }
|
||||
else { return new CraftAmbient(server, (EntityAmbient) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityArmorStand) { return new CraftArmorStand(server, (EntityArmorStand) entity); }
|
||||
else { return new CraftLivingEntity(server, (EntityLiving) entity); }
|
||||
}
|
||||
else if (entity instanceof EntityComplexPart) {
|
||||
@@ -154,7 +158,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
else if (entity instanceof EntityTNTPrimed) { return new CraftTNTPrimed(server, (EntityTNTPrimed) entity); }
|
||||
else if (entity instanceof EntityFireworks) { return new CraftFirework(server, (EntityFireworks) entity); }
|
||||
|
||||
throw new AssertionError("Unknown entity " + entity == null ? null : entity.getClass());
|
||||
throw new AssertionError("Unknown entity " + (entity == null ? null : entity.getClass()));
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
@@ -224,7 +228,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
public List<org.bukkit.entity.Entity> getNearbyEntities(double x, double y, double z) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Entity> notchEntityList = entity.world.getEntities(entity, entity.boundingBox.grow(x, y, z));
|
||||
List<Entity> notchEntityList = entity.world.getEntities(entity, entity.getBoundingBox().grow(x, y, z));
|
||||
List<org.bukkit.entity.Entity> bukkitEntityList = new java.util.ArrayList<org.bukkit.entity.Entity>(notchEntityList.size());
|
||||
|
||||
for (Entity e : notchEntityList) {
|
||||
@@ -316,7 +320,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
}
|
||||
|
||||
public UUID getUniqueId() {
|
||||
return getHandle().uniqueID;
|
||||
return getHandle().getUniqueID();
|
||||
}
|
||||
|
||||
public int getTicksLived() {
|
||||
@@ -402,4 +406,34 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
||||
|
||||
return getHandle().vehicle.getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(String name) {
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
|
||||
getHandle().setCustomName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomName() {
|
||||
String name = getHandle().getCustomName();
|
||||
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean flag) {
|
||||
getHandle().setCustomNameVisible(flag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCustomNameVisible() {
|
||||
return getHandle().getCustomNameVisible();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ public class CraftFallingSand extends CraftEntity implements FallingSand {
|
||||
}
|
||||
|
||||
public int getBlockId() {
|
||||
return CraftMagicNumbers.getId(getHandle().id);
|
||||
return CraftMagicNumbers.getId(getHandle().getBlock().getBlock());
|
||||
}
|
||||
|
||||
public byte getBlockData() {
|
||||
return (byte) getHandle().data;
|
||||
return (byte) getHandle().getBlock().getBlock().toLegacyData(getHandle().getBlock());
|
||||
}
|
||||
|
||||
public boolean getDropItem() {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.EntityFishingHook;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.MathHelper;
|
||||
@@ -50,7 +51,7 @@ public class CraftFish extends AbstractProjectile implements Fish {
|
||||
EntityFishingHook hook = getHandle();
|
||||
|
||||
if (this.biteChance == -1) {
|
||||
if (hook.world.isRainingAt(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ))) {
|
||||
if (hook.world.isRainingAt(new BlockPosition(MathHelper.floor(hook.locX), MathHelper.floor(hook.locY) + 1, MathHelper.floor(hook.locZ)))) {
|
||||
return 1/300.0;
|
||||
}
|
||||
return 1/500.0;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityGuardian;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Guardian;
|
||||
|
||||
public class CraftGuardian extends CraftMonster implements Guardian {
|
||||
|
||||
public CraftGuardian(CraftServer server, EntityGuardian entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftGuardian";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.GUARDIAN;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.EntityHanging;
|
||||
import net.minecraft.server.EnumDirection;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
@@ -23,30 +25,27 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
||||
public boolean setFacingDirection(BlockFace face, boolean force) {
|
||||
Block block = getLocation().getBlock().getRelative(getAttachedFace()).getRelative(face.getOppositeFace()).getRelative(getFacing());
|
||||
EntityHanging hanging = getHandle();
|
||||
int x = hanging.x, y = hanging.y, z = hanging.z, dir = hanging.direction;
|
||||
hanging.x = block.getX();
|
||||
hanging.y = block.getY();
|
||||
hanging.z = block.getZ();
|
||||
BlockPosition old = hanging.getBlockPosition();
|
||||
EnumDirection dir = hanging.direction;
|
||||
hanging.blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
|
||||
switch (face) {
|
||||
case SOUTH:
|
||||
default:
|
||||
getHandle().setDirection(0);
|
||||
getHandle().setDirection(EnumDirection.SOUTH);
|
||||
break;
|
||||
case WEST:
|
||||
getHandle().setDirection(1);
|
||||
getHandle().setDirection(EnumDirection.WEST);
|
||||
break;
|
||||
case NORTH:
|
||||
getHandle().setDirection(2);
|
||||
getHandle().setDirection(EnumDirection.NORTH);
|
||||
break;
|
||||
case EAST:
|
||||
getHandle().setDirection(3);
|
||||
getHandle().setDirection(EnumDirection.EAST);
|
||||
break;
|
||||
}
|
||||
if (!force && !hanging.survives()) {
|
||||
// Revert since it doesn't fit
|
||||
hanging.x = x;
|
||||
hanging.y = y;
|
||||
hanging.z = z;
|
||||
hanging.blockPosition = old;
|
||||
hanging.setDirection(dir);
|
||||
return false;
|
||||
}
|
||||
@@ -55,14 +54,14 @@ public class CraftHanging extends CraftEntity implements Hanging {
|
||||
|
||||
public BlockFace getFacing() {
|
||||
switch (this.getHandle().direction) {
|
||||
case 0:
|
||||
case SOUTH:
|
||||
default:
|
||||
return BlockFace.SOUTH;
|
||||
case 1:
|
||||
case WEST:
|
||||
return BlockFace.WEST;
|
||||
case 2:
|
||||
case NORTH:
|
||||
return BlockFace.NORTH;
|
||||
case 3:
|
||||
case EAST:
|
||||
return BlockFace.EAST;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class CraftHorse extends CraftAnimals implements Horse {
|
||||
public void setOwner(AnimalTamer owner) {
|
||||
if (owner != null) {
|
||||
setTamed(true);
|
||||
getHandle().setPathEntity(null);
|
||||
getHandle().setGoalTarget(null, null, false);
|
||||
setOwnerUUID(owner.getUniqueId());
|
||||
} else {
|
||||
setTamed(false);
|
||||
|
||||
@@ -2,16 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.Container;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityMinecartHopper;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
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;
|
||||
import net.minecraft.server.TileEntityHopper;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -194,38 +185,38 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
break;
|
||||
case DISPENSER:
|
||||
if (craftinv.getInventory() instanceof TileEntityDispenser) {
|
||||
getHandle().openDispenser((TileEntityDispenser) craftinv.getInventory());
|
||||
getHandle().openTileEntity((TileEntityDispenser) craftinv.getInventory());
|
||||
} else {
|
||||
openCustomInventory(inventory, player, 3);
|
||||
openCustomInventory(inventory, player, "minecraft:dispenser");
|
||||
}
|
||||
break;
|
||||
case FURNACE:
|
||||
if (craftinv.getInventory() instanceof TileEntityFurnace) {
|
||||
getHandle().openFurnace((TileEntityFurnace) craftinv.getInventory());
|
||||
getHandle().openTileEntity((TileEntityFurnace) craftinv.getInventory());
|
||||
} else {
|
||||
openCustomInventory(inventory, player, 2);
|
||||
openCustomInventory(inventory, player, "minecraft:furnace");
|
||||
}
|
||||
break;
|
||||
case WORKBENCH:
|
||||
openCustomInventory(inventory, player, 1);
|
||||
openCustomInventory(inventory, player, "minecraft:crafting_table");
|
||||
break;
|
||||
case BREWING:
|
||||
if (craftinv.getInventory() instanceof TileEntityBrewingStand) {
|
||||
getHandle().openBrewingStand((TileEntityBrewingStand) craftinv.getInventory());
|
||||
getHandle().openTileEntity((TileEntityBrewingStand) craftinv.getInventory());
|
||||
} else {
|
||||
openCustomInventory(inventory, player, 5);
|
||||
openCustomInventory(inventory, player, "minecraft:brewing_stand");
|
||||
}
|
||||
break;
|
||||
case ENCHANTING:
|
||||
openCustomInventory(inventory, player, 4);
|
||||
openCustomInventory(inventory, player, "minecraft:enchanting_table");
|
||||
break;
|
||||
case HOPPER:
|
||||
if (craftinv.getInventory() instanceof TileEntityHopper) {
|
||||
getHandle().openHopper((TileEntityHopper) craftinv.getInventory());
|
||||
getHandle().openTileEntity((TileEntityHopper) craftinv.getInventory());
|
||||
} else if (craftinv.getInventory() instanceof EntityMinecartHopper) {
|
||||
getHandle().openMinecartHopper((EntityMinecartHopper) craftinv.getInventory());
|
||||
getHandle().openTileEntity((EntityMinecartHopper) craftinv.getInventory());
|
||||
} else {
|
||||
openCustomInventory(inventory, player, 9);
|
||||
openCustomInventory(inventory, player, "minecraft:hopper");
|
||||
}
|
||||
break;
|
||||
case CREATIVE:
|
||||
@@ -239,7 +230,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
return getHandle().activeContainer.getBukkitView();
|
||||
}
|
||||
|
||||
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
|
||||
private void openCustomInventory(Inventory inventory, EntityPlayer player, String windowType) {
|
||||
if (player.playerConnection == null) return;
|
||||
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
|
||||
|
||||
@@ -249,7 +240,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
String title = container.getBukkitView().getTitle();
|
||||
int size = container.getBukkitView().getTopInventory().getSize();
|
||||
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, true));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
|
||||
getHandle().activeContainer = container;
|
||||
getHandle().activeContainer.addSlotListener(player);
|
||||
}
|
||||
@@ -264,7 +255,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
if (location == null) {
|
||||
location = getLocation();
|
||||
}
|
||||
getHandle().startCrafting(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
getHandle().openTileEntity(new TileEntityContainerWorkbench(getHandle().world, new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
|
||||
if (force) {
|
||||
getHandle().activeContainer.checkReachable = false;
|
||||
}
|
||||
@@ -281,7 +272,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
if (location == null) {
|
||||
location = getLocation();
|
||||
}
|
||||
getHandle().startEnchanting(location.getBlockX(), location.getBlockY(), location.getBlockZ(), null);
|
||||
getHandle().openTileEntity((ITileEntityContainer) getHandle().world.getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ())));
|
||||
if (force) {
|
||||
getHandle().activeContainer.checkReachable = false;
|
||||
}
|
||||
@@ -311,10 +302,10 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
||||
|
||||
// Now open the window
|
||||
InventoryType type = inventory.getType();
|
||||
int windowType = CraftContainer.getNotchInventoryType(type);
|
||||
String windowType = CraftContainer.getNotchInventoryType(type);
|
||||
String title = inventory.getTitle();
|
||||
int size = inventory.getTopInventory().getSize();
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, title, size, false));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
|
||||
player.activeContainer = container;
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
||||
@@ -197,11 +197,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
|
||||
}
|
||||
|
||||
if (entity instanceof EntityEnderDragon) {
|
||||
((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
|
||||
} else {
|
||||
entity.damageEntity(reason, (float) amount);
|
||||
}
|
||||
entity.damageEntity(reason, (float) amount);
|
||||
}
|
||||
|
||||
public Location getEyeLocation() {
|
||||
@@ -263,7 +259,7 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
removePotionEffect(effect.getType());
|
||||
}
|
||||
getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient()));
|
||||
getHandle().addEffect(new MobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), true));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -384,47 +380,6 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return super.teleport(location, cause);
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = "";
|
||||
}
|
||||
|
||||
// Names cannot be more than 64 characters due to DataWatcher limitations
|
||||
if (name.length() > 64) {
|
||||
name = name.substring(0, 64);
|
||||
}
|
||||
|
||||
((EntityInsentient) getHandle()).setCustomName(name);
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String name = ((EntityInsentient) getHandle()).getCustomName();
|
||||
|
||||
if (name == null || name.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean flag) {
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).setCustomNameVisible(flag);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).getCustomNameVisible();
|
||||
}
|
||||
|
||||
public boolean isLeashed() {
|
||||
if (!(getHandle() instanceof EntityInsentient)) {
|
||||
return false;
|
||||
|
||||
@@ -54,9 +54,7 @@ public class CraftPainting extends CraftHanging implements Painting {
|
||||
private void update() {
|
||||
WorldServer world = ((CraftWorld) getWorld()).getHandle();
|
||||
EntityPainting painting = new EntityPainting(world);
|
||||
painting.x = getHandle().x;
|
||||
painting.y = getHandle().y;
|
||||
painting.z = getHandle().z;
|
||||
painting.blockPosition = getHandle().blockPosition;
|
||||
painting.art = getHandle().art;
|
||||
painting.setDirection(getHandle().direction);
|
||||
getHandle().die();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -19,7 +21,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.bukkit.*;
|
||||
@@ -53,6 +54,7 @@ import org.bukkit.event.player.PlayerRegisterChannelEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerUnregisterChannelEvent;
|
||||
import org.bukkit.inventory.InventoryView.Property;
|
||||
import org.bukkit.map.MapCursor;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@@ -174,44 +176,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
@Override
|
||||
public String getPlayerListName() {
|
||||
return getHandle().listName;
|
||||
return CraftChatMessage.fromComponent(getHandle().listName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name) {
|
||||
String oldName = getHandle().listName;
|
||||
|
||||
if (name == null) {
|
||||
name = getName();
|
||||
}
|
||||
|
||||
if (oldName.equals(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (name.length() > 16) {
|
||||
throw new IllegalArgumentException("Player list names can only be a maximum of 16 characters long");
|
||||
}
|
||||
|
||||
// Collisions will make for invisible people
|
||||
for (int i = 0; i < server.getHandle().players.size(); ++i) {
|
||||
if (((EntityPlayer) server.getHandle().players.get(i)).listName.equals(name)) {
|
||||
throw new IllegalArgumentException(name + " is already assigned as a player list name for someone");
|
||||
}
|
||||
}
|
||||
|
||||
getHandle().listName = name;
|
||||
|
||||
// Change the name on the client side
|
||||
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;
|
||||
|
||||
if (entityplayer.getBukkitEntity().canSee(this)) {
|
||||
entityplayer.playerConnection.sendPacket(oldpacket);
|
||||
entityplayer.playerConnection.sendPacket(packet);
|
||||
getHandle().listName = name.equals(getName()) ? null : CraftChatMessage.fromString(name)[0];
|
||||
for (EntityPlayer player : (List<EntityPlayer>)server.getHandle().players) {
|
||||
if (player.getBukkitEntity().canSee(this)) {
|
||||
player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.UPDATE_DISPLAY_NAME, getHandle()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,7 +224,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
// Do not directly assign here, from the packethandler we'll assign it.
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnPosition(new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -343,7 +319,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int packetData = effect.getId();
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
|
||||
PacketPlayOutWorldEvent packet = new PacketPlayOutWorldEvent(packetData, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), data, false);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -368,10 +344,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void sendBlockChange(Location loc, int material, byte data) {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
|
||||
PacketPlayOutBlockChange packet = new PacketPlayOutBlockChange(((CraftWorld) loc.getWorld()).getHandle(), new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
|
||||
packet.block = CraftMagicNumbers.getBlock(material);
|
||||
packet.data = data;
|
||||
packet.block = CraftMagicNumbers.getBlock(material).fromLegacyData(data);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@@ -390,10 +365,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
throw new IllegalArgumentException("Must have at least 4 lines");
|
||||
}
|
||||
|
||||
// Limit to 15 chars per line and set null lines to blank
|
||||
String[] astring = CraftSign.sanitizeLines(lines);
|
||||
IChatBaseComponent[] components = CraftSign.sanitizeLines(lines);
|
||||
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateSign(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), astring));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateSign(getHandle().world, new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()), components));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -435,15 +409,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
RenderData data = ((CraftMapView) map).render(this);
|
||||
for (int x = 0; x < 128; ++x) {
|
||||
byte[] bytes = new byte[131];
|
||||
bytes[1] = (byte) x;
|
||||
for (int y = 0; y < 128; ++y) {
|
||||
bytes[y + 3] = data.buffer[y * 128 + x];
|
||||
Collection<MapIcon> icons = new ArrayList<MapIcon>();
|
||||
for (MapCursor cursor : data.cursors) {
|
||||
if (cursor.isVisible()) {
|
||||
icons.add(new MapIcon(cursor.getRawType(), cursor.getX(), cursor.getY(), cursor.getDirection()));
|
||||
}
|
||||
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), bytes);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
PacketPlayOutMap packet = new PacketPlayOutMap(map.getId(), map.getScale().getValue(), icons, data.buffer, 0, 0, 0, 0);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -455,7 +429,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
if (entity.playerConnection == null || entity.playerConnection.isDisconnected()) {
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entity.passenger != null) {
|
||||
@@ -781,7 +755,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
getHandle().e((Entity) getHandle()); // RENAME
|
||||
getHandle().playerInteractManager.setGameMode(EnumGamemode.getById(mode.getValue()));
|
||||
getHandle().fallDistance = 0;
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutGameStateChange(3, mode.getValue()));
|
||||
@@ -793,90 +768,108 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return GameMode.getByValue(getHandle().playerInteractManager.getGameMode().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveExp(int exp) {
|
||||
getHandle().giveExp(exp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveExpLevels(int levels) {
|
||||
getHandle().levelDown(levels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExp() {
|
||||
return getHandle().exp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExp(float exp) {
|
||||
getHandle().exp = exp;
|
||||
getHandle().lastSentExp = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel() {
|
||||
return getHandle().expLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int level) {
|
||||
getHandle().expLevel = level;
|
||||
getHandle().lastSentExp = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience() {
|
||||
return getHandle().expTotal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int exp) {
|
||||
getHandle().expTotal = exp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion() {
|
||||
return getHandle().getFoodData().exhaustionLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float value) {
|
||||
getHandle().getFoodData().exhaustionLevel = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation() {
|
||||
return getHandle().getFoodData().saturationLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float value) {
|
||||
getHandle().getFoodData().saturationLevel = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel() {
|
||||
return getHandle().getFoodData().foodLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int value) {
|
||||
getHandle().getFoodData().foodLevel = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation() {
|
||||
World world = getServer().getWorld(getHandle().spawnWorld);
|
||||
ChunkCoordinates bed = getHandle().getBed();
|
||||
BlockPosition bed = getHandle().getBed();
|
||||
|
||||
if (world != null && bed != null) {
|
||||
bed = EntityHuman.getBed(((CraftWorld) world).getHandle(), bed, getHandle().isRespawnForced());
|
||||
if (bed != null) {
|
||||
return new Location(world, bed.x, bed.y, bed.z);
|
||||
return new Location(world, bed.getX(), bed.getY(), bed.getZ());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location location) {
|
||||
setBedSpawnLocation(location, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBedSpawnLocation(Location location, boolean override) {
|
||||
if (location == null) {
|
||||
getHandle().setRespawnPosition(null, override);
|
||||
} else {
|
||||
getHandle().setRespawnPosition(new ChunkCoordinates(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override);
|
||||
getHandle().setRespawnPosition(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), override);
|
||||
getHandle().spawnWorld = location.getWorld().getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePlayer(Player player) {
|
||||
Validate.notNull(player, "hidden player cannot be null");
|
||||
if (getHandle().playerConnection == null) return;
|
||||
@@ -893,9 +886,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
|
||||
//remove the hidden player from this player user list
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), false, 9999));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPlayer(Player player) {
|
||||
Validate.notNull(player, "shown player cannot be null");
|
||||
if (getHandle().playerConnection == null) return;
|
||||
@@ -910,17 +904,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
entry.updatePlayer(getHandle());
|
||||
}
|
||||
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(player.getPlayerListName(), true, getHandle().ping));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.ADD_PLAYER, other));
|
||||
}
|
||||
|
||||
public void removeDisconnectingPlayer(Player player) {
|
||||
hiddenPlayers.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(Player player) {
|
||||
return !hiddenPlayers.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> serialize() {
|
||||
Map<String, Object> result = new LinkedHashMap<String, Object>();
|
||||
|
||||
@@ -929,6 +925,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return this;
|
||||
}
|
||||
@@ -955,14 +952,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getFirstPlayed() {
|
||||
return firstPlayed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastPlayed() {
|
||||
return lastPlayed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPlayedBefore() {
|
||||
return hasPlayedBefore;
|
||||
}
|
||||
@@ -1009,36 +1009,43 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
data.setString("lastKnownName", handle.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beginConversation(Conversation conversation) {
|
||||
return conversationTracker.beginConversation(conversation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation) {
|
||||
conversationTracker.abandonConversation(conversation, new ConversationAbandonedEvent(conversation, new ManuallyAbandonedConversationCanceller()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation conversation, ConversationAbandonedEvent details) {
|
||||
conversationTracker.abandonConversation(conversation, details);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptConversationInput(String input) {
|
||||
conversationTracker.acceptConversationInput(input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConversing() {
|
||||
return conversationTracker.isConversing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
|
||||
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
if (channels.contains(channel)) {
|
||||
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, message);
|
||||
PacketPlayOutCustomPayload packet = new PacketPlayOutCustomPayload(channel, new PacketDataSerializer(Unpooled.wrappedBuffer(message)));
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTexturePack(String url) {
|
||||
setResourcePack(url);
|
||||
}
|
||||
@@ -1047,7 +1054,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
public void setResourcePack(String url) {
|
||||
Validate.notNull(url, "Resource pack URL cannot be null");
|
||||
|
||||
getHandle().setResourcePack(url);
|
||||
getHandle().setResourcePack(url, "null");
|
||||
}
|
||||
|
||||
public void addChannel(String channel) {
|
||||
@@ -1062,6 +1069,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getListeningPluginChannels() {
|
||||
return ImmutableSet.copyOf(channels);
|
||||
}
|
||||
@@ -1082,7 +1090,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", stream.toByteArray()));
|
||||
getHandle().playerConnection.sendPacket(new PacketPlayOutCustomPayload("REGISTER", new PacketDataSerializer(Unpooled.wrappedBuffer(stream.toByteArray()))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1126,10 +1134,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
perm.clearPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying() {
|
||||
return getHandle().abilities.isFlying;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean value) {
|
||||
if (!getAllowFlight() && value) {
|
||||
throw new IllegalArgumentException("Cannot make player fly if getAllowFlight() is false");
|
||||
@@ -1139,10 +1149,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().updateAbilities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAllowFlight() {
|
||||
return getHandle().abilities.canFly;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAllowFlight(boolean value) {
|
||||
if (isFlying() && !value) {
|
||||
getHandle().abilities.isFlying = false;
|
||||
@@ -1161,6 +1173,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlySpeed(float value) {
|
||||
validateSpeed(value);
|
||||
EntityPlayer player = getHandle();
|
||||
@@ -1169,6 +1182,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWalkSpeed(float value) {
|
||||
validateSpeed(value);
|
||||
EntityPlayer player = getHandle();
|
||||
@@ -1176,10 +1190,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
player.updateAbilities();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFlySpeed() {
|
||||
return getHandle().abilities.flySpeed * 2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWalkSpeed() {
|
||||
return getHandle().abilities.walkSpeed * 2f;
|
||||
}
|
||||
@@ -1209,10 +1225,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
getHandle().triggerHealthUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftScoreboard getScoreboard() {
|
||||
return this.server.getScoreboardManager().getPlayerBoard(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScoreboard(Scoreboard scoreboard) {
|
||||
Validate.notNull(scoreboard, "Scoreboard cannot be null");
|
||||
PlayerConnection playerConnection = getHandle().playerConnection;
|
||||
@@ -1226,6 +1244,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
this.server.getScoreboardManager().setPlayerBoard(this, scoreboard);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealthScale(double value) {
|
||||
Validate.isTrue((float) value > 0F, "Must be greater than 0");
|
||||
healthScale = value;
|
||||
@@ -1233,16 +1252,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
updateScaledHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealthScale() {
|
||||
return healthScale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealthScaled(boolean scale) {
|
||||
if (scaledHealth != (scaledHealth = scale)) {
|
||||
updateScaledHealth();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHealthScaled() {
|
||||
return scaledHealth;
|
||||
}
|
||||
@@ -1285,6 +1307,6 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
break;
|
||||
}
|
||||
}
|
||||
collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged("generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
|
||||
collection.add(new AttributeModifiable(getHandle().getAttributeMap(), (new AttributeRanged(null, "generic.maxHealth", scaledHealth ? healthScale : getMaxHealth(), 0.0D, Float.MAX_VALUE)).a("Max Health").a(true)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityRabbit;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Rabbit;
|
||||
|
||||
public class CraftRabbit extends CraftAnimals implements Rabbit {
|
||||
|
||||
public CraftRabbit(CraftServer server, EntityRabbit entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftRabbit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType() {
|
||||
return EntityType.RABBIT;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntitySheep;
|
||||
|
||||
import net.minecraft.server.EnumColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -13,11 +14,11 @@ public class CraftSheep extends CraftAnimals implements Sheep {
|
||||
}
|
||||
|
||||
public DyeColor getColor() {
|
||||
return DyeColor.getByWoolData((byte) getHandle().getColor());
|
||||
return DyeColor.getByWoolData((byte) getHandle().getColor().getColorIndex());
|
||||
}
|
||||
|
||||
public void setColor(DyeColor color) {
|
||||
getHandle().setColor(color.getWoolData());
|
||||
getHandle().setColor(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
|
||||
@@ -54,7 +54,7 @@ public class CraftTameableAnimal extends CraftAnimals implements Tameable, Creat
|
||||
public void setOwner(AnimalTamer tamer) {
|
||||
if (tamer != null) {
|
||||
setTamed(true);
|
||||
getHandle().setPathEntity(null);
|
||||
getHandle().setGoalTarget(null, null, false);
|
||||
setOwnerUUID(tamer.getUniqueId());
|
||||
} else {
|
||||
setTamed(false);
|
||||
|
||||
@@ -3,10 +3,13 @@ package org.bukkit.craftbukkit.entity;
|
||||
import net.minecraft.server.EntityVillager;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
public class CraftVillager extends CraftAgeable implements Villager {
|
||||
public class CraftVillager extends CraftAgeable implements Villager, InventoryHolder {
|
||||
public CraftVillager(CraftServer server, EntityVillager entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
@@ -33,4 +36,9 @@ public class CraftVillager extends CraftAgeable implements Villager {
|
||||
Validate.notNull(profession);
|
||||
getHandle().setProfession(profession.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return new CraftInventory(getHandle().inventory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,10 @@ package org.bukkit.craftbukkit.entity;
|
||||
import net.minecraft.server.EntityWaterAnimal;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
|
||||
public class CraftWaterMob extends CraftCreature implements WaterMob {
|
||||
public class CraftWaterMob extends CraftLivingEntity implements WaterMob {
|
||||
|
||||
public CraftWaterMob(CraftServer server, EntityWaterAnimal entity) {
|
||||
super(server, entity);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityWolf;
|
||||
import net.minecraft.server.EnumColor;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@@ -30,10 +31,10 @@ public class CraftWolf extends CraftTameableAnimal implements Wolf {
|
||||
}
|
||||
|
||||
public DyeColor getCollarColor() {
|
||||
return DyeColor.getByWoolData((byte) getHandle().getCollarColor());
|
||||
return DyeColor.getByWoolData((byte) getHandle().getCollarColor().getColorIndex());
|
||||
}
|
||||
|
||||
public void setCollarColor(DyeColor color) {
|
||||
getHandle().setCollarColor(color.getWoolData());
|
||||
getHandle().setCollarColor(EnumColor.fromColorIndex(color.getWoolData()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,30 +9,7 @@ import java.util.Map;
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Functions;
|
||||
|
||||
import net.minecraft.server.ChunkCoordinates;
|
||||
import net.minecraft.server.Container;
|
||||
import net.minecraft.server.DamageSource;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.EntityArrow;
|
||||
import net.minecraft.server.EntityDamageSource;
|
||||
import net.minecraft.server.EntityDamageSourceIndirect;
|
||||
import net.minecraft.server.EntityEnderCrystal;
|
||||
import net.minecraft.server.EntityEnderDragon;
|
||||
import net.minecraft.server.EntityHuman;
|
||||
import net.minecraft.server.EntityInsentient;
|
||||
import net.minecraft.server.EntityItem;
|
||||
import net.minecraft.server.EntityLiving;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EntityPotion;
|
||||
import net.minecraft.server.Explosion;
|
||||
import net.minecraft.server.InventoryCrafting;
|
||||
import net.minecraft.server.ItemStack;
|
||||
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;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -97,9 +74,9 @@ public class CraftEventFactory {
|
||||
if (((CraftServer) Bukkit.getServer()).getHandle().getOPs().isEmpty()) return true;
|
||||
if (player.isOp()) return true;
|
||||
|
||||
ChunkCoordinates chunkcoordinates = worldServer.getSpawn();
|
||||
BlockPosition chunkcoordinates = worldServer.getSpawn();
|
||||
|
||||
int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.x), Math.abs(z - chunkcoordinates.z));
|
||||
int distanceFromSpawn = Math.max(Math.abs(x - chunkcoordinates.getX()), Math.abs(z - chunkcoordinates.getY()));
|
||||
return distanceFromSpawn > spawnSize;
|
||||
}
|
||||
|
||||
@@ -152,15 +129,15 @@ public class CraftEventFactory {
|
||||
/**
|
||||
* Bucket methods
|
||||
*/
|
||||
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemInHand) {
|
||||
public static PlayerBucketEmptyEvent callPlayerBucketEmptyEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, EnumDirection clickedFace, ItemStack itemInHand) {
|
||||
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) {
|
||||
public static PlayerBucketFillEvent callPlayerBucketFillEvent(EntityHuman who, int clickedX, int clickedY, int clickedZ, EnumDirection clickedFace, ItemStack itemInHand, net.minecraft.server.Item bucket) {
|
||||
return (PlayerBucketFillEvent) getPlayerBucketEvent(true, who, clickedX, clickedY, clickedZ, clickedFace, itemInHand, bucket);
|
||||
}
|
||||
|
||||
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
|
||||
private static PlayerEvent getPlayerBucketEvent(boolean isFilling, EntityHuman who, int clickedX, int clickedY, int clickedZ, EnumDirection clickedFace, ItemStack itemstack, net.minecraft.server.Item item) {
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = CraftItemStack.asNewCraftStack(item);
|
||||
Material bucket = CraftMagicNumbers.getMaterial(itemstack.getItem());
|
||||
@@ -192,20 +169,24 @@ public class CraftEventFactory {
|
||||
if (action != Action.LEFT_CLICK_AIR && action != Action.RIGHT_CLICK_AIR) {
|
||||
throw new AssertionError(String.format("%s performing %s with %s", who, action, itemstack));
|
||||
}
|
||||
return callPlayerInteractEvent(who, action, 0, 256, 0, 0, itemstack);
|
||||
return callPlayerInteractEvent(who, action, new BlockPosition(0, 256, 0), EnumDirection.SOUTH, itemstack);
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, int clickedX, int clickedY, int clickedZ, int clickedFace, ItemStack itemstack) {
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack) {
|
||||
return callPlayerInteractEvent(who, action, position, direction, itemstack, false);
|
||||
}
|
||||
|
||||
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, boolean cancelledBlock) {
|
||||
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
||||
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
||||
|
||||
CraftWorld craftWorld = (CraftWorld) player.getWorld();
|
||||
CraftServer craftServer = (CraftServer) player.getServer();
|
||||
|
||||
Block blockClicked = craftWorld.getBlockAt(clickedX, clickedY, clickedZ);
|
||||
BlockFace blockFace = CraftBlock.notchToBlockFace(clickedFace);
|
||||
Block blockClicked = craftWorld.getBlockAt(position.getX(), position.getY(), position.getZ());
|
||||
BlockFace blockFace = CraftBlock.notchToBlockFace(direction);
|
||||
|
||||
if (clickedY > 255) {
|
||||
if (position.getY() > 255) {
|
||||
blockClicked = null;
|
||||
switch (action) {
|
||||
case LEFT_CLICK_BLOCK:
|
||||
@@ -222,6 +203,9 @@ public class CraftEventFactory {
|
||||
}
|
||||
|
||||
PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace);
|
||||
if (cancelledBlock) {
|
||||
event.setUseInteractedBlock(Event.Result.DENY);
|
||||
}
|
||||
craftServer.getPluginManager().callEvent(event);
|
||||
|
||||
return event;
|
||||
@@ -415,7 +399,7 @@ public class CraftEventFactory {
|
||||
EntityDamageEvent event;
|
||||
if (damager == null) {
|
||||
event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions);
|
||||
} else if (entity instanceof EntityEnderDragon && ((EntityEnderDragon) entity).bC == damager) {
|
||||
} else if (entity instanceof EntityEnderDragon && ((EntityEnderDragon) entity).bx == damager) {
|
||||
event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions);
|
||||
} else {
|
||||
if (damager instanceof org.bukkit.entity.TNTPrimed) {
|
||||
@@ -840,7 +824,7 @@ public class CraftEventFactory {
|
||||
ItemStack itemInHand = player.inventory.getItem(itemInHandIndex);
|
||||
|
||||
// If they've got the same item in their hand, it'll need to be updated.
|
||||
if (itemInHand != null && itemInHand.getItem() == Items.BOOK_AND_QUILL) {
|
||||
if (itemInHand != null && itemInHand.getItem() == Items.WRITABLE_BOOK) {
|
||||
if (!editBookEvent.isCancelled()) {
|
||||
CraftItemStack.setItemMeta(itemInHand, editBookEvent.getNewBookMeta());
|
||||
if (editBookEvent.isSigning()) {
|
||||
@@ -876,6 +860,10 @@ public class CraftEventFactory {
|
||||
event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.server.Achievement) statistic));
|
||||
} else {
|
||||
org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
|
||||
if (stat == null) {
|
||||
System.err.println("Unhandled statistic: " + statistic);
|
||||
return null;
|
||||
}
|
||||
switch (stat) {
|
||||
case FALL_ONE_CM:
|
||||
case BOAT_ONE_CM:
|
||||
@@ -888,6 +876,9 @@ public class CraftEventFactory {
|
||||
case PLAY_ONE_TICK:
|
||||
case SWIM_ONE_CM:
|
||||
case WALK_ONE_CM:
|
||||
case SPRINT_ONE_CM:
|
||||
case CROUCH_ONE_CM:
|
||||
case TIME_SINCE_DEATH:
|
||||
// Do not process event for these - too spammy
|
||||
return null;
|
||||
default:
|
||||
|
||||
@@ -3,16 +3,7 @@ package org.bukkit.craftbukkit.generator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.BiomeBase;
|
||||
import net.minecraft.server.Chunk;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.ChunkSection;
|
||||
import net.minecraft.server.EnumCreatureType;
|
||||
import net.minecraft.server.IChunkProvider;
|
||||
import net.minecraft.server.IProgressUpdate;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.WorldGenStronghold;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
@@ -71,27 +62,14 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
if (xbtypes[sec] == null) {
|
||||
continue;
|
||||
}
|
||||
byte[] secBlkID = new byte[4096]; // Allocate blk ID bytes
|
||||
byte[] secExtBlkID = null; // Delay getting extended ID nibbles
|
||||
char[] secBlkID = new char[4096]; // Allocate blk ID bytes
|
||||
short[] bdata = xbtypes[sec];
|
||||
// Loop through data, 2 blocks at a time
|
||||
for (int i = 0, j = 0; i < bdata.length; i += 2, j++) {
|
||||
short b1 = bdata[i];
|
||||
short b2 = bdata[i + 1];
|
||||
byte extb = (byte) ((b1 >> 8) | ((b2 >> 4) & 0xF0));
|
||||
|
||||
secBlkID[i] = (byte) b1;
|
||||
secBlkID[(i + 1)] = (byte) b2;
|
||||
|
||||
if (extb != 0) { // If extended block ID data
|
||||
if (secExtBlkID == null) { // Allocate if needed
|
||||
secExtBlkID = new byte[2048];
|
||||
}
|
||||
secExtBlkID[j] = extb;
|
||||
}
|
||||
for (int i = 0; i < bdata.length; i++) {
|
||||
secBlkID[i] = (char) ((int)bdata[i] << 4);
|
||||
}
|
||||
// Build chunk section
|
||||
csect[sec] = new ChunkSection(sec << 4, true, secBlkID, secExtBlkID);
|
||||
csect[sec] = new ChunkSection(sec << 4, true, secBlkID);
|
||||
}
|
||||
}
|
||||
else { // Else check for byte-per-block section data
|
||||
@@ -107,7 +85,12 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
if (btypes[sec] == null) {
|
||||
continue;
|
||||
}
|
||||
csect[sec] = new ChunkSection(sec << 4, true, btypes[sec], null);
|
||||
|
||||
char[] secBlkID = new char[4096]; // Allocate block ID bytes
|
||||
for (int i = 0; i < secBlkID.length; i++) {
|
||||
secBlkID[i] = (char)(((int) btypes[sec][i]) << 4);
|
||||
}
|
||||
csect[sec] = new ChunkSection(sec << 4, true, secBlkID);
|
||||
}
|
||||
}
|
||||
else { // Else, fall back to pre 1.2 method
|
||||
@@ -124,7 +107,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
// Loop through sections
|
||||
for (int sec = 0; sec < scnt; sec++) {
|
||||
ChunkSection cs = null; // Add sections when needed
|
||||
byte[] csbytes = null;
|
||||
char[] csbytes = null;
|
||||
|
||||
for (int cy = 0; cy < 16; cy++) {
|
||||
int cyoff = cy | (sec << 4);
|
||||
@@ -140,7 +123,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
cs = csect[sec] = new ChunkSection(sec << 4, true);
|
||||
csbytes = cs.getIdArray();
|
||||
}
|
||||
csbytes[(cy << 8) | (cz << 4) | cx] = blk;
|
||||
csbytes[(cy << 8) | (cz << 4) | cx] = (char)((int)blk << 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +136,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
}
|
||||
}
|
||||
// Set biome grid
|
||||
byte[] biomeIndex = chunk.m();
|
||||
byte[] biomeIndex = chunk.getBiomeIndex();
|
||||
for (int i = 0; i < biomeIndex.length; i++) {
|
||||
biomeIndex[i] = (byte) (biomegrid.biome[i].id & 0xFF);
|
||||
}
|
||||
@@ -163,10 +146,20 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getChunkAt(BlockPosition blockPosition) {
|
||||
return getChunkAt(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
|
||||
}
|
||||
|
||||
public void getChunkAt(IChunkProvider icp, int i, int i1) {
|
||||
// Nothing!
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(IChunkProvider iChunkProvider, Chunk chunk, int i, int i1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean saveChunks(boolean bln, IProgressUpdate ipu) {
|
||||
return true;
|
||||
}
|
||||
@@ -206,14 +199,16 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
return generator.getDefaultPopulators(world);
|
||||
}
|
||||
|
||||
public List<?> getMobsFor(EnumCreatureType type, int x, int y, int z) {
|
||||
BiomeBase biomebase = world.getBiome(x, z);
|
||||
@Override
|
||||
public List<?> getMobsFor(EnumCreatureType type, BlockPosition position) {
|
||||
BiomeBase biomebase = world.getBiome(position);
|
||||
|
||||
return biomebase == null ? null : biomebase.getMobs(type);
|
||||
}
|
||||
|
||||
public ChunkPosition findNearestMapFeature(World world, String type, int x, int y, int z) {
|
||||
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, x, y, z) : null;
|
||||
@Override
|
||||
public BlockPosition findNearestMapFeature(World world, String type, BlockPosition position) {
|
||||
return "Stronghold".equals(type) && this.strongholdGen != null ? this.strongholdGen.getNearestGeneratedFeature(world, position) : null;
|
||||
}
|
||||
|
||||
public void recreateStructures(int i, int j) {}
|
||||
@@ -222,6 +217,11 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recreateStructures(Chunk chunk, int i, int i1) {
|
||||
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "CustomChunkGenerator";
|
||||
}
|
||||
|
||||
@@ -4,12 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.server.Chunk;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.EnumCreatureType;
|
||||
import net.minecraft.server.IChunkProvider;
|
||||
import net.minecraft.server.IProgressUpdate;
|
||||
import net.minecraft.server.World;
|
||||
import net.minecraft.server.*;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
@@ -21,66 +16,87 @@ public class NormalChunkGenerator extends InternalChunkGenerator {
|
||||
provider = world.worldProvider.getChunkProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] generate(org.bukkit.World world, Random random, int x, int z) {
|
||||
throw new UnsupportedOperationException("Not supported.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawn(org.bukkit.World world, int x, int z) {
|
||||
return ((CraftWorld) world).getHandle().worldProvider.canSpawn(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(org.bukkit.World world) {
|
||||
return new ArrayList<BlockPopulator>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(int i, int i1) {
|
||||
return provider.isChunkLoaded(i, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk getOrCreateChunk(int i, int i1) {
|
||||
return provider.getOrCreateChunk(i, i1);
|
||||
}
|
||||
|
||||
public Chunk getChunkAt(int i, int i1) {
|
||||
return provider.getChunkAt(i, i1);
|
||||
@Override
|
||||
public Chunk getChunkAt(BlockPosition blockPosition) {
|
||||
return provider.getChunkAt(blockPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getChunkAt(IChunkProvider icp, int i, int i1) {
|
||||
provider.getChunkAt(icp, i, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean a(IChunkProvider iChunkProvider, Chunk chunk, int i, int i1) {
|
||||
return provider.a(provider, chunk, i, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveChunks(boolean bln, IProgressUpdate ipu) {
|
||||
return provider.saveChunks(bln, ipu);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunks() {
|
||||
return provider.unloadChunks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSave() {
|
||||
return provider.canSave();
|
||||
}
|
||||
|
||||
public List<?> getMobsFor(EnumCreatureType ect, int i, int i1, int i2) {
|
||||
return provider.getMobsFor(ect, i, i1, i2);
|
||||
@Override
|
||||
public List<?> getMobsFor(EnumCreatureType ect, BlockPosition position) {
|
||||
return provider.getMobsFor(ect, position);
|
||||
}
|
||||
|
||||
public ChunkPosition findNearestMapFeature(World world, String string, int i, int i1, int i2) {
|
||||
return provider.findNearestMapFeature(world, string, i, i1, i2);
|
||||
}
|
||||
|
||||
public void recreateStructures(int i, int j) {
|
||||
provider.recreateStructures(i, j);
|
||||
@Override
|
||||
public BlockPosition findNearestMapFeature(World world, String string, BlockPosition position) {
|
||||
return provider.findNearestMapFeature(world, string, position);
|
||||
}
|
||||
|
||||
// n.m.s implementations always return 0. (The true implementation is in ChunkProviderServer)
|
||||
@Override
|
||||
public int getLoadedChunks() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recreateStructures(Chunk chunk, int i, int i1) {
|
||||
provider.recreateStructures(chunk, i, i1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "NormalWorldGenerator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c() {}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
@@ -76,7 +77,7 @@ public class CraftContainer extends Container {
|
||||
cachedTitle = view.getTitle();
|
||||
if (view.getPlayer() instanceof CraftPlayer) {
|
||||
CraftPlayer player = (CraftPlayer) view.getPlayer();
|
||||
int type = getNotchInventoryType(cachedType);
|
||||
String type = getNotchInventoryType(cachedType);
|
||||
IInventory top = ((CraftInventory)view.getTopInventory()).getInventory();
|
||||
IInventory bottom = ((CraftInventory)view.getBottomInventory()).getInventory();
|
||||
this.b.clear();
|
||||
@@ -85,44 +86,33 @@ public class CraftContainer extends Container {
|
||||
setupSlots(top, bottom);
|
||||
}
|
||||
int size = getSize();
|
||||
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, cachedTitle, size, true));
|
||||
player.getHandle().playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.windowId, type, new ChatComponentText(cachedTitle), size));
|
||||
player.updateInventory();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int getNotchInventoryType(InventoryType type) {
|
||||
int typeID;
|
||||
public static String getNotchInventoryType(InventoryType type) {
|
||||
switch(type) {
|
||||
case WORKBENCH:
|
||||
typeID = 1;
|
||||
break;
|
||||
return "minecraft:crafting_table";
|
||||
case FURNACE:
|
||||
typeID = 2;
|
||||
break;
|
||||
return "minecraft:furnace";
|
||||
case DISPENSER:
|
||||
typeID = 3;
|
||||
break;
|
||||
return "minecraft:dispenser";
|
||||
case ENCHANTING:
|
||||
typeID = 4;
|
||||
break;
|
||||
return "minecraft:enchanting_table";
|
||||
case BREWING:
|
||||
typeID = 5;
|
||||
break;
|
||||
return "minecraft:brewing_stand";
|
||||
case BEACON:
|
||||
typeID = 7;
|
||||
break;
|
||||
return "minecraft:beacon";
|
||||
case ANVIL:
|
||||
typeID = 8;
|
||||
break;
|
||||
return "minecraft:anvil";
|
||||
case HOPPER:
|
||||
typeID = 9;
|
||||
break;
|
||||
return "minecraft:hopper";
|
||||
default:
|
||||
typeID = 0;
|
||||
break;
|
||||
return "minecraft:chest";
|
||||
}
|
||||
return typeID;
|
||||
}
|
||||
|
||||
private void setupSlots(IInventory top, IInventory bottom) {
|
||||
|
||||
@@ -42,7 +42,7 @@ public class CraftInventory implements Inventory {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return getInventory().getInventoryName();
|
||||
return getInventory().getName();
|
||||
}
|
||||
|
||||
public ItemStack getItem(int index) {
|
||||
@@ -58,7 +58,6 @@ public class CraftInventory implements Inventory {
|
||||
for (int i = 0; i < size; i++) {
|
||||
items[i] = mcItems[i] == null ? null : CraftItemStack.asCraftMirror(mcItems[i]);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -421,7 +420,7 @@ public class CraftInventory implements Inventory {
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return inventory.getInventoryName();
|
||||
return inventory.getName();
|
||||
}
|
||||
|
||||
public InventoryType getType() {
|
||||
@@ -437,7 +436,7 @@ public class CraftInventory implements Inventory {
|
||||
} else if (inventory instanceof TileEntityFurnace) {
|
||||
return InventoryType.FURNACE;
|
||||
} else if (inventory instanceof ContainerEnchantTableInventory) {
|
||||
return InventoryType.ENCHANTING;
|
||||
return InventoryType.ENCHANTING;
|
||||
} else if (inventory instanceof TileEntityBrewingStand) {
|
||||
return InventoryType.BREWING;
|
||||
} else if (inventory instanceof CraftInventoryCustom.MinecraftInventory) {
|
||||
@@ -449,7 +448,7 @@ public class CraftInventory implements Inventory {
|
||||
} else if (inventory instanceof TileEntityBeacon) {
|
||||
return InventoryType.BEACON;
|
||||
} else if (inventory instanceof ContainerAnvilInventory) {
|
||||
return InventoryType.ANVIL;
|
||||
return InventoryType.ANVIL;
|
||||
} else if (inventory instanceof IHopper) {
|
||||
return InventoryType.HOPPER;
|
||||
} else {
|
||||
|
||||
@@ -55,7 +55,7 @@ public class CraftInventoryCrafting extends CraftInventory implements CraftingIn
|
||||
for (int j = 0; j < mcItems.length; j++) {
|
||||
items[i + j] = CraftItemStack.asCraftMirror(mcItems[j]);
|
||||
}
|
||||
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,9 @@ package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.ChatComponentText;
|
||||
|
||||
import net.minecraft.server.IChatBaseComponent;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@@ -106,10 +108,6 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||
}
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public int getMaxStackSize() {
|
||||
return maxStack;
|
||||
}
|
||||
@@ -143,21 +141,58 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||
public InventoryType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void closeContainer() {}
|
||||
|
||||
|
||||
public InventoryHolder getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void startOpen() {}
|
||||
|
||||
public boolean k_() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean b(int i, ItemStack itemstack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startOpen(EntityHuman entityHuman) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeContainer(EntityHuman entityHuman) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProperty(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(int i, int i1) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int g() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void l() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName() {
|
||||
return title != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChatBaseComponent getScoreboardDisplayName() {
|
||||
return new ChatComponentText(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import net.minecraft.server.ITileEntityContainer;
|
||||
import net.minecraft.server.ITileInventory;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.inventory.DoubleChestInventory;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -12,7 +14,7 @@ public class CraftInventoryDoubleChest extends CraftInventory implements DoubleC
|
||||
private final CraftInventory right;
|
||||
|
||||
public CraftInventoryDoubleChest(CraftInventory left, CraftInventory right) {
|
||||
super(new InventoryLargeChest("Large chest", left.getInventory(), right.getInventory()));
|
||||
super(new InventoryLargeChest("Large chest", (ITileInventory) left.getInventory(), (ITileInventory) right.getInventory()));
|
||||
this.left = left;
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@ public class CraftInventoryEnchanting extends CraftInventory implements Enchanti
|
||||
super(inventory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(ItemStack item) {
|
||||
setItem(0,item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem() {
|
||||
return getItem(0);
|
||||
}
|
||||
@@ -22,4 +24,14 @@ public class CraftInventoryEnchanting extends CraftInventory implements Enchanti
|
||||
public ContainerEnchantTableInventory getInventory() {
|
||||
return (ContainerEnchantTableInventory)inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecondary(ItemStack item) {
|
||||
setItem(1, item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getSecondary() {
|
||||
return getItem(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ public final class CraftItemFactory implements ItemFactory {
|
||||
return meta instanceof CraftMetaCharge ? meta : new CraftMetaCharge(meta);
|
||||
case ENCHANTED_BOOK:
|
||||
return meta instanceof CraftMetaEnchantedBook ? meta : new CraftMetaEnchantedBook(meta);
|
||||
case BANNER:
|
||||
return meta instanceof CraftMetaBanner ? meta : new CraftMetaBanner(meta);
|
||||
default:
|
||||
return new CraftMetaItem(meta);
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
NBTTagList list = getEnchantmentList(handle);
|
||||
if (list == null) {
|
||||
list = new NBTTagList();
|
||||
handle.tag.set(ENCHANTMENTS.NBT, list);
|
||||
handle.getTag().set(ENCHANTMENTS.NBT, list);
|
||||
}
|
||||
int size = list.size();
|
||||
|
||||
@@ -208,7 +208,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (item.tag == null) {
|
||||
if (item.getTag() == null) {
|
||||
item.setTag(new NBTTagCompound());
|
||||
}
|
||||
|
||||
@@ -255,9 +255,9 @@ public final class CraftItemStack extends ItemStack {
|
||||
return 0;
|
||||
}
|
||||
if (size == 1) {
|
||||
handle.tag.remove(ENCHANTMENTS.NBT);
|
||||
if (handle.tag.isEmpty()) {
|
||||
handle.tag = null;
|
||||
handle.getTag().remove(ENCHANTMENTS.NBT);
|
||||
if (handle.getTag().isEmpty()) {
|
||||
handle.setTag(null);
|
||||
}
|
||||
return level;
|
||||
}
|
||||
@@ -269,7 +269,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
listCopy.add(list.get(i));
|
||||
}
|
||||
}
|
||||
handle.tag.set(ENCHANTMENTS.NBT, listCopy);
|
||||
handle.getTag().set(ENCHANTMENTS.NBT, listCopy);
|
||||
|
||||
return level;
|
||||
}
|
||||
@@ -323,26 +323,28 @@ public final class CraftItemStack extends ItemStack {
|
||||
switch (getType(item)) {
|
||||
case WRITTEN_BOOK:
|
||||
case BOOK_AND_QUILL:
|
||||
return new CraftMetaBook(item.tag);
|
||||
return new CraftMetaBook(item.getTag());
|
||||
case SKULL_ITEM:
|
||||
return new CraftMetaSkull(item.tag);
|
||||
return new CraftMetaSkull(item.getTag());
|
||||
case LEATHER_HELMET:
|
||||
case LEATHER_CHESTPLATE:
|
||||
case LEATHER_LEGGINGS:
|
||||
case LEATHER_BOOTS:
|
||||
return new CraftMetaLeatherArmor(item.tag);
|
||||
return new CraftMetaLeatherArmor(item.getTag());
|
||||
case POTION:
|
||||
return new CraftMetaPotion(item.tag);
|
||||
return new CraftMetaPotion(item.getTag());
|
||||
case MAP:
|
||||
return new CraftMetaMap(item.tag);
|
||||
return new CraftMetaMap(item.getTag());
|
||||
case FIREWORK:
|
||||
return new CraftMetaFirework(item.tag);
|
||||
return new CraftMetaFirework(item.getTag());
|
||||
case FIREWORK_CHARGE:
|
||||
return new CraftMetaCharge(item.tag);
|
||||
return new CraftMetaCharge(item.getTag());
|
||||
case ENCHANTED_BOOK:
|
||||
return new CraftMetaEnchantedBook(item.tag);
|
||||
return new CraftMetaEnchantedBook(item.getTag());
|
||||
case BANNER:
|
||||
return new CraftMetaBanner(item.getTag());
|
||||
default:
|
||||
return new CraftMetaItem(item.tag);
|
||||
return new CraftMetaItem(item.getTag());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +363,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
return false;
|
||||
}
|
||||
if (CraftItemFactory.instance().equals(itemMeta, null)) {
|
||||
item.tag = null;
|
||||
item.setTag(null);
|
||||
return true;
|
||||
}
|
||||
if (!CraftItemFactory.instance().isApplicable(itemMeta, getType(item))) {
|
||||
@@ -397,7 +399,7 @@ public final class CraftItemStack extends ItemStack {
|
||||
if (!(that.getTypeId() == getTypeId() && getDurability() == that.getDurability())) {
|
||||
return false;
|
||||
}
|
||||
return hasItemMeta() ? that.hasItemMeta() && handle.tag.equals(that.handle.tag) : !that.hasItemMeta();
|
||||
return hasItemMeta() ? that.hasItemMeta() && handle.getTag().equals(that.handle.getTag()) : !that.hasItemMeta();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,6 +408,6 @@ public final class CraftItemStack extends ItemStack {
|
||||
}
|
||||
|
||||
static boolean hasItemMeta(net.minecraft.server.ItemStack item) {
|
||||
return !(item == null || item.tag == null || item.tag.isEmpty());
|
||||
return !(item == null || item.getTag() == null || item.getTag().isEmpty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
package org.bukkit.craftbukkit.inventory;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.NBTTagList;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
|
||||
@DelegateDeserialization(CraftMetaItem.SerializableMeta.class)
|
||||
public class CraftMetaBanner extends CraftMetaItem implements BannerMeta {
|
||||
|
||||
static final ItemMetaKey BASE = new ItemMetaKey("Base", "base-color");
|
||||
static final ItemMetaKey PATTERNS = new ItemMetaKey("Patterns", "patterns");
|
||||
static final ItemMetaKey COLOR = new ItemMetaKey("Color", "color");
|
||||
static final ItemMetaKey PATTERN = new ItemMetaKey("Pattern", "pattern");
|
||||
|
||||
private DyeColor base;
|
||||
private List<Pattern> patterns = new ArrayList<Pattern>();
|
||||
|
||||
CraftMetaBanner(CraftMetaItem meta) {
|
||||
super(meta);
|
||||
|
||||
if (!(meta instanceof CraftMetaBanner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CraftMetaBanner banner = (CraftMetaBanner) meta;
|
||||
base = banner.base;
|
||||
patterns = new ArrayList<Pattern>(banner.patterns);
|
||||
}
|
||||
|
||||
CraftMetaBanner(NBTTagCompound tag) {
|
||||
super(tag);
|
||||
|
||||
if (!tag.hasKey("BlockEntityTag")) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTTagCompound entityTag = tag.getCompound("BlockEntityTag");
|
||||
|
||||
base = entityTag.hasKey(BASE.NBT) ? DyeColor.getByDyeData((byte) entityTag.getInt(BASE.NBT)) : null;
|
||||
|
||||
if (entityTag.hasKey(PATTERNS.NBT)) {
|
||||
NBTTagList patterns = entityTag.getList(PATTERNS.NBT, 10);
|
||||
for (int i = 0; i < patterns.size(); i++) {
|
||||
NBTTagCompound p = (NBTTagCompound) patterns.get(i);
|
||||
this.patterns.add(new Pattern(DyeColor.getByDyeData((byte) p.getInt(COLOR.NBT)), PatternType.getByIdentifier(p.getString(PATTERN.NBT))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CraftMetaBanner(Map<String, Object> map) {
|
||||
super(map);
|
||||
|
||||
base = SerializableMeta.getObject(DyeColor.class, map, BASE.BUKKIT, true);
|
||||
|
||||
Iterable<?> rawPatternList = SerializableMeta.getObject(Iterable.class, map, PATTERNS.BUKKIT, true);
|
||||
if (rawPatternList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Object obj : rawPatternList) {
|
||||
if (!(obj instanceof Pattern)) {
|
||||
throw new IllegalArgumentException("Object in pattern list is not valid. " + obj.getClass());
|
||||
}
|
||||
addPattern((Pattern) obj);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
void applyToItem(NBTTagCompound tag) {
|
||||
super.applyToItem(tag);
|
||||
|
||||
NBTTagCompound entityTag = new NBTTagCompound();
|
||||
if (base != null) {
|
||||
entityTag.setInt(BASE.NBT, base.getDyeData());
|
||||
}
|
||||
|
||||
NBTTagList newPatterns = new NBTTagList();
|
||||
|
||||
for (Pattern p : patterns) {
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
compound.setInt(COLOR.NBT, p.getColor().getDyeData());
|
||||
compound.setString(PATTERN.NBT, p.getPattern().getIdentifier());
|
||||
newPatterns.add(compound);
|
||||
}
|
||||
entityTag.set(PATTERNS.NBT, newPatterns);
|
||||
|
||||
tag.set("BlockEntityTag", entityTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DyeColor getBaseColor() {
|
||||
return base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBaseColor(DyeColor color) {
|
||||
base = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pattern> getPatterns() {
|
||||
return new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPatterns(List<Pattern> patterns) {
|
||||
this.patterns = new ArrayList<Pattern>(patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPattern(Pattern pattern) {
|
||||
patterns.add(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern getPattern(int i) {
|
||||
return patterns.get(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pattern removePattern(int i) {
|
||||
return patterns.remove(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPattern(int i, Pattern pattern) {
|
||||
patterns.set(i, pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int numberOfPatterns() {
|
||||
return patterns.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
ImmutableMap.Builder<String, Object> serialize(ImmutableMap.Builder<String, Object> builder) {
|
||||
super.serialize(builder);
|
||||
|
||||
builder.put(BASE.BUKKIT, base);
|
||||
builder.put(PATTERNS.BUKKIT, ImmutableList.copyOf(patterns));
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
int applyHash() {
|
||||
final int original;
|
||||
int hash = original = super.applyHash();
|
||||
if (base != null) {
|
||||
hash = 31 * hash + base.hashCode();
|
||||
}
|
||||
if (!patterns.isEmpty()) {
|
||||
hash = 31 * hash + patterns.hashCode();
|
||||
}
|
||||
return original != hash ? CraftMetaBanner.class.hashCode() ^ hash : hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsCommon(CraftMetaItem meta) {
|
||||
if (!super.equalsCommon(meta)) {
|
||||
return false;
|
||||
}
|
||||
if (meta instanceof CraftMetaBanner) {
|
||||
CraftMetaBanner that = (CraftMetaBanner) meta;
|
||||
|
||||
return base == that.base && patterns.equals(that.patterns);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean notUncommon(CraftMetaItem meta) {
|
||||
return super.notUncommon(meta) && (meta instanceof CraftMetaBanner || (patterns.isEmpty() && base == null));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
boolean isEmpty() {
|
||||
return super.isEmpty() && patterns.isEmpty() && base == null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
boolean applicableTo(Material type) {
|
||||
return type == Material.BANNER;
|
||||
}
|
||||
}
|
||||
@@ -16,18 +16,25 @@ import org.bukkit.inventory.meta.BookMeta;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import net.minecraft.server.ChatSerializer;
|
||||
import net.minecraft.server.NBTTagString;
|
||||
import org.bukkit.craftbukkit.util.CraftChatMessage;
|
||||
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
static final ItemMetaKey BOOK_TITLE = new ItemMetaKey("title");
|
||||
static final ItemMetaKey BOOK_AUTHOR = new ItemMetaKey("author");
|
||||
static final ItemMetaKey BOOK_PAGES = new ItemMetaKey("pages");
|
||||
static final ItemMetaKey RESOLVED = new ItemMetaKey("resolved");
|
||||
static final ItemMetaKey GENERATION = new ItemMetaKey("generation");
|
||||
static final int MAX_PAGE_LENGTH = 256;
|
||||
static final int MAX_TITLE_LENGTH = 0xffff;
|
||||
|
||||
private String title;
|
||||
private String author;
|
||||
private List<String> pages = new ArrayList<String>();
|
||||
private Boolean resolved;
|
||||
private Integer generation;
|
||||
|
||||
CraftMetaBook(CraftMetaItem meta) {
|
||||
super(meta);
|
||||
@@ -39,6 +46,8 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
this.title = bookMeta.title;
|
||||
this.author = bookMeta.author;
|
||||
pages.addAll(bookMeta.pages);
|
||||
this.resolved = bookMeta.resolved;
|
||||
this.generation = bookMeta.generation;
|
||||
}
|
||||
|
||||
CraftMetaBook(NBTTagCompound tag) {
|
||||
@@ -51,6 +60,14 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
if (tag.hasKey(BOOK_AUTHOR.NBT)) {
|
||||
this.author = tag.getString(BOOK_AUTHOR.NBT);
|
||||
}
|
||||
|
||||
if (tag.hasKey(RESOLVED.NBT)) {
|
||||
resolved = tag.getBoolean(RESOLVED.NBT);
|
||||
}
|
||||
|
||||
if (tag.hasKey(GENERATION.NBT)) {
|
||||
generation = tag.getInt(GENERATION.NBT);
|
||||
}
|
||||
|
||||
if (tag.hasKey(BOOK_PAGES.NBT)) {
|
||||
NBTTagList pages = tag.getList(BOOK_PAGES.NBT, 8);
|
||||
@@ -58,6 +75,9 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
|
||||
for (int i = 0; i < pages.size(); i++) {
|
||||
String page = pages.getString(i);
|
||||
if (resolved != null && resolved) {
|
||||
page = CraftChatMessage.fromComponent(ChatSerializer.a(page));
|
||||
}
|
||||
pageArray[i] = page;
|
||||
}
|
||||
|
||||
@@ -74,6 +94,9 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
|
||||
Iterable<?> pages = SerializableMeta.getObject(Iterable.class, map, BOOK_PAGES.BUKKIT, true);
|
||||
CraftMetaItem.safelyAdd(pages, this.pages, MAX_PAGE_LENGTH);
|
||||
|
||||
resolved = SerializableMeta.getObject(Boolean.class, map, RESOLVED.BUKKIT, true);
|
||||
generation = SerializableMeta.getObject(Integer.class, map, GENERATION.BUKKIT, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +112,25 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
}
|
||||
|
||||
if (hasPages()) {
|
||||
itemData.set(BOOK_PAGES.NBT, createStringList(pages));
|
||||
NBTTagList list = new NBTTagList();
|
||||
for (String page : pages) {
|
||||
if (resolved != null && resolved) {
|
||||
list.add(new NBTTagString(
|
||||
ChatSerializer.a(CraftChatMessage.fromString(page, true)[0])
|
||||
));
|
||||
} else {
|
||||
list.add(new NBTTagString(page));
|
||||
}
|
||||
}
|
||||
itemData.set(BOOK_PAGES.NBT, list);
|
||||
}
|
||||
|
||||
if (resolved != null) {
|
||||
itemData.setBoolean(RESOLVED.NBT, resolved);
|
||||
}
|
||||
|
||||
if (generation != null) {
|
||||
itemData.setInt(GENERATION.NBT, generation);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,6 +296,14 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta {
|
||||
if (hasPages()) {
|
||||
builder.put(BOOK_PAGES.BUKKIT, pages);
|
||||
}
|
||||
|
||||
if (resolved != null) {
|
||||
builder.put(RESOLVED.BUKKIT, resolved);
|
||||
}
|
||||
|
||||
if (generation != null) {
|
||||
builder.put(GENERATION.BUKKIT, generation);
|
||||
}
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta {
|
||||
|
||||
setEffect(SerializableMeta.getObject(FireworkEffect.class, map, EXPLOSION.BUKKIT, true));
|
||||
}
|
||||
|
||||
|
||||
CraftMetaCharge(NBTTagCompound tag) {
|
||||
super(tag);
|
||||
|
||||
@@ -40,14 +40,17 @@ class CraftMetaCharge extends CraftMetaItem implements FireworkEffectMeta {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEffect(FireworkEffect effect) {
|
||||
this.effect = effect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEffect() {
|
||||
return effect != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FireworkEffect getEffect() {
|
||||
return effect;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ package org.bukkit.craftbukkit.inventory;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.GameProfileSerializer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
@@ -13,6 +11,7 @@ import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.google.common.collect.ImmutableMap.Builder;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
@@ -37,7 +37,7 @@ public class CraftMapCanvas implements MapCanvas {
|
||||
return;
|
||||
if (buffer[y * 128 + x] != color) {
|
||||
buffer[y * 128 + x] = color;
|
||||
mapView.worldMap.flagDirty(x, y, y);
|
||||
mapView.worldMap.flagDirty(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.bukkit.craftbukkit.map;
|
||||
|
||||
import net.minecraft.server.WorldMap;
|
||||
import net.minecraft.server.WorldMapDecoration;
|
||||
import net.minecraft.server.MapIcon;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -41,8 +41,9 @@ public class CraftMapRenderer extends MapRenderer {
|
||||
continue;
|
||||
}
|
||||
|
||||
WorldMapDecoration decoration = (WorldMapDecoration) worldMap.decorations.get(key);
|
||||
cursors.addCursor(decoration.locX, decoration.locY, (byte) (decoration.rotation & 15), decoration.type);
|
||||
|
||||
MapIcon decoration = (MapIcon) worldMap.decorations.get(key);
|
||||
cursors.addCursor(decoration.getX(), decoration.getY(), (byte) (decoration.getRotation() & 15), decoration.getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ import net.minecraft.server.EntitySmallFireball;
|
||||
import net.minecraft.server.EntitySnowball;
|
||||
import net.minecraft.server.EntityThrownExpBottle;
|
||||
import net.minecraft.server.EntityWitherSkull;
|
||||
import net.minecraft.server.EnumFacing;
|
||||
import net.minecraft.server.EnumDirection;
|
||||
import net.minecraft.server.IPosition;
|
||||
import net.minecraft.server.IProjectile;
|
||||
import net.minecraft.server.MathHelper;
|
||||
@@ -48,7 +48,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return dispenserBlock.getWorld().getWorld().getBlockAt(dispenserBlock.x, dispenserBlock.y, dispenserBlock.z);
|
||||
return dispenserBlock.getWorld().getWorld().getBlockAt(dispenserBlock.getPosition().getX(), dispenserBlock.getPosition().getY(), dispenserBlock.getPosition().getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,10 +60,10 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> projectile, Vector velocity) {
|
||||
Validate.isTrue(getBlock().getType() == Material.DISPENSER, "Block is no longer dispenser");
|
||||
// Copied from BlockDispenser.dispense()
|
||||
SourceBlock isourceblock = new SourceBlock(dispenserBlock.getWorld(), dispenserBlock.x, dispenserBlock.y, dispenserBlock.z);
|
||||
SourceBlock isourceblock = new SourceBlock(dispenserBlock.getWorld(), dispenserBlock.getPosition());
|
||||
// Copied from DispenseBehaviorProjectile
|
||||
IPosition iposition = BlockDispenser.a(isourceblock);
|
||||
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
|
||||
EnumDirection enumdirection = BlockDispenser.b(isourceblock.f());
|
||||
net.minecraft.server.World world = dispenserBlock.getWorld();
|
||||
net.minecraft.server.Entity launch = null;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
} else if (Egg.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityEgg(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
} else if (EnderPearl.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityEnderPearl(world);
|
||||
launch = new EntityEnderPearl(world, null);
|
||||
launch.setPosition(iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
} else if (ThrownExpBottle.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntityThrownExpBottle(world, iposition.getX(), iposition.getY(), iposition.getZ());
|
||||
@@ -83,13 +83,13 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
((EntityArrow) launch).fromPlayer = 1;
|
||||
((EntityArrow) launch).projectileSource = this;
|
||||
} else if (Fireball.class.isAssignableFrom(projectile)) {
|
||||
double d0 = iposition.getX() + (double) ((float) enumfacing.getAdjacentX() * 0.3F);
|
||||
double d1 = iposition.getY() + (double) ((float) enumfacing.getAdjacentY() * 0.3F);
|
||||
double d2 = iposition.getZ() + (double) ((float) enumfacing.getAdjacentZ() * 0.3F);
|
||||
double d0 = iposition.getX() + (double) ((float) enumdirection.getAdjacentX() * 0.3F);
|
||||
double d1 = iposition.getY() + (double) ((float) enumdirection.getAdjacentY() * 0.3F);
|
||||
double d2 = iposition.getZ() + (double) ((float) enumdirection.getAdjacentZ() * 0.3F);
|
||||
Random random = world.random;
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumfacing.getAdjacentZ();
|
||||
double d3 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentX();
|
||||
double d4 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentY();
|
||||
double d5 = random.nextGaussian() * 0.05D + (double) enumdirection.getAdjacentZ();
|
||||
|
||||
if (SmallFireball.class.isAssignableFrom(projectile)) {
|
||||
launch = new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5);
|
||||
@@ -129,7 +129,7 @@ public class CraftBlockProjectileSource implements BlockProjectileSource {
|
||||
b *= 1.25F;
|
||||
}
|
||||
// Copied from DispenseBehaviorProjectile
|
||||
((IProjectile) launch).shoot((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ(), b, a);
|
||||
((IProjectile) launch).shoot((double) enumdirection.getAdjacentX(), (double) ((float) enumdirection.getAdjacentY() + 0.1F), (double) enumdirection.getAdjacentZ(), b, a);
|
||||
}
|
||||
|
||||
if (velocity != null) {
|
||||
|
||||
@@ -17,9 +17,6 @@ final class CraftCriteria {
|
||||
for (Map.Entry<?, ?> entry : ((Map<?,?> ) IScoreboardCriteria.criteria).entrySet()) {
|
||||
String name = entry.getKey().toString();
|
||||
IScoreboardCriteria criteria = (IScoreboardCriteria) entry.getValue();
|
||||
if (!criteria.getName().equals(name)) {
|
||||
throw new AssertionError("Unexpected entry " + name + " to criteria " + criteria + "(" + criteria.getName() + ")");
|
||||
}
|
||||
|
||||
defaults.put(name, new CraftCriteria(criteria));
|
||||
}
|
||||
|
||||
@@ -97,13 +97,17 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
|
||||
public void resetScores(OfflinePlayer player) throws IllegalArgumentException {
|
||||
Validate.notNull(player, "OfflinePlayer cannot be null");
|
||||
|
||||
board.resetPlayerScores(player.getName());
|
||||
for (CraftObjective objective : objectives.values()) {
|
||||
board.resetPlayerScores(player.getName(), objective.getHandle()); // PAIL: check me
|
||||
}
|
||||
}
|
||||
|
||||
public void resetScores(String entry) throws IllegalArgumentException {
|
||||
Validate.notNull(entry, "Entry cannot be null");
|
||||
|
||||
board.resetPlayerScores(entry);
|
||||
for (CraftObjective objective : objectives.values()) {
|
||||
board.resetPlayerScores(entry, objective.getHandle()); // PAIL: check me
|
||||
}
|
||||
}
|
||||
|
||||
public Team getPlayerTeam(OfflinePlayer player) throws IllegalArgumentException {
|
||||
|
||||
@@ -1,128 +0,0 @@
|
||||
package org.bukkit.craftbukkit.updater;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class ArtifactDetails {
|
||||
private String brokenReason;
|
||||
private boolean isBroken;
|
||||
private int buildNumber;
|
||||
private String htmlUrl;
|
||||
private String version;
|
||||
private Date created;
|
||||
private FileDetails file;
|
||||
private ChannelDetails channel;
|
||||
|
||||
public ChannelDetails getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public void setChannel(ChannelDetails channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public boolean isIsBroken() {
|
||||
return isBroken;
|
||||
}
|
||||
|
||||
public void setIsBroken(boolean isBroken) {
|
||||
this.isBroken = isBroken;
|
||||
}
|
||||
|
||||
public FileDetails getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(FileDetails file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getBrokenReason() {
|
||||
return brokenReason;
|
||||
}
|
||||
|
||||
public void setBrokenReason(String brokenReason) {
|
||||
this.brokenReason = brokenReason;
|
||||
}
|
||||
|
||||
public int getBuildNumber() {
|
||||
return buildNumber;
|
||||
}
|
||||
|
||||
public void setBuildNumber(int buildNumber) {
|
||||
this.buildNumber = buildNumber;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getHtmlUrl() {
|
||||
return htmlUrl;
|
||||
}
|
||||
|
||||
public void setHtmlUrl(String htmlUrl) {
|
||||
this.htmlUrl = htmlUrl;
|
||||
}
|
||||
|
||||
public boolean isBroken() {
|
||||
return isBroken;
|
||||
}
|
||||
|
||||
public void setBroken(boolean isBroken) {
|
||||
this.isBroken = isBroken;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public static class FileDetails {
|
||||
private String url;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ChannelDetails {
|
||||
private String name;
|
||||
private String slug;
|
||||
private int priority;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public String getSlug() {
|
||||
return slug;
|
||||
}
|
||||
|
||||
public void setSlug(String slug) {
|
||||
this.slug = slug;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package org.bukkit.craftbukkit.updater;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class AutoUpdater {
|
||||
public static final String WARN_CONSOLE = "warn-console";
|
||||
public static final String WARN_OPERATORS = "warn-ops";
|
||||
|
||||
private final BukkitDLUpdaterService service;
|
||||
private final List<String> onUpdate = new ArrayList<String>();
|
||||
private final List<String> onBroken = new ArrayList<String>();
|
||||
private final Logger log;
|
||||
private final String channel;
|
||||
private boolean enabled;
|
||||
private ArtifactDetails current = null;
|
||||
private ArtifactDetails latest = null;
|
||||
private boolean suggestChannels = true;
|
||||
|
||||
public AutoUpdater(BukkitDLUpdaterService service, Logger log, String channel) {
|
||||
this.service = service;
|
||||
this.log = log;
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
public String getChannel() {
|
||||
return channel;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean isEnabled) {
|
||||
this.enabled = isEnabled;
|
||||
}
|
||||
|
||||
public boolean shouldSuggestChannels() {
|
||||
return suggestChannels;
|
||||
}
|
||||
|
||||
public void setSuggestChannels(boolean suggestChannels) {
|
||||
this.suggestChannels = suggestChannels;
|
||||
}
|
||||
|
||||
public List<String> getOnBroken() {
|
||||
return onBroken;
|
||||
}
|
||||
|
||||
public List<String> getOnUpdate() {
|
||||
return onUpdate;
|
||||
}
|
||||
|
||||
public boolean isUpdateAvailable() {
|
||||
if ((latest == null) || (current == null) || (!isEnabled())) {
|
||||
return false;
|
||||
} else {
|
||||
return latest.getCreated().after(current.getCreated());
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactDetails getCurrent() {
|
||||
return current;
|
||||
}
|
||||
|
||||
public ArtifactDetails getLatest() {
|
||||
return latest;
|
||||
}
|
||||
|
||||
public void check(final String currentSlug) {
|
||||
if (!isEnabled()) return;
|
||||
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
current = service.getArtifact(currentSlug, "information about this CraftBukkit version; perhaps you are running a custom one?");
|
||||
latest = service.getArtifact("latest-" + channel, "latest artifact information");
|
||||
|
||||
if (isUpdateAvailable()) {
|
||||
if ((current.isBroken()) && (onBroken.contains(WARN_CONSOLE))) {
|
||||
log.severe("----- Bukkit Auto Updater -----");
|
||||
log.severe("Your version of CraftBukkit is known to be broken. It is strongly advised that you update to a more recent version ASAP.");
|
||||
log.severe("Known issues with your version:");
|
||||
|
||||
for (String line : current.getBrokenReason().split("\n")) {
|
||||
log.severe("> " + line);
|
||||
}
|
||||
|
||||
log.severe("Newer version " + latest.getVersion() + " (build #" + latest.getBuildNumber() + ") was released on " + latest.getCreated() + ".");
|
||||
log.severe("Details: " + latest.getHtmlUrl());
|
||||
log.severe("Download: " + latest.getFile().getUrl());
|
||||
log.severe("----- ------------------- -----");
|
||||
} else if (onUpdate.contains(WARN_CONSOLE)) {
|
||||
log.warning("----- Bukkit Auto Updater -----");
|
||||
log.warning("Your version of CraftBukkit is out of date. Version " + latest.getVersion() + " (build #" + latest.getBuildNumber() + ") was released on " + latest.getCreated() + ".");
|
||||
log.warning("Details: " + latest.getHtmlUrl());
|
||||
log.warning("Download: " + latest.getFile().getUrl());
|
||||
log.warning("----- ------------------- -----");
|
||||
}
|
||||
} else if ((current != null) && (current.isBroken()) && (onBroken.contains(WARN_CONSOLE))) {
|
||||
log.severe("----- Bukkit Auto Updater -----");
|
||||
log.severe("Your version of CraftBukkit is known to be broken. It is strongly advised that you update to a more recent version ASAP.");
|
||||
log.severe("Known issues with your version:");
|
||||
|
||||
for (String line : current.getBrokenReason().split("\n")) {
|
||||
log.severe("> " + line);
|
||||
}
|
||||
|
||||
log.severe("Unfortunately, there is not yet a newer version suitable for your server. We would advise you wait an hour or two, or try out a dev build.");
|
||||
log.severe("----- ------------------- -----");
|
||||
} else if ((current != null) && (shouldSuggestChannels())) {
|
||||
ArtifactDetails.ChannelDetails prefChan = service.getChannel(channel, "preferred channel details");
|
||||
|
||||
if ((prefChan != null) && (current.getChannel().getPriority() < prefChan.getPriority())) {
|
||||
log.info("----- Bukkit Auto Updater -----");
|
||||
log.info("It appears that you're running a " + current.getChannel().getName() + ", when you've specified in bukkit.yml that you prefer to run " + prefChan.getName() + "s.");
|
||||
log.info("If you would like to be kept informed about new " + current.getChannel().getName() + " releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to '" + current.getChannel().getSlug() + "'.");
|
||||
log.info("With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.");
|
||||
log.info("If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.");
|
||||
log.info("----- ------------------- -----");
|
||||
}
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package org.bukkit.craftbukkit.updater;
|
||||
|
||||
import com.google.gson.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
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/";
|
||||
private static final DateDeserializer dateDeserializer = new DateDeserializer();
|
||||
private final String host;
|
||||
|
||||
public BukkitDLUpdaterService(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public ArtifactDetails getArtifact(String slug, String name) {
|
||||
try {
|
||||
return fetchArtifact(slug);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getUserAgent() {
|
||||
return "CraftBukkit/" + BukkitDLUpdaterService.class.getPackage().getImplementationVersion() + "/" + System.getProperty("java.version");
|
||||
}
|
||||
|
||||
public ArtifactDetails fetchArtifact(String slug) throws IOException {
|
||||
URL url = new URL("http", host, API_PREFIX_ARTIFACT + slug + "/");
|
||||
InputStreamReader reader = null;
|
||||
|
||||
try {
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", getUserAgent());
|
||||
reader = new InputStreamReader(connection.getInputStream());
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
|
||||
return gson.fromJson(reader, ArtifactDetails.class);
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArtifactDetails.ChannelDetails getChannel(String slug, String name) {
|
||||
try {
|
||||
return fetchChannel(slug);
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not get " + name + ": " + ex.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArtifactDetails.ChannelDetails fetchChannel(String slug) throws IOException {
|
||||
URL url = new URL("http", host, API_PREFIX_CHANNEL + slug + "/");
|
||||
InputStreamReader reader = null;
|
||||
|
||||
try {
|
||||
URLConnection connection = url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", getUserAgent());
|
||||
reader = new InputStreamReader(connection.getInputStream());
|
||||
Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, dateDeserializer).setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES).create();
|
||||
|
||||
return gson.fromJson(reader, ArtifactDetails.ChannelDetails.class);
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class DateDeserializer implements JsonDeserializer<Date> {
|
||||
private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public Date deserialize(JsonElement je, Type type, JsonDeserializationContext jdc) throws JsonParseException {
|
||||
try {
|
||||
return format.parse(je.getAsString());
|
||||
} catch (ParseException ex) {
|
||||
throw new JsonParseException("Date is not formatted correctly", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.BlockPosition;
|
||||
import net.minecraft.server.IBlockData;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
@@ -35,6 +37,11 @@ public class BlockStateListPopulator {
|
||||
|
||||
public void setTypeUpdate(int x, int y, int z, Block block) {
|
||||
this.setType(x, y, z, block);
|
||||
}
|
||||
|
||||
public void setTypeUpdate(BlockPosition position, IBlockData data) {
|
||||
setTypeAndData(position.getX(), position.getY(), position.getZ(), data.getBlock(), data.getBlock().toLegacyData(data), 0);
|
||||
|
||||
}
|
||||
|
||||
public void setType(int x, int y, int z, Block block) {
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class CraftChatMessage {
|
||||
static {
|
||||
Builder<Character, EnumChatFormat> builder = ImmutableMap.builder();
|
||||
for (EnumChatFormat format : EnumChatFormat.values()) {
|
||||
builder.put(Character.toLowerCase(format.getChar()), format);
|
||||
builder.put(Character.toLowerCase(format.toString().charAt(1)), format);
|
||||
}
|
||||
formatMap = builder.build();
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public final class CraftChatMessage {
|
||||
private int currentIndex;
|
||||
private final String message;
|
||||
|
||||
private StringMessage(String message) {
|
||||
private StringMessage(String message, boolean keepNewlines) {
|
||||
this.message = message;
|
||||
if (message == null) {
|
||||
output = new IChatBaseComponent[] { currentChatComponent };
|
||||
@@ -71,7 +71,7 @@ public final class CraftChatMessage {
|
||||
case UNDERLINE:
|
||||
modifier.setUnderline(Boolean.TRUE);
|
||||
break;
|
||||
case RANDOM:
|
||||
case OBFUSCATED:
|
||||
modifier.setRandom(Boolean.TRUE);
|
||||
break;
|
||||
default:
|
||||
@@ -82,7 +82,11 @@ public final class CraftChatMessage {
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
currentChatComponent = null;
|
||||
if (keepNewlines) {
|
||||
currentChatComponent.addSibling(new ChatComponentText("\n"));
|
||||
} else {
|
||||
currentChatComponent = null;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
modifier.setChatClickable(new ChatClickable(EnumClickAction.OPEN_URL, match));
|
||||
@@ -119,7 +123,38 @@ public final class CraftChatMessage {
|
||||
}
|
||||
|
||||
public static IChatBaseComponent[] fromString(String message) {
|
||||
return new StringMessage(message).getOutput();
|
||||
return fromString(message, false);
|
||||
}
|
||||
|
||||
public static IChatBaseComponent[] fromString(String message, boolean keepNewlines) {
|
||||
return new StringMessage(message, keepNewlines).getOutput();
|
||||
}
|
||||
|
||||
public static String fromComponent(IChatBaseComponent component) {
|
||||
if (component == null) return "";
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
for (IChatBaseComponent c : (Iterable<IChatBaseComponent>) component) {
|
||||
ChatModifier modi = c.getChatModifier();
|
||||
out.append(modi.getColor() == null ? EnumChatFormat.BLACK : modi.getColor());
|
||||
if (modi.isBold()) {
|
||||
out.append(EnumChatFormat.BOLD);
|
||||
}
|
||||
if (modi.isItalic()) {
|
||||
out.append(EnumChatFormat.ITALIC);
|
||||
}
|
||||
if (modi.isUnderlined()) {
|
||||
out.append(EnumChatFormat.UNDERLINE);
|
||||
}
|
||||
if (modi.isStrikethrough()) {
|
||||
out.append(EnumChatFormat.STRIKETHROUGH);
|
||||
}
|
||||
if (modi.isRandom()) {
|
||||
out.append(EnumChatFormat.OBFUSCATED);
|
||||
}
|
||||
out.append(c.getText());
|
||||
}
|
||||
return out.toString();
|
||||
}
|
||||
|
||||
private CraftChatMessage() {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.server.Block;
|
||||
import net.minecraft.server.Blocks;
|
||||
import net.minecraft.server.Item;
|
||||
import net.minecraft.server.MinecraftKey;
|
||||
import net.minecraft.server.MojangsonParser;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.StatisticList;
|
||||
@@ -88,12 +91,16 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
|
||||
@Override
|
||||
public Material getMaterialFromInternalName(String name) {
|
||||
return getMaterial((Item) Item.REGISTRY.get(name));
|
||||
return getMaterial((Item) Item.REGISTRY.get(new MinecraftKey(name)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompleteInternalMaterialName(String token, List<String> completions) {
|
||||
return StringUtil.copyPartialMatches(token, Item.REGISTRY.keySet(), completions);
|
||||
ArrayList<String> results = Lists.newArrayList();
|
||||
for (MinecraftKey key : (Set<MinecraftKey>)Item.REGISTRY.keySet()) {
|
||||
results.add(key.toString());
|
||||
}
|
||||
return StringUtil.copyPartialMatches(token, results, completions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LazyPlayerSet extends LazyHashSet<Player> {
|
||||
|
||||
@Override
|
||||
HashSet<Player> makeReference() {
|
||||
if (reference != null) {
|
||||
throw new IllegalStateException("Reference already created!");
|
||||
}
|
||||
List<EntityPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
||||
HashSet<Player> reference = new HashSet<Player>(players.size());
|
||||
for (EntityPlayer player : players) {
|
||||
reference.add(player.getBukkitEntity());
|
||||
}
|
||||
return reference;
|
||||
}
|
||||
|
||||
}
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class LazyPlayerSet extends LazyHashSet<Player> {
|
||||
|
||||
@Override
|
||||
HashSet<Player> makeReference() {
|
||||
if (reference != null) {
|
||||
throw new IllegalStateException("Reference already created!");
|
||||
}
|
||||
List<EntityPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
||||
HashSet<Player> reference = new HashSet<Player>(players.size());
|
||||
for (EntityPlayer player : players) {
|
||||
reference.add(player.getBukkitEntity());
|
||||
}
|
||||
return reference;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.bukkit.craftbukkit.util;
|
||||
|
||||
import net.minecraft.util.com.google.gson.Gson;
|
||||
import net.minecraft.util.com.google.common.base.Charsets;
|
||||
import net.minecraft.util.org.apache.commons.io.IOUtils;
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.gson.Gson;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@@ -12,6 +11,7 @@ import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
public class MojangNameLookup {
|
||||
private static final Logger logger = LogManager.getFormatterLogger(MojangNameLookup.class);
|
||||
|
||||
@@ -5,7 +5,7 @@ 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 com.mojang.util.QueueLogAppender;
|
||||
import org.bukkit.craftbukkit.Main;
|
||||
|
||||
public class TerminalConsoleWriterThread implements Runnable {
|
||||
|
||||
Reference in New Issue
Block a user