Fixed issue for when NPC is spawned onJoin.
Skin was not showing because the PacketPlayOutPlayerInfo (remove) was sent too early. Delay this by a factor of 10 to prevent this.
This commit is contained in:
parent
3120613f85
commit
e0862fcfb6
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_10_R1.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_10_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_10_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().subtract(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(true);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_10_R1 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_11_R1.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_11_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_11_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(true);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_11_R1 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_12_R1.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_12_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_12_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(true);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_12_R1 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -80,7 +80,7 @@ public class NPC_v1_8_R1 extends NPC {
|
|||
hologram.spawn(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_8_R2.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_8_R2.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_8_R2 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(false);
|
||||
|
||||
|
@ -82,9 +79,8 @@ public class NPC_v1_8_R2 extends NPC {
|
|||
|
||||
hologram.spawn(player);
|
||||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_8_R3.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_8_R3.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_8_R3 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().add(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(false);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_8_R3 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_9_R1.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_9_R1.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_9_R1 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().subtract(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(false);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_9_R1 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,7 +13,6 @@ import net.jitse.npclib.nms.v1_9_R2.packets.PacketPlayOutScoreboardTeamWrapper;
|
|||
import net.jitse.npclib.skin.Skin;
|
||||
import net.minecraft.server.v1_9_R2.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -37,9 +36,7 @@ public class NPC_v1_9_R2 extends NPC {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void create(Location location) {
|
||||
this.location = location;
|
||||
|
||||
public void createPackets() {
|
||||
this.hologram = new Hologram(location.clone().subtract(0, 0.5, 0), lines);
|
||||
hologram.generatePackets(false);
|
||||
|
||||
|
@ -84,7 +81,7 @@ public class NPC_v1_9_R2 extends NPC {
|
|||
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () ->
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 5);
|
||||
playerConnection.sendPacket(packetPlayOutPlayerInfoRemove), 50);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
|
@ -47,6 +48,13 @@ public class NPCLibPlugin extends JavaPlugin implements Listener {
|
|||
getServer().getConsoleSender().sendMessage(ChatColor.BLUE + "[NPCLib] " + ChatColor.WHITE + "plugin disabled.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
if (npc != null) {
|
||||
npc.show(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerShift(PlayerToggleSneakEvent event) {
|
||||
if (event.isSneaking()) {
|
||||
|
|
Loading…
Reference in New Issue