Fix the spacing and clean it up.

This commit is contained in:
graywolf336
2014-07-27 14:46:25 -05:00
parent f89de50d75
commit 71a60e6ee3
92 changed files with 9955 additions and 9940 deletions

View File

@ -8,21 +8,21 @@ package com.graywolf336.jail.beans;
* @version 1.0.0
*/
public class CachePrisoner {
private Jail jail;
private Prisoner p;
public CachePrisoner(Jail jail, Prisoner prisoner) {
this.jail = jail;
this.p = prisoner;
}
/** Gets the Jail this cache is in. */
public Jail getJail() {
return this.jail;
}
/** Gets the Prisoner in this cache. */
public Prisoner getPrisoner() {
return this.p;
}
private Jail jail;
private Prisoner p;
public CachePrisoner(Jail jail, Prisoner prisoner) {
this.jail = jail;
this.p = prisoner;
}
/** Gets the Jail this cache is in. */
public Jail getJail() {
return this.jail;
}
/** Gets the Prisoner in this cache. */
public Prisoner getPrisoner() {
return this.p;
}
}

View File

@ -14,131 +14,131 @@ import org.bukkit.block.Chest;
* @version 1.1.2
*/
public class Cell {
private String name;
private Prisoner p;
private HashSet<SimpleLocation> signs;
private SimpleLocation teleport, chest;
/** Creates a new Cell with the given name
*
* @param name The name of the cell.
*/
public Cell(String name) {
this.name = name;
this.signs = new HashSet<SimpleLocation>();
}
/** Gets the name of the cell. */
public String getName() {
return this.name;
}
/** Updates the signs of the cell, with the player name and time and such. TODO */
public void update() {
//TODO: Update the signs
}
/** Sets the prisoner in this cell. */
public void setPrisoner(Prisoner prisoner) {
this.p = prisoner;
}
/** Gets the prisoner being held in this cell. */
public Prisoner getPrisoner() {
return this.p;
}
/** Nullifies the prisoner data. */
public void removePrisoner() {
this.p = null;
}
/** Returns true if there is currently a prisoner in this cell. */
public boolean hasPrisoner() {
return this.p != null; //Return true if prison is not null, as when it isn't null we have a prisoner in this cell
}
/** Adds all the given signs to the cell. */
public void addAllSigns(HashSet<SimpleLocation> signs) {
this.signs.addAll(signs);
}
/** Adds a sign to the cell. */
public void addSign(SimpleLocation sign) {
this.signs.add(sign);
}
/** Returns all the signs for this cell. */
public HashSet<SimpleLocation> getSigns() {
return this.signs;
}
/** Returns the entire list of signs in a string. */
public String getSignString() {
String r = "";
for(SimpleLocation s : signs) {
if(r.isEmpty()) {
r = s.toString();
}else {
r += ";" + s.toString();
}
}
return r;
}
/** Sets the location of where the prisoner will be teleported at when jailed here. */
public void setTeleport(SimpleLocation location) {
this.teleport = location;
}
/** Gets the teleport location where the prisoner will be teleported at when jailed here. */
public Location getTeleport() {
return this.teleport.getLocation();
}
/** Sets the location of the chest. */
public void setChestLocation(Location location) {
this.chest = new SimpleLocation(location);
}
/**
* Gets the location of the chest, returns null if no chest is stored at this cell.
*
* @return The location of the chest, null if none.
*/
public Location getChestLocation() {
return this.chest.getLocation();
}
/**
* Gets the chest for this cell, returns null if there is no chest or the location we have is not a chest.
*
* @return The chest and its state.
*/
public Chest getChest() {
if(this.chest == null) return null;
if((this.chest.getLocation().getBlock() == null) || (this.chest.getLocation().getBlock().getType() != Material.CHEST)) return null;
return (Chest) this.chest.getLocation().getBlock().getState();
}
/**
* Checks if the chest location doesn't equal null and if it is a double chest.
*
* @return true if there is a chest, false if there isn't.
*/
public boolean hasChest() {
Chest c = getChest();
if(c != null) {
if(c.getInventory().getSize() >= 40)
return true;
else {
Bukkit.getLogger().severe("The cell " + this.name + " has chest that isn't a double chest, please fix.");
return false;
}
}else
return false;
}
private String name;
private Prisoner p;
private HashSet<SimpleLocation> signs;
private SimpleLocation teleport, chest;
/** Creates a new Cell with the given name
*
* @param name The name of the cell.
*/
public Cell(String name) {
this.name = name;
this.signs = new HashSet<SimpleLocation>();
}
/** Gets the name of the cell. */
public String getName() {
return this.name;
}
/** Updates the signs of the cell, with the player name and time and such. TODO */
public void update() {
//TODO: Update the signs
}
/** Sets the prisoner in this cell. */
public void setPrisoner(Prisoner prisoner) {
this.p = prisoner;
}
/** Gets the prisoner being held in this cell. */
public Prisoner getPrisoner() {
return this.p;
}
/** Nullifies the prisoner data. */
public void removePrisoner() {
this.p = null;
}
/** Returns true if there is currently a prisoner in this cell. */
public boolean hasPrisoner() {
return this.p != null; //Return true if prison is not null, as when it isn't null we have a prisoner in this cell
}
/** Adds all the given signs to the cell. */
public void addAllSigns(HashSet<SimpleLocation> signs) {
this.signs.addAll(signs);
}
/** Adds a sign to the cell. */
public void addSign(SimpleLocation sign) {
this.signs.add(sign);
}
/** Returns all the signs for this cell. */
public HashSet<SimpleLocation> getSigns() {
return this.signs;
}
/** Returns the entire list of signs in a string. */
public String getSignString() {
String r = "";
for(SimpleLocation s : signs) {
if(r.isEmpty()) {
r = s.toString();
}else {
r += ";" + s.toString();
}
}
return r;
}
/** Sets the location of where the prisoner will be teleported at when jailed here. */
public void setTeleport(SimpleLocation location) {
this.teleport = location;
}
/** Gets the teleport location where the prisoner will be teleported at when jailed here. */
public Location getTeleport() {
return this.teleport.getLocation();
}
/** Sets the location of the chest. */
public void setChestLocation(Location location) {
this.chest = new SimpleLocation(location);
}
/**
* Gets the location of the chest, returns null if no chest is stored at this cell.
*
* @return The location of the chest, null if none.
*/
public Location getChestLocation() {
return this.chest.getLocation();
}
/**
* Gets the chest for this cell, returns null if there is no chest or the location we have is not a chest.
*
* @return The chest and its state.
*/
public Chest getChest() {
if(this.chest == null) return null;
if((this.chest.getLocation().getBlock() == null) || (this.chest.getLocation().getBlock().getType() != Material.CHEST)) return null;
return (Chest) this.chest.getLocation().getBlock().getState();
}
/**
* Checks if the chest location doesn't equal null and if it is a double chest.
*
* @return true if there is a chest, false if there isn't.
*/
public boolean hasChest() {
Chest c = getChest();
if(c != null) {
if(c.getInventory().getSize() >= 40)
return true;
else {
Bukkit.getLogger().severe("The cell " + this.name + " has chest that isn't a double chest, please fix.");
return false;
}
}else
return false;
}
}

View File

