3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-20 21:40:06 +01:00
Paper/nms-patches/PlayerList.patch

769 Zeilen
41 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/PlayerList.java
+++ b/net/minecraft/server/PlayerList.java
2020-06-25 02:00:00 +02:00
@@ -21,6 +21,27 @@
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;
+
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.CraftWorld;
+
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.util.CraftChatMessage;
+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 {
2019-12-10 23:00:00 +01:00
public static final File b = new File("banned-players.json");
2020-06-25 02:00:00 +02:00
@@ -30,14 +51,16 @@
2019-04-25 04:00:00 +02:00
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");
private final MinecraftServer server;
- 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();
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
2020-06-25 02:00:00 +02:00
public final WorldNBTStorage playerFileData;
2017-07-17 01:55:47 +02:00
private boolean hasWhitelist;
2020-06-25 02:00:00 +02:00
private final IRegistryCustom.Dimension s;
@@ -47,13 +70,23 @@
private boolean v;
private int w;
+ // CraftBukkit start
+ private CraftServer cserver;
+
2020-06-25 02:00:00 +02:00
public PlayerList(MinecraftServer minecraftserver, IRegistryCustom.Dimension iregistrycustom_dimension, WorldNBTStorage worldnbtstorage, int i) {
2019-04-23 04:00:00 +02:00
+ this.cserver = minecraftserver.server = new CraftServer((DedicatedServer) minecraftserver, this);
+ minecraftserver.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
+ minecraftserver.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(minecraftserver.server));
+ // CraftBukkit end
+
2019-12-10 23:00:00 +01:00
this.k = new GameProfileBanList(PlayerList.b);
this.l = new IpBanList(PlayerList.c);
this.operators = new OpList(PlayerList.d);
this.whitelist = new WhiteList(PlayerList.e);
2017-07-17 01:55:47 +02:00
- this.o = Maps.newHashMap();
- this.p = Maps.newHashMap();
+ // CraftBukkit start
+ // this.o = Maps.newHashMap();
+ // this.p = Maps.newHashMap();
+ // CraftBukkit end
this.server = minecraftserver;
2020-06-25 02:00:00 +02:00
this.s = iregistrycustom_dimension;
2019-04-23 04:00:00 +02:00
this.maxPlayers = i;
2020-06-25 02:00:00 +02:00
@@ -69,6 +102,12 @@
usercache.a(gameprofile);
NBTTagCompound nbttagcompound = this.a(entityplayer);
2020-06-25 02:00:00 +02:00
ResourceKey resourcekey;
+ // CraftBukkit start - Better rename detection
2015-02-04 21:33:06 +01:00
+ if (nbttagcompound != null && nbttagcompound.hasKey("bukkit")) {
+ NBTTagCompound bukkit = nbttagcompound.getCompound("bukkit");
+ s = bukkit.hasKeyOfType("lastKnownName", 8) ? bukkit.getString("lastKnownName") : s;
+ }
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
if (nbttagcompound != null) {
DataResult dataresult = DimensionManager.a(new Dynamic(DynamicOpsNBT.a, nbttagcompound.get("Dimension")));
@@ -99,7 +138,8 @@
s1 = networkmanager.getSocketAddress().toString();
}
2019-12-10 23:00:00 +01:00
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
+ // CraftBukkit - Moved message to after join
2019-12-10 23:00:00 +01:00
+ // PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
2020-06-25 02:00:00 +02:00
WorldData worlddata = worldserver1.getWorldData();
2016-11-17 02:41:03 +01:00
2020-06-25 02:00:00 +02:00
this.a(entityplayer, (EntityPlayer) null, worldserver1);
@@ -109,6 +149,7 @@
2019-12-10 23:00:00 +01:00
boolean flag1 = gamerules.getBoolean(GameRules.REDUCED_DEBUG_INFO);
2020-06-25 02:00:00 +02:00
playerconnection.sendPacket(new PacketPlayOutLogin(entityplayer.getId(), entityplayer.playerInteractManager.getGameMode(), entityplayer.playerInteractManager.c(), BiomeManager.a(worldserver1.getSeed()), worlddata.isHardcore(), this.server.E(), this.s, worldserver1.getTypeKey(), worldserver1.getDimensionKey(), this.getMaxPlayers(), this.viewDistance, flag1, !flag, worldserver1.isDebugWorld(), worldserver1.isFlatWorld()));
+ 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));
2020-06-25 02:00:00 +02:00
@@ -127,19 +168,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});
}
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
+ chatmessage.a(EnumChatFormat.YELLOW);
+ String joinMessage = CraftChatMessage.fromComponent(chatmessage);
2020-06-25 02:00:00 +02:00
- this.sendMessage(chatmessage.a(EnumChatFormat.YELLOW), ChatMessageType.SYSTEM, SystemUtils.b);
2019-12-10 23:00:00 +01:00
playerconnection.a(entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch);
2019-04-23 04:00:00 +02:00
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)) {
2020-06-25 02:00:00 +02:00
+ server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b));
2019-04-23 04:00:00 +02:00
+ }
+ }
+ // 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;
+ // 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
2020-06-25 02:00:00 +02:00
+ if (entityplayer.world == worldserver1 && !worldserver1.getPlayers().contains(entityplayer)) {
+ worldserver1.addPlayerJoin(entityplayer);
2019-04-23 04:00:00 +02:00
+ this.server.getBossBattleCustomData().a(entityplayer);
}
2020-06-25 02:00:00 +02:00
- worldserver1.addPlayerJoin(entityplayer);
2019-04-23 04:00:00 +02:00
- this.server.getBossBattleCustomData().a(entityplayer);
2020-06-25 02:00:00 +02:00
+ worldserver1 = entityplayer.getWorldServer(); // CraftBukkit - Update in case join event changed it
2019-04-23 04:00:00 +02:00
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
this.a(entityplayer, worldserver1);
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());
2020-06-25 02:00:00 +02:00
@@ -155,8 +238,11 @@
2019-04-23 04:00:00 +02:00
if (nbttagcompound != null && nbttagcompound.hasKeyOfType("RootVehicle", 10)) {
NBTTagCompound nbttagcompound1 = nbttagcompound.getCompound("RootVehicle");
2020-06-25 02:00:00 +02:00
- Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), worldserver1, (entity1) -> {
- return !worldserver1.addEntitySerialized(entity1) ? null : entity1;
2019-04-23 04:00:00 +02:00
+ // CraftBukkit start
2020-06-25 02:00:00 +02:00
+ WorldServer finalWorldServer = worldserver1;
2019-04-23 04:00:00 +02:00
+ Entity entity = EntityTypes.a(nbttagcompound1.getCompound("Entity"), finalWorldServer, (entity1) -> {
+ return !finalWorldServer.addEntitySerialized(entity1) ? null : entity1;
+ // CraftBukkit end
});
if (entity != null) {
2020-06-25 02:00:00 +02:00
@@ -199,6 +285,8 @@
}
2016-02-29 22:32:46 +01:00
entityplayer.syncInventory();
+ // CraftBukkit - Moved from above, added world
2020-06-25 02:00:00 +02:00
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", entityplayer.getDisplayName().getString(), s1, entityplayer.getId(), worldserver1.worldDataServer.getName(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ());
}
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
2020-06-25 02:00:00 +02:00
@@ -231,30 +319,31 @@
}
2018-08-26 04:00:00 +02:00
public void setPlayerFileData(WorldServer worldserver) {
+ if (playerFileData != null) return; // CraftBukkit
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
2020-06-25 02:00:00 +02:00
@@ -282,14 +371,15 @@
}
2017-07-17 01:55:47 +02:00
protected void savePlayerFile(EntityPlayer entityplayer) {
+ 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) {
2020-06-25 02:00:00 +02:00
serverstatisticmanager.save();
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) {
2020-06-25 02:00:00 +02:00
advancementdataplayer.b();
@@ -297,10 +387,21 @@
}
- 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);
+
+ // CraftBukkit start - Quitting must be before we do final save of data, in case plugins need to modify it
+ entityplayer.closeInventory();
+
+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game");
+ cserver.getPluginManager().callEvent(playerQuitEvent);
+ entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
+
+ entityplayer.playerTick(); // SPIGOT-924
+ // CraftBukkit end
+
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();
2020-06-25 02:00:00 +02:00
@@ -332,18 +433,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
2020-06-25 02:00:00 +02:00
+ }
+
+ // CraftBukkit start
2020-06-25 02:00:00 +02:00
+ // this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
2015-02-26 23:41:06 +01:00
+ PacketPlayOutPlayerInfo packet = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entityplayer);
+ for (int i = 0; i < players.size(); i++) {
2015-02-26 23:41:06 +01:00
+ EntityPlayer entityplayer2 = (EntityPlayer) this.players.get(i);
+
2015-02-26 23:41:06 +01:00
+ if (entityplayer2.getBukkitEntity().canSee(entityplayer.getBukkitEntity())) {
+ entityplayer2.playerConnection.sendPacket(packet);
+ } else {
2015-02-26 23:41:06 +01:00
+ entityplayer2.getBukkitEntity().removeDisconnectingPlayer(entityplayer.getBukkitEntity());
+ }
2020-06-25 02:00:00 +02:00
}
+ // This removes the scoreboard (and player reference) for the specific player in the manager
+ cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
- this.sendAll(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, new EntityPlayer[]{entityplayer}));
+ return playerQuitEvent.getQuitMessage(); // CraftBukkit
}
2018-07-15 02:00:00 +02:00
- @Nullable
- public IChatBaseComponent attemptLogin(SocketAddress socketaddress, GameProfile gameprofile) {
+ // 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)) {
+ // Moved from processLogin
+ UUID uuid = EntityHuman.a(gameprofile);
2018-12-25 22:00:00 +01:00
+ List<EntityPlayer> list = Lists.newArrayList();
+
+ 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);
+ }
+ }
+
2018-12-25 22:00:00 +01:00
+ Iterator iterator = list.iterator();
+
+ 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]));
+ }
2015-02-26 23:41:06 +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();
+
2020-06-25 02:00:00 +02:00
+ EntityPlayer entity = new EntityPlayer(this.server, this.server.getWorldServer(World.OVERWORLD), gameprofile, new PlayerInteractManager(this.server.getWorldServer(World.OVERWORLD)));
+ Player player = entity.getBukkitEntity();
+ PlayerLoginEvent event = new PlayerLoginEvent(player, hostname, ((java.net.InetSocketAddress) socketaddress).getAddress());
2018-07-15 02:00:00 +02: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()});
2020-06-25 02:00:00 +02:00
@@ -351,10 +500,12 @@
2019-05-27 22:30:00 +02:00
chatmessage.addSibling(new ChatMessage("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.g.format(gameprofilebanentry.getExpires())}));
}
2018-07-15 02:00:00 +02:00
- return chatmessage;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else if (!this.isWhitelisted(gameprofile)) {
2020-06-25 02:00:00 +02:00
- return new ChatMessage("multiplayer.disconnect.not_whitelisted");
- } else if (this.l.isBanned(socketaddress)) {
2020-06-25 02:00:00 +02:00
+ chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted");
2018-07-15 02:00:00 +02:00
+ event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, CraftChatMessage.fromComponent(chatmessage));
+ } 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()});
2020-06-25 02:00:00 +02:00
@@ -362,13 +513,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())}));
}
2018-07-15 02:00:00 +02:00
- return chatmessage;
+ // return chatmessage;
+ event.disallow(PlayerLoginEvent.Result.KICK_BANNED, CraftChatMessage.fromComponent(chatmessage));
} else {
2020-06-25 02:00:00 +02:00
- return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
+ // return this.players.size() >= this.maxPlayers && !this.f(gameprofile) ? new ChatMessage("multiplayer.disconnect.server_full") : null;
2015-05-05 22:43:47 +02:00
+ if (this.players.size() >= this.maxPlayers && !this.f(gameprofile)) {
+ event.disallow(PlayerLoginEvent.Result.KICK_FULL, "The server is full");
+ }
2020-06-25 02:00:00 +02:00
}
+
+ cserver.getPluginManager().callEvent(event);
+ if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
+ loginlistener.disconnect(event.getKickMessage());
+ return null;
2020-06-25 02:00:00 +02:00
+ }
+ return entity;
}
- public EntityPlayer processLogin(GameProfile gameprofile) {
+ public EntityPlayer processLogin(GameProfile gameprofile, EntityPlayer player) { // CraftBukkit - added EntityPlayer
+ /* CraftBukkit startMoved up
UUID uuid = EntityHuman.a(gameprofile);
2018-12-25 22:00:00 +01:00
List<EntityPlayer> list = Lists.newArrayList();
2020-06-25 02:00:00 +02:00
@@ -404,13 +567,23 @@
}
2020-06-25 02:00:00 +02:00
return new EntityPlayer(this.server, worldserver, gameprofile, (PlayerInteractManager) object);
2015-02-26 23:41:06 +01:00
+ */
+ return player;
+ // CraftBukkit end
}
+ // CraftBukkit start
2020-06-25 02:00:00 +02:00
public EntityPlayer moveToWorld(EntityPlayer entityplayer, boolean flag) {
+ return this.moveToWorld(entityplayer, this.server.getWorldServer(entityplayer.getSpawnDimension()), flag, null, true);
+ }
+
2020-06-25 02:00:00 +02:00
+ public EntityPlayer moveToWorld(EntityPlayer entityplayer, WorldServer worldserver, boolean flag, Location location, boolean avoidSuffocation) {
+ entityplayer.stopRiding(); // CraftBukkit
this.players.remove(entityplayer);
2019-04-23 04:00:00 +02:00
entityplayer.getWorldServer().removePlayer(entityplayer);
2020-06-25 02:00:00 +02:00
BlockPosition blockposition = entityplayer.getSpawn();
boolean flag1 = entityplayer.isSpawnForced();
+ /* CraftBukkit start
2020-06-25 02:00:00 +02:00
WorldServer worldserver = this.server.getWorldServer(entityplayer.getSpawnDimension());
Optional optional;
2020-06-25 02:00:00 +02:00
@@ -430,6 +603,11 @@
}
2020-06-25 02:00:00 +02:00
EntityPlayer entityplayer1 = new EntityPlayer(this.server, worldserver1, 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
entityplayer1.playerConnection = entityplayer.playerConnection;
2017-05-14 04:00:00 +02:00
entityplayer1.copyFrom(entityplayer, flag);
2020-06-25 02:00:00 +02:00
@@ -443,41 +621,103 @@
2017-05-14 04:00:00 +02:00
entityplayer1.addScoreboardTag(s);
2016-02-29 22:32:46 +01:00
}
2020-06-25 02:00:00 +02:00
- this.a(entityplayer1, entityplayer, worldserver1);
+ // this.a(entityplayer1, entityplayer, worldserver1); // CraftBukkit - removed
boolean flag2 = false;
2019-04-25 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
- if (optional.isPresent()) {
- Vec3D vec3d = (Vec3D) optional.get();
+ // CraftBukkit start - fire PlayerRespawnEvent
+ if (location == null) {
+ boolean isBedSpawn = false;
2020-06-25 02:00:00 +02:00
+ WorldServer worldserver1 = this.server.getWorldServer(entityplayer.getSpawnDimension());
+ if (worldserver1 != null) {
+ Optional optional;
+
+ if (blockposition != null) {
+ optional = EntityHuman.getBed(worldserver1, blockposition, flag1, flag);
+ } else {
+ optional = Optional.empty();
+ }
- entityplayer1.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, 0.0F, 0.0F);
- entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false);
- flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor;
- } else if (blockposition != null) {
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F));
2019-04-25 04:00:00 +02:00
+ if (optional.isPresent()) {
+ Vec3D vec3d = (Vec3D) optional.get();
+
+ isBedSpawn = true;
2020-06-25 02:00:00 +02:00
+ location = new Location(worldserver1.getWorld(), vec3d.x, vec3d.y, vec3d.z);
+
+ entityplayer1.setRespawnPosition(worldserver1.getDimensionKey(), blockposition, flag1, false);
+ flag2 = !flag && worldserver1.getType(blockposition).getBlock() instanceof BlockRespawnAnchor;
+ } else if (blockposition != null) {
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.a, 0.0F));
+ }
+ }
+
+ if (location == null) {
2020-06-25 02:00:00 +02:00
+ worldserver1 = this.server.getWorldServer(World.OVERWORLD);
+ blockposition = entityplayer1.getSpawnPoint(worldserver1);
+ location = new Location(worldserver1.getWorld(), (double) ((float) blockposition.getX() + 0.5F), (double) ((float) blockposition.getY() + 0.1F), (double) ((float) blockposition.getZ() + 0.5F));
+ }
+
+ Player respawnPlayer = cserver.getPlayer(entityplayer1);
+ PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(respawnPlayer, location, isBedSpawn && !flag2, flag2);
+ cserver.getPluginManager().callEvent(respawnEvent);
+
+ location = respawnEvent.getRespawnLocation();
+ if (!flag) entityplayer.reset(); // SPIGOT-4785
+ } else {
2020-06-25 02:00:00 +02:00
+ location.setWorld(worldserver.getWorld());
}
2020-06-25 02:00:00 +02:00
+ WorldServer worldserver1 = ((CraftWorld) location.getWorld()).getHandle();
+ entityplayer1.forceSetPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
- while (!worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
+ while (avoidSuffocation && !worldserver1.getCubes(entityplayer1) && entityplayer1.locY() < 256.0D) {
2019-12-10 23:00:00 +01:00
entityplayer1.setPosition(entityplayer1.locX(), entityplayer1.locY() + 1.0D, entityplayer1.locZ());
}
+ // CraftBukkit start
2020-06-25 02:00:00 +02:00
+ WorldData worlddata = worldserver1.getWorldData();
+ entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(worldserver1.getTypeKey(), worldserver1.getDimensionKey(), BiomeManager.a(worldserver1.getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), worldserver1.isDebugWorld(), worldserver1.isFlatWorld(), flag));
+ entityplayer1.spawnIn(worldserver1);
+ entityplayer1.dead = false;
2020-06-25 02:00:00 +02:00
+ entityplayer1.playerConnection.teleport(new Location(worldserver1.getWorld(), entityplayer1.locX(), entityplayer1.locY(), entityplayer1.locZ(), entityplayer1.yaw, entityplayer1.pitch));
+ entityplayer1.setSneaking(false);
2019-04-23 04:00:00 +02:00
2020-06-25 02:00:00 +02:00
- WorldData worlddata = entityplayer1.world.getWorldData();
-
- entityplayer1.playerConnection.sendPacket(new PacketPlayOutRespawn(entityplayer1.world.getTypeKey(), entityplayer1.world.getDimensionKey(), BiomeManager.a(entityplayer1.getWorldServer().getSeed()), entityplayer1.playerInteractManager.getGameMode(), entityplayer1.playerInteractManager.c(), entityplayer1.getWorldServer().isDebugWorld(), entityplayer1.getWorldServer().isFlatWorld(), flag));
2019-12-10 23:00:00 +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);
2020-06-25 02:00:00 +02:00
entityplayer1.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver1.getSpawn()));
2019-04-23 04:00:00 +02:00
entityplayer1.playerConnection.sendPacket(new PacketPlayOutServerDifficulty(worlddata.getDifficulty(), worlddata.isDifficultyLocked()));
entityplayer1.playerConnection.sendPacket(new PacketPlayOutExperience(entityplayer1.exp, entityplayer1.expTotal, entityplayer1.expLevel));
2020-06-25 02:00:00 +02:00
this.a(entityplayer1, worldserver1);
2019-04-23 04:00:00 +02:00
this.d(entityplayer1);
2020-06-25 02:00:00 +02:00
- worldserver1.addPlayerRespawn(entityplayer1);
- this.players.add(entityplayer1);
2015-02-26 23:41:06 +01:00
- this.j.put(entityplayer1.getUniqueID(), entityplayer1);
- entityplayer1.syncInventory();
+ if (!entityplayer.playerConnection.isDisconnected()) {
2020-06-25 02:00:00 +02:00
+ worldserver1.addPlayerRespawn(entityplayer1);
+ this.players.add(entityplayer1);
2015-02-26 23:41:06 +01:00
+ this.j.put(entityplayer1.getUniqueID(), entityplayer1);
+ }
+ // entityplayer1.syncInventory();
entityplayer1.setHealth(entityplayer1.getHealth());
2020-06-25 02:00:00 +02:00
if (flag2) {
entityplayer1.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.BLOCK_RESPAWN_ANCHOR_DEPLETE, SoundCategory.BLOCKS, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), 1.0F, 1.0F));
}
+ // 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-12-10 23:00:00 +01:00
+ entityplayer.triggerDimensionAdvancements(((CraftWorld) fromWorld).getHandle());
2017-05-14 04:00:00 +02:00
+
+ // Don't fire on respawn
+ if (fromWorld != location.getWorld()) {
+ PlayerChangedWorldEvent event = new PlayerChangedWorldEvent(entityplayer.getBukkitEntity(), fromWorld);
+ server.server.getPluginManager().callEvent(event);
+ }
2020-06-25 02:00:00 +02:00
+ // Save player file again if they were disconnected
+ if (entityplayer.playerConnection.isDisconnected()) {
+ this.savePlayerFile(entityplayer);
+ }
+ // CraftBukkit end
return entityplayer1;
}
2020-06-25 02:00:00 +02:00
@@ -490,7 +730,18 @@
public void tick() {
2020-06-25 02:00:00 +02:00
if (++this.w > 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
2020-06-25 02:00:00 +02:00
this.w = 0;
2016-11-28 00:02:40 +01:00
}
2020-06-25 02:00:00 +02:00
@@ -503,6 +754,25 @@
}
+ // 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);
+ }
+ }
+
+ 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);
+ }
+
+ }
+ // CraftBukkit end
+
2020-06-25 02:00:00 +02:00
public void a(Packet<?> packet, ResourceKey<World> resourcekey) {
2018-08-26 04:00:00 +02:00
for (int i = 0; i < this.players.size(); ++i) {
EntityPlayer entityplayer = (EntityPlayer) this.players.get(i);
2020-06-25 02:00:00 +02:00
@@ -603,6 +873,7 @@
2018-07-15 02:00:00 +02:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, b0));
}
2018-07-15 02:00:00 +02:00
+ entityplayer.getBukkitEntity().recalculatePermissions(); // CraftBukkit
this.server.getCommandDispatcher().a(entityplayer);
}
2020-06-25 02:00:00 +02:00
@@ -635,6 +906,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);
+ // 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
+
2020-06-25 02:00:00 +02:00
if (entityplayer != entityhuman && entityplayer.world.getDimensionKey() == resourcekey) {
2019-12-10 23:00:00 +01:00
double d4 = d0 - entityplayer.locX();
double d5 = d1 - entityplayer.locY();
2020-06-25 02:00:00 +02:00
@@ -674,23 +951,34 @@
public void reloadWhitelist() {}
2019-04-23 04:00:00 +02:00
public void a(EntityPlayer entityplayer, WorldServer worldserver) {
2020-06-25 02:00:00 +02:00
- WorldBorder worldborder = this.server.D().getWorldBorder();
2015-02-26 23:41:06 +01:00
+ WorldBorder worldborder = entityplayer.world.getWorldBorder(); // CraftBukkit
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)));
2020-06-25 02:00:00 +02:00
entityplayer.playerConnection.sendPacket(new PacketPlayOutSpawnPosition(worldserver.getSpawn()));
2017-05-19 13:00:13 +02:00
if (worldserver.isRaining()) {
2020-06-25 02:00:00 +02:00
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F));
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F)));
- entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F)));
+ // CraftBukkit start - handle player weather
2020-06-25 02:00:00 +02:00
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.b, 0.0F));
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.h, worldserver.d(1.0F)));
+ // entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.i, worldserver.b(1.0F)));
+ 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);
+ // 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));
+ // CraftBukkit start - from GameRules
2019-06-21 12:00:00 +02:00
+ int i = entityplayer.world.getGameRules().getBoolean(GameRules.REDUCED_DEBUG_INFO) ? 22 : 23;
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutEntityStatus(entityplayer, (byte) i));
+ float immediateRespawn = entityplayer.world.getGameRules().getBoolean(GameRules.DO_IMMEDIATE_RESPAWN) ? 1.0F: 0.0F;
2020-06-25 02:00:00 +02:00
+ entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.l, immediateRespawn));
+ // CraftBukkit end
}
public int getPlayerCount() {
@@ -743,31 +1031,54 @@
entityplayer.playerInteractManager.a(this.u, EnumGamemode.NOT_SET);
}
- entityplayer.playerInteractManager.b(worldserver.getMinecraftServer().getSaveData().getGameType());
+ entityplayer.playerInteractManager.b(worldserver.worldDataServer.getGameType()); // CraftBukkit
}
2019-04-23 04:00:00 +02:00
public void shutdown() {
- for (int i = 0; i < this.players.size(); ++i) {
2020-06-25 02:00:00 +02:00
- ((EntityPlayer) this.players.get(i)).playerConnection.disconnect(new ChatMessage("multiplayer.disconnect.server_shutdown"));
+ // CraftBukkit start - disconnect safely
+ for (EntityPlayer player : this.players) {
+ player.playerConnection.disconnect(this.server.server.getShutdownMessage()); // CraftBukkit - add custom shutdown message
}
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
+
+ }
+ // CraftBukkit start
+ public void sendMessage(IChatBaseComponent[] iChatBaseComponents) {
+ for (IChatBaseComponent component : iChatBaseComponents) {
2020-06-25 02:00:00 +02:00
+ sendMessage(component, ChatMessageType.SYSTEM, SystemUtils.b);
+ }
2020-06-25 02:00:00 +02:00
}
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
public void sendMessage(IChatBaseComponent ichatbasecomponent, ChatMessageType chatmessagetype, UUID uuid) {
this.server.sendMessage(ichatbasecomponent, uuid);
- this.sendAll(new PacketPlayOutChat(ichatbasecomponent, chatmessagetype, uuid));
+ // CraftBukkit start - we run this through our processor first so we can get web links etc
2020-06-25 02:00:00 +02:00
+ this.sendAll(new PacketPlayOutChat(CraftChatMessage.fixComponent(ichatbasecomponent), chatmessagetype, uuid));
+ // CraftBukkit end
2020-06-25 02:00:00 +02:00
+ }
+
+ public void sendMessage(IChatBaseComponent ichatbasecomponent) {
+ this.sendMessage(ichatbasecomponent, ChatMessageType.SYSTEM, SystemUtils.b);
2017-07-17 01:55:47 +02:00
}
2017-08-03 15:00:00 +02:00
- public ServerStatisticManager getStatisticManager(EntityHuman entityhuman) {
- UUID uuid = entityhuman.getUniqueID();
2017-07-17 01:55:47 +02:00
- ServerStatisticManager serverstatisticmanager = uuid == null ? null : (ServerStatisticManager) this.o.get(uuid);
+ // CraftBukkit start
+ public ServerStatisticManager getStatisticManager(EntityPlayer entityhuman) {
+ ServerStatisticManager serverstatisticmanager = entityhuman.getStatisticManager();
+ return serverstatisticmanager == null ? getStatisticManager(entityhuman.getUniqueID(), entityhuman.getDisplayName().getString()) : serverstatisticmanager;
+ }
+
+ public ServerStatisticManager getStatisticManager(UUID uuid, String displayName) {
2020-06-25 02:00:00 +02:00
+ EntityPlayer entityhuman = this.getPlayer(uuid);
+ ServerStatisticManager serverstatisticmanager = entityhuman == null ? null : (ServerStatisticManager) entityhuman.getStatisticManager();
2017-07-17 01:55:47 +02:00
+ // CraftBukkit end
if (serverstatisticmanager == null) {
2020-06-25 02:00:00 +02:00
File file = this.server.a(SavedFile.STATS).toFile();
File file1 = new File(file, uuid + ".json");
if (!file1.exists()) {
- File file2 = new File(file, entityhuman.getDisplayName().getString() + ".json");
+ File file2 = new File(file, displayName + ".json"); // CraftBukkit
if (file2.exists() && file2.isFile()) {
file2.renameTo(file1);
2020-06-25 02:00:00 +02:00
@@ -775,7 +1086,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;
2020-06-25 02:00:00 +02:00
@@ -783,14 +1094,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) {
2020-06-25 02:00:00 +02:00
File file = this.server.a(SavedFile.ADVANCEMENTS).toFile();
2017-07-17 01:55:47 +02:00
File file1 = new File(file, uuid + ".json");
2020-06-25 02:00:00 +02:00
advancementdataplayer = new AdvancementDataPlayer(this.server.getDataFixer(), this, this.server.getAdvancementData(), file1, entityplayer);
2017-07-17 01:55:47 +02:00
- this.p.put(uuid, advancementdataplayer);
+ // this.p.put(uuid, advancementdataplayer); // CraftBukkit
}
advancementdataplayer.a(entityplayer);
2020-06-25 02:00:00 +02:00
@@ -826,13 +1137,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();
2020-06-25 02:00:00 +02:00
advancementdataplayer.a(this.server.getAdvancementData());
2017-07-17 01:55:47 +02:00
+ }*/
+
+ for (EntityPlayer player : players) {
2020-06-25 02:00:00 +02:00
+ player.getAdvancementData().a(this.server.getAdvancementData());
2017-07-17 01:55:47 +02:00
+ player.getAdvancementData().b(player); // CraftBukkit - trigger immediate flush of advancements
}
+ // 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());