mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-26 20:55:44 +01:00
Remove old files
This commit is contained in:
parent
808bfd30b4
commit
5d2ce8d37f
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user