@ -10,35 +10,35 @@ import com.graywolf336.jail.enums.Confirmation;
* @since 3.0.0
*/
public class ConfirmPlayer {
private String name;
private String[] args;
private Confirmation confirm;
private Long expires;
public ConfirmPlayer(String name, String[] args, Confirmation confirm) {
this.name = name;
this.args = args;
this.confirm = confirm;
this.expires = System.currentTimeMillis() + 5000L;
}
/** Returns the name of the thing needing to confirm. */
public String getName() {
return this.name;
}
/** Returns the initial arguments they sent with their command. */
public String[] getArguments() {
return this.args;
}
/** Returns what they are {@link Confirmation confirming}. */
public Confirmation getConfirming() {
return this.confirm;
}
/** Returns the time in milliseconds their confirmation time frame expires. */
public Long getExpiryTime() {
return this.expires;
}
private String name;
private String[] args;
private Confirmation confirm;
private Long expires;
public ConfirmPlayer(String name, String[] args, Confirmation confirm) {
this.name = name;
this.args = args;
this.confirm = confirm;
this.expires = System.currentTimeMillis() + 5000L;
}
/** Returns the name of the thing needing to confirm. */
public String getName() {
return this.name;
}
/** Returns the initial arguments they sent with their command. */
public String[] getArguments() {
return this.args;
}
/** Returns what they are {@link Confirmation confirming}. */
public Confirmation getConfirming() {
return this.confirm;
}
/** Returns the time in milliseconds their confirmation time frame expires. */
public Long getExpiryTime() {
return this.expires;
}
}

View File

@ -1,227 +1,227 @@
package com.graywolf336.jail.beans;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
/**
* Represents an instance of a player creating something, whether it be a jail or cell.
*
* @author graywolf336
* @since 3.0.0
* @version 1.1.0
*
*/
public class CreationPlayer {
private String jailName, cellName;
private int step;
private int x1, y1, z1, x2, y2, z2;
private String inWorld, freeWorld;
private double inX, inY, inZ, freeX, freeY, freeZ;
private float inPitch, inYaw, freePitch, freeYaw;
private HashSet<SimpleLocation> signs;
private Location chest;
/**
* Create a new instance of a CreationPlayer, given the name of the jail.
*
* @param jailName The name of the jail.
*/
public CreationPlayer(String jailName) {
this.jailName = jailName;
this.step = 1; //Set the default to 1 when creating this.
}
/**
* Creates a new instance of a CreationPlayer, give the name of the jail and cell.
*
* @param jailName The name of the jail.
* @param cellName The name of the cell.
*/
public CreationPlayer(String jailName, String cellName) {
this.jailName = jailName;
this.cellName = cellName;
this.signs = new HashSet<SimpleLocation>();
this.step = 1;
}
/** Gets the name of the jail. */
public String getJailName() {
return this.jailName;
}
/** Gets the name of the cell. */
public String getCellName() {
return this.cellName;
}
/**
* Returns the step the creation is in.
*
* <p>
*
* If it is a <strong>Jail</strong>, then when these numbers are returned it means the following:
* <ol>
* <li>Creating the first block of the Jail region.</li>
* <li>Creating the second block of the Jail region.</li>
* <li>Creating the teleport in location.</li>
* <li>Creating the teleport out location.</li>
* </ol>
*
* If it is a <strong>Cell</strong>, then when these numbers are returned it means the following:
* <ol>
* <li>Setting the teleport in location.</li>
* <li>Setting all the signs.</li>
* <li>Setting the double chest.</li>
* </ol>
*
* @return The step of the Jail/Cell Creation, as an integer.
*/
public int getStep() {
return this.step;
}
/**
* Sets the step of the creation.
*
* @param step The state of the creation, see {@link #getStep() getStep} for more information.
*/
public void setStep(int step) {
this.step = step;
}
/**
* Increments the current step up one.
*
* <p>
*
* <em>Notice:</em> Using this method can cause the step to go above four (three for cell),
* which might cause errors later on. Only use when you know that it won't
* be used again or you know for a fact that the next step is not above four (three for cell).
*
*/
public void nextStep() {
this.step++;
}
/** Sets the first corner with the given location. */
public void setCornerOne(Location loc) {
this.x1 = loc.getBlockX();
this.y1 = loc.getBlockY();
this.z1 = loc.getBlockZ();
}
/** Sets the first corner with the given x, y, and z. */
public void setCornerOne(int x, int y, int z) {
this.x1 = x;
this.y1 = y;
this.z1 = z;
}
/** Returns the <strong>first corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong> */
public int[] getCornerOne() {
int[] t = {x1, y1, z1};
return t;
}
/** Sets the second corner with the given location. */
public void setCornerTwo(Location loc) {
this.x2 = loc.getBlockX();
this.y2 = loc.getBlockY();
this.z2 = loc.getBlockZ();
}
/** Sets the second corner with the given x, y, and z. */
public void setCornerTwo(int x, int y, int z) {
this.x2 = x;
this.y2 = y;
this.z2 = z;
}
/** Returns the <strong>second corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong> */
public int[] getCornerTwo() {
int[] t = {x2, y2, z2};
return t;
}
/** Sets the teleport in coords from the given location. */
public void setTeleportIn(Location location) {
this.inWorld = location.getWorld().getName();
this.inX = location.getX();
this.inY = location.getY();
this.inZ = location.getZ();
this.inYaw = location.getYaw();
this.inPitch = location.getPitch();
}
/** Sets the teleport in coords from the given params. */
public void setTeleportIn(String world, double x, double y, double z, float yaw, float pitch) {
this.inWorld = world;
this.inX = x;
this.inY = y;
this.inZ = z;
this.inYaw = yaw;
this.inPitch = pitch;
}
/** Gets the teleport in location in a {@link Location}. */
public Location getTeleportIn() {
return new Location(Bukkit.getWorld(inWorld), inX, inY, inZ, inYaw, inPitch);
}
/** Gets the teleport in location in a {@link SimpleLocation}. */
public SimpleLocation getTeleportInSL() {
return new SimpleLocation(inWorld, inX, inY, inZ, inYaw, inPitch);
}
/** Sets the teleport free coords from the given location. */
public void setTeleportFree(Location location) {
this.freeWorld = location.getWorld().getName();
this.freeX = location.getX();
this.freeY = location.getY();
this.freeZ = location.getZ();
this.freeYaw = location.getYaw();
this.freePitch = location.getPitch();
}
/** Sets the teleport in coords from the given params. */
public void setTeleportFree(String world, double x, double y, double z, float yaw, float pitch) {
this.freeWorld = world;
this.freeX = x;
this.freeY = y;
this.freeZ = z;
this.freeYaw = yaw;
this.freePitch = pitch;
}
/** Gets the teleport free location in a {@link Location}. */
public Location getTeleportFree() {
return new Location(Bukkit.getWorld(freeWorld), freeX, freeY, freeZ, freeYaw, freePitch);
}
/** Gets the teleport free location in a {@link SimpleLocation}. */
public SimpleLocation getTeleportFreeSL() {
return new SimpleLocation(freeWorld, freeX, freeY, freeZ, freeYaw, freePitch);
}
/** Adds a sign to this cell. */
public void addSign(SimpleLocation sign) {
this.signs.add(sign);
}
/** Returns all the signs, null if none (usually null when a jail is being created). */
public HashSet<SimpleLocation> getSigns() {
return this.signs == null ? null : new HashSet<SimpleLocation>(this.signs);
}
/** Sets the chest's location, used mainly for cells. */
public void setChestLocation(Location loc) {
this.chest = loc;
}
/** Gets the chest's location. */
public Location getChestLocation() {
return this.chest;
}
}
package com.graywolf336.jail.beans;
import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Location;
/**
* Represents an instance of a player creating something, whether it be a jail or cell.
*
* @author graywolf336
* @since 3.0.0
* @version 1.1.0
*
*/
public class CreationPlayer {
private String jailName, cellName;
private int step;
private int x1, y1, z1, x2, y2, z2;
private String inWorld, freeWorld;
private double inX, inY, inZ, freeX, freeY, freeZ;
private float inPitch, inYaw, freePitch, freeYaw;
private HashSet<SimpleLocation> signs;
private Location chest;
/**
* Create a new instance of a CreationPlayer, given the name of the jail.
*
* @param jailName The name of the jail.
*/
public CreationPlayer(String jailName) {
this.jailName = jailName;
this.step = 1; //Set the default to 1 when creating this.
}
/**
* Creates a new instance of a CreationPlayer, give the name of the jail and cell.
*
* @param jailName The name of the jail.
* @param cellName The name of the cell.
*/
public CreationPlayer(String jailName, String cellName) {
this.jailName = jailName;
this.cellName = cellName;
this.signs = new HashSet<SimpleLocation>();
this.step = 1;
}
/** Gets the name of the jail. */
public String getJailName() {
return this.jailName;
}
/** Gets the name of the cell. */
public String getCellName() {
return this.cellName;
}
/**
* Returns the step the creation is in.
*
* <p>
*
* If it is a <strong>Jail</strong>, then when these numbers are returned it means the following:
* <ol>
* <li>Creating the first block of the Jail region.</li>
* <li>Creating the second block of the Jail region.</li>
* <li>Creating the teleport in location.</li>
* <li>Creating the teleport out location.</li>
* </ol>
*
* If it is a <strong>Cell</strong>, then when these numbers are returned it means the following:
* <ol>
* <li>Setting the teleport in location.</li>
* <li>Setting all the signs.</li>
* <li>Setting the double chest.</li>
* </ol>
*
* @return The step of the Jail/Cell Creation, as an integer.
*/
public int getStep() {
return this.step;
}
/**
* Sets the step of the creation.
*
* @param step The state of the creation, see {@link #getStep() getStep} for more information.
*/
public void setStep(int step) {
this.step = step;
}
/**
* Increments the current step up one.
*
* <p>
*
* <em>Notice:</em> Using this method can cause the step to go above four (three for cell),
* which might cause errors later on. Only use when you know that it won't
* be used again or you know for a fact that the next step is not above four (three for cell).
*
*/
public void nextStep() {
this.step++;
}
/** Sets the first corner with the given location. */
public void setCornerOne(Location loc) {
this.x1 = loc.getBlockX();
this.y1 = loc.getBlockY();
this.z1 = loc.getBlockZ();
}
/** Sets the first corner with the given x, y, and z. */
public void setCornerOne(int x, int y, int z) {
this.x1 = x;
this.y1 = y;
this.z1 = z;
}
/** Returns the <strong>first corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong> */
public int[] getCornerOne() {
int[] t = {x1, y1, z1};
return t;
}
/** Sets the second corner with the given location. */
public void setCornerTwo(Location loc) {
this.x2 = loc.getBlockX();
this.y2 = loc.getBlockY();
this.z2 = loc.getBlockZ();
}
/** Sets the second corner with the given x, y, and z. */
public void setCornerTwo(int x, int y, int z) {
this.x2 = x;
this.y2 = y;
this.z2 = z;
}
/** Returns the <strong>second corner</strong> coords an array of int. <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong> */
public int[] getCornerTwo() {
int[] t = {x2, y2, z2};
return t;
}
/** Sets the teleport in coords from the given location. */
public void setTeleportIn(Location location) {
this.inWorld = location.getWorld().getName();
this.inX = location.getX();
this.inY = location.getY();
this.inZ = location.getZ();
this.inYaw = location.getYaw();
this.inPitch = location.getPitch();
}
/** Sets the teleport in coords from the given params. */
public void setTeleportIn(String world, double x, double y, double z, float yaw, float pitch) {
this.inWorld = world;
this.inX = x;
this.inY = y;
this.inZ = z;
this.inYaw = yaw;
this.inPitch = pitch;
}
/** Gets the teleport in location in a {@link Location}. */
public Location getTeleportIn() {
return new Location(Bukkit.getWorld(inWorld), inX, inY, inZ, inYaw, inPitch);
}
/** Gets the teleport in location in a {@link SimpleLocation}. */
public SimpleLocation getTeleportInSL() {
return new SimpleLocation(inWorld, inX, inY, inZ, inYaw, inPitch);
}
/** Sets the teleport free coords from the given location. */
public void setTeleportFree(Location location) {
this.freeWorld = location.getWorld().getName();
this.freeX = location.getX();
this.freeY = location.getY();
this.freeZ = location.getZ();
this.freeYaw = location.getYaw();
this.freePitch = location.getPitch();
}
/** Sets the teleport in coords from the given params. */
public void setTeleportFree(String world, double x, double y, double z, float yaw, float pitch) {
this.freeWorld = world;
this.freeX = x;
this.freeY = y;
this.freeZ = z;
this.freeYaw = yaw;
this.freePitch = pitch;
}
/** Gets the teleport free location in a {@link Location}. */
public Location getTeleportFree() {
return new Location(Bukkit.getWorld(freeWorld), freeX, freeY, freeZ, freeYaw, freePitch);
}
/** Gets the teleport free location in a {@link SimpleLocation}. */
public SimpleLocation getTeleportFreeSL() {
return new SimpleLocation(freeWorld, freeX, freeY, freeZ, freeYaw, freePitch);
}
/** Adds a sign to this cell. */
public void addSign(SimpleLocation sign) {
this.signs.add(sign);
}
/** Returns all the signs, null if none (usually null when a jail is being created). */
public HashSet<SimpleLocation> getSigns() {
return this.signs == null ? null : new HashSet<SimpleLocation>(this.signs);
}
/** Sets the chest's location, used mainly for cells. */
public void setChestLocation(Location loc) {
this.chest = loc;
}
/** Gets the chest's location. */
public Location getChestLocation() {
return this.chest;
}
}

