2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/PlayerList.java
+++ b/net/minecraft/server/PlayerList.java
2019-04-25 04:00:00 +02:00
@@ -19,6 +19,27 @@
2014-11-25 22:32:16 +01:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
2016-11-28 00:02:40 +01:00
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+
2014-11-25 22:32:16 +01:00
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
2014-12-12 08:20:42 +01:00
+import org.bukkit.craftbukkit.util.CraftChatMessage;
2014-11-25 22:32:16 +01:00
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerChangedWorldEvent;
+import org.bukkit.event.player.PlayerPortalEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerLoginEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+import org.bukkit.event.player.PlayerRespawnEvent;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+import org.bukkit.util.Vector;
+// CraftBukkit end
+
public abstract class PlayerList {
public static final File a = new File("banned-players.json");
2019-04-25 04:00:00 +02:00
@@ -28,14 +49,16 @@
private static final Logger LOGGER = LogManager.getLogger();
2018-12-06 00:00:00 +01:00
private static final SimpleDateFormat g = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
2014-11-25 22:32:16 +01:00
private final MinecraftServer server;
2015-06-06 11:33:48 +02:00
- public final List<EntityPlayer> players = Lists.newArrayList();
+ public final List<EntityPlayer> players = new java.util.concurrent.CopyOnWriteArrayList(); // CraftBukkit - ArrayList -> CopyOnWriteArrayList: Iterator safety
2015-02-26 23:41:06 +01:00
private final Map<UUID, EntityPlayer> j = Maps.newHashMap();
2014-11-25 22:32:16 +01:00
private final GameProfileBanList k;
private final IpBanList l;
2017-07-17 01:55:47 +02:00
private final OpList operators;
private final WhiteList whitelist;
- private final Map<UUID, ServerStatisticManager> o;
- private final Map<UUID, AdvancementDataPlayer> p;
+ // CraftBukkit start
+ // private final Map<UUID, ServerStatisticManager> o;
+ // private final Map<UUID, AdvancementDataPlayer> p;
+ // CraftBukkit end
public IPlayerFileData playerFileData;
private boolean hasWhitelist;
2019-04-23 04:00:00 +02:00
protected final int maxPlayers;
2019-04-25 04:00:00 +02:00
@@ -44,13 +67,23 @@
2017-05-14 04:00:00 +02:00
private boolean u;
private int v;
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
+ private CraftServer cserver;
+
2019-04-23 04:00:00 +02:00
public PlayerList(MinecraftServer minecraftserver, int i) {
+ this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this);
2014-11-25 22:32:16 +01:00
+ minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
+ minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server));
+ // CraftBukkit end
2016-06-25 12:38:13 +02:00
+
2014-11-25 22:32:16 +01:00
this.k = new GameProfileBanList(PlayerList.a);
this.l = new IpBanList(PlayerList.b);
this.operators = new OpList(PlayerList.c);
2017-07-17 01:55:47 +02:00
this.whitelist = new WhiteList(PlayerList.d);
- this.o = Maps.newHashMap();
- this.p = Maps.newHashMap();
+ // CraftBukkit start
+ // this.o = Maps.newHashMap();
+ // this.p = Maps.newHashMap();
+ // CraftBukkit end
this.server = minecraftserver;
2019-04-23 04:00:00 +02:00
this.maxPlayers = i;
2018-07-15 02:00:00 +02:00
this.getProfileBans().a(true);
2019-04-25 04:00:00 +02:00
@@ -66,6 +99,12 @@
2015-02-04 20:29:07 +01:00
usercache.a(gameprofile);
NBTTagCompound nbttagcompound = this.a(entityplayer);
2019-04-23 04:00:00 +02:00
WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
2015-02-04 20:29:07 +01:00
+ // CraftBukkit start - Better rename detection
2015-02-04 21:33:06 +01:00
+ if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
2015-02-04 20:29:07 +01:00
+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
+ }
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
entityplayer.spawnIn(worldserver);
2015-02-04 20:29:07 +01:00
entityplayer.playerInteractManager.a((WorldServer) entityplayer.world);
2019-05-12 03:15:48 +02:00
@@ -75,13 +114,16 @@
2014-11-25 22:32:16 +01:00
s1 = networkmanager.getSocketAddress().toString();
}
2019-04-25 04:00:00 +02:00
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX, entityplayer.locY, entityplayer.locZ);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit - Moved message to after join
2019-04-25 04:00:00 +02:00
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX, entityplayer.locY, entityplayer.locZ);
2014-11-25 22:32:16 +01:00
WorldData worlddata = worldserver.getWorldData();
2016-11-17 02:41:03 +01:00
2019-04-23 04:00:00 +02:00
this.a(entityplayer, (EntityPlayer) null, worldserver);
2014-11-25 22:32:16 +01:00
PlayerConnection playerconnection = new PlayerConnection(this.server, networkmanager, entityplayer);
2019-06-21 12:00:00 +02:00
- playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager(), this.getMaxPlayers(), worlddata.getType(), this.viewDistance, worldserver.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO)));
2019-05-12 03:15:48 +02:00
+ // CraftBukkit - getType()
2019-06-21 12:00:00 +02:00
+ playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), worlddata.isHardcore(), worldserver.worldProvider.getDimensionManager().getType(), this.getMaxPlayers(), worlddata.getType(), this.viewDistance, worldserver.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO)));
2014-11-25 22:32:16 +01:00
+ entityplayer.getBukkitEntity().sendSupportedChannels(); // CraftBukkit
2019-04-23 04:00:00 +02:00
playerconnection.sendPacket(new PacketPlayOutCustomPayload(PacketPlayOutCustomPayload.a, (new PacketDataSerializer(Unpooled.buffer())).a(this.getServer().getServerModName())));
2015-05-05 22:43:47 +02:00
playerconnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
2016-11-17 02:41:03 +01:00
playerconnection.sendPacket(new PacketPlayOutAbilities(entityplayer.abilities));
2019-05-12 03:15:48 +02:00
@@ -100,19 +142,61 @@
2019-04-23 04:00:00 +02:00
} else {
2019-05-27 22:30:00 +02:00
chatmessage = new ChatMessage("multiplayer.player.joined.renamed", new Object[]{entityplayer.getScoreboardDisplayName(), s});
2015-02-04 00:38:21 +01:00
}
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
+ chatmessage.a(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW));
2019-04-23 04:00:00 +02:00
playerconnection.a(entityplayer.locX, entityplayer.locY, entityplayer.locZ, entityplayer.yaw, entityplayer.pitch);
this.players.add(entityplayer);
this.j.put(entityplayer.getUniqueID(), entityplayer);
2019-05-27 22:30:00 +02:00
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer}));
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{entityplayer})); // CraftBukkit - replaced with loop below
2019-04-23 04:00:00 +02:00
+
+ // CraftBukkit start
+ PlayerJoinEvent playerJoinEvent = new PlayerJoinEvent(cserver.getPlayer(entityplayer), joinMessage);
+ cserver.getPluginManager().callEvent(playerJoinEvent);
+
+ if (!entityplayer.playerConnection.networkManager.isConnected()) {
+ return;
+ }
+
+ joinMessage = playerJoinEvent.getJoinMessage();
+
+ if (joinMessage != null && joinMessage.length() > 0) {
+ for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
+ server.getPlayerList().sendAll(new PacketPlayOutChat(line));
+ }
+ }
+ // CraftBukkit end
+
+ // CraftBukkit start - sendAll above replaced with this loop
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityplayer);
for (int i = 0; i < this.players.size(); ++i) {
2019-05-27 22:30:00 +02:00
- entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[]{(EntityPlayer) this.players.get(i)}));
2019-04-23 04:00:00 +02:00
+ EntityPlayer entityplayer1 = (EntityPlayer) this.players.get(i);
+
+ if (entityplayer1.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer1.playerConnection.sendPacket(packet);
+ }
+
+ if (!entityplayer.getBukkitEntity().canSee(entityplayer1.getBukkitEntity())) {
+ continue;
+ }
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, new EntityPlayer[] { entityplayer1}));
+ }
+ entityplayer.sentListPacket = true;
2015-02-04 00:38:21 +01:00
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
+
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityplayer.getId(), entityplayer.datawatcher, true)); // CraftBukkit - BungeeCord#2321, send complete data to self on spawn
+
+ // CraftBukkit start - Only add if the player wasn't moved in the event
+ if (entityplayer.world == worldserver && !worldserver.getPlayers().contains(entityplayer)) {
+ worldserver.addPlayerJoin(entityplayer);
+ this.server.getBossBattleCustomData().a(entityplayer);
}
- worldserver.addPlayerJoin(entityplayer);
- this.server.getBossBattleCustomData().a(entityplayer);
2014-11-25 22:32:16 +01:00
+ worldserver = server.getWorldServer(entityplayer.dimension); // CraftBukkit - Update in case join event changed it
2019-04-23 04:00:00 +02:00
+ // CraftBukkit end
this.a(entityplayer, worldserver);
2016-02-29 22:32:46 +01:00
if (!this.server.getResourcePack().isEmpty()) {
2019-04-23 04:00:00 +02:00
entityplayer.setResourcePack(this.server.getResourcePack(), this.server.getResourcePackHash());
2019-05-12 03:15:48 +02:00
@@ -128,8 +212,11 @@
2019-04-23 04:00:00 +02:00
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver, (entity1) -> {
- return !worldserver.addEntitySerialized(entity1) ? null : entity1;
+ // CraftBukkit start
+ WorldServer finalWorldServer = worldserver;
+ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
+ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1;
+ // CraftBukkit end
});
if (entity != null) {
2019-05-12 03:15:48 +02:00
@@ -165,6 +252,8 @@
2014-11-25 22:32:16 +01:00
}
2016-02-29 22:32:46 +01:00
entityplayer.syncInventory();
2014-11-25 22:32:16 +01:00
+ // CraftBukkit - Moved from above, added world
2019-04-25 04:00:00 +02:00
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.world.worldData.getName(), entityplayer.locX, entityplayer.locY, entityplayer.locZ);
2014-11-25 22:32:16 +01:00
}
2015-06-06 11:33:48 +02:00
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
2019-05-12 03:15:48 +02:00
@@ -197,31 +286,32 @@
2014-11-25 22:32:16 +01:00
}
2018-08-26 04:00:00 +02:00
public void setPlayerFileData(WorldServer worldserver) {
2014-11-25 22:32:16 +01:00
+ if (playerFileData != null) return; // CraftBukkit
2019-04-23 04:00:00 +02:00
this.playerFileData = worldserver.getDataManager();
2018-08-26 04:00:00 +02:00
worldserver.getWorldBorder().a(new IWorldBorderListener() {
2019-04-23 04:00:00 +02:00
@Override
2015-02-26 23:41:06 +01:00
public void a(WorldBorder worldborder, double d0) {
2016-02-29 22:32:46 +01:00
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_SIZE), worldborder.world);
}
2019-04-23 04:00:00 +02:00
@Override
2016-02-29 22:32:46 +01:00
public void a(WorldBorder worldborder, double d0, double d1, long i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.LERP_SIZE), worldborder.world);
}
2019-04-23 04:00:00 +02:00
@Override
2016-02-29 22:32:46 +01:00
public void a(WorldBorder worldborder, double d0, double d1) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_CENTER), worldborder.world);
}
2019-04-23 04:00:00 +02:00
@Override
2016-02-29 22:32:46 +01:00
public void a(WorldBorder worldborder, int i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_TIME), worldborder.world);
}
2019-04-23 04:00:00 +02:00
@Override
2016-02-29 22:32:46 +01:00
public void b(WorldBorder worldborder, int i) {
- PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS));
+ PlayerList.this.sendAll(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.SET_WARNING_BLOCKS), worldborder.world);
}
2019-04-23 04:00:00 +02:00
@Override
2019-05-12 03:15:48 +02:00
@@ -249,14 +339,15 @@
2018-10-02 17:41:47 +02:00
}
2017-07-17 01:55:47 +02:00
protected void savePlayerFile(EntityPlayer entityplayer) {
2018-10-02 17:41:47 +02:00
+ if (!entityplayer.getBukkitEntity().isPersistent()) return; // CraftBukkit
2017-07-17 01:55:47 +02:00
this.playerFileData.save(entityplayer);
- ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) this.o.get(entityplayer.getUniqueID());
+ ServerStatisticManager serverstatisticmanager = (ServerStatisticManager) entityplayer.getStatisticManager(); // CraftBukkit
if (serverstatisticmanager != null) {
2018-07-15 02:00:00 +02:00
serverstatisticmanager.a();
2017-07-17 01:55:47 +02:00
}
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(entityplayer.getUniqueID());
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
if (advancementdataplayer != null) {
advancementdataplayer.c();
2019-05-12 03:15:48 +02:00
@@ -264,10 +355,21 @@
2015-02-04 00:38:21 +01:00
}
2014-11-25 22:32:16 +01:00
- public void disconnect(EntityPlayer entityplayer) {
+ public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
2018-07-15 02:00:00 +02:00
WorldServer worldserver = entityplayer.getWorldServer();
2016-02-29 22:32:46 +01:00
2018-07-15 02:00:00 +02:00
entityplayer.a(StatisticList.LEAVE_GAME);
2014-11-25 22:32:16 +01:00
+
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleInventoryCloseEvent(entityplayer);
+
2016-07-07 02:43:49 +02:00
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
2014-11-25 22:32:16 +01:00
+ cserver.getPluginManager().callEvent(playerQuitEvent);
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
2016-06-25 12:38:13 +02:00
+
2016-11-17 02:41:03 +01:00
+ entityplayer.playerTick();// SPIGOT-924
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
2016-06-25 12:38:13 +02:00
+
2014-11-25 22:32:16 +01:00
this.savePlayerFile(entityplayer);
2016-02-29 22:32:46 +01:00
if (entityplayer.isPassenger()) {
2018-07-15 02:00:00 +02:00
Entity entity = entityplayer.getRootVehicle();
2019-05-12 03:15:48 +02:00
@@ -298,18 +400,66 @@
2017-07-17 01:55:47 +02:00
if (entityplayer1 == entityplayer) {
this.j.remove(uuid);
- this.o.remove(uuid);
- this.p.remove(uuid);
+ // CraftBukkit start
+ // this.o.remove(uuid);
+ // this.p.remove(uuid);
+ // CraftBukkit end
2018-01-23 12:49:26 +01:00
}
2019-05-27 22:30:00 +02:00
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
2019-05-27 22:30:00 +02:00
+ // this.sendAll(new PacketPlayOutPlayerInfo(EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
2015-02-26 23:41:06 +01:00
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer);
2014-11-25 22:32:16 +01:00
+ for (int i = 0; i < players.size(); i++) {
2015-02-26 23:41:06 +01:00
+ EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i);
2014-11-25 22:32:16 +01:00
+
2015-02-26 23:41:06 +01:00
+ if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer2.playerConnection.sendPacket(packet);
2014-11-25 22:32:16 +01:00
+ } else {
2015-02-26 23:41:06 +01:00
+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity());
2014-11-25 22:32:16 +01:00
+ }
2018-01-23 12:49:26 +01:00
+ }
2014-11-25 22:32:16 +01:00
+ // This removes the scoreboard (and player reference) for the specific player in the manager
+ cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
+ // CraftBukkit end
2018-01-23 12:49:26 +01:00
+
2014-11-25 22:32:16 +01:00
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit
}
2018-07-15 02:00:00 +02:00
- @Nullable
- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer
+ public EntityPlayer attemptLogin(LoginListener loginlistener, GameProfile gameprofile, String hostname) {
2018-07-15 02:00:00 +02:00
ChatMessage chatmessage;
- if (this.k.isBanned(gameprofile)) {
2014-12-06 21:53:57 +01:00
+ // Moved from processLogin
+ UUID uuid = EntityHuman.a(gameprofile);
2018-12-25 22:00:00 +01:00
+ List<EntityPlayer> list = Lists.newArrayList();
2014-12-06 21:53:57 +01:00
+
+ EntityPlayer entityplayer;
+
+ for (int i = 0; i < this.players.size(); ++i) {
+ entityplayer = (EntityPlayer) this.players.get(i);
+ if (entityplayer.getUniqueID().equals(uuid)) {
2018-12-25 22:00:00 +01:00
+ list.add(entityplayer);
2014-12-06 21:53:57 +01:00
+ }
+ }
+
2018-12-25 22:00:00 +01:00
+ Iterator iterator = list.iterator();
2014-12-06 21:53:57 +01:00
+
+ while (iterator.hasNext()) {
+ entityplayer = (EntityPlayer) iterator.next();
+ savePlayerFile(entityplayer); // CraftBukkit - Force the player's inventory to be saved
2017-05-30 13:25:59 +02:00
+ entityplayer.playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.duplicate_login", new Object[0]));
2014-12-06 21:53:57 +01:00
+ }
2015-02-26 23:41:06 +01:00
+
2014-11-25 22:32:16 +01:00
+ // Instead of kicking then returning, we need to store the kick reason
+ // in the event, check with plugins to see if it's ok, and THEN kick
+ // depending on the outcome.
+ SocketAddress socketaddress = loginlistener.networkManager.getSocketAddress();
+
2018-08-26 04:00:00 +02:00
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(DimensionManager.OVERWORLD)));
2014-11-25 22:32:16 +01:00
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
2018-07-15 02:00:00 +02:00
+
2014-11-25 22:32:16 +01:00
+ if (getProfileBans().isBanned(gameprofile) && !getProfileBans().get(gameprofile).hasExpired()) {
GameProfileBanEntry gameprofilebanentry = (GameProfileBanEntry) this.k.get(gameprofile);
2019-05-27 22:30:00 +02:00
chatmessage = new ChatMessage("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
2019-05-12 03:15:48 +02:00
@@ -317,10 +467,12 @@
2019-05-27 22:30:00 +02:00
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())}));
2014-11-25 22:32:16 +01:00
}
2018-07-15 02:00:00 +02:00
- return chatmessage;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
2014-11-25 22:32:16 +01:00
} else if (!this.isWhitelisted(gameprofile)) {
2018-07-15 02:00:00 +02:00
- return new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]);
2014-11-25 22:32:16 +01:00
- } else if (this.l.isBanned(socketaddress)) {
2018-07-15 02:00:00 +02:00
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted", new Object[0]);
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
2014-11-25 22:32:16 +01:00
+ } else if (getIPBans().isBanned(socketaddress) && !getIPBans().get(socketaddress).hasExpired()) {
IpBanEntry ipbanentry = this.l.get(socketaddress);
2019-05-27 22:30:00 +02:00
chatmessage = new ChatMessage("multiplayer.disconnect.banned_ip.reason", new Object[]{ipbanentry.getReason()});
2019-05-12 03:15:48 +02:00
@@ -328,13 +480,25 @@
2019-05-27 22:30:00 +02:00
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned_ip.expiration", new Object[]{PlayerList.g.format(ipbanentry.getExpires())}));
2014-11-25 22:32:16 +01:00
}
2018-07-15 02:00:00 +02:00
- return chatmessage;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
2014-11-25 22:32:16 +01:00
} else {
2018-07-15 02:00:00 +02:00
- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null;
+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full", new Object[0]) : null;
2015-05-05 22:43:47 +02:00
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
2014-11-25 22:32:16 +01:00
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
2018-08-26 04:00:00 +02:00
}
2014-11-25 22:32:16 +01:00
+
+ cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(event.getKickMessage());
+ return null;
2018-08-26 04:00:00 +02:00
+ }
2014-11-25 22:32:16 +01:00
+ return entity;
}
- public EntityPlayer processLogin(GameProfile gameprofile) {
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
2014-12-06 21:53:57 +01:00
+ /* CraftBukkit startMoved up
2014-11-25 22:32:16 +01:00
UUID uuid = EntityHuman.a(gameprofile);
2018-12-25 22:00:00 +01:00
List<EntityPlayer> list = Lists.newArrayList();
2014-11-25 22:32:16 +01:00
2019-05-12 03:15:48 +02:00
@@ -369,14 +533,24 @@
2014-11-25 22:32:16 +01:00
}
2018-08-26 04:00:00 +02:00
return new EntityPlayer(this.server, this.server.getWorldServer(DimensionManager.OVERWORLD), gameprofile, (PlayerInteractManager) object);
2015-02-26 23:41:06 +01:00
+ */
2014-11-25 22:32:16 +01:00
+ return player;
2016-06-25 12:38:13 +02:00
+ // CraftBukkit end
2014-11-25 22:32:16 +01:00
}
+ // CraftBukkit start
2018-08-26 04:00:00 +02:00
public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag) {
+ return this.moveToWorld(entityplayer, dimensionmanager, flag, null, true);
2014-11-25 22:32:16 +01:00
+ }
2016-03-06 04:35:33 +01:00
+
2018-08-26 04:00:00 +02:00
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, DimensionManager dimensionmanager, boolean flag, Location location, boolean avoidSuffocation) {
2017-04-21 06:56:41 +02:00
+ entityplayer.stopRiding(); // CraftBukkit
2014-11-25 22:32:16 +01:00
this.players.remove(entityplayer);
2019-04-23 04:00:00 +02:00
entityplayer.getWorldServer().removePlayer(entityplayer);
2014-11-25 22:32:16 +01:00
BlockPosition blockposition = entityplayer.getBed();
boolean flag1 = entityplayer.isRespawnForced();
+ /* CraftBukkit start
2018-08-26 04:00:00 +02:00
entityplayer.dimension = dimensionmanager;
2014-11-25 22:32:16 +01:00
Object object;
2019-05-12 03:15:48 +02:00
@@ -387,6 +561,11 @@
2014-11-25 22:32:16 +01:00
}
EntityPlayer entityplayer1 = new EntityPlayer(this.server, this.server.getWorldServer(entityplayer.dimension), entityplayer.getProfile(), (PlayerInteractManager) object);
+ // */
+ EntityPlayer entityplayer1 = entityplayer;
+ org.bukkit.World fromWorld = entityplayer.getBukkitEntity().getWorld();
+ entityplayer.viewingCredits = false;
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
2014-11-25 22:32:16 +01:00
entityplayer1.playerConnection = entityplayer.playerConnection;
2017-05-14 04:00:00 +02:00
entityplayer1.copyFrom(entityplayer, flag);
2019-05-12 03:15:48 +02:00
@@ -400,42 +579,100 @@
2017-05-14 04:00:00 +02:00
entityplayer1.addScoreboardTag(s);
2016-02-29 22:32:46 +01:00
}
2014-11-25 22:32:16 +01:00
- WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension);
+ // WorldServer worldserver = this.server.getWorldServer(entityplayer.dimension); // CraftBukkit - handled later
- this.a(entityplayer1, entityplayer, worldserver);
- if (blockposition != null) {
2019-04-25 04:00:00 +02:00
- Optional<Vec3D> optional = EntityHuman.getBed(this.server.getWorldServer(entityplayer.dimension), blockposition, flag1);
2019-04-23 04:00:00 +02:00
+ // this.a(entityplayer1, entityplayer, worldserver); // CraftBukkit - removed
2019-04-25 04:00:00 +02:00
- if (optional.isPresent()) {
- Vec3D vec3d = (Vec3D) optional.get();
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - fire PlayerRespawnEvent
+ if (location == null) {
+ boolean isBedSpawn = false;
+ CraftWorld cworld = (CraftWorld) this.server.server.getWorld(entityplayer.spawnWorld);
+ if (cworld != null && blockposition != null) {
2019-04-25 04:00:00 +02:00
+ Optional<Vec3D> optional = EntityHuman.getBed(cworld.getHandle(), blockposition, flag1);
- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F);
- entityplayer1.setRespawnPosition(blockposition, flag1);
- } else {
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F));
+ if (optional.isPresent()) {
+ Vec3D vec3d = (Vec3D) optional.get();
+
2014-11-25 22:32:16 +01:00
+ isBedSpawn = true;
2019-04-25 04:00:00 +02:00
+ location = new Location(cworld, vec3d.x, vec3d.y, vec3d.z);
2014-11-25 22:32:16 +01:00
+ } else {
+ entityplayer1.setRespawnPosition(null, true);
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(0, 0.0F));
+ }
2018-08-26 04:00:00 +02:00
}
2014-11-25 22:32:16 +01:00
+
+ if (location == null) {
+ cworld = (CraftWorld) this.server.server.getWorlds().get(0);
2018-07-15 02:00:00 +02:00
+ blockposition = entityplayer1.getSpawnPoint(cworld.getHandle());
2016-03-06 04:35:33 +01:00
+ location = new Location(cworld, (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
2018-08-26 04:00:00 +02:00
+ }
2014-11-25 22:32:16 +01:00
+
+ Player respawnPlayer = cserver.getPlayer(entityplayer1);
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn);
+ cserver.getPluginManager().callEvent(respawnEvent);
+
+ location = respawnEvent.getRespawnLocation();
2019-04-27 07:43:04 +02:00
+ if (!flag) entityplayer.reset(); // SPIGOT-4785
2014-11-25 22:32:16 +01:00
+ } else {
2018-08-26 04:00:00 +02:00
+ location.setWorld(server.getWorldServer(dimensionmanager).getWorld());
2014-11-25 22:32:16 +01:00
}
+ WorldServer worldserver = ((CraftWorld) location.getWorld()).getHandle();
2016-10-23 05:00:35 +02:00
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
2019-04-23 04:00:00 +02:00
- while (!worldserver.getCubes(entityplayer1) && entityplayer1.locY < 256.0D) {
+ while (avoidSuffocation && !worldserver.getCubes(entityplayer1) && entityplayer1.locY < 256.0D) {
2014-11-25 22:32:16 +01:00
entityplayer1.setPosition(entityplayer1.locX, entityplayer1.locY + 1.0D, entityplayer1.locZ);
}
+ // CraftBukkit start
+ // Force the client to refresh their chunk cache
2015-03-08 11:58:10 +01:00
+ if (fromWorld.getEnvironment() == worldserver.getWorld().getEnvironment()) {
2019-04-23 04:00:00 +02:00
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getDimensionID() >= 0 ? DimensionManager.NETHER : DimensionManager.OVERWORLD, worldserver.getWorldData().getType(), entityplayer.playerInteractManager.getGameMode()));
2015-03-08 11:58:10 +01:00
+ }
2016-06-09 03:43:49 +02:00
2019-04-23 04:00:00 +02:00
- WorldData worlddata = entityplayer1.world.getWorldData();
+ WorldData worlddata = worldserver.getWorldData();
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.dimension, worlddata.getType(), entityplayer1.playerInteractManager.getGameMode()));
2019-05-12 03:15:48 +02:00
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver.worldProvider.getDimensionManager().getType(), worldserver.getWorldData().getType(), entityplayer1.playerInteractManager.getGameMode()));
2014-11-25 22:32:16 +01:00
+ entityplayer1.spawnIn(worldserver);
+ entityplayer1.dead = false;
+ entityplayer1.playerConnection.teleport(new Location(worldserver.getWorld(), entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch));
+ entityplayer1.setSneaking(false);
2019-04-25 04:00:00 +02:00
BlockPosition blockposition1 = worldserver.getSpawn();
2019-04-23 04:00:00 +02:00
2014-11-25 22:32:16 +01:00
- entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
+ // entityplayer1.playerConnection.a(entityplayer1.locX, entityplayer1.locY, entityplayer1.locZ, entityplayer1.yaw, entityplayer1.pitch);
2019-04-25 04:00:00 +02:00
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition1));
2019-04-23 04:00:00 +02:00
entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
2014-11-25 22:32:16 +01:00
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
2019-04-23 04:00:00 +02:00
this.a(entityplayer1, worldserver);
this.d(entityplayer1);
- worldserver.addPlayerRespawn(entityplayer1);
2014-11-25 22:32:16 +01:00
- this.players.add(entityplayer1);
2015-02-26 23:41:06 +01:00
- this.j.put(entityplayer1.getUniqueID(), entityplayer1);
2016-03-06 06:25:50 +01:00
- entityplayer1.syncInventory();
2014-11-25 22:32:16 +01:00
+ if (!entityplayer.playerConnection.isDisconnected()) {
2019-04-23 04:00:00 +02:00
+ worldserver.addPlayerRespawn(entityplayer1);
2014-11-25 22:32:16 +01:00
+ this.players.add(entityplayer1);
2015-02-26 23:41:06 +01:00
+ this.j.put(entityplayer1.getUniqueID(), entityplayer1);
2014-11-25 22:32:16 +01:00
+ }
2016-03-06 06:25:50 +01:00
+ // entityplayer1.syncInventory();
2016-03-06 04:35:33 +01:00
entityplayer1.setHealth(entityplayer1.getHealth());
2014-11-25 22:32:16 +01:00
+ // Added from changeDimension
+ updateClient(entityplayer); // Update health, etc...
+ entityplayer.updateAbilities();
+ for (Object o1 : entityplayer.getEffects()) {
+ MobEffect mobEffect = (MobEffect) o1;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityEffect(entityplayer.getId(), mobEffect));
+ }
+
2017-05-14 04:00:00 +02:00
+ // Fire advancement trigger
2019-04-23 04:00:00 +02:00
+ entityplayer.b(((CraftWorld) fromWorld).getHandle());
2017-05-14 04:00:00 +02:00
+
2014-11-25 22:32:16 +01:00
+ // Don't fire on respawn
+ if (fromWorld != location.getWorld()) {
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
+ server.server.getPluginManager().callEvent(event);
+ }
+
+ // Save player file again if they were disconnected
+ if (entityplayer.playerConnection.isDisconnected()) {
+ this.savePlayerFile(entityplayer);
+ }
+ // CraftBukkit end
return entityplayer1;
}
2019-05-12 03:15:48 +02:00
@@ -448,7 +685,18 @@
2014-11-25 22:32:16 +01:00
public void tick() {
2017-05-14 04:00:00 +02:00
if (++this.v > 600) {
2016-11-28 00:02:40 +01:00
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, this.players));
+ // CraftBukkit start
+ for (int i = 0; i < this.players.size(); ++i) {
+ final EntityPlayer target = (EntityPlayer) this.players.get(i);
+
+ target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() {
+ @Override
+ public boolean apply(EntityPlayer input) {
+ return target.getBukkitEntity().canSee(input.getBukkitEntity());
+ }
+ })));
+ }
+ // CraftBukkit end
2017-05-14 04:00:00 +02:00
this.v = 0;
2016-11-28 00:02:40 +01:00
}
2019-05-12 03:15:48 +02:00
@@ -461,6 +709,25 @@
2014-12-10 20:16:37 +01:00
}
2015-06-07 22:04:28 +02:00
+ // CraftBukkit start - add a world/entity limited version
+ public void sendAll(Packet packet, EntityHuman entityhuman) {
+ for (int i = 0; i < this.players.size(); ++i) {
+ EntityPlayer entityplayer = this.players.get(i);
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
+ continue;
+ }
+ ((EntityPlayer) this.players.get(i)).playerConnection.sendPacket(packet);
+ }
+ }
+
2014-12-10 20:16:37 +01:00
+ public void sendAll(Packet packet, World world) {
2019-04-23 04:00:00 +02:00
+ for (int i = 0; i < world.getPlayers().size(); ++i) {
+ ((EntityPlayer) world.getPlayers().get(i)).playerConnection.sendPacket(packet);
2014-12-10 20:16:37 +01:00
+ }
+
+ }
+ // CraftBukkit end
+
2018-08-26 04:00:00 +02:00
public void a(Packet<?> packet, DimensionManager dimensionmanager) {
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2019-05-12 03:15:48 +02:00
@@ -561,6 +828,7 @@
2018-07-15 02:00:00 +02:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
}
2014-11-25 22:32:16 +01:00
2018-07-15 02:00:00 +02:00
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommandDispatcher().a(entityplayer);
2014-11-25 22:32:16 +01:00
}
2019-05-12 03:15:48 +02:00
@@ -593,6 +861,12 @@
2018-08-26 04:00:00 +02:00
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - Test if player receiving packet can see the source of the packet
+ if (entityhuman != null && entityhuman instanceof EntityPlayer && !entityplayer.getBukkitEntity().canSee(((EntityPlayer) entityhuman).getBukkitEntity())) {
+ continue;
+ }
+ // CraftBukkit end
+
2018-08-26 04:00:00 +02:00
if (entityplayer != entityhuman && entityplayer.dimension == dimensionmanager) {
2014-11-25 22:32:16 +01:00
double d4 = d0 - entityplayer.locX;
double d5 = d1 - entityplayer.locY;
2019-05-12 03:15:48 +02:00
@@ -632,7 +906,7 @@
2014-11-25 22:32:16 +01:00
public void reloadWhitelist() {}
2019-04-23 04:00:00 +02:00
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
2018-08-26 04:00:00 +02:00
- WorldBorder worldborder = this.server.getWorldServer(DimensionManager.OVERWORLD).getWorldBorder();
2015-02-26 23:41:06 +01:00
+ WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit
2014-11-25 22:32:16 +01:00
2015-02-26 23:41:06 +01:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutWorldBorder(worldborder, PacketPlayOutWorldBorder.EnumWorldBorderAction.INITIALIZE));
2019-06-21 12:00:00 +02:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutUpdateTime(worldserver.getTime(), worldserver.getDayTime(), worldserver.getGameRules().getBoolean(GameRules.DO_DAYLIGHT_CYCLE)));
2019-05-12 03:15:48 +02:00
@@ -640,17 +914,26 @@
2016-11-17 02:41:03 +01:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(blockposition));
2017-05-19 13:00:13 +02:00
if (worldserver.isRaining()) {
2014-11-25 22:32:16 +01:00
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
2019-04-23 04:00:00 +02:00
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.h(1.0F)));
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.f(1.0F)));
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start - handle player weather
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(1, 0.0F));
2019-04-23 04:00:00 +02:00
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, worldserver.h(1.0F)));
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, worldserver.f(1.0F)));
2014-11-25 22:32:16 +01:00
+ entityplayer.setPlayerWeather(org.bukkit.WeatherType.DOWNFALL, false);
2019-05-14 02:00:00 +02:00
+ entityplayer.updateWeather(-worldserver.rainLevel, worldserver.rainLevel, -worldserver.thunderLevel, worldserver.thunderLevel);
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
}
}
public void updateClient(EntityPlayer entityplayer) {
entityplayer.updateInventory(entityplayer.defaultContainer);
- entityplayer.triggerHealthUpdate();
+ // entityplayer.triggerHealthUpdate();
+ entityplayer.getBukkitEntity().updateScaledHealth(); // CraftBukkit - Update scaled health on respawn and worldchange
entityplayer.playerConnection.sendPacket(new PacketPlayOutHeldItemSlot(entityplayer.inventory.itemInHandIndex));
2019-01-02 00:57:47 +01:00
+ // CraftBukkit start - from GameRules
2019-06-21 12:00:00 +02:00
+ int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23;
2019-01-02 00:57:47 +01:00
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
+ // CraftBukkit end
2014-11-25 22:32:16 +01:00
}
2019-01-02 00:57:47 +01:00
public int getPlayerCount() {
2019-05-12 03:15:48 +02:00
@@ -707,26 +990,39 @@
2016-08-23 06:02:48 +02:00
}
2014-11-25 22:32:16 +01:00
2019-04-23 04:00:00 +02:00
public void shutdown() {
2016-08-23 06:02:48 +02:00
- for (int i = 0; i < this.players.size(); ++i) {
2017-05-30 13:25:59 +02:00
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown", new Object[0]));
2016-08-23 06:02:48 +02:00
+ // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) {
+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
2014-11-25 22:32:16 +01:00
}
2016-08-23 06:02:48 +02:00
+ // CraftBukkit end
2016-12-20 21:00:00 +01:00
}
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) {
+ sendMessage(component, true);
+ }
2016-12-20 21:00:00 +01:00
+ }
2014-11-25 22:32:16 +01:00
+ // CraftBukkit end
2016-12-20 21:00:00 +01:00
+
2014-11-25 22:32:16 +01:00
public void sendMessage(IChatBaseComponent ichatbasecomponent, boolean flag) {
this.server.sendMessage(ichatbasecomponent);
2017-05-14 04:00:00 +02:00
ChatMessageType chatmessagetype = flag ? ChatMessageType.SYSTEM : ChatMessageType.CHAT;
2014-12-12 08:20:42 +01:00
2017-05-14 04:00:00 +02:00
- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype));
2014-12-12 08:20:42 +01:00
+ // CraftBukkit start - we run this through our processor first so we can get web links etc
2017-05-14 04:00:00 +02:00
+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype));
2014-12-12 08:20:42 +01:00
+ // CraftBukkit end
}
public void sendMessage(IChatBaseComponent ichatbasecomponent) {
2017-07-17 01:55:47 +02:00
this.sendMessage(ichatbasecomponent, true);
}
2017-08-03 15:00:00 +02:00
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
2017-07-17 01:55:47 +02:00
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
UUID uuid = entityhuman.getUniqueID();
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid);
+ ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager();
+ // CraftBukkit end
if (serverstatisticmanager == null) {
2018-08-26 04:00:00 +02:00
File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "stats");
2019-05-12 03:15:48 +02:00
@@ -741,7 +1037,7 @@
2018-07-15 02:00:00 +02:00
}
2017-07-17 01:55:47 +02:00
serverstatisticmanager = new ServerStatisticManager(this.server, file1);
- this.o.put(uuid, serverstatisticmanager);
+ // this.o.put(uuid, serverstatisticmanager); // CraftBukkit
}
return serverstatisticmanager;
2019-05-12 03:15:48 +02:00
@@ -749,14 +1045,14 @@
2017-07-17 01:55:47 +02:00
2019-04-23 04:00:00 +02:00
public AdvancementDataPlayer f(EntityPlayer entityplayer) {
2017-07-17 01:55:47 +02:00
UUID uuid = entityplayer.getUniqueID();
- AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) this.p.get(uuid);
+ AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) entityplayer.getAdvancementData(); // CraftBukkit
if (advancementdataplayer == null) {
2018-08-26 04:00:00 +02:00
File file = new File(this.server.getWorldServer(DimensionManager.OVERWORLD).getDataManager().getDirectory(), "advancements");
2017-07-17 01:55:47 +02:00
File file1 = new File(file, uuid + ".json");
advancementdataplayer = new AdvancementDataPlayer(this.server, file1, entityplayer);
- this.p.put(uuid, advancementdataplayer);
+ // this.p.put(uuid, advancementdataplayer); // CraftBukkit
}
advancementdataplayer.a(entityplayer);
2019-05-12 03:15:48 +02:00
@@ -792,13 +1088,20 @@
2017-07-17 01:55:47 +02:00
}
public void reload() {
- Iterator iterator = this.p.values().iterator();
+ // CraftBukkit start
+ /*Iterator iterator = this.p.values().iterator();
while (iterator.hasNext()) {
AdvancementDataPlayer advancementdataplayer = (AdvancementDataPlayer) iterator.next();
2017-05-16 13:22:07 +02:00
advancementdataplayer.b();
2017-07-17 01:55:47 +02:00
+ }*/
+
2017-05-16 13:22:07 +02:00
+ for (EntityPlayer player : players) {
2017-07-17 01:55:47 +02:00
+ player.getAdvancementData().b();
+ player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements
}
2017-05-16 13:22:07 +02:00
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
this.sendAll(new PacketPlayOutTags(this.server.getTagRegistry()));
PacketPlayOutRecipeUpdate packetplayoutrecipeupdate = new PacketPlayOutRecipeUpdate(this.server.getCraftingManager().b());