For v1.1.1, fixes reload bug.
This commit is contained in:
parent
63f60c4208
commit
11936e630c
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-api</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-commons</artifactId>
|
||||
|
|
|
@ -57,7 +57,12 @@ public abstract class NPC {
|
|||
return gameProfile;
|
||||
}
|
||||
|
||||
|
||||
public void destroy() {
|
||||
destroy(true);
|
||||
}
|
||||
|
||||
public void destroy(boolean scheduler) {
|
||||
NPCManager.remove(this);
|
||||
|
||||
// Destroy NPC for every player that is still seeing it.
|
||||
|
@ -66,7 +71,7 @@ public abstract class NPC {
|
|||
continue;
|
||||
}
|
||||
|
||||
hide(Bukkit.getPlayer(uuid), true);
|
||||
hide(Bukkit.getPlayer(uuid), true, scheduler);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,10 +136,10 @@ public abstract class NPC {
|
|||
protected abstract void sendShowPackets(Player player);
|
||||
|
||||
public void hide(Player player) {
|
||||
hide(player, false);
|
||||
hide(player, false, true);
|
||||
}
|
||||
|
||||
public void hide(Player player, boolean auto) {
|
||||
public void hide(Player player, boolean auto, boolean scheduler) {
|
||||
NPCDestroyEvent event = new NPCDestroyEvent(this, player, auto ? TriggerType.AUTOMATIC : TriggerType.MANUAL);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
|
@ -142,7 +147,7 @@ public abstract class NPC {
|
|||
}
|
||||
|
||||
if (auto) {
|
||||
sendHidePackets(player);
|
||||
sendHidePackets(player, scheduler);
|
||||
} else {
|
||||
if (!shown.contains(player.getUniqueId())) {
|
||||
throw new RuntimeException("Cannot call hide method without calling NPC#show.");
|
||||
|
@ -151,7 +156,7 @@ public abstract class NPC {
|
|||
shown.remove(player.getUniqueId());
|
||||
|
||||
if (player.getWorld().equals(location.getWorld()) && player.getLocation().distance(location) <= autoHideDistance) {
|
||||
sendHidePackets(player);
|
||||
sendHidePackets(player, scheduler);
|
||||
} else {
|
||||
if (autoHidden.contains(player.getUniqueId())) {
|
||||
autoHidden.remove(player.getUniqueId());
|
||||
|
@ -161,5 +166,5 @@ public abstract class NPC {
|
|||
}
|
||||
|
||||
// Internal method.
|
||||
protected abstract void sendHidePackets(Player player);
|
||||
protected abstract void sendHidePackets(Player player, boolean scheduler);
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class ChunkListener implements Listener {
|
|||
continue;
|
||||
}
|
||||
|
||||
npc.hide(Bukkit.getPlayer(uuid), true);
|
||||
npc.hide(Bukkit.getPlayer(uuid), true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class PlayerListener implements Listener {
|
|||
if (npc.getLocation().getWorld().equals(from)) {
|
||||
if (!npc.getAutoHidden().contains(player.getUniqueId())) {
|
||||
npc.getAutoHidden().add(player.getUniqueId());
|
||||
npc.hide(player, true);
|
||||
npc.hide(player, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class PlayerListener implements Listener {
|
|||
} else {
|
||||
// Check if the player and NPC are out of range to sendHidePackets it.
|
||||
if (!inRange) {
|
||||
npc.hide(player, true);
|
||||
npc.hide(player, true, true);
|
||||
npc.getAutoHidden().add(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_10_R1</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_10_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_10_R1 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_11_R1</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_11_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_11_R1 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_12_R1</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_12_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_12_R1 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_8_R1</artifactId>
|
||||
|
|
|
@ -87,7 +87,7 @@ public class NPC_v1_8_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -95,8 +95,12 @@ public class NPC_v1_8_R1 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_8_R2</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_8_R2 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_8_R2 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_8_R3</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_8_R3 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_8_R3 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_9_R1</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_9_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_9_R1 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib-nms</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-nms-v1_9_R2</artifactId>
|
||||
|
|
|
@ -88,7 +88,7 @@ public class NPC_v1_9_R2 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void sendHidePackets(Player player) {
|
||||
public void sendHidePackets(Player player, boolean scheduler) {
|
||||
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
|
||||
|
||||
playerConnection.sendPacket(packetPlayOutEntityDestroy);
|
||||
|
@ -96,8 +96,12 @@ public class NPC_v1_9_R2 extends NPC {
|
|||
|
||||
hologram.destroy(player);
|
||||
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
if (scheduler) {
|
||||
// Sending this a bit later so the player doesn't see the name (for that split second).
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister), 5);
|
||||
} else {
|
||||
playerConnection.sendPacket(packetPlayOutScoreboardTeamUnregister);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<parent>
|
||||
<groupId>net.jitse</groupId>
|
||||
<artifactId>npclib</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.1.1</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>npclib-plugin</artifactId>
|
||||
|
|
Loading…
Reference in New Issue