View File

@ -20,375 +20,375 @@ import com.graywolf336.jail.Util;
* @version 1.0.3
*/
public class Jail {
private JailMain plugin;
private boolean enabled;
private HashMap<String, Cell> cells;
private HashMap<UUID, Prisoner> nocellPrisoners;//prisoners who aren't in a cell
private String name = "", world = "";
private int minX, minY, minZ, maxX, maxY, maxZ;
private Location in, free;
public Jail(JailMain plugin, String name) {
this.plugin = plugin;
this.enabled = true;
this.name = name;
cells = new HashMap<String, Cell>();
nocellPrisoners = new HashMap<UUID, Prisoner>();
}
/** Gets the instance of the plugin's main class. */
public JailMain getPlugin() {
return this.plugin;
}
/** Sets whether this jail can be used or not. */
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/** Gets whether this jail is enabled or not. */
public boolean isEnabled() {
return this.enabled;
}
/** Sets the name of the jail. */
public void setName(String name) {
this.name = name;
}
/** Gets the name of the jail. */
public String getName() {
return this.name;
}
/** Sets the location of the <b>minimum</b> point to the given location's coordinates. */
public void setMinPoint(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.minX = location.getBlockX();
this.minY = location.getBlockY();
this.minZ = location.getBlockZ();
}
/** Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>. */
public void setMinPoint(int[] coords) {
if(coords.length != 3) return;
this.minX = coords[0];
this.minY = coords[1];
this.minZ = coords[2];
}
/** Gets the minimum point as a Bukkit Location class. */
public Location getMinPoint() {
return new Location(plugin.getServer().getWorld(world), minX, minY, minZ);
}
/** Sets the location of the <b>maximum</b> point to the given location's coordinates. */
public void setMaxPoint(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.maxX = location.getBlockX();
this.maxY = location.getBlockY();
this.maxZ = location.getBlockZ();
}
/** Gets the minimum point as a Bukkit Location class. */
public Location getMaxPoint() {
return new Location(plugin.getServer().getWorld(world), maxX, maxY, maxZ);
}
/** Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>. */
public void setMaxPoint(int[] coords) {
if(coords.length != 3) return;
this.maxX = coords[0];
this.maxY = coords[1];
this.maxZ = coords[2];
}
/** Sets the name of the world this Jail is in. */
public void setWorld(String name) {
this.world = name;
}
/** Gets the name of the world this Jail is in. */
public String getWorldName() {
return this.world;
}
/** Gets the instance of the {@link World world} this Jail is in. */
public World getWorld() {
return plugin.getServer().getWorld(world);
}
/** Sets the {@link Location location} of the teleport <strong>in</strong>. */
public void setTeleportIn(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.in = location;
}
/** Gets the {@link Location location} of the teleport in. */
public Location getTeleportIn() {
return this.in;
}
/** Sets the {@link Location location} of the teleport for the <strong>free</strong> spot. */
public void setTeleportFree(Location location) {
this.free = location;
}
/** Gets the {@link Location location} of the teleport free spot.*/
public Location getTeleportFree() {
return this.free;
}
/** Add a prisoner to this jail. */
public void addPrisoner(Prisoner p) {
this.nocellPrisoners.put(p.getUUID(), p);
}
/** Removes a prisoner from this jail, doesn't remove it from the cell. */
public void removePrisoner(Prisoner p) {
this.nocellPrisoners.remove(p.getUUID());
}
/** Adds a cell to the Jail. */
public void addCell(Cell cell, boolean save) {
if(save) plugin.getJailIO().saveCell(this, cell);
this.cells.put(cell.getName(), cell);
}
/** Gets the cell with the given name. */
public Cell getCell(String name) {
return this.cells.get(name);
}
/** Checks if the given name is a valid cell. */
public boolean isValidCell(String name) {
return this.cells.get(name) != null;
}
/** Removes the cell from the jail. */
public void removeCell(String name) {
Cell c = this.cells.get(name);
//If we have a chest, clear the inventory
if(c.hasChest()) {
c.getChest().getInventory().clear();
}
//For each sign, clear the lines on the sign
for(SimpleLocation s : c.getSigns()) {
if(s.getLocation().getBlock() instanceof Sign) {
Sign sign = (Sign) s.getLocation().getBlock();
for(int i = 0; i < 4; i++) {
sign.setLine(i, "");
}
}
}
//remove the information from the storage first as it requires an instance
plugin.getJailIO().removeCell(this, c);
//now remove it from the local storage
this.cells.remove(name);
}
/** Returns the cell which the given player name is jailed in, null if not. */
public Cell getCellPrisonerIsIn(UUID uuid) {
for(Cell c : cells.values())
if(c.hasPrisoner())
if(c.getPrisoner().getUUID().equals(uuid))
return c;
return null;
}
/** Returns the first empty cell, returns null if there aren't any cells or any free cells. */
public Cell getFirstEmptyCell() {
for(Cell c : getCells())
if(c.hasPrisoner())
continue;
else
return c;
return null;
}
/** Gets the amount of cells the jail. */
public int getCellCount() {
return this.cells.size();
}
/** Gets all the cells in the jail. */
public HashSet<Cell> getCells() {
return new HashSet<Cell>(this.cells.values());
}
/** Gets the closest cell to the provided location, via the teleport in location of the cells. */
public Cell getNearestCell(Location loc) {
Cell cell = null;
double distance = -1;
for(Cell c : getCells()) {
//Check if the worlds are the same, if not we can't calculate anything
if(c.getTeleport().getWorld().getName().equalsIgnoreCase(loc.getWorld().getName())) {
//They are in the same world
double dist = c.getTeleport().distance(loc);
if (dist < distance || distance < 0) {
cell = c;
distance = dist;
}
}else {
//If they aren't, return the first cell found.
return c;
}
}
return cell;
}
/** Clears all the prisoners from this Jail. */
public void clearPrisoners() {
//Remove the prisoners from all the cells
for(Cell c : getCells()) {
c.removePrisoner();
}
//Replace all the current no cell prisoners with
//a new hashset of prisoners.
this.nocellPrisoners = new HashMap<UUID, Prisoner>();
}
/** Gets a HashMap of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
public HashMap<UUID, Prisoner> getAllPrisoners() {
HashMap<UUID, Prisoner> all = new HashMap<UUID, Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
for(Cell c : cells.values())
if(c.hasPrisoner())
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
return all;
}
/** Gets a HashSet of the prisoners <b>in cells</b>. */
public HashSet<Prisoner> getPrisonersInCells() {
HashSet<Prisoner> all = new HashSet<Prisoner>();
for(Cell c : getCells())
if(c.hasPrisoner())
all.add(c.getPrisoner());
return all;
}
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
public HashMap<UUID, Prisoner> getPrisonersNotInCells() {
return this.nocellPrisoners;
}
/**
* Returns whether the player is a prisoner in the system, whether in a cell or no cell.
*
* @param player The {@link Player player instance} of the person we're checking.
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(Player player) {
return this.isPlayerAPrisoner(player.getUniqueId());
}
/**
* Returns whether the uuid of a player is a prisoner in the system, whether in a cell or no cell.
*
* @param uuid The uuid of the person we're checking.
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(UUID uuid) {
return this.isPlayerAPrisoner(uuid);
}
/**
* Returns whether the uuid of a player is a prisoner in this jail, no matter if they're in a cell or not.
*
* @param uuid The name of the person we're checking.
* @return true if is a prisoner, false if not.
*/
private boolean isPlayerAPrisoner(UUID uuid) {
return this.getAllPrisoners().containsKey(uuid);
}
/**
* Checks if the given uuid of a player is a prisoner in a cell.
*
* @param uuid of the prisoner to check.
* @return true if is jailed in a cell, false if not.
*/
public boolean isJailedInACell(UUID uuid) {
if(this.nocellPrisoners.containsKey(uuid)) return false;
for(Cell c : cells.values())
if(c.getPrisoner() != null)
if(c.getPrisoner().getUUID().equals(uuid))
return true;
return false;
}
/**
* Gets the {@link Prisoner prisoner} instance for the given name.
*
* @param name The name of the prisoner to get.
* @return the prisoner instance, can be null
*/
public Prisoner getPrisonerByLastKnownName(String name) {
for(Prisoner p : this.getAllPrisoners().values())
if(p.getLastKnownName().equalsIgnoreCase(name))
return p;
return null;
}
/**
* Gets the {@link Prisoner prisoner} instance for the given uuid.
*
* @param uuid The uuid of the prisoner to get.
* @return the prisoner instance, can be null
*/
public Prisoner getPrisoner(UUID uuid) {
if(this.nocellPrisoners.containsKey(uuid)) return this.nocellPrisoners.get(uuid);
for(Cell c : cells.values())
if(c.hasPrisoner())
if(c.getPrisoner().getUUID().equals(uuid))
return c.getPrisoner();
return null;
}
/**
* Returns the squared distance between teleport location of this jail
* and specified location in blocks. If locations are not in same world,
* distance cannot be calculated and it will return Integer.MAX_VALUE.
*
* @param loc The location to check
* @return Distance between the location provided and the teleport in location.
*/
public double getDistance(Location loc) {
if (!loc.getWorld().getName().equalsIgnoreCase(getTeleportIn().getWorld().getName())) return (double) Integer.MAX_VALUE;
else return loc.distance(getTeleportIn());
}
/**
* Returns whether the given location is inside this Jail.
*
* @param loc to check whether is inside this jail
* @return True if the location is in the jail, false if it isn't
*/
public boolean isInside(Location loc) {
if(loc.getWorld().getName().equalsIgnoreCase(world)) {
return Util.isInsideAB(loc.toVector(), new Vector(minX, minY, minZ), new Vector(maxX, maxY, maxZ));
}else {
return false;
}
}
private JailMain plugin;
private boolean enabled;
private HashMap<String, Cell> cells;
private HashMap<UUID, Prisoner> nocellPrisoners;//prisoners who aren't in a cell
private String name = "", world = "";
private int minX, minY, minZ, maxX, maxY, maxZ;
private Location in, free;
public Jail(JailMain plugin, String name) {
this.plugin = plugin;
this.enabled = true;
this.name = name;
cells = new HashMap<String, Cell>();
nocellPrisoners = new HashMap<UUID, Prisoner>();
}
/** Gets the instance of the plugin's main class. */
public JailMain getPlugin() {
return this.plugin;
}
/** Sets whether this jail can be used or not. */
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/** Gets whether this jail is enabled or not. */
public boolean isEnabled() {
return this.enabled;
}
/** Sets the name of the jail. */
public void setName(String name) {
this.name = name;
}
/** Gets the name of the jail. */
public String getName() {
return this.name;
}
/** Sets the location of the <b>minimum</b> point to the given location's coordinates. */
public void setMinPoint(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.minX = location.getBlockX();
this.minY = location.getBlockY();
this.minZ = location.getBlockZ();
}
/** Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>. */
public void setMinPoint(int[] coords) {
if(coords.length != 3) return;
this.minX = coords[0];
this.minY = coords[1];
this.minZ = coords[2];
}
/** Gets the minimum point as a Bukkit Location class. */
public Location getMinPoint() {
return new Location(plugin.getServer().getWorld(world), minX, minY, minZ);
}
/** Sets the location of the <b>maximum</b> point to the given location's coordinates. */
public void setMaxPoint(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.maxX = location.getBlockX();
this.maxY = location.getBlockY();
this.maxZ = location.getBlockZ();
}
/** Gets the minimum point as a Bukkit Location class. */
public Location getMaxPoint() {
return new Location(plugin.getServer().getWorld(world), maxX, maxY, maxZ);
}
/** Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>. */
public void setMaxPoint(int[] coords) {
if(coords.length != 3) return;
this.maxX = coords[0];
this.maxY = coords[1];
this.maxZ = coords[2];
}
/** Sets the name of the world this Jail is in. */
public void setWorld(String name) {
this.world = name;
}
/** Gets the name of the world this Jail is in. */
public String getWorldName() {
return this.world;
}
/** Gets the instance of the {@link World world} this Jail is in. */
public World getWorld() {
return plugin.getServer().getWorld(world);
}
/** Sets the {@link Location location} of the teleport <strong>in</strong>. */
public void setTeleportIn(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.in = location;
}
/** Gets the {@link Location location} of the teleport in. */
public Location getTeleportIn() {
return this.in;
}
/** Sets the {@link Location location} of the teleport for the <strong>free</strong> spot. */
public void setTeleportFree(Location location) {
this.free = location;
}
/** Gets the {@link Location location} of the teleport free spot.*/
public Location getTeleportFree() {
return this.free;
}
/** Add a prisoner to this jail. */
public void addPrisoner(Prisoner p) {
this.nocellPrisoners.put(p.getUUID(), p);
}
/** Removes a prisoner from this jail, doesn't remove it from the cell. */
public void removePrisoner(Prisoner p) {
this.nocellPrisoners.remove(p.getUUID());
}
/** Adds a cell to the Jail. */
public void addCell(Cell cell, boolean save) {
if(save) plugin.getJailIO().saveCell(this, cell);
this.cells.put(cell.getName(), cell);
}
/** Gets the cell with the given name. */
public Cell getCell(String name) {
return this.cells.get(name);
}
/** Checks if the given name is a valid cell. */
public boolean isValidCell(String name) {
return this.cells.get(name) != null;
}
/** Removes the cell from the jail. */
public void removeCell(String name) {
Cell c = this.cells.get(name);
//If we have a chest, clear the inventory
if(c.hasChest()) {
c.getChest().getInventory().clear();
}
//For each sign, clear the lines on the sign
for(SimpleLocation s : c.getSigns()) {
if(s.getLocation().getBlock() instanceof Sign) {
Sign sign = (Sign) s.getLocation().getBlock();
for(int i = 0; i < 4; i++) {
sign.setLine(i, "");
}
}
}
//remove the information from the storage first as it requires an instance
plugin.getJailIO().removeCell(this, c);
//now remove it from the local storage
this.cells.remove(name);
}
/** Returns the cell which the given player name is jailed in, null if not. */
public Cell getCellPrisonerIsIn(UUID uuid) {
for(Cell c : cells.values())
if(c.hasPrisoner())
if(c.getPrisoner().getUUID().equals(uuid))
return c;
return null;
}
/** Returns the first empty cell, returns null if there aren't any cells or any free cells. */
public Cell getFirstEmptyCell() {
for(Cell c : getCells())
if(c.hasPrisoner())
continue;
else
return c;
return null;
}
/** Gets the amount of cells the jail. */
public int getCellCount() {
return this.cells.size();
}
/** Gets all the cells in the jail. */
public HashSet<Cell> getCells() {
return new HashSet<Cell>(this.cells.values());
}
/** Gets the closest cell to the provided location, via the teleport in location of the cells. */
public Cell getNearestCell(Location loc) {
Cell cell = null;
double distance = -1;
for(Cell c : getCells()) {
//Check if the worlds are the same, if not we can't calculate anything
if(c.getTeleport().getWorld().getName().equalsIgnoreCase(loc.getWorld().getName())) {
//They are in the same world
double dist = c.getTeleport().distance(loc);
if (dist < distance || distance < 0) {
cell = c;
distance = dist;
}
}else {
//If they aren't, return the first cell found.
return c;
}
}
return cell;
}
/** Clears all the prisoners from this Jail. */
public void clearPrisoners() {
//Remove the prisoners from all the cells
for(Cell c : getCells()) {
c.removePrisoner();
}
//Replace all the current no cell prisoners with
//a new hashset of prisoners.
this.nocellPrisoners = new HashMap<UUID, Prisoner>();
}
/** Gets a HashMap of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
public HashMap<UUID, Prisoner> getAllPrisoners() {
HashMap<UUID, Prisoner> all = new HashMap<UUID, Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
for(Cell c : cells.values())
if(c.hasPrisoner())
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
return all;
}
/** Gets a HashSet of the prisoners <b>in cells</b>. */
public HashSet<Prisoner> getPrisonersInCells() {
HashSet<Prisoner> all = new HashSet<Prisoner>();
for(Cell c : getCells())
if(c.hasPrisoner())
all.add(c.getPrisoner());
return all;
}
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
public HashMap<UUID, Prisoner> getPrisonersNotInCells() {
return this.nocellPrisoners;
}
/**
* Returns whether the player is a prisoner in the system, whether in a cell or no cell.
*
* @param player The {@link Player player instance} of the person we're checking.
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(Player player) {
return this.isPlayerAPrisoner(player.getUniqueId());
}
/**
* Returns whether the uuid of a player is a prisoner in the system, whether in a cell or no cell.
*
* @param uuid The uuid of the person we're checking.
* @return true if is jailed, false if not.
*/
public boolean isPlayerJailed(UUID uuid) {
return this.isPlayerAPrisoner(uuid);
}
/**
* Returns whether the uuid of a player is a prisoner in this jail, no matter if they're in a cell or not.
*
* @param uuid The name of the person we're checking.
* @return true if is a prisoner, false if not.
*/
private boolean isPlayerAPrisoner(UUID uuid) {
return this.getAllPrisoners().containsKey(uuid);
}
/**
* Checks if the given uuid of a player is a prisoner in a cell.
*
* @param uuid of the prisoner to check.
* @return true if is jailed in a cell, false if not.
*/
public boolean isJailedInACell(UUID uuid) {
if(this.nocellPrisoners.containsKey(uuid)) return false;
for(Cell c : cells.values())
if(c.getPrisoner() != null)
if(c.getPrisoner().getUUID().equals(uuid))
return true;
return false;
}
/**
* Gets the {@link Prisoner prisoner} instance for the given name.
*
* @param name The name of the prisoner to get.
* @return the prisoner instance, can be null
*/
public Prisoner getPrisonerByLastKnownName(String name) {
for(Prisoner p : this.getAllPrisoners().values())
if(p.getLastKnownName().equalsIgnoreCase(name))
return p;
return null;
}
/**
* Gets the {@link Prisoner prisoner} instance for the given uuid.
*
* @param uuid The uuid of the prisoner to get.
* @return the prisoner instance, can be null
*/
public Prisoner getPrisoner(UUID uuid) {
if(this.nocellPrisoners.containsKey(uuid)) return this.nocellPrisoners.get(uuid);
for(Cell c : cells.values())
if(c.hasPrisoner())
if(c.getPrisoner().getUUID().equals(uuid))
return c.getPrisoner();
return null;
}
/**
* Returns the squared distance between teleport location of this jail
* and specified location in blocks. If locations are not in same world,
* distance cannot be calculated and it will return Integer.MAX_VALUE.
*
* @param loc The location to check
* @return Distance between the location provided and the teleport in location.
*/
public double getDistance(Location loc) {
if (!loc.getWorld().getName().equalsIgnoreCase(getTeleportIn().getWorld().getName())) return Integer.MAX_VALUE;
else return loc.distance(getTeleportIn());
}
/**
* Returns whether the given location is inside this Jail.
*
* @param loc to check whether is inside this jail
* @return True if the location is in the jail, false if it isn't
*/
public boolean isInside(Location loc) {
if(loc.getWorld().getName().equalsIgnoreCase(world)) {
return Util.isInsideAB(loc.toVector(), new Vector(minX, minY, minZ), new Vector(maxX, maxY, maxZ));
}else {
return false;
}
}
}

