mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-22 08:15:05 +01:00
Update CraftBukkit to Minecraft 1.4.6
By: feildmaster <admin@feildmaster.com>
This commit is contained in:
parent
d626642cc6
commit
fde7669132
16 changed files with 130 additions and 93 deletions
|
@ -4,7 +4,7 @@
|
|||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.4.5-R1.1-SNAPSHOT</version>
|
||||
<version>1.4.6-R0.1-SNAPSHOT</version>
|
||||
<name>CraftBukkit</name>
|
||||
<url>http://www.bukkit.org</url>
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<api.version>unknown</api.version>
|
||||
<junit.version>4.11</junit.version>
|
||||
<minecraft.version>1.4.5</minecraft.version>
|
||||
<minecraft_version>1_4_5</minecraft_version>
|
||||
<minecraft.version>1.4.6</minecraft.version>
|
||||
<minecraft_version>1_4_6</minecraft_version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
|
@ -288,7 +288,7 @@
|
|||
<version>2.11</version>
|
||||
<configuration>
|
||||
<workingDirectory>${basedir}/target/test-server</workingDirectory>
|
||||
<excludes>
|
||||
<excludes>
|
||||
<exclude>org/bukkit/craftbukkit/updater/BukkitDLUpdaterServiceTest.java</exclude>
|
||||
<exclude>org/bukkit/craftbukkit/inventory/ItemStackBookTest.java</exclude>
|
||||
<exclude>org/bukkit/craftbukkit/inventory/ItemStackLeatherTest.java</exclude>
|
||||
|
|
|
@ -106,7 +106,7 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
for (Object obj : server.getHandle().players) {
|
||||
EntityPlayer player = (EntityPlayer) obj;
|
||||
if (player.name.equalsIgnoreCase(getName())) {
|
||||
return (player.netServerHandler != null) ? player.netServerHandler.getPlayer() : null;
|
||||
return (player.playerConnection != null) ? player.playerConnection.getPlayer() : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,14 @@ import net.minecraft.server.ChunkCoordinates;
|
|||
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.EnumGamemode;
|
||||
import net.minecraft.server.ExceptionWorldConflict;
|
||||
import net.minecraft.server.PlayerList;
|
||||
import net.minecraft.server.RecipesFurnace;
|
||||
import net.minecraft.server.IProgressUpdate;
|
||||
import net.minecraft.server.IWorldAccess;
|
||||
|
@ -37,8 +39,6 @@ import net.minecraft.server.MinecraftServer;
|
|||
import net.minecraft.server.MobEffectList;
|
||||
import net.minecraft.server.PropertyManager;
|
||||
import net.minecraft.server.ServerCommand;
|
||||
import net.minecraft.server.ServerConfigurationManager;
|
||||
import net.minecraft.server.ServerConfigurationManagerAbstract;
|
||||
import net.minecraft.server.ServerNBTManager;
|
||||
import net.minecraft.server.WorldLoaderServer;
|
||||
import net.minecraft.server.WorldManager;
|
||||
|
@ -144,7 +144,7 @@ public final class CraftServer implements Server {
|
|||
private final StandardMessenger messenger = new StandardMessenger();
|
||||
private final PluginManager pluginManager = new SimplePluginManager(this, commandMap);
|
||||
protected final MinecraftServer console;
|
||||
protected final ServerConfigurationManager server;
|
||||
protected final DedicatedPlayerList playerList;
|
||||
private final Map<String, World> worlds = new LinkedHashMap<String, World>();
|
||||
private YamlConfiguration configuration;
|
||||
private final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
|
@ -159,16 +159,22 @@ public final class CraftServer implements Server {
|
|||
private int ambientSpawn = -1;
|
||||
private File container;
|
||||
private WarningState warningState = WarningState.DEFAULT;
|
||||
private final BooleanWrapper online = new BooleanWrapper();
|
||||
|
||||
private final class BooleanWrapper {
|
||||
private boolean value = true;
|
||||
}
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
|
||||
CraftItemFactory.instance();
|
||||
}
|
||||
|
||||
public CraftServer(MinecraftServer console, ServerConfigurationManagerAbstract server) {
|
||||
public CraftServer(MinecraftServer console, PlayerList playerList) {
|
||||
this.console = console;
|
||||
this.server = (ServerConfigurationManager) server;
|
||||
this.playerList = (DedicatedPlayerList) playerList;
|
||||
this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
|
||||
online.value = console.getPropertyManager().getBoolean("online-mode", true);
|
||||
|
||||
Bukkit.setServer(this);
|
||||
|
||||
|
@ -299,11 +305,11 @@ public final class CraftServer implements Server {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Player[] getOnlinePlayers() {
|
||||
List<EntityPlayer> online = server.players;
|
||||
List<EntityPlayer> online = playerList.players;
|
||||
Player[] players = new Player[online.size()];
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
players[i] = online.get(i).netServerHandler.getPlayer();
|
||||
players[i] = online.get(i).playerConnection.getPlayer();
|
||||
}
|
||||
|
||||
return players;
|
||||
|
@ -345,7 +351,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public Player getPlayer(final EntityPlayer entity) {
|
||||
return entity.netServerHandler.getPlayer();
|
||||
return entity.playerConnection.getPlayer();
|
||||
}
|
||||
|
||||
public List<Player> matchPlayer(String partialName) {
|
||||
|
@ -370,7 +376,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public int getMaxPlayers() {
|
||||
return server.getMaxPlayers();
|
||||
return playerList.getMaxPlayers();
|
||||
}
|
||||
|
||||
// NOTE: These are dependent on the corrisponding call in MinecraftServer
|
||||
|
@ -478,8 +484,8 @@ public final class CraftServer implements Server {
|
|||
return new ArrayList<World>(worlds.values());
|
||||
}
|
||||
|
||||
public ServerConfigurationManager getHandle() {
|
||||
return server;
|
||||
public DedicatedPlayerList getHandle() {
|
||||
return playerList;
|
||||
}
|
||||
|
||||
// NOTE: Should only be called from DedicatedServer.ah()
|
||||
|
@ -520,7 +526,7 @@ public final class CraftServer implements Server {
|
|||
boolean monsters = config.getBoolean("spawn-monsters", console.worlds.get(0).difficulty > 0);
|
||||
int difficulty = config.getInt("difficulty", console.worlds.get(0).difficulty);
|
||||
|
||||
console.setOnlineMode(config.getBoolean("online-mode", console.getOnlineMode()));
|
||||
online.value = config.getBoolean("online-mode", console.getOnlineMode());
|
||||
console.setSpawnAnimals(config.getBoolean("spawn-animals", console.getSpawnAnimals()));
|
||||
console.setPvP(config.getBoolean("pvp", console.getPvP()));
|
||||
console.setAllowFlight(config.getBoolean("allow-flight", console.getAllowFlight()));
|
||||
|
@ -833,7 +839,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public void savePlayers() {
|
||||
server.savePlayers();
|
||||
playerList.savePlayers();
|
||||
}
|
||||
|
||||
public void configureDbConfig(ServerConfig config) {
|
||||
|
@ -946,7 +952,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return console.getOnlineMode();
|
||||
return online.value;
|
||||
}
|
||||
|
||||
public boolean getAllowFlight() {
|
||||
|
@ -1059,24 +1065,24 @@ public final class CraftServer implements Server {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Set<String> getIPBans() {
|
||||
return server.getIPBans().getEntries().keySet();
|
||||
return playerList.getIPBans().getEntries().keySet();
|
||||
}
|
||||
|
||||
public void banIP(String address) {
|
||||
BanEntry entry = new BanEntry(address);
|
||||
server.getIPBans().add(entry);
|
||||
server.getIPBans().save();
|
||||
playerList.getIPBans().add(entry);
|
||||
playerList.getIPBans().save();
|
||||
}
|
||||
|
||||
public void unbanIP(String address) {
|
||||
server.getIPBans().remove(address);
|
||||
server.getIPBans().save();
|
||||
playerList.getIPBans().remove(address);
|
||||
playerList.getIPBans().save();
|
||||
}
|
||||
|
||||
public Set<OfflinePlayer> getBannedPlayers() {
|
||||
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
|
||||
|
||||
for (Object name : server.getNameBans().getEntries().keySet()) {
|
||||
for (Object name : playerList.getNameBans().getEntries().keySet()) {
|
||||
result.add(getOfflinePlayer((String) name));
|
||||
}
|
||||
|
||||
|
@ -1084,14 +1090,14 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public void setWhitelist(boolean value) {
|
||||
server.hasWhitelist = value;
|
||||
playerList.hasWhitelist = value;
|
||||
console.getPropertyManager().a("white-list", value);
|
||||
}
|
||||
|
||||
public Set<OfflinePlayer> getWhitelistedPlayers() {
|
||||
Set<OfflinePlayer> result = new LinkedHashSet<OfflinePlayer>();
|
||||
|
||||
for (Object name : server.getWhitelisted()) {
|
||||
for (Object name : playerList.getWhitelisted()) {
|
||||
if (((String)name).length() == 0 || ((String)name).startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1104,7 +1110,7 @@ public final class CraftServer implements Server {
|
|||
public Set<OfflinePlayer> getOperators() {
|
||||
Set<OfflinePlayer> result = new HashSet<OfflinePlayer>();
|
||||
|
||||
for (Object name : server.getOPs()) {
|
||||
for (Object name : playerList.getOPs()) {
|
||||
result.add(getOfflinePlayer((String) name));
|
||||
}
|
||||
|
||||
|
@ -1112,7 +1118,7 @@ public final class CraftServer implements Server {
|
|||
}
|
||||
|
||||
public void reloadWhitelist() {
|
||||
server.reloadWhitelist();
|
||||
playerList.reloadWhitelist();
|
||||
}
|
||||
|
||||
public GameMode getDefaultGameMode() {
|
||||
|
|
|
@ -222,7 +222,7 @@ public class CraftWorld implements World {
|
|||
}
|
||||
|
||||
public boolean isChunkInUse(int x, int z) {
|
||||
return world.getPlayerManager().isChunkInUse(x, z);
|
||||
return world.getPlayerChunkMap().isChunkInUse(x, z);
|
||||
}
|
||||
|
||||
public boolean loadChunk(int x, int z, boolean generate) {
|
||||
|
@ -430,9 +430,9 @@ public class CraftWorld implements World {
|
|||
// Forces the client to update to the new time immediately
|
||||
for (Player p : getPlayers()) {
|
||||
CraftPlayer cp = (CraftPlayer) p;
|
||||
if (cp.getHandle().netServerHandler == null) continue;
|
||||
if (cp.getHandle().playerConnection == null) continue;
|
||||
|
||||
cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime()));
|
||||
cp.getHandle().playerConnection.sendPacket(new Packet4UpdateTime(cp.getHandle().world.getTime(), cp.getHandle().getPlayerTime()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -767,12 +767,12 @@ public class CraftWorld implements World {
|
|||
radius *= radius;
|
||||
|
||||
for (Player player : getPlayers()) {
|
||||
if (((CraftPlayer) player).getHandle().netServerHandler == null) continue;
|
||||
if (((CraftPlayer) player).getHandle().playerConnection == null) continue;
|
||||
if (!location.getWorld().equals(player.getWorld())) continue;
|
||||
|
||||
distance = (int) player.getLocation().distanceSquared(location);
|
||||
if (distance <= radius) {
|
||||
((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,8 @@ public class CraftEnchantment extends Enchantment {
|
|||
return "OXYGEN";
|
||||
case 6:
|
||||
return "WATER_WORKER";
|
||||
case 7:
|
||||
return "THORNS";
|
||||
case 16:
|
||||
return "DAMAGE_ALL";
|
||||
case 17:
|
||||
|
|
|
@ -148,6 +148,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||
else { return new CraftHanging(server, (EntityHanging) 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 IllegalArgumentException("Unknown entity");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import net.minecraft.server.EntityFireworks;
|
||||
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Firework;
|
||||
|
||||
public class CraftFirework extends CraftEntity implements Firework {
|
||||
|
||||
public CraftFirework(CraftServer server, EntityFireworks entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityFireworks getHandle() {
|
||||
return (EntityFireworks) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CraftFirework";
|
||||
}
|
||||
|
||||
public EntityType getType() {
|
||||
return EntityType.FIREWORK;
|
||||
}
|
||||
}
|
|
@ -229,7 +229,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
}
|
||||
|
||||
private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) {
|
||||
if (player.netServerHandler == null) return;
|
||||
if (player.playerConnection == null) return;
|
||||
Container container = new CraftContainer(inventory, this, player.nextContainerCounter());
|
||||
|
||||
container = CraftEventFactory.callInventoryOpenEvent(player, container);
|
||||
|
@ -238,7 +238,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
String title = container.getBukkitView().getTitle();
|
||||
int size = container.getBukkitView().getTopInventory().getSize();
|
||||
|
||||
player.netServerHandler.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size));
|
||||
player.playerConnection.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size));
|
||||
getHandle().activeContainer = container;
|
||||
getHandle().activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
@ -279,10 +279,10 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
|
||||
public void openInventory(InventoryView inventory) {
|
||||
if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support?
|
||||
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
|
||||
if (((EntityPlayer) getHandle()).playerConnection == null) return;
|
||||
if (getHandle().activeContainer != getHandle().defaultContainer) {
|
||||
// fire INVENTORY_CLOSE if one already open
|
||||
((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
|
||||
((EntityPlayer)getHandle()).playerConnection.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId));
|
||||
}
|
||||
EntityPlayer player = (EntityPlayer) getHandle();
|
||||
Container container;
|
||||
|
@ -303,7 +303,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
int windowType = CraftContainer.getNotchInventoryType(type);
|
||||
String title = inventory.getTitle();
|
||||
int size = inventory.getTopInventory().getSize();
|
||||
player.netServerHandler.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size));
|
||||
player.playerConnection.sendPacket(new Packet100OpenWindow(container.windowId, windowType, title, size));
|
||||
player.activeContainer = container;
|
||||
player.activeContainer.addSlotListener(player);
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ public class CraftItem extends CraftEntity implements Item {
|
|||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return CraftItemStack.asCraftMirror(item.itemStack);
|
||||
return CraftItemStack.asCraftMirror(item.getItemStack());
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack stack) {
|
||||
item.itemStack = CraftItemStack.asNMSCopy(stack);
|
||||
item.setItemStack(CraftItemStack.asNMSCopy(stack));
|
||||
}
|
||||
|
||||
public int getPickupDelay() {
|
||||
|
|
|
@ -255,8 +255,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
|||
getHandle().effects.remove(type.getId());
|
||||
getHandle().updateEffects = true;
|
||||
if (getHandle() instanceof EntityPlayer) {
|
||||
if (((EntityPlayer) getHandle()).netServerHandler == null) return;
|
||||
((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
|
||||
if (((EntityPlayer) getHandle()).playerConnection == null) return;
|
||||
((EntityPlayer) getHandle()).playerConnection.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,9 +94,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public InetSocketAddress getAddress() {
|
||||
if (getHandle().netServerHandler == null) return null;
|
||||
if (getHandle().playerConnection == null) return null;
|
||||
|
||||
SocketAddress addr = getHandle().netServerHandler.networkManager.getSocketAddress();
|
||||
SocketAddress addr = getHandle().playerConnection.networkManager.getSocketAddress();
|
||||
if (addr instanceof InetSocketAddress) {
|
||||
return (InetSocketAddress) addr;
|
||||
} else {
|
||||
|
@ -123,9 +123,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void sendRawMessage(String message) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().netServerHandler.sendPacket(new Packet3Chat(message));
|
||||
getHandle().playerConnection.sendPacket(new Packet3Chat(message));
|
||||
}
|
||||
|
||||
public void sendMessage(String message) {
|
||||
|
@ -181,11 +181,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping);
|
||||
for (int i = 0; i < server.getHandle().players.size(); ++i) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i);
|
||||
if (entityplayer.netServerHandler == null) continue;
|
||||
if (entityplayer.playerConnection == null) continue;
|
||||
|
||||
if (entityplayer.getBukkitEntity().canSee(this)) {
|
||||
entityplayer.netServerHandler.sendPacket(oldpacket);
|
||||
entityplayer.netServerHandler.sendPacket(packet);
|
||||
entityplayer.playerConnection.sendPacket(oldpacket);
|
||||
entityplayer.playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -211,16 +211,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void kickPlayer(String message) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().netServerHandler.disconnect(message == null ? "" : message);
|
||||
getHandle().playerConnection.disconnect(message == null ? "" : message);
|
||||
}
|
||||
|
||||
public void setCompassTarget(Location loc) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
// Do not directly assign here, from the packethandler we'll assign it.
|
||||
getHandle().netServerHandler.sendPacket(new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
getHandle().playerConnection.sendPacket(new Packet6SpawnPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
|
||||
public Location getCompassTarget() {
|
||||
|
@ -228,9 +228,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void chat(String msg) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
getHandle().netServerHandler.chat(msg, false);
|
||||
getHandle().playerConnection.chat(msg, false);
|
||||
}
|
||||
|
||||
public boolean performCommand(String command) {
|
||||
|
@ -238,36 +238,36 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void playNote(Location loc, byte instrument, byte note) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
|
||||
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument, note));
|
||||
}
|
||||
|
||||
public void playNote(Location loc, Instrument instrument, Note note) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int id = getHandle().world.getTypeId(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
getHandle().netServerHandler.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
|
||||
getHandle().playerConnection.sendPacket(new Packet54PlayNoteBlock(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), id, instrument.getType(), note.getId()));
|
||||
}
|
||||
|
||||
public void playSound(Location loc, Sound sound, float volume, float pitch) {
|
||||
if (loc == null || sound == null || getHandle().netServerHandler == null) return;
|
||||
if (loc == null || sound == null || getHandle().playerConnection == null) return;
|
||||
|
||||
double x = loc.getBlockX() + 0.5;
|
||||
double y = loc.getBlockY() + 0.5;
|
||||
double z = loc.getBlockZ() + 0.5;
|
||||
|
||||
Packet62NamedSoundEffect packet = new Packet62NamedSoundEffect(CraftSound.getSound(sound), x, y, z, volume, pitch);
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public void playEffect(Location loc, Effect effect, int data) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
int packetData = effect.getId();
|
||||
Packet61WorldEvent packet = new Packet61WorldEvent(packetData, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), data, false);
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public <T> void playEffect(Location loc, Effect effect, T data) {
|
||||
|
@ -286,17 +286,17 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void sendBlockChange(Location loc, int material, byte data) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
Packet53BlockChange packet = new Packet53BlockChange(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), ((CraftWorld) loc.getWorld()).getHandle());
|
||||
|
||||
packet.material = material;
|
||||
packet.data = data;
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
public boolean sendChunkChange(Location loc, int sx, int sy, int sz, byte[] data) {
|
||||
if (getHandle().netServerHandler == null) return false;
|
||||
if (getHandle().playerConnection == null) return false;
|
||||
|
||||
/*
|
||||
int x = loc.getBlockX();
|
||||
|
@ -320,7 +320,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
Packet51MapChunk packet = new Packet51MapChunk(x, y, z, sx, sy, sz, data);
|
||||
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
|
||||
return true;
|
||||
*/
|
||||
|
@ -329,7 +329,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void sendMap(MapView map) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
RenderData data = ((CraftMapView) map).render(this);
|
||||
for (int x = 0; x < 128; ++x) {
|
||||
|
@ -339,7 +339,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
bytes[y + 3] = data.buffer[y * 128 + x];
|
||||
}
|
||||
Packet131ItemData packet = new Packet131ItemData((short) Material.MAP.getId(), map.getId(), bytes);
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
public boolean teleport(Location location, PlayerTeleportEvent.TeleportCause cause) {
|
||||
EntityPlayer entity = getHandle();
|
||||
|
||||
if (entity.netServerHandler == null || entity.netServerHandler.disconnected) {
|
||||
if (entity.playerConnection == null || entity.playerConnection.disconnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
// Check if the fromWorld and toWorld are the same.
|
||||
if (fromWorld == toWorld) {
|
||||
entity.netServerHandler.teleport(to);
|
||||
entity.playerConnection.teleport(to);
|
||||
} else {
|
||||
// Close any foreign inventory
|
||||
if (getHandle().activeContainer != getHandle().defaultContainer){
|
||||
|
@ -460,14 +460,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
private void sendStatistic(int id, int amount) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
while (amount > Byte.MAX_VALUE) {
|
||||
sendStatistic(id, Byte.MAX_VALUE);
|
||||
amount -= Byte.MAX_VALUE;
|
||||
}
|
||||
|
||||
getHandle().netServerHandler.sendPacket(new Packet200Statistic(id, amount));
|
||||
getHandle().playerConnection.sendPacket(new Packet200Statistic(id, amount));
|
||||
}
|
||||
|
||||
public void setPlayerTime(long time, boolean relative) {
|
||||
|
@ -520,7 +520,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
@Override
|
||||
public void setGameMode(GameMode mode) {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
if (mode == null) {
|
||||
throw new IllegalArgumentException("Mode cannot be null");
|
||||
|
@ -533,14 +533,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
return;
|
||||
}
|
||||
|
||||
getHandle().itemInWorldManager.setGameMode(EnumGamemode.a(mode.getValue()));
|
||||
getHandle().netServerHandler.sendPacket(new Packet70Bed(3, mode.getValue()));
|
||||
getHandle().playerInteractManager.setGameMode(EnumGamemode.a(mode.getValue()));
|
||||
getHandle().playerConnection.sendPacket(new Packet70Bed(3, mode.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode() {
|
||||
return GameMode.getByValue(getHandle().itemInWorldManager.getGameMode().a());
|
||||
return GameMode.getByValue(getHandle().playerInteractManager.getGameMode().a());
|
||||
}
|
||||
|
||||
public void giveExp(int exp) {
|
||||
|
@ -624,7 +624,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
public void hidePlayer(Player player) {
|
||||
Validate.notNull(player, "hidden player cannot be null");
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
if (equals(player)) return;
|
||||
if (hiddenPlayers.containsKey(player.getName())) return;
|
||||
hiddenPlayers.put(player.getName(), player);
|
||||
|
@ -638,12 +638,12 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
//remove the hidden player from this player user list
|
||||
getHandle().netServerHandler.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), false, 9999));
|
||||
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), false, 9999));
|
||||
}
|
||||
|
||||
public void showPlayer(Player player) {
|
||||
Validate.notNull(player, "shown player cannot be null");
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
if (equals(player)) return;
|
||||
if (!hiddenPlayers.containsKey(player.getName())) return;
|
||||
hiddenPlayers.remove(player.getName());
|
||||
|
@ -655,7 +655,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
entry.updatePlayer(getHandle());
|
||||
}
|
||||
|
||||
getHandle().netServerHandler.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), true, getHandle().ping));
|
||||
getHandle().playerConnection.sendPacket(new Packet201PlayerInfo(player.getPlayerListName(), true, getHandle().ping));
|
||||
}
|
||||
|
||||
public boolean canSee(Player player) {
|
||||
|
@ -771,14 +771,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
|
||||
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
|
||||
StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message);
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
|
||||
if (channels.contains(channel)) {
|
||||
Packet250CustomPayload packet = new Packet250CustomPayload();
|
||||
packet.tag = channel;
|
||||
packet.length = message.length;
|
||||
packet.data = message;
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -799,7 +799,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
}
|
||||
|
||||
public void sendSupportedChannels() {
|
||||
if (getHandle().netServerHandler == null) return;
|
||||
if (getHandle().playerConnection == null) return;
|
||||
Set<String> listening = server.getMessenger().getIncomingChannels();
|
||||
|
||||
if (!listening.isEmpty()) {
|
||||
|
@ -820,7 +820,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||
packet.data = stream.toByteArray();
|
||||
packet.length = packet.data.length;
|
||||
|
||||
getHandle().netServerHandler.sendPacket(packet);
|
||||
getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ public class CraftEventFactory {
|
|||
|
||||
public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
|
||||
if (player.activeContainer != player.defaultContainer) { // fire INVENTORY_CLOSE if one already open
|
||||
player.netServerHandler.handleContainerClose(new Packet101CloseWindow(player.activeContainer.windowId));
|
||||
player.playerConnection.handleContainerClose(new Packet101CloseWindow(player.activeContainer.windowId));
|
||||
}
|
||||
|
||||
CraftServer server = ((WorldServer) player.world).getServer();
|
||||
|
|
|
@ -91,7 +91,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
|||
}
|
||||
}
|
||||
// Build chunk section
|
||||
csect[sec] = new ChunkSection(sec << 4, secBlkID, secExtBlkID);
|
||||
csect[sec] = new ChunkSection(sec << 4, true, secBlkID, secExtBlkID);
|
||||
}
|
||||
}
|
||||
else { // Else check for byte-per-block section data
|
||||
|
@ -107,7 +107,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
|||
if (btypes[sec] == null) {
|
||||
continue;
|
||||
}
|
||||
csect[sec] = new ChunkSection(sec << 4, btypes[sec], null);
|
||||
csect[sec] = new ChunkSection(sec << 4, true, btypes[sec], null);
|
||||
}
|
||||
}
|
||||
else { // Else, fall back to pre 1.2 method
|
||||
|
@ -137,7 +137,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
|
|||
|
||||
if (blk != 0) { // If non-empty
|
||||
if (cs == null) { // If no section yet, get one
|
||||
cs = csect[sec] = new ChunkSection(sec << 4);
|
||||
cs = csect[sec] = new ChunkSection(sec << 4, true);
|
||||
csbytes = cs.g();
|
||||
}
|
||||
csbytes[(cy << 8) | (cz << 4) | cx] = blk;
|
||||
|
|
|
@ -85,7 +85,7 @@ public class CraftContainer extends Container {
|
|||
setupSlots(top, bottom);
|
||||
}
|
||||
int size = getSize();
|
||||
player.getHandle().netServerHandler.sendPacket(new Packet100OpenWindow(this.windowId, type, cachedTitle, size));
|
||||
player.getHandle().playerConnection.sendPacket(new Packet100OpenWindow(this.windowId, type, cachedTitle, size));
|
||||
player.updateInventory();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -36,8 +36,8 @@ import com.google.common.collect.ImmutableMap;
|
|||
* <li> void applyToItem(NBTTagCompound tag)
|
||||
* <li> boolean applicableTo(Material type)
|
||||
* <br><br>
|
||||
* <li> boolean notUncommon(CraftMetaItem meta)
|
||||
* <li> boolean equalsCommon(CraftMetaItem meta)
|
||||
* <li> boolean notUncommon(CraftMetaItem meta)
|
||||
* <br><br>
|
||||
* <li> boolean isEmpty()
|
||||
* <li> boolean is{Type}Empty()
|
||||
|
|
|
@ -14,7 +14,7 @@ public class LazyPlayerSet extends LazyHashSet<Player> {
|
|||
if (reference != null) {
|
||||
throw new IllegalStateException("Reference already created!");
|
||||
}
|
||||
List<EntityPlayer> players = MinecraftServer.getServer().getServerConfigurationManager().players;
|
||||
List<EntityPlayer> players = MinecraftServer.getServer().getPlayerList().players;
|
||||
HashSet<Player> reference = new HashSet<Player>(players.size());
|
||||
for (EntityPlayer player : players) {
|
||||
reference.add(player.getBukkitEntity());
|
||||
|
|
Loading…
Add table
Reference in a new issue