More code for #20

Started work on 1.8 R2 to 1.9 R2 with some slight errors, will be fixed later. 1.8 R1 should be working though.
This commit is contained in:
Jitse Boonstra
2019-10-20 11:36:37 +02:00
parent 96028d2ca1
commit cd1115d2a3
14 changed files with 289 additions and 35 deletions
@@ -20,10 +20,10 @@ interface PacketHandler {
void sendMetadataPacket(Player player);
void sendEquipmentPacket(Player player, NPCSlot slot);
void sendEquipmentPacket(Player player, NPCSlot slot, boolean auto);
default void sendEquipmentPackets(Player player) {
for (NPCSlot slot : NPCSlot.values())
sendEquipmentPacket(player, slot);
sendEquipmentPacket(player, slot, true);
}
}
@@ -41,7 +41,8 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
protected Location location;
protected Skin skin;
protected ItemStack helmet, chestplate, leggings, boots, inHand;
// offHand support in 1.9 R1 and later.
protected ItemStack helmet, chestplate, leggings, boots, inHand, offHand;
public SimpleNPC(NPCLib instance, List<String> lines) {
this.instance = instance;
@@ -280,7 +281,7 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
case BOOTS:
this.boots = item;
break;
case IN_HAND:
case MAINHAND:
this.inHand = item;
break;
default:
@@ -290,7 +291,7 @@ public abstract class SimpleNPC implements NPC, PacketHandler {
for (UUID shownUuid : shown) {
Player player = Bukkit.getPlayer(shownUuid);
if (player != null && isShown(player)) {
sendEquipmentPacket(player, slot);
sendEquipmentPacket(player, slot, false);
}
}
return this;