View File

@ -15,273 +15,273 @@ import org.bukkit.Location;
* @version 3.0.2
*/
public class Prisoner {
private String uuid, name, jailer, reason, inventory, armor;
private boolean muted, offlinePending, teleporting, toBeTransferred, changed;
private long time, afk;
private Location previousPosition;
private GameMode previousGameMode;
/**
* Creates a new prisoner with a name and whether they are muted or not.
*
* @param uuid The uuid of the prisoner
* @param name The name of the prisoner
* @param muted Whether the prisoner is muted or not
* @param time The amount of remaining time the prisoner has
* @param jailer The name of the person who jailed this prisoner
* @param reason The reason why this prisoner is in jail
*/
public Prisoner(String uuid, String name, boolean muted, long time, String jailer, String reason) {
this.uuid = uuid;
this.name = name;
this.muted = muted;
this.time = time;
this.jailer = jailer;
this.reason = reason;
this.offlinePending = false;
this.teleporting = false;
this.toBeTransferred = false;
this.previousPosition = null;
this.previousGameMode = GameMode.SURVIVAL;
this.inventory = "";
this.armor = "";
this.afk = 0;
this.changed = false;
}
/** Returns the UUID of the prisoner. */
public UUID getUUID() {
return UUID.fromString(this.uuid);
}
/** Gets the name of this prisoner. */
public String getLastKnownName() {
return this.name;
}
/** Sets the name of this prisoner. */
public String setLastKnownName(String username) {
this.name = username;
this.changed = true;
return this.name;
}
/** Gets the reason this player was jailed for. */
public String getReason() {
return this.reason;
}
/**
* Sets the reason this player was jailed for.
*
* @param reason the player was jailed.
* @return the reason the player was jailed, what we have stored about them.
*/
public String setReason(String reason) {
this.reason = reason;
this.changed = true;
return this.reason;
}
/** Gets the person who jailed this prisoner. */
public String getJailer() {
return this.jailer;
}
/** Sets the person who jailed this prisoner. */
public void setJailer(String jailer) {
this.jailer = jailer;
this.changed = true;
}
/** Gets whether the prisoner is muted or not. */
public boolean isMuted() {
return this.muted;
}
/** Sets whether the prisoner is muted or not. */
public void setMuted(boolean muted) {
this.muted = muted;
this.changed = true;
}
/** Gets the remaining time the prisoner has. */
public long getRemainingTime() {
return this.time;
}
/** Gets the remaining time the prisoner has in minutes. */
public long getRemainingTimeInMinutes() {
return TimeUnit.MINUTES.convert(time, TimeUnit.MILLISECONDS);
}
/** Gets the remaining time the prison has in minutes except only in int format. */
public int getRemainingTimeInMinutesInt() {
return (int) this.getRemainingTimeInMinutes();
}
/**
* Sets the remaining time the prisoner has left.
*
* @param time The amount of time left, in milliseconds.
*/
public void setRemainingTime(long time) {
this.time = time;
this.changed = true;
}
/**
* Adds the given time to the remaining time the prisoner has left.
*
* @param time to add to the prisoner's remaining time.
* @return the new remaining time the prisoner has
*/
public long addTime(long time) {
this.time += time;
this.changed = true;
return this.time;
}
/**
* Subtracts the given time from the remaining time the prisoner has left.
*
* @param time to subtract from the prisoner's remaining time.
* @return the new remaining time the prisoner has
*/
public long subtractTime(long time) {
this.time -= time;
this.changed = true;
return this.time;
}
/** Gets whether the player is offline or not. */
public boolean isOfflinePending() {
return this.offlinePending;
}
/** Sets whether the player is offline or not. */
public void setOfflinePending(boolean offline) {
this.offlinePending = offline;
this.changed = true;
}
/** Gets whether the player is being teleported or not. */
public boolean isTeleporting() {
return this.teleporting;
}
/** Sets whether the player is being teleported or not. */
public void setTeleporting(boolean teleport) {
this.teleporting = teleport;
}
/** Gets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
public boolean isToBeTransferred() {
return this.toBeTransferred;
}
/** Sets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
public void setToBeTransferred(boolean transferred) {
this.toBeTransferred = transferred;
this.changed = true;
}
/** Gets the previous location of this player, can be null. */
public Location getPreviousLocation() {
return this.previousPosition;
}
/** Gets the previous location of this player, separated by a comma. */
public String getPreviousLocationString() {
if(previousPosition == null) return "";
else if(previousPosition.getWorld() == null) return "";
else return previousPosition.getWorld().getName() + "," +
previousPosition.getX() + "," +
previousPosition.getY() + "," +
previousPosition.getZ() + "," +
previousPosition.getYaw() + "," +
previousPosition.getPitch();
}
/** Sets the previous location of this player. */
public void setPreviousPosition(Location location) {
this.previousPosition = location;
}
/** Sets the previous location of this player from a comma separated string. */
public void setPreviousPosition(String location) {
if(location == null) return;
if(location.isEmpty()) return;
this.changed = true;
String[] s = location.split(",");
this.previousPosition = new Location(Bukkit.getWorld(s[0]),
Double.valueOf(s[1]),
Double.valueOf(s[2]),
Double.valueOf(s[3]),
Float.valueOf(s[4]),
Float.valueOf(s[5]));
}
/** Gets the previous gamemode of this player. */
public GameMode getPreviousGameMode() {
return this.previousGameMode;
}
/** Sets the previous gamemode of this player. */
public void setPreviousGameMode(GameMode previous) {
this.previousGameMode = previous;
this.changed = true;
}
/** Sets the previous gamemode of this player based upon the provided string. */
public void setPreviousGameMode(String previous) {
if(previous == null) return;
else if(previous.isEmpty()) return;
else this.previousGameMode = GameMode.valueOf(previous);
this.changed = true;
}
/** Gets the inventory string for this player, it is encoded in Base64 string. */
public String getInventory() {
return this.inventory;
}
/** Sets the inventory Base64 string. */
public void setInventory(String inventory) {
this.inventory = inventory;
this.changed = true;
}
/** Gets the armor content, encoded in Base64 string. */
public String getArmor() {
return this.armor;
}
/** Sets the armor inventory Base64 string. */
public void setArmor(String armor) {
this.armor = armor;
this.changed = true;
}
/** Gets the time, in milliseconds, this prisoner has been afk. */
public long getAFKTime() {
return this.afk;
}
/** Sets the time, in milliseconds, this prisoner has been afk. */
public void setAFKTime(long time) {
this.afk = time;
}
/** Checks if the prisoner was changed or not. */
public boolean wasChanged() {
return this.changed;
}
/** Sets whether the prisoner was changed or not. */
public boolean setChanged(boolean change) {
this.changed = change;
return this.changed;
}
private String uuid, name, jailer, reason, inventory, armor;
private boolean muted, offlinePending, teleporting, toBeTransferred, changed;
private long time, afk;
private Location previousPosition;
private GameMode previousGameMode;
/**
* Creates a new prisoner with a name and whether they are muted or not.
*
* @param uuid The uuid of the prisoner
* @param name The name of the prisoner
* @param muted Whether the prisoner is muted or not
* @param time The amount of remaining time the prisoner has
* @param jailer The name of the person who jailed this prisoner
* @param reason The reason why this prisoner is in jail
*/
public Prisoner(String uuid, String name, boolean muted, long time, String jailer, String reason) {
this.uuid = uuid;
this.name = name;
this.muted = muted;
this.time = time;
this.jailer = jailer;
this.reason = reason;
this.offlinePending = false;
this.teleporting = false;
this.toBeTransferred = false;
this.previousPosition = null;
this.previousGameMode = GameMode.SURVIVAL;
this.inventory = "";
this.armor = "";
this.afk = 0;
this.changed = false;
}
/** Returns the UUID of the prisoner. */
public UUID getUUID() {
return UUID.fromString(this.uuid);
}
/** Gets the name of this prisoner. */
public String getLastKnownName() {
return this.name;
}
/** Sets the name of this prisoner. */
public String setLastKnownName(String username) {
this.name = username;
this.changed = true;
return this.name;
}
/** Gets the reason this player was jailed for. */
public String getReason() {
return this.reason;
}
/**
* Sets the reason this player was jailed for.
*
* @param reason the player was jailed.
* @return the reason the player was jailed, what we have stored about them.
*/
public String setReason(String reason) {
this.reason = reason;
this.changed = true;
return this.reason;
}
/** Gets the person who jailed this prisoner. */
public String getJailer() {
return this.jailer;
}
/** Sets the person who jailed this prisoner. */
public void setJailer(String jailer) {
this.jailer = jailer;
this.changed = true;
}
/** Gets whether the prisoner is muted or not. */
public boolean isMuted() {
return this.muted;
}
/** Sets whether the prisoner is muted or not. */
public void setMuted(boolean muted) {
this.muted = muted;
this.changed = true;
}
/** Gets the remaining time the prisoner has. */
public long getRemainingTime() {
return this.time;
}
/** Gets the remaining time the prisoner has in minutes. */
public long getRemainingTimeInMinutes() {
return TimeUnit.MINUTES.convert(time, TimeUnit.MILLISECONDS);
}
/** Gets the remaining time the prison has in minutes except only in int format. */
public int getRemainingTimeInMinutesInt() {
return (int) this.getRemainingTimeInMinutes();
}
/**
* Sets the remaining time the prisoner has left.
*
* @param time The amount of time left, in milliseconds.
*/
public void setRemainingTime(long time) {
this.time = time;
this.changed = true;
}
/**
* Adds the given time to the remaining time the prisoner has left.
*
* @param time to add to the prisoner's remaining time.
* @return the new remaining time the prisoner has
*/
public long addTime(long time) {
this.time += time;
this.changed = true;
return this.time;
}
/**
* Subtracts the given time from the remaining time the prisoner has left.
*
* @param time to subtract from the prisoner's remaining time.
* @return the new remaining time the prisoner has
*/
public long subtractTime(long time) {
this.time -= time;
this.changed = true;
return this.time;
}
/** Gets whether the player is offline or not. */
public boolean isOfflinePending() {
return this.offlinePending;
}
/** Sets whether the player is offline or not. */
public void setOfflinePending(boolean offline) {
this.offlinePending = offline;
this.changed = true;
}
/** Gets whether the player is being teleported or not. */
public boolean isTeleporting() {
return this.teleporting;
}
/** Sets whether the player is being teleported or not. */
public void setTeleporting(boolean teleport) {
this.teleporting = teleport;
}
/** Gets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
public boolean isToBeTransferred() {
return this.toBeTransferred;
}
/** Sets whether the prisoner is going to be transferred or not, mainly for teleporting on join purposes. */
public void setToBeTransferred(boolean transferred) {
this.toBeTransferred = transferred;
this.changed = true;
}
/** Gets the previous location of this player, can be null. */
public Location getPreviousLocation() {
return this.previousPosition;
}
/** Gets the previous location of this player, separated by a comma. */
public String getPreviousLocationString() {
if(previousPosition == null) return "";
else if(previousPosition.getWorld() == null) return "";
else return previousPosition.getWorld().getName() + "," +
previousPosition.getX() + "," +
previousPosition.getY() + "," +
previousPosition.getZ() + "," +
previousPosition.getYaw() + "," +
previousPosition.getPitch();
}
/** Sets the previous location of this player. */
public void setPreviousPosition(Location location) {
this.previousPosition = location;
}
/** Sets the previous location of this player from a comma separated string. */
public void setPreviousPosition(String location) {
if(location == null) return;
if(location.isEmpty()) return;
this.changed = true;
String[] s = location.split(",");
this.previousPosition = new Location(Bukkit.getWorld(s[0]),
Double.valueOf(s[1]),
Double.valueOf(s[2]),
Double.valueOf(s[3]),
Float.valueOf(s[4]),
Float.valueOf(s[5]));
}
/** Gets the previous gamemode of this player. */
public GameMode getPreviousGameMode() {
return this.previousGameMode;
}
/** Sets the previous gamemode of this player. */
public void setPreviousGameMode(GameMode previous) {
this.previousGameMode = previous;
this.changed = true;
}
/** Sets the previous gamemode of this player based upon the provided string. */
public void setPreviousGameMode(String previous) {
if(previous == null) return;
else if(previous.isEmpty()) return;
else this.previousGameMode = GameMode.valueOf(previous);
this.changed = true;
}
/** Gets the inventory string for this player, it is encoded in Base64 string. */
public String getInventory() {
return this.inventory;
}
/** Sets the inventory Base64 string. */
public void setInventory(String inventory) {
this.inventory = inventory;
this.changed = true;
}
/** Gets the armor content, encoded in Base64 string. */
public String getArmor() {
return this.armor;
}
/** Sets the armor inventory Base64 string. */
public void setArmor(String armor) {
this.armor = armor;
this.changed = true;
}
/** Gets the time, in milliseconds, this prisoner has been afk. */
public long getAFKTime() {
return this.afk;
}
/** Sets the time, in milliseconds, this prisoner has been afk. */
public void setAFKTime(long time) {
this.afk = time;
}
/** Checks if the prisoner was changed or not. */
public boolean wasChanged() {
return this.changed;
}
/** Sets whether the prisoner was changed or not. */
public boolean setChanged(boolean change) {
this.changed = change;
return this.changed;
}
}

