This commit is contained in:
Jitse Boonstra
2019-11-04 10:13:19 +01:00
3 changed files with 64 additions and 1 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-all</artifactId> <artifactId>netty-all</artifactId>
<version>4.1.33.Final</version> <version>4.1.42.Final</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
@@ -101,6 +101,14 @@ public interface NPC {
* @return Object instance. * @return Object instance.
*/ */
NPC toggleState(NPCState state); NPC toggleState(NPCState state);
/**
* Get state of NPC.
*
* @param state The state requested.
* @return boolean on/off status.
*/
boolean getState(NPCState state);
/** /**
* Change the item in the inventory of the NPC. * Change the item in the inventory of the NPC.
@@ -112,4 +120,19 @@ public interface NPC {
NPC setItem(NPCSlot slot, ItemStack item); NPC setItem(NPCSlot slot, ItemStack item);
NPC setText(List<String> text); NPC setText(List<String> text);
/**
* Get the text of an NPC
*
* @return List<String> text
*/
List<String> getText();
/**
* Get a NPC's item.
*
* @param slot The slot the item is in.
* @return ItemStack item.
*/
ItemStack getItem(NPCSlot slot);
} }
@@ -220,6 +220,18 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
} }
} }
@Override
public boolean getState(NPCState state) {
if (activeStates.length != 0) {
for (int i = 0; i < activeStates.length; i++) {
if (activeStates[i] == state) {
return true;
}
}
}
return false;
}
@Override @Override
public NPC toggleState(NPCState state) { public NPC toggleState(NPCState state) {
int inActiveStatesIndex = -1; int inActiveStatesIndex = -1;
@@ -263,6 +275,29 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
return this; 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 @Override
public NPC setItem(NPCSlot slot, ItemStack item) { public NPC setItem(NPCSlot slot, ItemStack item) {
if (slot == null) { if (slot == null) {
@@ -315,4 +350,9 @@ public abstract class NPCBase implements NPC, NPCPacketHandler {
this.text = text; this.text = text;
return this; return this;
} }
@Override
public List<String> getText() {
return text;
}
} }