Merge branch 'master' of git@github.com:graywolf336/Jail.git
This commit is contained in:
commit
82f17f3a4b
@ -378,7 +378,6 @@ public class JailIO {
|
|||||||
//that doesn't exist anymore
|
//that doesn't exist anymore
|
||||||
List<Integer> cellsToRemove = new LinkedList<Integer>();
|
List<Integer> cellsToRemove = new LinkedList<Integer>();
|
||||||
|
|
||||||
int cs = 0;
|
|
||||||
try {
|
try {
|
||||||
if(con == null) this.prepareStorage(false);
|
if(con == null) this.prepareStorage(false);
|
||||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "cells");
|
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "cells");
|
||||||
@ -405,7 +404,6 @@ public class JailIO {
|
|||||||
|
|
||||||
|
|
||||||
j.addCell(c, false);
|
j.addCell(c, false);
|
||||||
cs++;
|
|
||||||
}else {
|
}else {
|
||||||
cellsToRemove.add(set.getInt("cellid"));
|
cellsToRemove.add(set.getInt("cellid"));
|
||||||
}
|
}
|
||||||
@ -444,8 +442,6 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.getLogger().info("Loaded " + cs + (cs == 1 ? " cell." : " cells."));
|
|
||||||
|
|
||||||
//This list contains a string which refers to the name of the prisoner in sql
|
//This list contains a string which refers to the name of the prisoner in sql
|
||||||
//this list only gets populated if there are prisoners which reference a jail
|
//this list only gets populated if there are prisoners which reference a jail
|
||||||
//that doesn't exist anymore
|
//that doesn't exist anymore
|
||||||
@ -538,6 +534,9 @@ public class JailIO {
|
|||||||
int js = pl.getJailManager().getJails().size();
|
int js = pl.getJailManager().getJails().size();
|
||||||
pl.getLogger().info("Loaded " + js + (js == 1 ? " jail." : " jails."));
|
pl.getLogger().info("Loaded " + js + (js == 1 ? " jail." : " jails."));
|
||||||
|
|
||||||
|
int cs = pl.getJailManager().getAllCells().size();
|
||||||
|
pl.getLogger().info("Loaded " + cs + (cs == 1 ? " cell." : " cells."));
|
||||||
|
|
||||||
int ps = pl.getJailManager().getAllPrisoners().size();
|
int ps = pl.getJailManager().getAllPrisoners().size();
|
||||||
pl.getLogger().info("Loaded " + ps + (ps == 1 ? " prisoner." : " prisoners."));
|
pl.getLogger().info("Loaded " + ps + (ps == 1 ? " prisoner." : " prisoners."));
|
||||||
}
|
}
|
||||||
@ -644,6 +643,21 @@ public class JailIO {
|
|||||||
pl.getLogger().severe("Failed to load the jail " + j.getName() + " as the world '" + j.getWorldName() + "' does not exist (is null). Did you remove this world?");
|
pl.getLogger().severe("Failed to load the jail " + j.getName() + " as the world '" + j.getWorldName() + "' does not exist (is null). Did you remove this world?");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Saves everything about a jail, don't usually call this. */
|
||||||
|
public void saveEverything() {
|
||||||
|
long st = System.currentTimeMillis();
|
||||||
|
|
||||||
|
for(Jail j : pl.getJailManager().getJails()) {
|
||||||
|
saveJail(j);
|
||||||
|
|
||||||
|
for(Cell c : j.getCells()) {
|
||||||
|
saveCell(j, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pl.debug("Saving everything took " + (System.currentTimeMillis() - st) + " millis.");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the provided {@link Jail jail} to the storage system we are using.
|
* Saves the provided {@link Jail jail} to the storage system we are using.
|
||||||
*
|
*
|
||||||
@ -728,7 +742,7 @@ public class JailIO {
|
|||||||
try {
|
try {
|
||||||
if(con == null) this.prepareStorage(false);
|
if(con == null) this.prepareStorage(false);
|
||||||
|
|
||||||
for(Prisoner p : j.getPrisonersNotInCells()) {
|
for(Prisoner p : j.getPrisonersNotInCells().values()) {
|
||||||
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
|
PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
|
||||||
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||||
pPS.setString(1, p.getUUID().toString());
|
pPS.setString(1, p.getUUID().toString());
|
||||||
@ -834,7 +848,7 @@ public class JailIO {
|
|||||||
|
|
||||||
//Null all the prisoners out before we save them again, this way no prisoners are left behind
|
//Null all the prisoners out before we save them again, this way no prisoners are left behind
|
||||||
flat.set(node + "prisoners", null);
|
flat.set(node + "prisoners", null);
|
||||||
for(Prisoner p : j.getPrisonersNotInCells()) {
|
for(Prisoner p : j.getPrisonersNotInCells().values()) {
|
||||||
String pNode = node + "prisoners." + p.getUUID().toString() + ".";
|
String pNode = node + "prisoners." + p.getUUID().toString() + ".";
|
||||||
flat.set(pNode + "name", p.getLastKnownName());
|
flat.set(pNode + "name", p.getLastKnownName());
|
||||||
flat.set(pNode + "muted", p.isMuted());
|
flat.set(pNode + "muted", p.isMuted());
|
||||||
@ -908,11 +922,12 @@ public class JailIO {
|
|||||||
pPS.setFloat(6, p.getRemainingTime());
|
pPS.setFloat(6, p.getRemainingTime());
|
||||||
pPS.setBoolean(7, p.isOfflinePending());
|
pPS.setBoolean(7, p.isOfflinePending());
|
||||||
pPS.setBoolean(8, p.isToBeTransferred());
|
pPS.setBoolean(8, p.isToBeTransferred());
|
||||||
pPS.setString(9, p.getReason());
|
pPS.setString(9, p.getJailer());
|
||||||
pPS.setBytes(10, p.getInventory().getBytes());
|
pPS.setString(10, p.getReason());
|
||||||
pPS.setBytes(11, p.getArmor().getBytes());
|
pPS.setBytes(11, p.getInventory().getBytes());
|
||||||
pPS.setString(12, p.getPreviousLocationString());
|
pPS.setBytes(12, p.getArmor().getBytes());
|
||||||
pPS.setString(13, p.getPreviousGameMode().toString());
|
pPS.setString(13, p.getPreviousLocationString());
|
||||||
|
pPS.setString(14, p.getPreviousGameMode().toString());
|
||||||
|
|
||||||
pPS.executeUpdate();
|
pPS.executeUpdate();
|
||||||
pPS.close();
|
pPS.close();
|
||||||
|
@ -51,8 +51,8 @@ public class JailMain extends JavaPlugin {
|
|||||||
//Try to load the old stuff before we load anything, esp the storage stuff
|
//Try to load the old stuff before we load anything, esp the storage stuff
|
||||||
LegacyManager lm = new LegacyManager(this);
|
LegacyManager lm = new LegacyManager(this);
|
||||||
if(lm.doWeNeedToConvert()) {
|
if(lm.doWeNeedToConvert()) {
|
||||||
boolean converted = lm.convertOldData();
|
lm.convertOldData();
|
||||||
if(!converted) getLogger().severe("We was unable to convert some, or all, of the old data.");
|
if(!lm.wasAnythingConverted()) getLogger().severe("We was unable to convert some, or all, of the old data.");
|
||||||
}
|
}
|
||||||
|
|
||||||
io = new JailIO(this);
|
io = new JailIO(this);
|
||||||
@ -67,6 +67,11 @@ public class JailMain extends JavaPlugin {
|
|||||||
|
|
||||||
io.loadJails();
|
io.loadJails();
|
||||||
|
|
||||||
|
//If we converted something, let's save EVERYTHING including the cells
|
||||||
|
if(lm.wasAnythingConverted()) {
|
||||||
|
io.saveEverything();
|
||||||
|
}
|
||||||
|
|
||||||
cmdHand = new CommandHandler(this);
|
cmdHand = new CommandHandler(this);
|
||||||
jh = new JailHandler(this);
|
jh = new JailHandler(this);
|
||||||
pm = new PrisonerManager(this);
|
pm = new PrisonerManager(this);
|
||||||
@ -166,7 +171,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
|
|
||||||
if(getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
if(getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||||
for(Jail j : jm.getJails()) {
|
for(Jail j : jm.getJails()) {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||||
if(getServer().getPlayer(p.getUUID()) != null) {
|
if(getServer().getPlayer(p.getUUID()) != null) {
|
||||||
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
|
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
|
||||||
}
|
}
|
||||||
|
@ -155,17 +155,30 @@ public class JailManager {
|
|||||||
return this.jails.get(name) != null;
|
return this.jails.get(name) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all the {@link Cell cells} in the jail system, best for system wide count of the cells or touching each cell.
|
||||||
|
*
|
||||||
|
* @return HashSet of all the Cells.
|
||||||
|
*/
|
||||||
|
public HashSet<Cell> getAllCells() {
|
||||||
|
HashSet<Cell> cells = new HashSet<Cell>();
|
||||||
|
|
||||||
|
for(Jail j : jails.values())
|
||||||
|
cells.addAll(j.getCells());
|
||||||
|
|
||||||
|
return cells;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the prisoners in the system, best for a system wide count of the prisoners or accessing all the prisoners at once.
|
* Gets all the prisoners in the system, best for a system wide count of the prisoners or accessing all the prisoners at once.
|
||||||
*
|
*
|
||||||
* @return HashSet of Prisoners.
|
* @return HashSet of Prisoners.
|
||||||
*/
|
*/
|
||||||
public HashSet<Prisoner> getAllPrisoners() {
|
public HashMap<UUID, Prisoner> getAllPrisoners() {
|
||||||
HashSet<Prisoner> prisoners = new HashSet<Prisoner>();
|
HashMap<UUID, Prisoner> prisoners = new HashMap<UUID, Prisoner>();
|
||||||
|
|
||||||
for(Jail j : jails.values()) {
|
for(Jail j : jails.values())
|
||||||
prisoners.addAll(j.getAllPrisoners());
|
prisoners.putAll(j.getAllPrisoners());
|
||||||
}
|
|
||||||
|
|
||||||
return prisoners;
|
return prisoners;
|
||||||
}
|
}
|
||||||
@ -230,7 +243,7 @@ public class JailManager {
|
|||||||
*/
|
*/
|
||||||
public Jail getJailPlayerIsInByLastKnownName(String username) {
|
public Jail getJailPlayerIsInByLastKnownName(String username) {
|
||||||
for(Jail j : jails.values())
|
for(Jail j : jails.values())
|
||||||
for(Prisoner p : j.getAllPrisoners())
|
for(Prisoner p : j.getAllPrisoners().values())
|
||||||
if(p.getLastKnownName().equalsIgnoreCase(username))
|
if(p.getLastKnownName().equalsIgnoreCase(username))
|
||||||
return j;
|
return j;
|
||||||
|
|
||||||
@ -244,7 +257,7 @@ public class JailManager {
|
|||||||
* @return {@link Prisoner prisoner} data
|
* @return {@link Prisoner prisoner} data
|
||||||
*/
|
*/
|
||||||
public Prisoner getPrisonerByLastKnownName(String username) {
|
public Prisoner getPrisonerByLastKnownName(String username) {
|
||||||
for(Prisoner p : this.getAllPrisoners())
|
for(Prisoner p : this.getAllPrisoners().values())
|
||||||
if(p.getLastKnownName().equalsIgnoreCase(username))
|
if(p.getLastKnownName().equalsIgnoreCase(username))
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
@ -273,7 +286,7 @@ public class JailManager {
|
|||||||
Jail j = getJail(jail);
|
Jail j = getJail(jail);
|
||||||
|
|
||||||
if(j != null) {
|
if(j != null) {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||||
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
|
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,7 +310,7 @@ public class JailManager {
|
|||||||
return getPlugin().getJailIO().getLanguageString(LangString.NOJAILS);
|
return getPlugin().getJailIO().getLanguageString(LangString.NOJAILS);
|
||||||
}else {
|
}else {
|
||||||
for(Jail j : getJails()) {
|
for(Jail j : getJails()) {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||||
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
|
getPlugin().getPrisonerManager().releasePrisoner(getPlugin().getServer().getPlayer(p.getUUID()), p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class JailTimer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Jail j : pl.getJailManager().getJails()) {
|
for(Jail j : pl.getJailManager().getJails()) {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||||
//only execute this code if the prisoner's time is more than 0 milliseconds
|
//only execute this code if the prisoner's time is more than 0 milliseconds
|
||||||
if(p.getRemainingTime() > 0) {
|
if(p.getRemainingTime() > 0) {
|
||||||
Player player = pl.getServer().getPlayer(p.getUUID());
|
Player player = pl.getServer().getPlayer(p.getUUID());
|
||||||
|
@ -43,13 +43,13 @@ public class ScoreBoardManager {
|
|||||||
* @param pris data for the provided prisoner
|
* @param pris data for the provided prisoner
|
||||||
*/
|
*/
|
||||||
public void addScoreBoard(Player player, Prisoner pris) {
|
public void addScoreBoard(Player player, Prisoner pris) {
|
||||||
if(!boards.containsKey(player.getName())) {
|
if(!boards.containsKey(player.getUniqueId())) {
|
||||||
boards.put(player.getUniqueId(), man.getNewScoreboard());
|
boards.put(player.getUniqueId(), man.getNewScoreboard());
|
||||||
Objective o = boards.get(player.getName()).registerNewObjective("test", "dummy");
|
Objective o = boards.get(player.getUniqueId()).registerNewObjective("test", "dummy");
|
||||||
o.setDisplaySlot(DisplaySlot.SIDEBAR);
|
o.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
|
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
|
||||||
o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||||
player.setScoreboard(boards.get(player.getName()));
|
player.setScoreboard(boards.get(player.getUniqueId()));
|
||||||
}else {
|
}else {
|
||||||
updatePrisonersBoard(player, pris);
|
updatePrisonersBoard(player, pris);
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public class ScoreBoardManager {
|
|||||||
/** Updates the prisoners time on their scoreboard. */
|
/** Updates the prisoners time on their scoreboard. */
|
||||||
private void updatePrisonersTime() {
|
private void updatePrisonersTime() {
|
||||||
for(Jail j : pl.getJailManager().getJails()) {
|
for(Jail j : pl.getJailManager().getJails()) {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||||
if(pl.getServer().getPlayer(p.getUUID()) != null) {
|
if(pl.getServer().getPlayer(p.getUUID()) != null) {
|
||||||
addScoreBoard(pl.getServer().getPlayer(p.getUUID()), p);
|
addScoreBoard(pl.getServer().getPlayer(p.getUUID()), p);
|
||||||
}
|
}
|
||||||
@ -99,6 +99,6 @@ public class ScoreBoardManager {
|
|||||||
* @param pris data for the player
|
* @param pris data for the player
|
||||||
*/
|
*/
|
||||||
private void updatePrisonersBoard(Player player, Prisoner pris) {
|
private void updatePrisonersBoard(Player player, Prisoner pris) {
|
||||||
boards.get(player.getName()).getObjective("test").getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
boards.get(player.getUniqueId()).getObjective("test").getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.graywolf336.jail.Util;
|
|||||||
public class Jail {
|
public class Jail {
|
||||||
private JailMain plugin;
|
private JailMain plugin;
|
||||||
private HashMap<String, Cell> cells;
|
private HashMap<String, Cell> cells;
|
||||||
private HashSet<Prisoner> nocellPrisoners;//prisoners who aren't in a cell
|
private HashMap<UUID, Prisoner> nocellPrisoners;//prisoners who aren't in a cell
|
||||||
private String name = "", world = "";
|
private String name = "", world = "";
|
||||||
private int minX, minY, minZ, maxX, maxY, maxZ;
|
private int minX, minY, minZ, maxX, maxY, maxZ;
|
||||||
private SimpleLocation in, free;
|
private SimpleLocation in, free;
|
||||||
@ -32,7 +32,7 @@ public class Jail {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
cells = new HashMap<String, Cell>();
|
cells = new HashMap<String, Cell>();
|
||||||
nocellPrisoners = new HashSet<Prisoner>();
|
nocellPrisoners = new HashMap<UUID, Prisoner>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the instance of the plugin's main class. */
|
/** Gets the instance of the plugin's main class. */
|
||||||
@ -135,7 +135,7 @@ public class Jail {
|
|||||||
|
|
||||||
/** Add a prisoner to this jail. */
|
/** Add a prisoner to this jail. */
|
||||||
public void addPrisoner(Prisoner p) {
|
public void addPrisoner(Prisoner p) {
|
||||||
this.nocellPrisoners.add(p);
|
this.nocellPrisoners.put(p.getUUID(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes a prisoner from this jail, doesn't remove it from the cell. */
|
/** Removes a prisoner from this jail, doesn't remove it from the cell. */
|
||||||
@ -246,16 +246,16 @@ public class Jail {
|
|||||||
|
|
||||||
//Replace all the current no cell prisoners with
|
//Replace all the current no cell prisoners with
|
||||||
//a new hashset of prisoners.
|
//a new hashset of prisoners.
|
||||||
this.nocellPrisoners = new HashSet<Prisoner>();
|
this.nocellPrisoners = new HashMap<UUID, Prisoner>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets a HashSet of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
|
/** Gets a HashMap of <b>all</b> the prisoners, the ones in cells and ones who aren't. */
|
||||||
public HashSet<Prisoner> getAllPrisoners() {
|
public HashMap<UUID, Prisoner> getAllPrisoners() {
|
||||||
HashSet<Prisoner> all = new HashSet<Prisoner>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
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())
|
for(Cell c : cells.values())
|
||||||
if(c.hasPrisoner())
|
if(c.hasPrisoner())
|
||||||
all.add(c.getPrisoner());
|
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
|
||||||
|
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ public class Jail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
|
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
|
||||||
public HashSet<Prisoner> getPrisonersNotInCells() {
|
public HashMap<UUID, Prisoner> getPrisonersNotInCells() {
|
||||||
return this.nocellPrisoners;
|
return this.nocellPrisoners;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,11 +303,7 @@ public class Jail {
|
|||||||
* @return true if is a prisoner, false if not.
|
* @return true if is a prisoner, false if not.
|
||||||
*/
|
*/
|
||||||
private boolean isPlayerAPrisoner(UUID uuid) {
|
private boolean isPlayerAPrisoner(UUID uuid) {
|
||||||
for(Prisoner p : this.getAllPrisoners())
|
return this.getAllPrisoners().containsKey(uuid);
|
||||||
if(p.getUUID().equals(uuid))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -317,9 +313,7 @@ public class Jail {
|
|||||||
* @return true if is jailed in a cell, false if not.
|
* @return true if is jailed in a cell, false if not.
|
||||||
*/
|
*/
|
||||||
public boolean isJailedInACell(UUID uuid) {
|
public boolean isJailedInACell(UUID uuid) {
|
||||||
for(Prisoner p : nocellPrisoners)
|
if(this.nocellPrisoners.containsKey(uuid)) return false;
|
||||||
if(p.getUUID().equals(uuid))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for(Cell c : cells.values())
|
for(Cell c : cells.values())
|
||||||
if(c.getPrisoner() != null)
|
if(c.getPrisoner() != null)
|
||||||
@ -336,7 +330,7 @@ public class Jail {
|
|||||||
* @return the prisoner instance, can be null
|
* @return the prisoner instance, can be null
|
||||||
*/
|
*/
|
||||||
public Prisoner getPrisonerByLastKnownName(String name) {
|
public Prisoner getPrisonerByLastKnownName(String name) {
|
||||||
for(Prisoner p : this.getAllPrisoners())
|
for(Prisoner p : this.getAllPrisoners().values())
|
||||||
if(p.getLastKnownName().equalsIgnoreCase(name))
|
if(p.getLastKnownName().equalsIgnoreCase(name))
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
@ -350,9 +344,12 @@ public class Jail {
|
|||||||
* @return the prisoner instance, can be null
|
* @return the prisoner instance, can be null
|
||||||
*/
|
*/
|
||||||
public Prisoner getPrisoner(UUID uuid) {
|
public Prisoner getPrisoner(UUID uuid) {
|
||||||
for(Prisoner p : this.getAllPrisoners())
|
if(this.nocellPrisoners.containsKey(uuid)) return this.nocellPrisoners.get(uuid);
|
||||||
if(p.getUUID().equals(uuid))
|
|
||||||
return p;
|
for(Cell c : cells.values())
|
||||||
|
if(c.hasPrisoner())
|
||||||
|
if(c.getPrisoner().getUUID().equals(uuid))
|
||||||
|
return c.getPrisoner();
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -41,13 +41,13 @@ public class JailListCommand implements Command {
|
|||||||
//No jail was found
|
//No jail was found
|
||||||
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
|
||||||
}else {
|
}else {
|
||||||
HashSet<Prisoner> pris = j.getAllPrisoners();
|
Collection<Prisoner> pris = j.getAllPrisoners().values();
|
||||||
|
|
||||||
if(pris.isEmpty()) {
|
if(pris.isEmpty()) {
|
||||||
//If there are no prisoners, then send that message
|
//If there are no prisoners, then send that message
|
||||||
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOPRISONERS, j.getName()));
|
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOPRISONERS, j.getName()));
|
||||||
}else {
|
}else {
|
||||||
for(Prisoner p : j.getAllPrisoners()) {
|
for(Prisoner p : pris) {
|
||||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||||
//prisoner: reason; jailer (time in minutes)
|
//prisoner: reason; jailer (time in minutes)
|
||||||
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||||
|
@ -41,7 +41,7 @@ public class JailTransferAllCommand implements Command {
|
|||||||
jm.getPlugin().debug("Sending the transferring off, jail checks all came clean.");
|
jm.getPlugin().debug("Sending the transferring off, jail checks all came clean.");
|
||||||
|
|
||||||
Jail old = jm.getJail(args[1]);
|
Jail old = jm.getJail(args[1]);
|
||||||
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners());
|
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners().values());
|
||||||
|
|
||||||
//Transfer all the prisoners
|
//Transfer all the prisoners
|
||||||
for(Prisoner p : oldPrisoners) {
|
for(Prisoner p : oldPrisoners) {
|
||||||
|
@ -27,9 +27,11 @@ import com.graywolf336.jail.enums.Settings;
|
|||||||
public class LegacyManager {
|
public class LegacyManager {
|
||||||
private JailMain pl;
|
private JailMain pl;
|
||||||
private YamlConfiguration global;
|
private YamlConfiguration global;
|
||||||
|
private boolean wasConverted;
|
||||||
|
|
||||||
public LegacyManager(JailMain plugin) {
|
public LegacyManager(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.pl = plugin;
|
||||||
|
this.wasConverted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
|
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
|
||||||
@ -37,6 +39,15 @@ public class LegacyManager {
|
|||||||
return new File(pl.getDataFolder(), "global.yml").exists();
|
return new File(pl.getDataFolder(), "global.yml").exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if we converted anything and it was successful.
|
||||||
|
*
|
||||||
|
* @return true if everything converted successfully, was if not.
|
||||||
|
*/
|
||||||
|
public boolean wasAnythingConverted() {
|
||||||
|
return this.wasConverted;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean convertOldData() {
|
public boolean convertOldData() {
|
||||||
File f = new File(pl.getDataFolder(), "global.yml");
|
File f = new File(pl.getDataFolder(), "global.yml");
|
||||||
|
|
||||||
@ -64,6 +75,7 @@ public class LegacyManager {
|
|||||||
loadOldConfig();
|
loadOldConfig();
|
||||||
loadOldData();
|
loadOldData();
|
||||||
moveOldConfigs();
|
moveOldConfigs();
|
||||||
|
this.wasConverted = true;
|
||||||
pl.getLogger().info("...finished converting configs and data.");
|
pl.getLogger().info("...finished converting configs and data.");
|
||||||
return true;
|
return true;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
@ -380,6 +392,27 @@ public class LegacyManager {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PricePerMinute:
|
||||||
|
if(global.contains(s.getString())) {
|
||||||
|
c.set(Settings.JAILPAYPRICEPERMINUTE.getPath(), OldSettings.getGlobalInt(global, s));
|
||||||
|
pl.debug(Settings.JAILPAYPRICEPERMINUTE.getPath() + " <-- " + s.getString());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
case PriceForInfiniteJail:
|
||||||
|
if(global.contains(s.getString())) {
|
||||||
|
c.set(Settings.JAILPAYPRICEINFINITE.getPath(), OldSettings.getGlobalInt(global, s));
|
||||||
|
pl.debug(Settings.JAILPAYPRICEINFINITE.getPath() + " <-- " + s.getString());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
case JailPayCurrency:
|
||||||
|
if(global.contains(s.getString())) {
|
||||||
|
Material mat = Material.getMaterial(OldSettings.getGlobalInt(global, s));
|
||||||
|
if(mat != null) {
|
||||||
|
c.set(Settings.JAILPAYITEM.getPath(), mat.toString().toLowerCase());
|
||||||
|
pl.debug(Settings.JAILPAYPRICEINFINITE.getPath() + " <-- " + s.getString());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ public class OldInputOutput {
|
|||||||
|
|
||||||
//Load the prisoner if he is a valid prisoner
|
//Load the prisoner if he is a valid prisoner
|
||||||
if(!player.isEmpty()) {
|
if(!player.isEmpty()) {
|
||||||
Prisoner p = j.getPrisonerByLastKnownName(name);
|
Prisoner p = j.getPrisonerByLastKnownName(player);
|
||||||
|
|
||||||
if(p != null) {
|
if(p != null) {
|
||||||
j.removePrisoner(p);
|
j.removePrisoner(p);
|
||||||
|
@ -50,9 +50,9 @@ public enum OldSetting {
|
|||||||
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
|
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
|
||||||
|
|
||||||
//JailPay
|
//JailPay
|
||||||
PricePerMinute("JailPay.PricePerMinute", 10),//TODO
|
PricePerMinute("JailPay.PricePerMinute", 10),//done
|
||||||
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//TODO
|
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//done
|
||||||
JailPayCurrency("JailPay.Currency", 0),//TODO
|
JailPayCurrency("JailPay.Currency", 0),//done
|
||||||
|
|
||||||
//Guards
|
//Guards
|
||||||
GuardHealth("Guards.GuardHealth", 8),//TODO
|
GuardHealth("Guards.GuardHealth", 8),//TODO
|
||||||
|
@ -27,8 +27,9 @@ public class MoveProtectionListener implements Listener {
|
|||||||
//Other wise we don't need to deal with it.
|
//Other wise we don't need to deal with it.
|
||||||
if(pl.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
if(pl.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
||||||
//Let's be sure the player we're dealing with is in jail
|
//Let's be sure the player we're dealing with is in jail
|
||||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
|
||||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||||
|
if(j != null) {
|
||||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
//If the player is being teleported, let's ignore it
|
//If the player is being teleported, let's ignore it
|
||||||
|
@ -76,7 +76,7 @@ public class PlayerListener implements Listener {
|
|||||||
Set<Player> rec = new HashSet<Player>(event.getRecipients());
|
Set<Player> rec = new HashSet<Player>(event.getRecipients());
|
||||||
|
|
||||||
for(Jail j : pl.getJailManager().getJails())
|
for(Jail j : pl.getJailManager().getJails())
|
||||||
for(Prisoner p : j.getAllPrisoners())
|
for(Prisoner p : j.getAllPrisoners().values())
|
||||||
rec.remove(pl.getServer().getPlayer(p.getUUID()));
|
rec.remove(pl.getServer().getPlayer(p.getUUID()));
|
||||||
|
|
||||||
event.getRecipients().clear();
|
event.getRecipients().clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user