View File

@ -12,92 +12,92 @@ import org.bukkit.World;
* @version 1.1.1
*/
public class SimpleLocation {
private String world;
private double x, y, z;
private float yaw, pitch;
/**
* Creates a new SimpleLocation with each detail provided separately.
*
* @param world as a string
* @param x coordinate as a double
* @param y coordinate as a double
* @param z coordinate as a double
* @param yaw as a float
* @param pitch as a float
*/
public SimpleLocation(String world, double x, double y, double z, float yaw, float pitch) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
}
/**
* Creates a new SimpleLocation with all the detail provided from {@link Location}.
*
* @param location to convert to a SimpleLocation
*/
public SimpleLocation(Location location) {
this.world = location.getWorld().getName();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
/**
* Creates a new Simple Location with all the inputs being in string.
*
* @param world the name of the world
* @param x coordinate as a string
* @param y coordinate as a string
* @param z coordinate as a string
*/
public SimpleLocation(String world, String x, String y, String z) {
this.world = world;
this.x = Double.valueOf(x);
this.y = Double.valueOf(y);
this.z = Double.valueOf(z);
this.yaw = 0;
this.pitch = 0;
}
/**
* Creates a new SimpleLocation with each detail provided separately.
*
* @param world as a string
* @param x coordinate as a double
* @param y coordinate as a double
* @param z coordinate as a double
*/
public SimpleLocation(String world, double x, double y, double z) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
}
private String world;
private double x, y, z;
private float yaw, pitch;
/** Returns the instance from Bukkit of the world this location is in. */
public World getWorld() {
return Bukkit.getWorld(world);
}
/** Returns the name of the world this location is in. */
public String getWorldName() {
return this.world;
}
/** Returns a new {@link Location} from this SimpleLocation. */
public Location getLocation() {
return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
}
@Override
public String toString() {
return world + "," + x + "," + y + "," + z + "," + yaw + "," + pitch;
}
/**
* Creates a new SimpleLocation with each detail provided separately.
*
* @param world as a string
* @param x coordinate as a double
* @param y coordinate as a double
* @param z coordinate as a double
* @param yaw as a float
* @param pitch as a float
*/
public SimpleLocation(String world, double x, double y, double z, float yaw, float pitch) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
}
/**
* Creates a new SimpleLocation with all the detail provided from {@link Location}.
*
* @param location to convert to a SimpleLocation
*/
public SimpleLocation(Location location) {
this.world = location.getWorld().getName();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
/**
* Creates a new Simple Location with all the inputs being in string.
*
* @param world the name of the world
* @param x coordinate as a string
* @param y coordinate as a string
* @param z coordinate as a string
*/
public SimpleLocation(String world, String x, String y, String z) {
this.world = world;
this.x = Double.valueOf(x);
this.y = Double.valueOf(y);
this.z = Double.valueOf(z);
this.yaw = 0;
this.pitch = 0;
}
/**
* Creates a new SimpleLocation with each detail provided separately.
*
* @param world as a string
* @param x coordinate as a double
* @param y coordinate as a double
* @param z coordinate as a double
*/
public SimpleLocation(String world, double x, double y, double z) {
this.world = world;
this.x = x;
this.y = y;
this.z = z;
}
/** Returns the instance from Bukkit of the world this location is in. */
public World getWorld() {
return Bukkit.getWorld(world);
}
/** Returns the name of the world this location is in. */
public String getWorldName() {
return this.world;
}
/** Returns a new {@link Location} from this SimpleLocation. */
public Location getLocation() {
return new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
}
@Override
public String toString() {
return world + "," + x + "," + y + "," + z + "," + yaw + "," + pitch;
}
}

