Make NPCBase.java compliant with updated NPC.java

Makes NPCBase compliant with net.jitse.npclib.api.NPC.
Implements NPC#getText() to return List<String> and NPC#getSlot(NPCSlot slot) to return ItemStack.
This commit is contained in:
A248 2019-10-31 19:57:04 -04:00 committed by GitHub
parent d7144e445e
commit b97361516c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 0 deletions

View File

@ -263,6 +263,29 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
return this;
}
@Override
public ItemStack getItem(NPCSlot slot) {
if (slot == null) {
throw new NullPointerException("Slot cannot be null");
}
switch (slot) {
case HELMET:
return this.helmet;
case CHESTPLATE:
return this.chestplate;
case LEGGINGS:
return this.leggings;
case BOOTS:
return this.boots;
case MAINHAND:
return this.inHand;
case OFFHAND:
return this.offHand;
default:
throw new IllegalArgumentException("Entered an invalid inventory slot");
}
}
@Override
public NPC setItem(NPCSlot slot, ItemStack item) {
if (slot == null) {
@ -315,4 +338,9 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
this.text = text;
return this;
}
@Override
public List<String> getText() {
return text;
}
}