diff --git a/src/main/java/net/citizensnpcs/trait/Positions.java b/src/main/java/net/citizensnpcs/trait/Positions.java deleted file mode 100644 index 2f7cb552e..000000000 --- a/src/main/java/net/citizensnpcs/trait/Positions.java +++ /dev/null @@ -1,75 +0,0 @@ -package net.citizensnpcs.trait; - - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.Location; - -import net.citizensnpcs.api.exception.NPCLoadException; -import net.citizensnpcs.api.trait.Trait; -import net.citizensnpcs.api.util.DataKey; -import net.citizensnpcs.util.Position; -import net.citizensnpcs.util.Util; - -public class Positions extends Trait { - private final List positions = new ArrayList(); - - Position currentPosition = null; - - public Positions() { - super("positions"); - } - - @Override - public void load(DataKey key) throws NPCLoadException { - for (DataKey sub : key.getRelative("list").getIntegerSubKeys()) - try { - positions.add(new Position(sub.getString("").split(";")[0], Float.valueOf(sub.getString("").split(";")[1]), Float.valueOf(sub.getString("").split(";")[2]))) ; - } catch(Exception e) { /* Perhaps remove the entry if bad? Warn console? */ } - } - - @Override - public void save(DataKey key) { - key.removeKey("list"); - for (int i = 0; i < positions.size(); i++) - key.setString("list." + String.valueOf(i), positions.get(i).stringValue()); - } - - public List getPositions() { - return positions; - } - - public boolean addPosition(String name, Location location) { - Position newPosition = new Position(name, location.getPitch(), location.getYaw()); - - if (positions.contains(newPosition)) return false; - positions.add(newPosition); - return true; - } - - public boolean removePosition(Position position) { - if (positions.contains(position)) { - positions.remove(position); - return true; - } - else return false; - } - - public Position getPosition(String name) { - for (Position position : positions) - if (position.getName().equalsIgnoreCase(name)) return position; - - return null; - } - - public void assumePosition(Position position) { - - if (!npc.isSpawned()) - npc.spawn(npc.getTrait(CurrentLocation.class).getLocation()); - - Util.assumePosition(npc.getBukkitEntity(), position); - } - - -} diff --git a/src/main/java/net/citizensnpcs/util/Position.java b/src/main/java/net/citizensnpcs/util/Position.java deleted file mode 100644 index 981fb22f2..000000000 --- a/src/main/java/net/citizensnpcs/util/Position.java +++ /dev/null @@ -1,62 +0,0 @@ -package net.citizensnpcs.util; - -import org.apache.commons.lang.builder.EqualsBuilder; -import org.apache.commons.lang.builder.HashCodeBuilder; - -/* - * Position object which holds yaw/pitch of the head with a name to identify. - */ - -public class Position { - private final String name; - private final float yaw; - private final float pitch; - - public Position(String name, float pitch, float yaw) { - this.yaw = yaw; - this.pitch = pitch; - this.name = name; - } - - @Override - public int hashCode() { - return new HashCodeBuilder(13, 21). - append(name). - toHashCode(); - } - - @Override - public String toString() { - return "Name: " + name + " Pitch: " + pitch + " Yaw: " + yaw; - } - - public String stringValue() { - return name + ";" + pitch + ";" + yaw; - } - - public float getYaw() { - return yaw; - } - - public float getPitch() { - return pitch; - } - - public String getName() { - return name; - } - - @Override - public boolean equals(Object object) { - if (object == null) return false; - if (object == this) return true; - if (object.getClass() != getClass()) - return false; - - Position op = (Position) object; - return new EqualsBuilder(). - append(name, op.getName()). - isEquals(); - } - -} \ No newline at end of file