View File

@ -9,52 +9,52 @@ package com.graywolf336.jail.beans;
*
*/
public class Stick {
private String jail, reason;
private long time;
private double health;
/**
* Creates a new Jail Stick instance.
*
* @param jail the player will be jailed in.
* @param reason the player will be jailed for.
* @param time the player will be jailed for.
* @param health a player must have, at the least, before being able to be jailed with this stick, -1 disables this feature
*/
public Stick(String jail, String reason, long time, double health) {
this.jail = jail;
this.reason = reason;
this.time = time;
this.health = health;
}
/** Gets the name of the jail a player will be sent when jailed via this jail stick. */
public String getJail() {
return this.jail;
}
/** Gets the reason a player will be jailed for when jailed via this stick. */
public String getReason() {
return this.reason;
}
/** Gets the amount of time a player has to serve when they are jailed via this stick. */
public long getTime() {
return this.time;
}
/** Gets the amount of health a player has to have before getting jailed via this stick.
*
* <p />
*
* See here for reference: http://dev.bukkit.org/bukkit-plugins/jail/tickets/415/
*/
public double getHealth() {
return this.health;
}
@Override
public String toString() {
return time + "," + jail + "," + reason + "," + health;
}
private String jail, reason;
private long time;
private double health;
/**
* Creates a new Jail Stick instance.
*
* @param jail the player will be jailed in.
* @param reason the player will be jailed for.
* @param time the player will be jailed for.
* @param health a player must have, at the least, before being able to be jailed with this stick, -1 disables this feature
*/
public Stick(String jail, String reason, long time, double health) {
this.jail = jail;
this.reason = reason;
this.time = time;
this.health = health;
}
/** Gets the name of the jail a player will be sent when jailed via this jail stick. */
public String getJail() {
return this.jail;
}
/** Gets the reason a player will be jailed for when jailed via this stick. */
public String getReason() {
return this.reason;
}
/** Gets the amount of time a player has to serve when they are jailed via this stick. */
public long getTime() {
return this.time;
}
/** Gets the amount of health a player has to have before getting jailed via this stick.
*
* <p />
*
* See here for reference: http://dev.bukkit.org/bukkit-plugins/jail/tickets/415/
*/
public double getHealth() {
return this.health;
}
@Override
public String toString() {
return time + "," + jail + "," + reason + "," + health;
}
}