Remove old files

This commit is contained in:
Jeremy Schroeder 2012-09-28 13:36:14 -04:00
parent 808bfd30b4
commit 5d2ce8d37f
2 changed files with 0 additions and 137 deletions

View File

@ -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<Position> positions = new ArrayList<Position>();
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<Position> 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);
}
}

View File

@ -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();
}
}