Fully fix kick bug for all versions.
The problem was that if a scoreboard team is sent while it's already registered, the player will disconnect. Since there does not appear to be any downside to never removing the team, we just won't remove the team, and send the team only once. If there are any problems with this in the future, we can implement a smart solution which will be able to handle the packet sending properly.
This commit is contained in:
@@ -15,5 +15,5 @@ interface PacketHandler {
|
||||
|
||||
void sendShowPackets(Player player);
|
||||
|
||||
void sendHidePackets(Player player, boolean scheduler);
|
||||
void sendHidePackets(Player player);
|
||||
}
|
||||
|
||||
@@ -58,20 +58,14 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
this.skin = skin;
|
||||
|
||||
gameProfile.getProperties().get("textures").clear();
|
||||
|
||||
if (skin != null) {
|
||||
if (skin != null)
|
||||
gameProfile.getProperties().put("textures", new Property("textures", skin.getValue(), skin.getSignature()));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
destroy(true);
|
||||
}
|
||||
|
||||
public void destroy(boolean scheduler) {
|
||||
NPCManager.remove(this);
|
||||
|
||||
// Destroy NPC for every player that is still seeing it.
|
||||
@@ -80,7 +74,7 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
continue;
|
||||
}
|
||||
|
||||
hide(Bukkit.getPlayer(uuid), true, scheduler);
|
||||
hide(Bukkit.getPlayer(uuid), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +125,11 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void onLogout(Player player) {
|
||||
getAutoHidden().remove(player.getUniqueId());
|
||||
getShown().remove(player.getUniqueId()); // Don't need to use NPC#hide since the entity is not registered in the NMS server.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Player player) {
|
||||
show(player, false);
|
||||
@@ -181,10 +180,10 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
|
||||
@Override
|
||||
public void hide(Player player) {
|
||||
hide(player, false, true);
|
||||
hide(player, false);
|
||||
}
|
||||
|
||||
public void hide(Player player, boolean auto, boolean scheduler) {
|
||||
public void hide(Player player, boolean auto) {
|
||||
NPCHideEvent event = new NPCHideEvent(this, player, auto);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
@@ -192,7 +191,7 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
}
|
||||
|
||||
if (auto) {
|
||||
sendHidePackets(player, scheduler);
|
||||
sendHidePackets(player);
|
||||
} else {
|
||||
if (!shown.contains(player.getUniqueId())) {
|
||||
throw new RuntimeException("Cannot call hide method without calling NPC#show.");
|
||||
@@ -202,7 +201,7 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
|
||||
|
||||
if (player.getWorld().equals(location.getWorld()) && player.getLocation().distance(location)
|
||||
<= instance.getAutoHideDistance()) {
|
||||
sendHidePackets(player, scheduler);
|
||||
sendHidePackets(player);
|
||||
} else {
|
||||
autoHidden.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user