Fix the spacing and clean it up.
This commit is contained in:
parent
f89de50d75
commit
71a60e6ee3
@ -26,72 +26,72 @@ import org.bukkit.Location;
|
||||
* @version 1.0.2
|
||||
*/
|
||||
public class HandCuffManager {
|
||||
private HashMap<UUID, Long> handcuffed;
|
||||
private HashMap<UUID, Location> locs;
|
||||
private HashMap<UUID, Long> handcuffed;
|
||||
private HashMap<UUID, Location> locs;
|
||||
|
||||
/** Constructs a new HandCuff Manager, for handling all the handcuffing. */
|
||||
public HandCuffManager() {
|
||||
this.handcuffed = new HashMap<UUID, Long>();
|
||||
this.locs = new HashMap<UUID, Location>();
|
||||
}
|
||||
/** Constructs a new HandCuff Manager, for handling all the handcuffing. */
|
||||
public HandCuffManager() {
|
||||
this.handcuffed = new HashMap<UUID, Long>();
|
||||
this.locs = new HashMap<UUID, Location>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds handcuffs to a player.
|
||||
*
|
||||
* @param uuid of the player
|
||||
* @param location where the player was handcuffed, so they can't move
|
||||
*/
|
||||
public void addHandCuffs(UUID uuid, Location location) {
|
||||
this.handcuffed.put(uuid, System.currentTimeMillis());
|
||||
this.locs.put(uuid, location);
|
||||
}
|
||||
/**
|
||||
* Adds handcuffs to a player.
|
||||
*
|
||||
* @param uuid of the player
|
||||
* @param location where the player was handcuffed, so they can't move
|
||||
*/
|
||||
public void addHandCuffs(UUID uuid, Location location) {
|
||||
this.handcuffed.put(uuid, System.currentTimeMillis());
|
||||
this.locs.put(uuid, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the handcuffs from the given player.
|
||||
*
|
||||
* @param uuid of the person to remove the handcuffs from
|
||||
*/
|
||||
public void removeHandCuffs(UUID uuid) {
|
||||
this.handcuffed.remove(uuid);
|
||||
this.locs.remove(uuid);
|
||||
}
|
||||
/**
|
||||
* Removes the handcuffs from the given player.
|
||||
*
|
||||
* @param uuid of the person to remove the handcuffs from
|
||||
*/
|
||||
public void removeHandCuffs(UUID uuid) {
|
||||
this.handcuffed.remove(uuid);
|
||||
this.locs.remove(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets if the player is handcuffed or not.
|
||||
*
|
||||
* @param uuid of the player to check
|
||||
* @return true if they are handcuffed, false if not
|
||||
*/
|
||||
public boolean isHandCuffed(UUID uuid) {
|
||||
return this.handcuffed.containsKey(uuid);
|
||||
}
|
||||
/**
|
||||
* Gets if the player is handcuffed or not.
|
||||
*
|
||||
* @param uuid of the player to check
|
||||
* @return true if they are handcuffed, false if not
|
||||
*/
|
||||
public boolean isHandCuffed(UUID uuid) {
|
||||
return this.handcuffed.containsKey(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next Long time we should send a message to the player.
|
||||
*
|
||||
* @param uuid of the player to get the name we're supposed to message them next
|
||||
* @return long value of the system time in milliseconds
|
||||
*/
|
||||
public Long getNextMessageTime(UUID uuid) {
|
||||
return this.handcuffed.get(uuid);
|
||||
}
|
||||
/**
|
||||
* Gets the next Long time we should send a message to the player.
|
||||
*
|
||||
* @param uuid of the player to get the name we're supposed to message them next
|
||||
* @return long value of the system time in milliseconds
|
||||
*/
|
||||
public Long getNextMessageTime(UUID uuid) {
|
||||
return this.handcuffed.get(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the time to the next 10 seconds from now to when we should send them a message.
|
||||
*
|
||||
* @param uuid of the player we're setting the message time to
|
||||
*/
|
||||
public void updateNextTime(UUID uuid) {
|
||||
this.handcuffed.put(uuid, System.currentTimeMillis() + 10000);
|
||||
}
|
||||
/**
|
||||
* Updates the time to the next 10 seconds from now to when we should send them a message.
|
||||
*
|
||||
* @param uuid of the player we're setting the message time to
|
||||
*/
|
||||
public void updateNextTime(UUID uuid) {
|
||||
this.handcuffed.put(uuid, System.currentTimeMillis() + 10000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location where the given player was handcuffed at.
|
||||
*
|
||||
* @param uuid of the player get the location for
|
||||
* @return the location where the player was handcuffed at
|
||||
*/
|
||||
public Location getLocation(UUID uuid) {
|
||||
return this.locs.get(uuid);
|
||||
}
|
||||
/**
|
||||
* Gets the location where the given player was handcuffed at.
|
||||
*
|
||||
* @param uuid of the player get the location for
|
||||
* @return the location where the player was handcuffed at
|
||||
*/
|
||||
public Location getLocation(UUID uuid) {
|
||||
return this.locs.get(uuid);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,286 +31,286 @@ import com.graywolf336.jail.listeners.WorldListener;
|
||||
* @version 3.0.0
|
||||
*/
|
||||
public class JailMain extends JavaPlugin {
|
||||
private CommandHandler cmdHand;
|
||||
private HandCuffManager hcm;
|
||||
private JailHandler jh;
|
||||
private JailIO io;
|
||||
private JailManager jm;
|
||||
private JailPayManager jpm;
|
||||
private JailStickManager jsm;
|
||||
private JailTimer jt;
|
||||
private PrisonerManager pm;
|
||||
private ScoreBoardManager sbm;
|
||||
private MoveProtectionListener mpl;
|
||||
private Update update;
|
||||
private boolean debug = false;
|
||||
private int updateCheckTask = -1;
|
||||
private CommandHandler cmdHand;
|
||||
private HandCuffManager hcm;
|
||||
private JailHandler jh;
|
||||
private JailIO io;
|
||||
private JailManager jm;
|
||||
private JailPayManager jpm;
|
||||
private JailStickManager jsm;
|
||||
private JailTimer jt;
|
||||
private PrisonerManager pm;
|
||||
private ScoreBoardManager sbm;
|
||||
private MoveProtectionListener mpl;
|
||||
private Update update;
|
||||
private boolean debug = false;
|
||||
private int updateCheckTask = -1;
|
||||
|
||||
public void onEnable() {
|
||||
long st = System.currentTimeMillis();
|
||||
loadConfig();
|
||||
public void onEnable() {
|
||||
long st = System.currentTimeMillis();
|
||||
loadConfig();
|
||||
|
||||
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
||||
if(debug) getLogger().info("Debugging enabled.");
|
||||
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
||||
if(debug) getLogger().info("Debugging enabled.");
|
||||
|
||||
hcm = new HandCuffManager();
|
||||
jm = new JailManager(this);
|
||||
hcm = new HandCuffManager();
|
||||
jm = new JailManager(this);
|
||||
|
||||
//Try to load the old stuff before we load anything, esp the storage stuff
|
||||
LegacyManager lm = new LegacyManager(this);
|
||||
if(lm.doWeNeedToConvert()) {
|
||||
lm.convertOldData();
|
||||
if(!lm.wasAnythingConverted()) getLogger().severe("We was unable to convert some, or all, of the old data.");
|
||||
}
|
||||
//Try to load the old stuff before we load anything, esp the storage stuff
|
||||
LegacyManager lm = new LegacyManager(this);
|
||||
if(lm.doWeNeedToConvert()) {
|
||||
lm.convertOldData();
|
||||
if(!lm.wasAnythingConverted()) getLogger().severe("We was unable to convert some, or all, of the old data.");
|
||||
}
|
||||
|
||||
io = new JailIO(this);
|
||||
io.loadLanguage();
|
||||
io = new JailIO(this);
|
||||
io.loadLanguage();
|
||||
|
||||
//If the prepareStorage returns false, we need to disable the plugin
|
||||
if(!io.prepareStorage(true)) {
|
||||
this.getLogger().severe("An error occured while preparing the connection to the storage, please see the error above for more information.");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
//If the prepareStorage returns false, we need to disable the plugin
|
||||
if(!io.prepareStorage(true)) {
|
||||
this.getLogger().severe("An error occured while preparing the connection to the storage, please see the error above for more information.");
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
io.loadJails();
|
||||
io.loadJails();
|
||||
|
||||
//If we converted something, let's save EVERYTHING including the cells
|
||||
if(lm.wasAnythingConverted()) {
|
||||
io.saveEverything();
|
||||
}
|
||||
//If we converted something, let's save EVERYTHING including the cells
|
||||
if(lm.wasAnythingConverted()) {
|
||||
io.saveEverything();
|
||||
}
|
||||
|
||||
cmdHand = new CommandHandler(this);
|
||||
jh = new JailHandler(this);
|
||||
pm = new PrisonerManager(this);
|
||||
cmdHand = new CommandHandler(this);
|
||||
jh = new JailHandler(this);
|
||||
pm = new PrisonerManager(this);
|
||||
|
||||
PluginManager plm = this.getServer().getPluginManager();
|
||||
plm.registerEvents(new BlockListener(this), this);
|
||||
plm.registerEvents(new CacheListener(this), this);
|
||||
plm.registerEvents(new EntityListener(this), this);
|
||||
plm.registerEvents(new HandCuffListener(this), this);
|
||||
plm.registerEvents(new JailingListener(this), this);
|
||||
plm.registerEvents(new PlayerListener(this), this);
|
||||
plm.registerEvents(new ProtectionListener(this), this);
|
||||
plm.registerEvents(new WorldListener(this), this);
|
||||
PluginManager plm = this.getServer().getPluginManager();
|
||||
plm.registerEvents(new BlockListener(this), this);
|
||||
plm.registerEvents(new CacheListener(this), this);
|
||||
plm.registerEvents(new EntityListener(this), this);
|
||||
plm.registerEvents(new HandCuffListener(this), this);
|
||||
plm.registerEvents(new JailingListener(this), this);
|
||||
plm.registerEvents(new PlayerListener(this), this);
|
||||
plm.registerEvents(new ProtectionListener(this), this);
|
||||
plm.registerEvents(new WorldListener(this), this);
|
||||
|
||||
//Only register the move protection listener if this is enabled in the
|
||||
//config when we first start the plugin. The reason for this change is
|
||||
//that the move event is called a ton of times per single move and so
|
||||
//not registering this event listener will hopefully safe some performance.
|
||||
//But doing this also forces people to restart their server if they to
|
||||
//enable it after disabling it.
|
||||
if(getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
||||
this.mpl = new MoveProtectionListener(this);
|
||||
plm.registerEvents(this.mpl, this);
|
||||
}
|
||||
//Only register the move protection listener if this is enabled in the
|
||||
//config when we first start the plugin. The reason for this change is
|
||||
//that the move event is called a ton of times per single move and so
|
||||
//not registering this event listener will hopefully safe some performance.
|
||||
//But doing this also forces people to restart their server if they to
|
||||
//enable it after disabling it.
|
||||
if(getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
||||
this.mpl = new MoveProtectionListener(this);
|
||||
plm.registerEvents(this.mpl, this);
|
||||
}
|
||||
|
||||
jt = new JailTimer(this);
|
||||
sbm = new ScoreBoardManager(this);
|
||||
reloadJailPayManager();
|
||||
reloadJailSticks();
|
||||
reloadUpdateCheck();
|
||||
jt = new JailTimer(this);
|
||||
sbm = new ScoreBoardManager(this);
|
||||
reloadJailPayManager();
|
||||
reloadJailSticks();
|
||||
reloadUpdateCheck();
|
||||
|
||||
new JailsAPI(this);
|
||||
debug("Took " + (System.currentTimeMillis() - st) + " to enable the plugin.");
|
||||
getLogger().info("Completed enablement.");
|
||||
}
|
||||
new JailsAPI(this);
|
||||
debug("Took " + (System.currentTimeMillis() - st) + " to enable the plugin.");
|
||||
getLogger().info("Completed enablement.");
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
if(jm != null)
|
||||
for(Jail j : jm.getJails())
|
||||
io.saveJail(j);
|
||||
public void onDisable() {
|
||||
if(jm != null)
|
||||
for(Jail j : jm.getJails())
|
||||
io.saveJail(j);
|
||||
|
||||
if(jt != null)
|
||||
if(jt.getTimer() != null)
|
||||
jt.getTimer().stop();
|
||||
if(jt != null)
|
||||
if(jt.getTimer() != null)
|
||||
jt.getTimer().stop();
|
||||
|
||||
if(io != null)
|
||||
io.closeConnection();
|
||||
if(io != null)
|
||||
io.closeConnection();
|
||||
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
update = null;
|
||||
jt = null;
|
||||
sbm = null;
|
||||
jpm = null;
|
||||
cmdHand = null;
|
||||
pm = null;
|
||||
jm = null;
|
||||
jsm = null;
|
||||
io = null;
|
||||
hcm = null;
|
||||
}
|
||||
update = null;
|
||||
jt = null;
|
||||
sbm = null;
|
||||
jpm = null;
|
||||
cmdHand = null;
|
||||
pm = null;
|
||||
jm = null;
|
||||
jsm = null;
|
||||
io = null;
|
||||
hcm = null;
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
//Only create the default config if it doesn't exist
|
||||
saveDefaultConfig();
|
||||
private void loadConfig() {
|
||||
//Only create the default config if it doesn't exist
|
||||
saveDefaultConfig();
|
||||
|
||||
//Append new key-value pairs to the config
|
||||
getConfig().options().copyDefaults(true);
|
||||
//Append new key-value pairs to the config
|
||||
getConfig().options().copyDefaults(true);
|
||||
|
||||
// Set the header and save
|
||||
// Set the header and save
|
||||
getConfig().options().header(getHeader());
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
private String getHeader() {
|
||||
String sep = System.getProperty("line.separator");
|
||||
private String getHeader() {
|
||||
String sep = System.getProperty("line.separator");
|
||||
|
||||
return "###################" + sep
|
||||
+ "Jail v" + this.getDescription().getVersion() + " config file" + sep
|
||||
+ "Note: You -must- use spaces instead of tabs!" + sep +
|
||||
"###################";
|
||||
}
|
||||
return "###################" + sep
|
||||
+ "Jail v" + this.getDescription().getVersion() + " config file" + sep
|
||||
+ "Note: You -must- use spaces instead of tabs!" + sep +
|
||||
"###################";
|
||||
}
|
||||
|
||||
/* Majority of the new command system was heavily influenced by the MobArena.
|
||||
* Thank you garbagemule for the great system you have in place there.
|
||||
*
|
||||
* Send the command off to the CommandHandler class, that way this main class doesn't get clogged up.
|
||||
*/
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||
if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
||||
jh.parseCommand(jm, sender, args);
|
||||
}else {
|
||||
cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
||||
}
|
||||
/* Majority of the new command system was heavily influenced by the MobArena.
|
||||
* Thank you garbagemule for the great system you have in place there.
|
||||
*
|
||||
* Send the command off to the CommandHandler class, that way this main class doesn't get clogged up.
|
||||
*/
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
||||
if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
||||
jh.parseCommand(jm, sender, args);
|
||||
}else {
|
||||
cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
||||
}
|
||||
|
||||
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
||||
}
|
||||
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
||||
}
|
||||
|
||||
/** Reloads the scoreboard manager class, useful when something is changed int he config about it. */
|
||||
public void reloadScoreBoardManager() {
|
||||
this.sbm.removeAllScoreboards();
|
||||
this.sbm = null;
|
||||
this.sbm = new ScoreBoardManager(this);
|
||||
/** Reloads the scoreboard manager class, useful when something is changed int he config about it. */
|
||||
public void reloadScoreBoardManager() {
|
||||
this.sbm.removeAllScoreboards();
|
||||
this.sbm = null;
|
||||
this.sbm = new ScoreBoardManager(this);
|
||||
|
||||
if(getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
for(Jail j : jm.getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
if(getServer().getPlayer(p.getUUID()) != null) {
|
||||
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
for(Jail j : jm.getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
if(getServer().getPlayer(p.getUUID()) != null) {
|
||||
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
|
||||
public void reloadJailSticks() {
|
||||
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
if(this.jsm != null) {
|
||||
this.jsm.removeAllStickUsers();
|
||||
this.jsm = null;
|
||||
}
|
||||
/** Reloads the Jail Sticks, so the new ones can be loaded from the config. */
|
||||
public void reloadJailSticks() {
|
||||
if(getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
if(this.jsm != null) {
|
||||
this.jsm.removeAllStickUsers();
|
||||
this.jsm = null;
|
||||
}
|
||||
|
||||
this.jsm = new JailStickManager(this);
|
||||
}
|
||||
}
|
||||
this.jsm = new JailStickManager(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the {@link JailPayManager}.
|
||||
*
|
||||
* @throws Exception If we couldn't successfully create a new Jail Pay Manager instance.
|
||||
*/
|
||||
public void reloadJailPayManager() {
|
||||
this.jpm = null;
|
||||
/**
|
||||
* Reloads the {@link JailPayManager}.
|
||||
*
|
||||
* @throws Exception If we couldn't successfully create a new Jail Pay Manager instance.
|
||||
*/
|
||||
public void reloadJailPayManager() {
|
||||
this.jpm = null;
|
||||
|
||||
if(getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
if(getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
this.jpm = new JailPayManager(this);
|
||||
}else {
|
||||
getConfig().set(Settings.JAILPAYENABLED.getPath(), false);
|
||||
getLogger().severe("Jail Pay couldn't find an economy, disabling Jail Pay.");
|
||||
}
|
||||
}
|
||||
}
|
||||
if(getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
if(getServer().getPluginManager().isPluginEnabled("Vault")) {
|
||||
this.jpm = new JailPayManager(this);
|
||||
}else {
|
||||
getConfig().set(Settings.JAILPAYENABLED.getPath(), false);
|
||||
getLogger().severe("Jail Pay couldn't find an economy, disabling Jail Pay.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reloads the update checker, in case they changed a setting about it. */
|
||||
public void reloadUpdateCheck() {
|
||||
getServer().getScheduler().cancelTask(updateCheckTask);
|
||||
update = new Update(this);
|
||||
if(getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||
try {
|
||||
updateCheckTask = getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||
public void run() {
|
||||
update.query();
|
||||
}
|
||||
}, 80L, Util.getTime(getConfig().getString(Settings.UPDATETIME.getPath()), TimeUnit.SECONDS) * 20).getTaskId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Was unable to schedule the update checking, please check your time format is correct.");
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Reloads the update checker, in case they changed a setting about it. */
|
||||
public void reloadUpdateCheck() {
|
||||
getServer().getScheduler().cancelTask(updateCheckTask);
|
||||
update = new Update(this);
|
||||
if(getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||
try {
|
||||
updateCheckTask = getServer().getScheduler().runTaskTimerAsynchronously(this, new Runnable() {
|
||||
public void run() {
|
||||
update.query();
|
||||
}
|
||||
}, 80L, Util.getTime(getConfig().getString(Settings.UPDATETIME.getPath()), TimeUnit.SECONDS) * 20).getTaskId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
getLogger().severe("Was unable to schedule the update checking, please check your time format is correct.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the {@link HandCuffManager} instance. */
|
||||
public HandCuffManager getHandCuffManager() {
|
||||
return this.hcm;
|
||||
}
|
||||
/** Gets the {@link HandCuffManager} instance. */
|
||||
public HandCuffManager getHandCuffManager() {
|
||||
return this.hcm;
|
||||
}
|
||||
|
||||
/** Gets the {@link JailIO} instance. */
|
||||
public JailIO getJailIO() {
|
||||
return this.io;
|
||||
}
|
||||
/** Gets the {@link JailIO} instance. */
|
||||
public JailIO getJailIO() {
|
||||
return this.io;
|
||||
}
|
||||
|
||||
/** Gets the {@link JailManager} instance. */
|
||||
public JailManager getJailManager() {
|
||||
return this.jm;
|
||||
}
|
||||
/** Gets the {@link JailManager} instance. */
|
||||
public JailManager getJailManager() {
|
||||
return this.jm;
|
||||
}
|
||||
|
||||
/** Gets the {@link JailPayManager} instance. */
|
||||
public JailPayManager getJailPayManager() {
|
||||
return this.jpm;
|
||||
}
|
||||
/** Gets the {@link JailPayManager} instance. */
|
||||
public JailPayManager getJailPayManager() {
|
||||
return this.jpm;
|
||||
}
|
||||
|
||||
/** Gets the {@link PrisonerManager} instance. */
|
||||
public PrisonerManager getPrisonerManager() {
|
||||
return this.pm;
|
||||
}
|
||||
/** Gets the {@link PrisonerManager} instance. */
|
||||
public PrisonerManager getPrisonerManager() {
|
||||
return this.pm;
|
||||
}
|
||||
|
||||
/** Gets the {@link JailStickManager} instance. */
|
||||
public JailStickManager getJailStickManager() {
|
||||
return this.jsm;
|
||||
}
|
||||
/** Gets the {@link JailStickManager} instance. */
|
||||
public JailStickManager getJailStickManager() {
|
||||
return this.jsm;
|
||||
}
|
||||
|
||||
/** Gets the {@link ScoreBoardManager} instance. */
|
||||
public ScoreBoardManager getScoreBoardManager() {
|
||||
return this.sbm;
|
||||
}
|
||||
/** Gets the {@link ScoreBoardManager} instance. */
|
||||
public ScoreBoardManager getScoreBoardManager() {
|
||||
return this.sbm;
|
||||
}
|
||||
|
||||
/** Gets the {@link Update} instance. */
|
||||
public Update getUpdate() {
|
||||
return this.update;
|
||||
}
|
||||
/** Gets the {@link Update} instance. */
|
||||
public Update getUpdate() {
|
||||
return this.update;
|
||||
}
|
||||
|
||||
/** Sets whether the plugin is in debugging or not. */
|
||||
public boolean setDebugging(boolean debug) {
|
||||
this.debug = debug;
|
||||
/** Sets whether the plugin is in debugging or not. */
|
||||
public boolean setDebugging(boolean debug) {
|
||||
this.debug = debug;
|
||||
|
||||
//Save whether we are debugging when we disable the plugin
|
||||
getConfig().set(Settings.DEBUG.getPath(), this.debug);
|
||||
saveConfig();
|
||||
//Save whether we are debugging when we disable the plugin
|
||||
getConfig().set(Settings.DEBUG.getPath(), this.debug);
|
||||
saveConfig();
|
||||
|
||||
return this.debug;
|
||||
}
|
||||
return this.debug;
|
||||
}
|
||||
|
||||
/** Returns if the plugin is in debug state or not. */
|
||||
public boolean inDebug() {
|
||||
return this.debug;
|
||||
}
|
||||
/** Returns if the plugin is in debug state or not. */
|
||||
public boolean inDebug() {
|
||||
return this.debug;
|
||||
}
|
||||
|
||||
/** Logs a debugging message to the console if debugging is enabled. */
|
||||
public void debug(String message) {
|
||||
if(inDebug()) getLogger().info("[Debug]: " + message);
|
||||
}
|
||||
/** Logs a debugging message to the console if debugging is enabled. */
|
||||
public void debug(String message) {
|
||||
if(inDebug()) getLogger().info("[Debug]: " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is only for testing, there is no need to use this.
|
||||
*
|
||||
* @return the move protection listener
|
||||
* @deprecated
|
||||
*/
|
||||
public MoveProtectionListener getPlayerMoveListener() {
|
||||
return this.mpl;
|
||||
}
|
||||
/**
|
||||
* This method is only for testing, there is no need to use this.
|
||||
*
|
||||
* @return the move protection listener
|
||||
* @deprecated
|
||||
*/
|
||||
public MoveProtectionListener getPlayerMoveListener() {
|
||||
return this.mpl;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -11,156 +11,156 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class JailPayManager {
|
||||
private Economy economy = null;
|
||||
private double minteCost, infiniteCost;
|
||||
private Material item;
|
||||
private boolean infinite, timed;
|
||||
private Economy economy = null;
|
||||
private double minteCost, infiniteCost;
|
||||
private Material item;
|
||||
private boolean infinite, timed;
|
||||
|
||||
public JailPayManager(JailMain plugin) {
|
||||
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase()));
|
||||
if(this.item == null) this.item = Material.AIR;
|
||||
public JailPayManager(JailMain plugin) {
|
||||
this.item = Material.getMaterial(plugin.getConfig().getString(Settings.JAILPAYITEM.getPath().toUpperCase()));
|
||||
if(this.item == null) this.item = Material.AIR;
|
||||
|
||||
this.minteCost = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath());
|
||||
this.minteCost = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath());
|
||||
|
||||
if(!this.usingItemsForPayment()) {
|
||||
if(!this.setupEconomy(plugin)) {
|
||||
plugin.getConfig().set(Settings.JAILPAYENABLED.getPath(), false);
|
||||
}
|
||||
}
|
||||
if(!this.usingItemsForPayment()) {
|
||||
if(!this.setupEconomy(plugin)) {
|
||||
plugin.getConfig().set(Settings.JAILPAYENABLED.getPath(), false);
|
||||
}
|
||||
}
|
||||
|
||||
this.timed = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath()) != 0;
|
||||
this.infinite = plugin.getConfig().getDouble(Settings.JAILPAYPRICEINFINITE.getPath()) != 0;
|
||||
}
|
||||
this.timed = plugin.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath()) != 0;
|
||||
this.infinite = plugin.getConfig().getDouble(Settings.JAILPAYPRICEINFINITE.getPath()) != 0;
|
||||
}
|
||||
|
||||
/** Checks if paying for infinite is enabled. */
|
||||
public boolean isInfiniteEnabled() {
|
||||
return this.infinite;
|
||||
}
|
||||
/** Checks if paying for infinite is enabled. */
|
||||
public boolean isInfiniteEnabled() {
|
||||
return this.infinite;
|
||||
}
|
||||
|
||||
/** Checks if paying for timed is enabled. */
|
||||
public boolean isTimedEnabled() {
|
||||
return this.timed;
|
||||
}
|
||||
/** Checks if paying for timed is enabled. */
|
||||
public boolean isTimedEnabled() {
|
||||
return this.timed;
|
||||
}
|
||||
|
||||
/** Gets how much it cost per minute in string format. */
|
||||
public String getCostPerMinute() {
|
||||
return String.valueOf(this.minteCost);
|
||||
}
|
||||
/** Gets how much it cost per minute in string format. */
|
||||
public String getCostPerMinute() {
|
||||
return String.valueOf(this.minteCost);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates how much players have to pay to get completely free.
|
||||
*
|
||||
* @param prisoner data of who we're calculating
|
||||
* @return The economy cost the prisoner will need to pay to get completely free.
|
||||
*/
|
||||
public double calculateBill(Prisoner prisoner) {
|
||||
return prisoner.getRemainingTime() > 0 ? prisoner.getRemainingTimeInMinutes() * this.minteCost : infiniteCost;
|
||||
}
|
||||
/**
|
||||
* Calculates how much players have to pay to get completely free.
|
||||
*
|
||||
* @param prisoner data of who we're calculating
|
||||
* @return The economy cost the prisoner will need to pay to get completely free.
|
||||
*/
|
||||
public double calculateBill(Prisoner prisoner) {
|
||||
return prisoner.getRemainingTime() > 0 ? prisoner.getRemainingTimeInMinutes() * this.minteCost : infiniteCost;
|
||||
}
|
||||
|
||||
/** Gets how many minutes someone is paying for (rounds to the lowest number). */
|
||||
public long getMinutesPayingFor(double amount) {
|
||||
return (long) Math.floor(amount / this.minteCost);
|
||||
}
|
||||
/** Gets how many minutes someone is paying for (rounds to the lowest number). */
|
||||
public long getMinutesPayingFor(double amount) {
|
||||
return (long) Math.floor(amount / this.minteCost);
|
||||
}
|
||||
|
||||
/** Returns if we are using items for payment instead of economy. */
|
||||
public boolean usingItemsForPayment() {
|
||||
return this.item != Material.AIR;
|
||||
}
|
||||
/** Returns if we are using items for payment instead of economy. */
|
||||
public boolean usingItemsForPayment() {
|
||||
return this.item != Material.AIR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Material} it costs for jail pay, will be air if using economy.
|
||||
*
|
||||
* @return The item type it costs, air if using virtual economy.
|
||||
*/
|
||||
public Material getItemItCost() {
|
||||
return this.item;
|
||||
}
|
||||
/**
|
||||
* Gets the {@link Material} it costs for jail pay, will be air if using economy.
|
||||
*
|
||||
* @return The item type it costs, air if using virtual economy.
|
||||
*/
|
||||
public Material getItemItCost() {
|
||||
return this.item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the player has enough money/items to pay what they have said they want to.
|
||||
*
|
||||
* @param p The player who is doing the paying.
|
||||
* @param amt The amount to check they if they have.
|
||||
* @return true if they have enough, false if not.
|
||||
*/
|
||||
public boolean hasEnoughToPay(Player p, double amt) {
|
||||
if(this.usingItemsForPayment()) {
|
||||
return p.getInventory().contains(this.item, (int) Math.ceil(amt));
|
||||
}else {
|
||||
/**
|
||||
* Checks if the player has enough money/items to pay what they have said they want to.
|
||||
*
|
||||
* @param p The player who is doing the paying.
|
||||
* @param amt The amount to check they if they have.
|
||||
* @return true if they have enough, false if not.
|
||||
*/
|
||||
public boolean hasEnoughToPay(Player p, double amt) {
|
||||
if(this.usingItemsForPayment()) {
|
||||
return p.getInventory().contains(this.item, (int) Math.ceil(amt));
|
||||
}else {
|
||||
|
||||
return this.economy.has(p.getName(), amt);
|
||||
}
|
||||
}
|
||||
return this.economy.has(p.getName(), amt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pays the required fees from the given player, removing items or money from economy.
|
||||
*
|
||||
* @param p The player who is paying.
|
||||
* @param amt The amount of items or money to withdraw from the player.
|
||||
*/
|
||||
public void pay(Player p, double amt) {
|
||||
if(this.usingItemsForPayment()) {
|
||||
int amtNeeded = (int) Math.ceil(amt);
|
||||
/**
|
||||
* Pays the required fees from the given player, removing items or money from economy.
|
||||
*
|
||||
* @param p The player who is paying.
|
||||
* @param amt The amount of items or money to withdraw from the player.
|
||||
*/
|
||||
public void pay(Player p, double amt) {
|
||||
if(this.usingItemsForPayment()) {
|
||||
int amtNeeded = (int) Math.ceil(amt);
|
||||
|
||||
for (int i = 0; i < p.getInventory().getSize(); i++) {
|
||||
ItemStack it = p.getInventory().getItem(i);
|
||||
for (int i = 0; i < p.getInventory().getSize(); i++) {
|
||||
ItemStack it = p.getInventory().getItem(i);
|
||||
|
||||
//The item is either air or we doesn't match out needs
|
||||
if(it == null || it.getType() != this.item) continue;
|
||||
//The item is either air or we doesn't match out needs
|
||||
if(it == null || it.getType() != this.item) continue;
|
||||
|
||||
//If the itemstack has more than or equal to the amount
|
||||
//that we need, remove it and subject from the amt needed
|
||||
if (amtNeeded >= it.getAmount()) {
|
||||
amtNeeded -= it.getAmount();
|
||||
p.getInventory().clear(i);
|
||||
} else {
|
||||
//Otherwise, subject from the itemstack just the amount we need
|
||||
it.setAmount(it.getAmount() - amtNeeded);
|
||||
p.getInventory().setItem(i, it);
|
||||
amtNeeded = 0;
|
||||
}
|
||||
//If the itemstack has more than or equal to the amount
|
||||
//that we need, remove it and subject from the amt needed
|
||||
if (amtNeeded >= it.getAmount()) {
|
||||
amtNeeded -= it.getAmount();
|
||||
p.getInventory().clear(i);
|
||||
} else {
|
||||
//Otherwise, subject from the itemstack just the amount we need
|
||||
it.setAmount(it.getAmount() - amtNeeded);
|
||||
p.getInventory().setItem(i, it);
|
||||
amtNeeded = 0;
|
||||
}
|
||||
|
||||
if (amtNeeded == 0) break;
|
||||
}
|
||||
}else {
|
||||
this.economy.withdrawPlayer(p.getName(), amt);
|
||||
}
|
||||
}
|
||||
if (amtNeeded == 0) break;
|
||||
}
|
||||
}else {
|
||||
this.economy.withdrawPlayer(p.getName(), amt);
|
||||
}
|
||||
}
|
||||
|
||||
/** Gets the name of the item in nice capitals. */
|
||||
public String getCurrencyName(){
|
||||
if(this.usingItemsForPayment()) {
|
||||
String name = item.toString().replaceAll("_", " ");
|
||||
/** Gets the name of the item in nice capitals. */
|
||||
public String getCurrencyName(){
|
||||
if(this.usingItemsForPayment()) {
|
||||
String name = item.toString().replaceAll("_", " ");
|
||||
|
||||
if(name.contains(" ")){
|
||||
String[] split = name.split(" ");
|
||||
for(int i=0; i < split.length; i++){
|
||||
split[i] = split[i].substring(0, 1).toUpperCase() + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
if(name.contains(" ")){
|
||||
String[] split = name.split(" ");
|
||||
for(int i=0; i < split.length; i++){
|
||||
split[i] = split[i].substring(0, 1).toUpperCase() + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
name = "";
|
||||
for(String s : split){
|
||||
name += " " + s;
|
||||
}
|
||||
name = "";
|
||||
for(String s : split){
|
||||
name += " " + s;
|
||||
}
|
||||
|
||||
name = name.substring(1);
|
||||
} else {
|
||||
name = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
|
||||
}
|
||||
name = name.substring(1);
|
||||
} else {
|
||||
name = name.substring(0, 1).toUpperCase() + name.substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
return name;
|
||||
}else {
|
||||
return this.economy.currencyNamePlural();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
}else {
|
||||
return this.economy.currencyNamePlural();
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the economy provider to do transaction with. */
|
||||
public Economy getEconomy() {
|
||||
return this.economy;
|
||||
}
|
||||
/** Returns the economy provider to do transaction with. */
|
||||
public Economy getEconomy() {
|
||||
return this.economy;
|
||||
}
|
||||
|
||||
private boolean setupEconomy(JailMain plugin) {
|
||||
if (economy != null) return true;
|
||||
private boolean setupEconomy(JailMain plugin) {
|
||||
if (economy != null) return true;
|
||||
|
||||
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||
if (economyProvider != null) {
|
||||
|
@ -18,134 +18,134 @@ import com.graywolf336.jail.enums.Settings;
|
||||
*
|
||||
*/
|
||||
public class JailStickManager {
|
||||
private ArrayList<UUID> stickers;
|
||||
private HashMap<Material, Stick> sticks;
|
||||
private ArrayList<UUID> stickers;
|
||||
private HashMap<Material, Stick> sticks;
|
||||
|
||||
public JailStickManager(JailMain plugin) {
|
||||
this.stickers = new ArrayList<UUID>();
|
||||
this.sticks = new HashMap<Material, Stick>();
|
||||
public JailStickManager(JailMain plugin) {
|
||||
this.stickers = new ArrayList<UUID>();
|
||||
this.sticks = new HashMap<Material, Stick>();
|
||||
|
||||
this.loadJailSticks(plugin);
|
||||
}
|
||||
this.loadJailSticks(plugin);
|
||||
}
|
||||
|
||||
private void loadJailSticks(JailMain pl) {
|
||||
//item name,time,jail name,reason
|
||||
if(pl.getJailManager().getJails().size() == 0) {
|
||||
pl.getLogger().warning("Can't have jail sticks without any jails.");
|
||||
}else {
|
||||
for(String s : pl.getConfig().getStringList(Settings.JAILSTICKSTICKS.getPath())) {
|
||||
pl.debug(s);
|
||||
String[] a = s.split(",");
|
||||
String jail = a[2];
|
||||
private void loadJailSticks(JailMain pl) {
|
||||
//item name,time,jail name,reason
|
||||
if(pl.getJailManager().getJails().size() == 0) {
|
||||
pl.getLogger().warning("Can't have jail sticks without any jails.");
|
||||
}else {
|
||||
for(String s : pl.getConfig().getStringList(Settings.JAILSTICKSTICKS.getPath())) {
|
||||
pl.debug(s);
|
||||
String[] a = s.split(",");
|
||||
String jail = a[2];
|
||||
|
||||
//Check if the jail given, if any, exists
|
||||
if(jail.isEmpty()) {
|
||||
jail = pl.getJailManager().getJail("").getName();
|
||||
}else {
|
||||
if(!pl.getJailManager().isValidJail(jail)) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("The above jail stick configuration is invalid and references a jail that doesn't exist.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//Check if the jail given, if any, exists
|
||||
if(jail.isEmpty()) {
|
||||
jail = pl.getJailManager().getJail("").getName();
|
||||
}else {
|
||||
if(!pl.getJailManager().isValidJail(jail)) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("The above jail stick configuration is invalid and references a jail that doesn't exist.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Material m = Material.getMaterial(a[0].toUpperCase());
|
||||
if(this.sticks.containsKey(m)) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("You can not use the same item for two different Jail Sticks. This already exists as a Jail Stick: " + a[0]);
|
||||
continue;
|
||||
}
|
||||
Material m = Material.getMaterial(a[0].toUpperCase());
|
||||
if(this.sticks.containsKey(m)) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("You can not use the same item for two different Jail Sticks. This already exists as a Jail Stick: " + a[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
long time = 5;
|
||||
try {
|
||||
time = Util.getTime(a[1]);
|
||||
} catch (Exception e) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("The time format on the above jail stick configuration is incorrect.");
|
||||
continue;
|
||||
}
|
||||
long time = 5;
|
||||
try {
|
||||
time = Util.getTime(a[1]);
|
||||
} catch (Exception e) {
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("The time format on the above jail stick configuration is incorrect.");
|
||||
continue;
|
||||
}
|
||||
|
||||
double health = -1;
|
||||
if(a.length > 5) health = Double.valueOf(a[4]);
|
||||
double health = -1;
|
||||
if(a.length > 5) health = Double.valueOf(a[4]);
|
||||
|
||||
try {
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, health));
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("Unable to create a new stick for " + a[0] + ", see the exception above for details.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.sticks.put(m, new Stick(jail, a[3], time, health));
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
pl.getLogger().severe(s);
|
||||
pl.getLogger().severe("Unable to create a new stick for " + a[0] + ", see the exception above for details.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int c = sticks.size();
|
||||
pl.getLogger().info("Loaded " + c + " jail stick" + (c == 1 ? "" : "s") + ".");
|
||||
}
|
||||
int c = sticks.size();
|
||||
pl.getLogger().info("Loaded " + c + " jail stick" + (c == 1 ? "" : "s") + ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Stick jail stick} by the provided {@link Material}, can be null.
|
||||
*
|
||||
* @param mat of the stick to get
|
||||
* @return The {@link Stick jail stick}
|
||||
*/
|
||||
public Stick getStick(Material mat) {
|
||||
return this.sticks.get(mat);
|
||||
}
|
||||
/**
|
||||
* Gets the {@link Stick jail stick} by the provided {@link Material}, can be null.
|
||||
*
|
||||
* @param mat of the stick to get
|
||||
* @return The {@link Stick jail stick}
|
||||
*/
|
||||
public Stick getStick(Material mat) {
|
||||
return this.sticks.get(mat);
|
||||
}
|
||||
|
||||
/** Checks if the provided Material is a valid {@link Stick jail stick}. */
|
||||
public boolean isValidStick(Material mat) {
|
||||
return this.sticks.containsKey(mat);
|
||||
}
|
||||
/** Checks if the provided Material is a valid {@link Stick jail stick}. */
|
||||
public boolean isValidStick(Material mat) {
|
||||
return this.sticks.containsKey(mat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a player to be using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to add
|
||||
*/
|
||||
public void addUsingStick(UUID id) {
|
||||
this.stickers.add(id);
|
||||
}
|
||||
/**
|
||||
* Adds a player to be using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to add
|
||||
*/
|
||||
public void addUsingStick(UUID id) {
|
||||
this.stickers.add(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a player from using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to remove using a jail stick
|
||||
*/
|
||||
public void removeUsingStick(UUID id) {
|
||||
this.stickers.remove(id);
|
||||
}
|
||||
/**
|
||||
* Removes a player from using a jail stick, with the uuid of the player.
|
||||
*
|
||||
* @param id of the player to remove using a jail stick
|
||||
*/
|
||||
public void removeUsingStick(UUID id) {
|
||||
this.stickers.remove(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the player is using a jail stick.
|
||||
*
|
||||
* @param id of the player to check if using one
|
||||
* @return true if the player is using a jail stick, false if not
|
||||
*/
|
||||
public boolean isUsingJailStick(UUID id) {
|
||||
return this.stickers.contains(id);
|
||||
}
|
||||
/**
|
||||
* Returns whether or not the player is using a jail stick.
|
||||
*
|
||||
* @param id of the player to check if using one
|
||||
* @return true if the player is using a jail stick, false if not
|
||||
*/
|
||||
public boolean isUsingJailStick(UUID id) {
|
||||
return this.stickers.contains(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles whether the player is using a jail stick, returning the true if enabled false if disabled.
|
||||
*
|
||||
* @param id of the player to toggle using a stick
|
||||
* @return true if we enabled it, false if we disabled it.
|
||||
*/
|
||||
public boolean toggleUsingStick(UUID id) {
|
||||
if(this.stickers.contains(id)) {
|
||||
this.stickers.remove(id);
|
||||
return false;
|
||||
}else {
|
||||
this.stickers.add(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Toggles whether the player is using a jail stick, returning the true if enabled false if disabled.
|
||||
*
|
||||
* @param id of the player to toggle using a stick
|
||||
* @return true if we enabled it, false if we disabled it.
|
||||
*/
|
||||
public boolean toggleUsingStick(UUID id) {
|
||||
if(this.stickers.contains(id)) {
|
||||
this.stickers.remove(id);
|
||||
return false;
|
||||
}else {
|
||||
this.stickers.add(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes all the users currently using the sticks. */
|
||||
public void removeAllStickUsers() {
|
||||
for(UUID id : stickers) {
|
||||
this.removeUsingStick(id);
|
||||
}
|
||||
}
|
||||
/** Removes all the users currently using the sticks. */
|
||||
public void removeAllStickUsers() {
|
||||
for(UUID id : stickers) {
|
||||
this.removeUsingStick(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,87 +21,87 @@ import com.graywolf336.jail.enums.Settings;
|
||||
*
|
||||
*/
|
||||
public class JailTimer {
|
||||
private JailMain pl;
|
||||
private Timer timer;
|
||||
private Long lastTime;
|
||||
private Long afkTime = 0L;
|
||||
private JailMain pl;
|
||||
private Timer timer;
|
||||
private Long lastTime;
|
||||
private Long afkTime = 0L;
|
||||
|
||||
public JailTimer(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
try {
|
||||
afkTime = Util.getTime(pl.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
||||
} catch (Exception e) {
|
||||
pl.getLogger().severe("Error while processing the max afk time: " + e.getMessage());
|
||||
}
|
||||
public JailTimer(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
try {
|
||||
afkTime = Util.getTime(pl.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
||||
} catch (Exception e) {
|
||||
pl.getLogger().severe("Error while processing the max afk time: " + e.getMessage());
|
||||
}
|
||||
|
||||
this.lastTime = System.currentTimeMillis();
|
||||
if(pl.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath())) {
|
||||
pl.getLogger().info("Using the Bukkit Scheduler.");
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new TimeEvent(), 200, 200);
|
||||
}else {
|
||||
pl.getLogger().info("Using the Java Timer.");
|
||||
timer = new Timer(10000, new ActionListener () {
|
||||
public void actionPerformed (ActionEvent event) {
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent());
|
||||
};
|
||||
});
|
||||
this.lastTime = System.currentTimeMillis();
|
||||
if(pl.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath())) {
|
||||
pl.getLogger().info("Using the Bukkit Scheduler.");
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new TimeEvent(), 200, 200);
|
||||
}else {
|
||||
pl.getLogger().info("Using the Java Timer.");
|
||||
timer = new Timer(10000, new ActionListener () {
|
||||
public void actionPerformed (ActionEvent event) {
|
||||
pl.getServer().getScheduler().scheduleSyncDelayedTask(pl, new TimeEvent());
|
||||
};
|
||||
});
|
||||
|
||||
timer.start();
|
||||
}
|
||||
timer.start();
|
||||
}
|
||||
|
||||
//Save all the jail information every minute, not every 10 seconds
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new Runnable() {
|
||||
public void run() {
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
pl.getJailIO().saveJail(j);
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}
|
||||
//Save all the jail information every minute, not every 10 seconds
|
||||
pl.getServer().getScheduler().runTaskTimerAsynchronously(pl, new Runnable() {
|
||||
public void run() {
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
pl.getJailIO().saveJail(j);
|
||||
}
|
||||
}
|
||||
}, 1200L, 1200L);
|
||||
}
|
||||
|
||||
/** Returns the instance of this timer. */
|
||||
public Timer getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
/** Returns the instance of this timer. */
|
||||
public Timer getTimer() {
|
||||
return this.timer;
|
||||
}
|
||||
|
||||
class TimeEvent implements Runnable {
|
||||
public void run() {
|
||||
long timePassed = System.currentTimeMillis() - lastTime;
|
||||
lastTime = System.currentTimeMillis();
|
||||
class TimeEvent implements Runnable {
|
||||
public void run() {
|
||||
long timePassed = System.currentTimeMillis() - lastTime;
|
||||
lastTime = System.currentTimeMillis();
|
||||
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
//only execute this code if the prisoner's time is more than 0 milliseconds
|
||||
//and they don't have any offline pending things
|
||||
if(p.getRemainingTime() > 0 && !p.isOfflinePending()) {
|
||||
Player player = pl.getServer().getPlayer(p.getUUID());
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
//only execute this code if the prisoner's time is more than 0 milliseconds
|
||||
//and they don't have any offline pending things
|
||||
if(p.getRemainingTime() > 0 && !p.isOfflinePending()) {
|
||||
Player player = pl.getServer().getPlayer(p.getUUID());
|
||||
|
||||
//Check if the player is offline
|
||||
if(player == null) {
|
||||
//if they are offline AND the config has counting down the time
|
||||
//while the prisoner is offline, then let's do it
|
||||
if(pl.getConfig().getBoolean(Settings.COUNTDOWNTIMEOFFLINE.getPath())) {
|
||||
//Set their remaining time but if it is less than zero, set it to zero
|
||||
p.setRemainingTime(Math.max(0, p.getRemainingTime() - timePassed));
|
||||
if(p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}
|
||||
}else {
|
||||
if(afkTime > 0) {
|
||||
p.setAFKTime(p.getAFKTime() + timePassed);
|
||||
if(p.getAFKTime() > afkTime) {
|
||||
p.setAFKTime(0);
|
||||
player.kickPlayer(Lang.AFKKICKMESSAGE.get());
|
||||
}
|
||||
}
|
||||
//Check if the player is offline
|
||||
if(player == null) {
|
||||
//if they are offline AND the config has counting down the time
|
||||
//while the prisoner is offline, then let's do it
|
||||
if(pl.getConfig().getBoolean(Settings.COUNTDOWNTIMEOFFLINE.getPath())) {
|
||||
//Set their remaining time but if it is less than zero, set it to zero
|
||||
p.setRemainingTime(Math.max(0, p.getRemainingTime() - timePassed));
|
||||
if(p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}
|
||||
}else {
|
||||
if(afkTime > 0) {
|
||||
p.setAFKTime(p.getAFKTime() + timePassed);
|
||||
if(p.getAFKTime() > afkTime) {
|
||||
p.setAFKTime(0);
|
||||
player.kickPlayer(Lang.AFKKICKMESSAGE.get());
|
||||
}
|
||||
}
|
||||
|
||||
//The prisoner isn't offline, so let's count down
|
||||
//Set their remaining time but if it is less than zero, set it to zero
|
||||
p.setRemainingTime(Math.max(0, p.getRemainingTime() - timePassed));
|
||||
if(p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//The prisoner isn't offline, so let's count down
|
||||
//Set their remaining time but if it is less than zero, set it to zero
|
||||
p.setRemainingTime(Math.max(0, p.getRemainingTime() - timePassed));
|
||||
if(p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,39 +13,39 @@ package com.graywolf336.jail;
|
||||
* @since 3.0.0
|
||||
*/
|
||||
public class JailsAPI {
|
||||
private static JailMain pl;
|
||||
private static JailMain pl;
|
||||
|
||||
public JailsAPI(JailMain plugin) {
|
||||
pl = plugin;
|
||||
}
|
||||
public JailsAPI(JailMain plugin) {
|
||||
pl = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of the {@link JailManager} which contains all the jails and in return prisoners.
|
||||
*
|
||||
* @return instance of the {@link JailManager}
|
||||
* @see JailManager
|
||||
*/
|
||||
public static JailManager getJailManager() {
|
||||
return pl.getJailManager();
|
||||
}
|
||||
/**
|
||||
* The instance of the {@link JailManager} which contains all the jails and in return prisoners.
|
||||
*
|
||||
* @return instance of the {@link JailManager}
|
||||
* @see JailManager
|
||||
*/
|
||||
public static JailManager getJailManager() {
|
||||
return pl.getJailManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of the {@link PrisonerManager} which handles all the jailing of players.
|
||||
*
|
||||
* @return instance of the {@link PrisonerManager}
|
||||
* @see PrisonerManager
|
||||
*/
|
||||
public static PrisonerManager getPrisonerManager() {
|
||||
return pl.getPrisonerManager();
|
||||
}
|
||||
/**
|
||||
* The instance of the {@link PrisonerManager} which handles all the jailing of players.
|
||||
*
|
||||
* @return instance of the {@link PrisonerManager}
|
||||
* @see PrisonerManager
|
||||
*/
|
||||
public static PrisonerManager getPrisonerManager() {
|
||||
return pl.getPrisonerManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* The instance of the {@link HandCuffManager} which handles all the handcuffing of players.
|
||||
*
|
||||
* @return instance of the {@link HandCuffManager}
|
||||
* @see HandCuffManager
|
||||
*/
|
||||
public static HandCuffManager getHandCuffManager() {
|
||||
return pl.getHandCuffManager();
|
||||
}
|
||||
/**
|
||||
* The instance of the {@link HandCuffManager} which handles all the handcuffing of players.
|
||||
*
|
||||
* @return instance of the {@link HandCuffManager}
|
||||
* @see HandCuffManager
|
||||
*/
|
||||
public static HandCuffManager getHandCuffManager() {
|
||||
return pl.getHandCuffManager();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,90 +15,90 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class ScoreBoardManager {
|
||||
private JailMain pl;
|
||||
private ScoreboardManager man;
|
||||
private HashMap<UUID, Scoreboard> boards;
|
||||
private OfflinePlayer time;
|
||||
private JailMain pl;
|
||||
private ScoreboardManager man;
|
||||
private HashMap<UUID, Scoreboard> boards;
|
||||
private OfflinePlayer time;
|
||||
|
||||
public ScoreBoardManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.man = plugin.getServer().getScoreboardManager();
|
||||
this.boards = new HashMap<UUID, Scoreboard>();
|
||||
this.time = plugin.getServer().getOfflinePlayer(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTIME.getPath())));
|
||||
public ScoreBoardManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.man = plugin.getServer().getScoreboardManager();
|
||||
this.boards = new HashMap<UUID, Scoreboard>();
|
||||
this.time = plugin.getServer().getOfflinePlayer(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTIME.getPath())));
|
||||
|
||||
//Start the task if it is enabled
|
||||
if(plugin.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
updatePrisonersTime();
|
||||
}
|
||||
}, 200L, 100L);
|
||||
}
|
||||
}
|
||||
//Start the task if it is enabled
|
||||
if(plugin.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
updatePrisonersTime();
|
||||
}
|
||||
}, 200L, 100L);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the jailing score board to the player if they don't have one, otherwise it just updates it.
|
||||
*
|
||||
* @param player of whom to add the scoreboard to.
|
||||
* @param pris data for the provided prisoner
|
||||
*/
|
||||
public void addScoreBoard(Player player, Prisoner pris) {
|
||||
if(!boards.containsKey(player.getUniqueId())) {
|
||||
boards.put(player.getUniqueId(), man.getNewScoreboard());
|
||||
Objective o = boards.get(player.getUniqueId()).registerNewObjective("test", "dummy");
|
||||
o.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
|
||||
o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||
player.setScoreboard(boards.get(player.getUniqueId()));
|
||||
}else {
|
||||
updatePrisonersBoard(player, pris);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Adds the jailing score board to the player if they don't have one, otherwise it just updates it.
|
||||
*
|
||||
* @param player of whom to add the scoreboard to.
|
||||
* @param pris data for the provided prisoner
|
||||
*/
|
||||
public void addScoreBoard(Player player, Prisoner pris) {
|
||||
if(!boards.containsKey(player.getUniqueId())) {
|
||||
boards.put(player.getUniqueId(), man.getNewScoreboard());
|
||||
Objective o = boards.get(player.getUniqueId()).registerNewObjective("test", "dummy");
|
||||
o.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath())));
|
||||
o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||
player.setScoreboard(boards.get(player.getUniqueId()));
|
||||
}else {
|
||||
updatePrisonersBoard(player, pris);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a player's jail scoreboard for their jail time and sets it to the main one.
|
||||
*
|
||||
* @param player of whom to remove the scoreboard for.
|
||||
*/
|
||||
public void removeScoreBoard(Player player) {
|
||||
boards.remove(player.getUniqueId());
|
||||
//TODO: See if this works or if we need to set it to a new one
|
||||
player.setScoreboard(man.getMainScoreboard());
|
||||
}
|
||||
/**
|
||||
* Removes a player's jail scoreboard for their jail time and sets it to the main one.
|
||||
*
|
||||
* @param player of whom to remove the scoreboard for.
|
||||
*/
|
||||
public void removeScoreBoard(Player player) {
|
||||
boards.remove(player.getUniqueId());
|
||||
//TODO: See if this works or if we need to set it to a new one
|
||||
player.setScoreboard(man.getMainScoreboard());
|
||||
}
|
||||
|
||||
/** Removes all of the scoreboards from the prisoners. */
|
||||
public void removeAllScoreboards() {
|
||||
HashMap<UUID, Scoreboard> temp = new HashMap<UUID, Scoreboard>(boards);
|
||||
/** Removes all of the scoreboards from the prisoners. */
|
||||
public void removeAllScoreboards() {
|
||||
HashMap<UUID, Scoreboard> temp = new HashMap<UUID, Scoreboard>(boards);
|
||||
|
||||
for(UUID id : temp.keySet()) {
|
||||
Player p = pl.getServer().getPlayer(id);
|
||||
for(UUID id : temp.keySet()) {
|
||||
Player p = pl.getServer().getPlayer(id);
|
||||
|
||||
if(p != null) {
|
||||
p.setScoreboard(man.getMainScoreboard());
|
||||
}
|
||||
if(p != null) {
|
||||
p.setScoreboard(man.getMainScoreboard());
|
||||
}
|
||||
|
||||
boards.remove(id);
|
||||
}
|
||||
}
|
||||
boards.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
/** Updates the prisoners time on their scoreboard. */
|
||||
private void updatePrisonersTime() {
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
if(pl.getServer().getPlayer(p.getUUID()) != null) {
|
||||
addScoreBoard(pl.getServer().getPlayer(p.getUUID()), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** Updates the prisoners time on their scoreboard. */
|
||||
private void updatePrisonersTime() {
|
||||
for(Jail j : pl.getJailManager().getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners().values()) {
|
||||
if(pl.getServer().getPlayer(p.getUUID()) != null) {
|
||||
addScoreBoard(pl.getServer().getPlayer(p.getUUID()), p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a player's time in the scoreboard.
|
||||
*
|
||||
* @param player of whom to update the scoreboard for.
|
||||
* @param pris data for the player
|
||||
*/
|
||||
private void updatePrisonersBoard(Player player, Prisoner pris) {
|
||||
boards.get(player.getUniqueId()).getObjective("test").getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||
}
|
||||
/**
|
||||
* Updates a player's time in the scoreboard.
|
||||
*
|
||||
* @param player of whom to update the scoreboard for.
|
||||
* @param pris data for the player
|
||||
*/
|
||||
private void updatePrisonersBoard(Player player, Prisoner pris) {
|
||||
boards.get(player.getUniqueId()).getObjective("test").getScore(time).setScore(pris.getRemainingTimeInMinutesInt());
|
||||
}
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ import org.json.simple.JSONValue;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class Update {
|
||||
private JailMain plugin;
|
||||
private JailMain plugin;
|
||||
|
||||
// The project's unique ID
|
||||
// The project's unique ID
|
||||
private static final int projectID = 31139;
|
||||
|
||||
// Static information for querying the API
|
||||
@ -29,23 +29,23 @@ public class Update {
|
||||
private String fileUrl = "", version = "";
|
||||
|
||||
public Update(JailMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void query() {
|
||||
String channel = plugin.getConfig().getString(Settings.UPDATECHANNEL.getPath(), "bukkit");
|
||||
String channel = plugin.getConfig().getString(Settings.UPDATECHANNEL.getPath(), "bukkit");
|
||||
URL url = null;
|
||||
|
||||
try {
|
||||
if(channel.equalsIgnoreCase("stable-dev")) {
|
||||
url = new URL(CI_STABLEDEV_API_QUERY);
|
||||
}else if(channel.equalsIgnoreCase("dev")) {
|
||||
url = new URL(CI_DEV_API_QUERY);
|
||||
}else {
|
||||
url = new URL(BUKKIT_API_QUERY);
|
||||
}
|
||||
if(channel.equalsIgnoreCase("stable-dev")) {
|
||||
url = new URL(CI_STABLEDEV_API_QUERY);
|
||||
}else if(channel.equalsIgnoreCase("dev")) {
|
||||
url = new URL(CI_DEV_API_QUERY);
|
||||
}else {
|
||||
url = new URL(BUKKIT_API_QUERY);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
plugin.getLogger().warning("The url for checking for an update was malformed, please open a ticket about this.");
|
||||
plugin.getLogger().warning("The url for checking for an update was malformed, please open a ticket about this.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -62,30 +62,30 @@ public class Update {
|
||||
String response = reader.readLine();
|
||||
|
||||
if(channel.equalsIgnoreCase("stable-dev") || channel.equalsIgnoreCase("dev")) {
|
||||
// Parse the object from the response from the CI server
|
||||
JSONObject obj = (JSONObject) JSONValue.parse(response);
|
||||
// Get the latest build number
|
||||
long number = Long.parseLong(obj.get("number").toString());
|
||||
// Get the current running version
|
||||
String[] ver = plugin.getDescription().getVersion().split("-b");
|
||||
// Let them know they're on a custom version when on build #0.
|
||||
if(ver[ver.length - 1].equalsIgnoreCase("0")) {
|
||||
plugin.getLogger().info("You are using a custom version, you can disable update checking.");
|
||||
}
|
||||
// Parse the object from the response from the CI server
|
||||
JSONObject obj = (JSONObject) JSONValue.parse(response);
|
||||
// Get the latest build number
|
||||
long number = Long.parseLong(obj.get("number").toString());
|
||||
// Get the current running version
|
||||
String[] ver = plugin.getDescription().getVersion().split("-b");
|
||||
// Let them know they're on a custom version when on build #0.
|
||||
if(ver[ver.length - 1].equalsIgnoreCase("0")) {
|
||||
plugin.getLogger().info("You are using a custom version, you can disable update checking.");
|
||||
}
|
||||
|
||||
// Parse the current build number to a number
|
||||
long curr = Long.parseLong(ver[ver.length - 1]);
|
||||
plugin.debug(number + " verus " + curr);
|
||||
// Check if the build on the CI server is higher than the one we're running
|
||||
needed = number > curr;
|
||||
// Parse the current build number to a number
|
||||
long curr = Long.parseLong(ver[ver.length - 1]);
|
||||
plugin.debug(number + " verus " + curr);
|
||||
// Check if the build on the CI server is higher than the one we're running
|
||||
needed = number > curr;
|
||||
|
||||
// Alert the console that an update is needed, if it is needed
|
||||
if(needed) {
|
||||
this.version = obj.get("fullDisplayName").toString();
|
||||
this.fileUrl = obj.get("url").toString();
|
||||
plugin.getLogger().info("New development version of Jail is available: " + this.version);
|
||||
plugin.getLogger().info(this.fileUrl);
|
||||
}
|
||||
// Alert the console that an update is needed, if it is needed
|
||||
if(needed) {
|
||||
this.version = obj.get("fullDisplayName").toString();
|
||||
this.fileUrl = obj.get("url").toString();
|
||||
plugin.getLogger().info("New development version of Jail is available: " + this.version);
|
||||
plugin.getLogger().info(this.fileUrl);
|
||||
}
|
||||
}else {
|
||||
// Parse the array of files from the query's response
|
||||
JSONArray array = (JSONArray) JSONValue.parse(response);
|
||||
@ -105,10 +105,10 @@ public class Update {
|
||||
this.needed = this.versionCompare(remoteVer, currentVer) > 0;
|
||||
|
||||
if(needed) {
|
||||
this.version = latest.get("name").toString();
|
||||
this.fileUrl = latest.get("fileUrl").toString();
|
||||
plugin.getLogger().info("New stable version of Jail is available: " + this.version);
|
||||
plugin.getLogger().info(this.fileUrl);
|
||||
this.version = latest.get("name").toString();
|
||||
this.fileUrl = latest.get("fileUrl").toString();
|
||||
plugin.getLogger().info("New stable version of Jail is available: " + this.version);
|
||||
plugin.getLogger().info(this.fileUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,7 +140,7 @@ public class Update {
|
||||
int i = 0;
|
||||
// set index to first non-equal ordinal or length of shortest version string
|
||||
while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
|
||||
i++;
|
||||
i++;
|
||||
}
|
||||
|
||||
// compare first non-equal ordinal number
|
||||
@ -157,16 +157,16 @@ public class Update {
|
||||
|
||||
/** Returns true if there is an update needed, false if not. */
|
||||
public boolean isAvailable() {
|
||||
return this.needed;
|
||||
return this.needed;
|
||||
}
|
||||
|
||||
/** Returns the new version. */
|
||||
public String getNewVersion() {
|
||||
return this.version;
|
||||
return this.version;
|
||||
}
|
||||
|
||||
/** Returns the new file url. */
|
||||
public String getFileUrl() {
|
||||
return this.fileUrl;
|
||||
return this.fileUrl;
|
||||
}
|
||||
}
|
||||
|
@ -32,25 +32,25 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 3.0.0
|
||||
*/
|
||||
public class Util {
|
||||
private final static Pattern DURATION_PATTERN = Pattern.compile("^(\\d+)\\s*(m(?:inute)?s?|h(?:ours?)?|d(?:ays?)?|s(?:econd)?s?)?$", Pattern.CASE_INSENSITIVE);
|
||||
private final static Pattern DURATION_PATTERN = Pattern.compile("^(\\d+)\\s*(m(?:inute)?s?|h(?:ours?)?|d(?:ays?)?|s(?:econd)?s?)?$", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
/**
|
||||
* Checks if the first {@link Vector} is inside this region.
|
||||
*
|
||||
* @param point The point to check
|
||||
* @param first point of the region
|
||||
* @param second second point of the region
|
||||
* @return True if all the coords of the first vector are in the entire region.
|
||||
*/
|
||||
public static boolean isInsideAB(Vector point, Vector first, Vector second) {
|
||||
boolean x = isInside(point.getBlockX(), first.getBlockX(), second.getBlockX());
|
||||
boolean y = isInside(point.getBlockY(), first.getBlockY(), second.getBlockY());
|
||||
boolean z = isInside(point.getBlockZ(), first.getBlockZ(), second.getBlockZ());
|
||||
/**
|
||||
* Checks if the first {@link Vector} is inside this region.
|
||||
*
|
||||
* @param point The point to check
|
||||
* @param first point of the region
|
||||
* @param second second point of the region
|
||||
* @return True if all the coords of the first vector are in the entire region.
|
||||
*/
|
||||
public static boolean isInsideAB(Vector point, Vector first, Vector second) {
|
||||
boolean x = isInside(point.getBlockX(), first.getBlockX(), second.getBlockX());
|
||||
boolean y = isInside(point.getBlockY(), first.getBlockY(), second.getBlockY());
|
||||
boolean z = isInside(point.getBlockZ(), first.getBlockZ(), second.getBlockZ());
|
||||
|
||||
return x && y && z;
|
||||
}
|
||||
return x && y && z;
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checks if two numbers are inside a point, or something.
|
||||
*
|
||||
* <p />
|
||||
@ -84,30 +84,30 @@ public class Util {
|
||||
* @return true if the list contains the provided value, false if it doesn't
|
||||
*/
|
||||
public static boolean isStringInsideList(List<String> list, String value) {
|
||||
for(String s : list)
|
||||
if(s.equalsIgnoreCase(value))
|
||||
return true;
|
||||
for(String s : list)
|
||||
if(s.equalsIgnoreCase(value))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Returns a colorful message from the color codes. */
|
||||
public static String getColorfulMessage(String message) {
|
||||
return message.replaceAll("(?i)&([0-9abcdefklmnor])", "\u00A7$1");
|
||||
}
|
||||
return message.replaceAll("(?i)&([0-9abcdefklmnor])", "\u00A7$1");
|
||||
}
|
||||
|
||||
/** Returns the wand used throughout the different creation steps. */
|
||||
public static ItemStack getWand() {
|
||||
ItemStack wand = new ItemStack(Material.WOOD_SWORD);
|
||||
ItemMeta meta = wand.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.AQUA + "Jail Wand");
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.add(ChatColor.BLUE + "The wand for creating");
|
||||
lore.add(ChatColor.BLUE + "a jail or cell.");
|
||||
meta.setLore(lore);
|
||||
wand.setItemMeta(meta);
|
||||
ItemStack wand = new ItemStack(Material.WOOD_SWORD);
|
||||
ItemMeta meta = wand.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.AQUA + "Jail Wand");
|
||||
LinkedList<String> lore = new LinkedList<String>();
|
||||
lore.add(ChatColor.BLUE + "The wand for creating");
|
||||
lore.add(ChatColor.BLUE + "a jail or cell.");
|
||||
meta.setLore(lore);
|
||||
wand.setItemMeta(meta);
|
||||
|
||||
return wand;
|
||||
return wand;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,7 +120,7 @@ public class Util {
|
||||
* @throws Exception if there are no matches
|
||||
*/
|
||||
public static Long getTime(String time, TimeUnit unit) throws Exception {
|
||||
return unit.convert(getTime(time), TimeUnit.MILLISECONDS);
|
||||
return unit.convert(getTime(time), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,33 +131,33 @@ public class Util {
|
||||
* @throws Exception if there are no matches
|
||||
*/
|
||||
public static Long getTime(String time) throws Exception {
|
||||
if(time.equalsIgnoreCase("-1")) return -1L;
|
||||
if(time.equalsIgnoreCase("-1")) return -1L;
|
||||
|
||||
Long t = 10L;
|
||||
Matcher match = DURATION_PATTERN.matcher(time);
|
||||
Long t = 10L;
|
||||
Matcher match = DURATION_PATTERN.matcher(time);
|
||||
|
||||
if (match.matches()) {
|
||||
String units = match.group(2);
|
||||
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.SECONDS);
|
||||
else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units))
|
||||
if (match.matches()) {
|
||||
String units = match.group(2);
|
||||
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.SECONDS);
|
||||
else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.MINUTES);
|
||||
else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.HOURS);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.HOURS);
|
||||
else if ("days".equals(units) || "day".equals(units) || "d".equals(units))
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.DAYS);
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.valueOf(match.group(1)), TimeUnit.DAYS);
|
||||
else {
|
||||
try {
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
|
||||
}catch(NumberFormatException e) {
|
||||
throw new Exception("Invalid format.");
|
||||
}
|
||||
try {
|
||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
|
||||
}catch(NumberFormatException e) {
|
||||
throw new Exception("Invalid format.");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
throw new Exception("Invalid format.");
|
||||
}
|
||||
}else {
|
||||
throw new Exception("Invalid format.");
|
||||
}
|
||||
|
||||
return t;
|
||||
return t;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,11 +168,11 @@ public class Util {
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
public static String[] playerInventoryToBase64(PlayerInventory playerInventory) throws IllegalStateException {
|
||||
//get the main content part, this doesn't return the armor
|
||||
String content = toBase64(playerInventory);
|
||||
String armor = itemStackArrayToBase64(playerInventory.getArmorContents());
|
||||
//get the main content part, this doesn't return the armor
|
||||
String content = toBase64(playerInventory);
|
||||
String armor = itemStackArrayToBase64(playerInventory.getArmorContents());
|
||||
|
||||
return new String[] { content, armor };
|
||||
return new String[] { content, armor };
|
||||
}
|
||||
|
||||
/**
|
||||
@ -188,7 +188,7 @@ public class Util {
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
public static String itemStackArrayToBase64(ItemStack[] items) throws IllegalStateException {
|
||||
try {
|
||||
try {
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
|
||||
|
||||
@ -259,7 +259,7 @@ public class Util {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Inventory fromBase64(String data) throws IOException {
|
||||
if(data.isEmpty()) return Bukkit.getServer().createInventory(null, 0);
|
||||
if(data.isEmpty()) return Bukkit.getServer().createInventory(null, 0);
|
||||
|
||||
try {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||
@ -290,16 +290,16 @@ public class Util {
|
||||
* @throws IOException
|
||||
*/
|
||||
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
|
||||
if(data.isEmpty()) return new ItemStack[] {};
|
||||
if(data.isEmpty()) return new ItemStack[] {};
|
||||
|
||||
try {
|
||||
try {
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||
BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
|
||||
ItemStack[] items = new ItemStack[dataInput.readInt()];
|
||||
|
||||
// Read the serialized inventory
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
items[i] = (ItemStack) dataInput.readObject();
|
||||
items[i] = (ItemStack) dataInput.readObject();
|
||||
}
|
||||
|
||||
dataInput.close();
|
||||
@ -309,38 +309,38 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static void restoreInventory(Player player, Prisoner prisoner) {
|
||||
try {
|
||||
Inventory content = Util.fromBase64(prisoner.getInventory());
|
||||
ItemStack[] armor = Util.itemStackArrayFromBase64(prisoner.getArmor());
|
||||
public static void restoreInventory(Player player, Prisoner prisoner) {
|
||||
try {
|
||||
Inventory content = Util.fromBase64(prisoner.getInventory());
|
||||
ItemStack[] armor = Util.itemStackArrayFromBase64(prisoner.getArmor());
|
||||
|
||||
for(ItemStack item : armor) {
|
||||
if(item == null)
|
||||
continue;
|
||||
else if(item.getType().toString().toLowerCase().contains("helmet"))
|
||||
player.getInventory().setHelmet(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("chestplate"))
|
||||
player.getInventory().setChestplate(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("leg"))
|
||||
player.getInventory().setLeggings(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("boots"))
|
||||
player.getInventory().setBoots(item);
|
||||
else if (player.getInventory().firstEmpty() == -1)
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
else
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
for(ItemStack item : armor) {
|
||||
if(item == null)
|
||||
continue;
|
||||
else if(item.getType().toString().toLowerCase().contains("helmet"))
|
||||
player.getInventory().setHelmet(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("chestplate"))
|
||||
player.getInventory().setChestplate(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("leg"))
|
||||
player.getInventory().setLeggings(item);
|
||||
else if(item.getType().toString().toLowerCase().contains("boots"))
|
||||
player.getInventory().setBoots(item);
|
||||
else if (player.getInventory().firstEmpty() == -1)
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
else
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
|
||||
for(ItemStack item : content.getContents()) {
|
||||
if(item == null) continue;
|
||||
else if(player.getInventory().firstEmpty() == -1)
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
else
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
||||
}
|
||||
}
|
||||
for(ItemStack item : content.getContents()) {
|
||||
if(item == null) continue;
|
||||
else if(player.getInventory().firstEmpty() == -1)
|
||||
player.getWorld().dropItem(player.getLocation(), item);
|
||||
else
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,21 +8,21 @@ package com.graywolf336.jail.beans;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class CachePrisoner {
|
||||
private Jail jail;
|
||||
private Prisoner p;
|
||||
private Jail jail;
|
||||
private Prisoner p;
|
||||
|
||||
public CachePrisoner(Jail jail, Prisoner prisoner) {
|
||||
this.jail = jail;
|
||||
this.p = prisoner;
|
||||
}
|
||||
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 Jail this cache is in. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the Prisoner in this cache. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.p;
|
||||
}
|
||||
/** Gets the Prisoner in this cache. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.p;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
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>();
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** Gets the prisoner being held in this cell. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
/** Nullifies the prisoner data. */
|
||||
public void removePrisoner() {
|
||||
this.p = null;
|
||||
}
|
||||
/** 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
|
||||
}
|
||||
/** 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 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);
|
||||
}
|
||||
/** 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 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 = "";
|
||||
/** 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();
|
||||
}
|
||||
}
|
||||
for(SimpleLocation s : signs) {
|
||||
if(r.isEmpty()) {
|
||||
r = s.toString();
|
||||
}else {
|
||||
r += ";" + s.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Sets the location of where the prisoner will be teleported at when jailed here. */
|
||||
public void setTeleport(SimpleLocation location) {
|
||||
this.teleport = location;
|
||||
}
|
||||
/** 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();
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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 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;
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
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;
|
||||
}
|
||||
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 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 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 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;
|
||||
}
|
||||
/** Returns the time in milliseconds their confirmation time frame expires. */
|
||||
public Long getExpiryTime() {
|
||||
return this.expires;
|
||||
}
|
||||
}
|
||||
|
@ -14,214 +14,214 @@ import org.bukkit.Location;
|
||||
*
|
||||
*/
|
||||
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;
|
||||
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.
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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 jail. */
|
||||
public String getJailName() {
|
||||
return this.jailName;
|
||||
}
|
||||
|
||||
/** Gets the name of the cell. */
|
||||
public String getCellName() {
|
||||
return this.cellName;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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++;
|
||||
}
|
||||
/**
|
||||
* 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 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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 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;
|
||||
}
|
||||
/** 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 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);
|
||||
}
|
||||
/** 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 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;
|
||||
}
|
||||
/** 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 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);
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** Gets the chest's location. */
|
||||
public Location getChestLocation() {
|
||||
return this.chest;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
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>();
|
||||
}
|
||||
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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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();
|
||||
/** 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();
|
||||
}
|
||||
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;
|
||||
/** 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];
|
||||
}
|
||||
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);
|
||||
}
|
||||
/** 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();
|
||||
/** 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();
|
||||
}
|
||||
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);
|
||||
}
|
||||
/** 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;
|
||||
/** 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];
|
||||
}
|
||||
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;
|
||||
}
|
||||
/** 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 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);
|
||||
}
|
||||
/** 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();
|
||||
/** 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;
|
||||
}
|
||||
this.in = location;
|
||||
}
|
||||
|
||||
/** Gets the {@link Location location} of the teleport in. */
|
||||
public Location getTeleportIn() {
|
||||
return this.in;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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());
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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);
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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();
|
||||
}
|
||||
/** 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, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
//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);
|
||||
}
|
||||
//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;
|
||||
/** 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;
|
||||
}
|
||||
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;
|
||||
/** 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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Gets the amount of cells the jail. */
|
||||
public int getCellCount() {
|
||||
return this.cells.size();
|
||||
}
|
||||
/** 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 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;
|
||||
/** 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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
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();
|
||||
}
|
||||
/** 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>();
|
||||
}
|
||||
//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
|
||||
/** 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());
|
||||
for(Cell c : cells.values())
|
||||
if(c.hasPrisoner())
|
||||
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
|
||||
|
||||
return all;
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
/** Gets a HashSet of the prisoners <b>in cells</b>. */
|
||||
public HashSet<Prisoner> getPrisonersInCells() {
|
||||
HashSet<Prisoner> all = new HashSet<Prisoner>();
|
||||
/** 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());
|
||||
for(Cell c : getCells())
|
||||
if(c.hasPrisoner())
|
||||
all.add(c.getPrisoner());
|
||||
|
||||
return all;
|
||||
}
|
||||
return all;
|
||||
}
|
||||
|
||||
/** Gets a HashSet of the prisoners <b>not</b> in cells.*/
|
||||
public HashMap<UUID, Prisoner> getPrisonersNotInCells() {
|
||||
return this.nocellPrisoners;
|
||||
}
|
||||
/** 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 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 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);
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
/**
|
||||
* 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;
|
||||
for(Cell c : cells.values())
|
||||
if(c.getPrisoner() != null)
|
||||
if(c.getPrisoner().getUUID().equals(uuid))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
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;
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
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);
|
||||
/**
|
||||
* 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();
|
||||
for(Cell c : cells.values())
|
||||
if(c.hasPrisoner())
|
||||
if(c.getPrisoner().getUUID().equals(uuid))
|
||||
return c.getPrisoner();
|
||||
|
||||
return null;
|
||||
}
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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. */
|
||||
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 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();
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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, 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();
|
||||
}
|
||||
/** 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. */
|
||||
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;
|
||||
/** 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]));
|
||||
}
|
||||
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;
|
||||
}
|
||||
/** 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. */
|
||||
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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
/** Sets whether the prisoner was changed or not. */
|
||||
public boolean setChanged(boolean change) {
|
||||
this.changed = change;
|
||||
return this.changed;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
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 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 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 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;
|
||||
}
|
||||
/**
|
||||
* 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 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 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);
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return world + "," + x + "," + y + "," + z + "," + yaw + "," + pitch;
|
||||
}
|
||||
}
|
||||
|
@ -9,52 +9,52 @@ package com.graywolf336.jail.beans;
|
||||
*
|
||||
*/
|
||||
public class Stick {
|
||||
private String jail, reason;
|
||||
private long time;
|
||||
private double 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;
|
||||
}
|
||||
/**
|
||||
* 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 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 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 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;
|
||||
}
|
||||
/** 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;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return time + "," + jail + "," + reason + "," + health;
|
||||
}
|
||||
}
|
||||
|
@ -12,20 +12,20 @@ import com.graywolf336.jail.JailManager;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public interface Command {
|
||||
/**
|
||||
* Execute the command given the arguments, returning whether the command handled it or not.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* When the method returns false, the usage message is printed to the sender. If the method
|
||||
* handles the command in any way, such as sending a message to the sender or actually doing
|
||||
* something, then it should return true so that the sender of the command doesn't get the
|
||||
* usage message.
|
||||
*
|
||||
* @param jm An instance of the {@link JailManager}
|
||||
* @param sender The {@link CommandSender sender} of the command
|
||||
* @param args The args, in an array
|
||||
* @return True if the method handled it in any way, false if we should send the usage message.
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception;
|
||||
/**
|
||||
* Execute the command given the arguments, returning whether the command handled it or not.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* When the method returns false, the usage message is printed to the sender. If the method
|
||||
* handles the command in any way, such as sending a message to the sender or actually doing
|
||||
* something, then it should return true so that the sender of the command doesn't get the
|
||||
* usage message.
|
||||
*
|
||||
* @param jm An instance of the {@link JailManager}
|
||||
* @param sender The {@link CommandSender sender} of the command
|
||||
* @param args The args, in an array
|
||||
* @return True if the method handled it in any way, false if we should send the usage message.
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception;
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.commands.HandCuffCommand;
|
||||
import com.graywolf336.jail.command.commands.ToggleJailDebugCommand;
|
||||
import com.graywolf336.jail.command.commands.UnHandCuffCommand;
|
||||
import com.graywolf336.jail.command.commands.UnJailForceCommand;
|
||||
import com.graywolf336.jail.command.commands.UnJailCommand;
|
||||
import com.graywolf336.jail.command.commands.UnJailForceCommand;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
/**
|
||||
@ -26,148 +26,148 @@ import com.graywolf336.jail.enums.Lang;
|
||||
*
|
||||
*/
|
||||
public class CommandHandler {
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
|
||||
public CommandHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
loadCommands();
|
||||
public CommandHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
loadCommands();
|
||||
|
||||
plugin.debug("Loaded " + commands.size() + " commands.");
|
||||
}
|
||||
plugin.debug("Loaded " + commands.size() + " commands.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If the command is registered or not.</li>
|
||||
* <li>If more than one command matches the command's name and sends the usage for each one.</li>
|
||||
* <li>If they have permission for it, if they don't then we send them a message stating so.</li>
|
||||
* <li>If the command needs a player instance, if so we send a message stating that.</li>
|
||||
* <li>If the required minimum arguments have been passed, if not sends the usage.</li>
|
||||
* <li>If the required maximum arguments have been passed (if there is a max, -1 if no max), if not sends the usage.</li>
|
||||
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param jailmanager The instance of {@link JailManager}.
|
||||
* @param sender The sender of the command.
|
||||
* @param commandLine The name of the command.
|
||||
* @param args The arguments passed to the command.
|
||||
*/
|
||||
public void handleCommand(JailManager jailmanager, CommandSender sender, String commandLine, String[] args) {
|
||||
List<Command> matches = getMatches(commandLine);
|
||||
/**
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If the command is registered or not.</li>
|
||||
* <li>If more than one command matches the command's name and sends the usage for each one.</li>
|
||||
* <li>If they have permission for it, if they don't then we send them a message stating so.</li>
|
||||
* <li>If the command needs a player instance, if so we send a message stating that.</li>
|
||||
* <li>If the required minimum arguments have been passed, if not sends the usage.</li>
|
||||
* <li>If the required maximum arguments have been passed (if there is a max, -1 if no max), if not sends the usage.</li>
|
||||
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param jailmanager The instance of {@link JailManager}.
|
||||
* @param sender The sender of the command.
|
||||
* @param commandLine The name of the command.
|
||||
* @param args The arguments passed to the command.
|
||||
*/
|
||||
public void handleCommand(JailManager jailmanager, CommandSender sender, String commandLine, String[] args) {
|
||||
List<Command> matches = getMatches(commandLine);
|
||||
|
||||
//If no matches were found, send them the unknown command message.
|
||||
if(matches.size() == 0) {
|
||||
if(commandLine.startsWith("jail")) {
|
||||
String j = commandLine.substring(0, 4);
|
||||
String a0 = commandLine.substring(4, commandLine.length());
|
||||
//If no matches were found, send them the unknown command message.
|
||||
if(matches.size() == 0) {
|
||||
if(commandLine.startsWith("jail")) {
|
||||
String j = commandLine.substring(0, 4);
|
||||
String a0 = commandLine.substring(4, commandLine.length());
|
||||
|
||||
ArrayList<String> args2 = new ArrayList<String>();
|
||||
for(String s : args)
|
||||
args2.add(s);
|
||||
args2.add(a0);
|
||||
ArrayList<String> args2 = new ArrayList<String>();
|
||||
for(String s : args)
|
||||
args2.add(s);
|
||||
args2.add(a0);
|
||||
|
||||
if(jailmanager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[args2.size()])))
|
||||
return;
|
||||
}
|
||||
if(jailmanager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[args2.size()])))
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.UNKNOWNCOMMAND.get(commandLine));
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(Lang.UNKNOWNCOMMAND.get(commandLine));
|
||||
return;
|
||||
}
|
||||
|
||||
//If more than one command was found, send them each command's help message.
|
||||
if(matches.size() > 1) {
|
||||
for(Command c : matches)
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
//If more than one command was found, send them each command's help message.
|
||||
if(matches.size() > 1) {
|
||||
for(Command c : matches)
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
|
||||
Command c = matches.get(0);
|
||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
||||
Command c = matches.get(0);
|
||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
||||
|
||||
// First, let's check if the sender has permission for the command.
|
||||
if(!sender.hasPermission(i.permission())) {
|
||||
sender.sendMessage(Lang.NOPERMISSION.get());
|
||||
return;
|
||||
}
|
||||
// First, let's check if the sender has permission for the command.
|
||||
if(!sender.hasPermission(i.permission())) {
|
||||
sender.sendMessage(Lang.NOPERMISSION.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Next, let's check if we need a player and then if the sender is actually a player
|
||||
if(i.needsPlayer() && !(sender instanceof Player)) {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
return;
|
||||
}
|
||||
// Next, let's check if we need a player and then if the sender is actually a player
|
||||
if(i.needsPlayer() && !(sender instanceof Player)) {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
return;
|
||||
}
|
||||
|
||||
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
||||
if(args.length < i.minimumArgs()) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
||||
if(args.length < i.minimumArgs()) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
|
||||
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
||||
if(i.maxArgs() != -1 && i.maxArgs() < args.length) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
||||
if(i.maxArgs() != -1 && i.maxArgs() < args.length) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
|
||||
// Since everything has been checked and we're all clear, let's execute it.
|
||||
// But if get back false, let's show the usage message.
|
||||
try {
|
||||
if(!c.execute(jailmanager, sender, args)) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
||||
showUsage(sender, c);
|
||||
}
|
||||
}
|
||||
// Since everything has been checked and we're all clear, let's execute it.
|
||||
// But if get back false, let's show the usage message.
|
||||
try {
|
||||
if(!c.execute(jailmanager, sender, args)) {
|
||||
showUsage(sender, c);
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
||||
showUsage(sender, c);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
|
||||
for(Entry<String, Command> entry : commands.entrySet()) {
|
||||
if(command.matches(entry.getKey())) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
for(Entry<String, Command> entry : commands.entrySet()) {
|
||||
if(command.matches(entry.getKey())) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the usage information to the sender, if they have permission.
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param command The command to send usage of.
|
||||
*/
|
||||
private void showUsage(CommandSender sender, Command command) {
|
||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||
if(!sender.hasPermission(info.permission())) return;
|
||||
/**
|
||||
* Shows the usage information to the sender, if they have permission.
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param command The command to send usage of.
|
||||
*/
|
||||
private void showUsage(CommandSender sender, Command command) {
|
||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||
if(!sender.hasPermission(info.permission())) return;
|
||||
|
||||
sender.sendMessage(info.usage());
|
||||
}
|
||||
sender.sendMessage(info.usage());
|
||||
}
|
||||
|
||||
/** Loads all the commands into the hashmap. */
|
||||
private void loadCommands() {
|
||||
load(HandCuffCommand.class);
|
||||
load(ToggleJailDebugCommand.class);
|
||||
load(UnHandCuffCommand.class);
|
||||
load(UnJailCommand.class);
|
||||
load(UnJailForceCommand.class);
|
||||
}
|
||||
/** Loads all the commands into the hashmap. */
|
||||
private void loadCommands() {
|
||||
load(HandCuffCommand.class);
|
||||
load(ToggleJailDebugCommand.class);
|
||||
load(UnHandCuffCommand.class);
|
||||
load(UnJailCommand.class);
|
||||
load(UnJailForceCommand.class);
|
||||
}
|
||||
|
||||
private void load(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
if(info == null) return;
|
||||
private void load(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
if(info == null) return;
|
||||
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,45 +31,45 @@ import java.lang.annotation.RetentionPolicy;
|
||||
*/
|
||||
@Retention (RetentionPolicy.RUNTIME)
|
||||
public @interface CommandInfo {
|
||||
/**
|
||||
* Gets the maximum amount of arguments required, -1 if no maximum (ex: Jailing someone with a reason or editing a reason).
|
||||
*
|
||||
* @return The maximum number of arguments required, -1 if no maximum.
|
||||
*/
|
||||
public int maxArgs();
|
||||
/**
|
||||
* Gets the maximum amount of arguments required, -1 if no maximum (ex: Jailing someone with a reason or editing a reason).
|
||||
*
|
||||
* @return The maximum number of arguments required, -1 if no maximum.
|
||||
*/
|
||||
public int maxArgs();
|
||||
|
||||
/**
|
||||
* Gets the minimum amount of arguments required.
|
||||
*
|
||||
* @return The minimum number of arguments required.
|
||||
*/
|
||||
public int minimumArgs();
|
||||
/**
|
||||
* Gets the minimum amount of arguments required.
|
||||
*
|
||||
* @return The minimum number of arguments required.
|
||||
*/
|
||||
public int minimumArgs();
|
||||
|
||||
/**
|
||||
* Whether the command needs a player context or not.
|
||||
*
|
||||
* @return True if requires a player, false if not.
|
||||
*/
|
||||
public boolean needsPlayer();
|
||||
/**
|
||||
* Whether the command needs a player context or not.
|
||||
*
|
||||
* @return True if requires a player, false if not.
|
||||
*/
|
||||
public boolean needsPlayer();
|
||||
|
||||
/**
|
||||
* A regex pattern that allows for alternatives to the command (ex: /jail or /j, /jailstatus or /js).
|
||||
*
|
||||
* @return The regex pattern to match.
|
||||
*/
|
||||
public String pattern();
|
||||
/**
|
||||
* A regex pattern that allows for alternatives to the command (ex: /jail or /j, /jailstatus or /js).
|
||||
*
|
||||
* @return The regex pattern to match.
|
||||
*/
|
||||
public String pattern();
|
||||
|
||||
/**
|
||||
* Gets the permission required to execute this command.
|
||||
*
|
||||
* @return The permission required.
|
||||
*/
|
||||
public String permission();
|
||||
/**
|
||||
* Gets the permission required to execute this command.
|
||||
*
|
||||
* @return The permission required.
|
||||
*/
|
||||
public String permission();
|
||||
|
||||
/**
|
||||
* Gets the usage message for this command.
|
||||
*
|
||||
* @return The usage message.
|
||||
*/
|
||||
public String usage();
|
||||
/**
|
||||
* Gets the usage message for this command.
|
||||
*
|
||||
* @return The usage message.
|
||||
*/
|
||||
public String usage();
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.subcommands.JailCreateCellCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailCheckCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailClearCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailConfirmCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailCreateCellCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailCreateCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailDeleteCellCommand;
|
||||
import com.graywolf336.jail.command.subcommands.JailDeleteCellsCommand;
|
||||
@ -37,176 +37,176 @@ import com.graywolf336.jail.command.subcommands.JailVersionCommand;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
public class JailHandler {
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
private LinkedHashMap<String, Command> commands;
|
||||
|
||||
public JailHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
loadCommands();
|
||||
public JailHandler(JailMain plugin) {
|
||||
commands = new LinkedHashMap<String, Command>();
|
||||
loadCommands();
|
||||
|
||||
plugin.debug("Loaded " + commands.size() + " sub-commands of /jail.");
|
||||
}
|
||||
plugin.debug("Loaded " + commands.size() + " sub-commands of /jail.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If they have permission for it, if they don't then we send them a message stating so.</li>
|
||||
* <li>If the command needs a player instance, if so we send a message stating that.</li>
|
||||
* <li>If the required minimum arguments have been passed, if not sends the usage.</li>
|
||||
* <li>If the required maximum arguments have been passed (if there is a max, -1 if no max), if not sends the usage.</li>
|
||||
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param jailmanager The instance of {@link JailManager}.
|
||||
* @param sender The sender of the command.
|
||||
* @param args The arguments passed to the command.
|
||||
*/
|
||||
public boolean parseCommand(JailManager jailmanager, CommandSender sender, String[] args) {
|
||||
Command c = null;
|
||||
/**
|
||||
* Handles the given command and checks that the command is in valid form.
|
||||
*
|
||||
* <p>
|
||||
*
|
||||
* It checks in the following order:
|
||||
* <ol>
|
||||
* <li>If they have permission for it, if they don't then we send them a message stating so.</li>
|
||||
* <li>If the command needs a player instance, if so we send a message stating that.</li>
|
||||
* <li>If the required minimum arguments have been passed, if not sends the usage.</li>
|
||||
* <li>If the required maximum arguments have been passed (if there is a max, -1 if no max), if not sends the usage.</li>
|
||||
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
||||
* </ol>
|
||||
*
|
||||
* @param jailmanager The instance of {@link JailManager}.
|
||||
* @param sender The sender of the command.
|
||||
* @param args The arguments passed to the command.
|
||||
*/
|
||||
public boolean parseCommand(JailManager jailmanager, CommandSender sender, String[] args) {
|
||||
Command c = null;
|
||||
|
||||
//If they didn't provide any arguments (aka just: /jail) then we will need to send them some help
|
||||
if(args.length == 0) {
|
||||
//TODO: Create the help page(s)
|
||||
c = getMatches("jail").get(0);
|
||||
//If they didn't provide any arguments (aka just: /jail) then we will need to send them some help
|
||||
if(args.length == 0) {
|
||||
//TODO: Create the help page(s)
|
||||
c = getMatches("jail").get(0);
|
||||
|
||||
}else {
|
||||
//Get the matches from the first argument passed
|
||||
List<Command> matches = getMatches(args[0]);
|
||||
}else {
|
||||
//Get the matches from the first argument passed
|
||||
List<Command> matches = getMatches(args[0]);
|
||||
|
||||
if(matches.size() == 0) {
|
||||
//No matches found, thus it is more likely than not they are trying to jail someone
|
||||
c = getMatches("jail").get(0);
|
||||
if(matches.size() == 0) {
|
||||
//No matches found, thus it is more likely than not they are trying to jail someone
|
||||
c = getMatches("jail").get(0);
|
||||
|
||||
} else if(matches.size() > 1) {
|
||||
//If there was found more than one match
|
||||
//then let's send the usage of each match to the sender
|
||||
for(Command cmd : matches)
|
||||
showUsage(sender, cmd);
|
||||
return true;
|
||||
} else if(matches.size() > 1) {
|
||||
//If there was found more than one match
|
||||
//then let's send the usage of each match to the sender
|
||||
for(Command cmd : matches)
|
||||
showUsage(sender, cmd);
|
||||
return true;
|
||||
|
||||
}else {
|
||||
//Only one match was found, so let's continue
|
||||
c = matches.get(0);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//Only one match was found, so let's continue
|
||||
c = matches.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
||||
|
||||
// First, let's check if the sender has permission for the command.
|
||||
if(!i.permission().isEmpty()) {
|
||||
if(!sender.hasPermission(i.permission())) {
|
||||
jailmanager.getPlugin().debug("Sender has no permission.");
|
||||
sender.sendMessage(Lang.NOPERMISSION.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// First, let's check if the sender has permission for the command.
|
||||
if(!i.permission().isEmpty()) {
|
||||
if(!sender.hasPermission(i.permission())) {
|
||||
jailmanager.getPlugin().debug("Sender has no permission.");
|
||||
sender.sendMessage(Lang.NOPERMISSION.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Next, let's check if we need a player and then if the sender is actually a player
|
||||
if(i.needsPlayer() && !(sender instanceof Player)) {
|
||||
jailmanager.getPlugin().debug("Sender is not a player.");
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
return true;
|
||||
}
|
||||
// Next, let's check if we need a player and then if the sender is actually a player
|
||||
if(i.needsPlayer() && !(sender instanceof Player)) {
|
||||
jailmanager.getPlugin().debug("Sender is not a player.");
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||
if(args.length - 1 < i.minimumArgs()) {
|
||||
jailmanager.getPlugin().debug("Sender didn't provide enough arguments.");
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||
if(args.length - 1 < i.minimumArgs()) {
|
||||
jailmanager.getPlugin().debug("Sender didn't provide enough arguments.");
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||
if(i.maxArgs() != -1 && i.maxArgs() < args.length - 1) {
|
||||
jailmanager.getPlugin().debug("Sender provided too many arguments.");
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||
if(i.maxArgs() != -1 && i.maxArgs() < args.length - 1) {
|
||||
jailmanager.getPlugin().debug("Sender provided too many arguments.");
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Since everything has been checked and we're all clear, let's execute it.
|
||||
// But if get back false, let's show the usage message.
|
||||
try {
|
||||
if(!c.execute(jailmanager, sender, args)) {
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(jailmanager.getPlugin().inDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Since everything has been checked and we're all clear, let's execute it.
|
||||
// But if get back false, let's show the usage message.
|
||||
try {
|
||||
if(!c.execute(jailmanager, sender, args)) {
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}else {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if(jailmanager.getPlugin().inDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
||||
showUsage(sender, c);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
private List<Command> getMatches(String command) {
|
||||
List<Command> result = new ArrayList<Command>();
|
||||
|
||||
for(Entry<String, Command> entry : commands.entrySet()) {
|
||||
if(command.matches(entry.getKey())) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
for(Entry<String, Command> entry : commands.entrySet()) {
|
||||
if(command.matches(entry.getKey())) {
|
||||
result.add(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the usage information to the sender, if they have permission.
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param command The command to send usage of.
|
||||
*/
|
||||
private void showUsage(CommandSender sender, Command command) {
|
||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||
if(!sender.hasPermission(info.permission())) return;
|
||||
/**
|
||||
* Shows the usage information to the sender, if they have permission.
|
||||
*
|
||||
* @param sender The sender of the command
|
||||
* @param command The command to send usage of.
|
||||
*/
|
||||
private void showUsage(CommandSender sender, Command command) {
|
||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||
if(!sender.hasPermission(info.permission())) return;
|
||||
|
||||
sender.sendMessage(info.usage());
|
||||
}
|
||||
sender.sendMessage(info.usage());
|
||||
}
|
||||
|
||||
private void loadCommands() {
|
||||
load(JailCreateCellCommand.class);
|
||||
load(JailCheckCommand.class);
|
||||
load(JailClearCommand.class);
|
||||
load(JailCommand.class);
|
||||
load(JailConfirmCommand.class);
|
||||
load(JailCreateCommand.class);
|
||||
load(JailDeleteCellCommand.class);
|
||||
load(JailDeleteCellsCommand.class);
|
||||
load(JailDeleteCommand.class);
|
||||
load(JailListCellsCommand.class);
|
||||
load(JailListCommand.class);
|
||||
load(JailMuteCommand.class);
|
||||
load(JailPayCommand.class);
|
||||
load(JailRecordCommand.class);
|
||||
load(JailReloadCommand.class);
|
||||
load(JailStatusCommand.class);
|
||||
load(JailStickCommand.class);
|
||||
load(JailStopCommand.class);
|
||||
load(JailTeleInCommand.class);
|
||||
load(JailTeleOutCommand.class);
|
||||
load(JailTimeCommand.class);
|
||||
load(JailTransferAllCommand.class);
|
||||
load(JailTransferCommand.class);
|
||||
load(JailVersionCommand.class);
|
||||
}
|
||||
private void loadCommands() {
|
||||
load(JailCreateCellCommand.class);
|
||||
load(JailCheckCommand.class);
|
||||
load(JailClearCommand.class);
|
||||
load(JailCommand.class);
|
||||
load(JailConfirmCommand.class);
|
||||
load(JailCreateCommand.class);
|
||||
load(JailDeleteCellCommand.class);
|
||||
load(JailDeleteCellsCommand.class);
|
||||
load(JailDeleteCommand.class);
|
||||
load(JailListCellsCommand.class);
|
||||
load(JailListCommand.class);
|
||||
load(JailMuteCommand.class);
|
||||
load(JailPayCommand.class);
|
||||
load(JailRecordCommand.class);
|
||||
load(JailReloadCommand.class);
|
||||
load(JailStatusCommand.class);
|
||||
load(JailStickCommand.class);
|
||||
load(JailStopCommand.class);
|
||||
load(JailTeleInCommand.class);
|
||||
load(JailTeleOutCommand.class);
|
||||
load(JailTimeCommand.class);
|
||||
load(JailTransferAllCommand.class);
|
||||
load(JailTransferCommand.class);
|
||||
load(JailVersionCommand.class);
|
||||
}
|
||||
|
||||
private void load(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
if(info == null) return;
|
||||
private void load(Class<? extends Command> c) {
|
||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||
if(info == null) return;
|
||||
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
commands.put(info.pattern(), c.newInstance());
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,33 +9,33 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "handcuff|hc",
|
||||
permission = "jail.command.handcuff",
|
||||
usage = "/handcuff [player]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "handcuff|hc",
|
||||
permission = "jail.command.handcuff",
|
||||
usage = "/handcuff [player]"
|
||||
)
|
||||
public class HandCuffCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
|
||||
|
||||
if(player == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
|
||||
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
||||
sender.sendMessage(Lang.CANTBEHANDCUFFED.get(player.getName()));
|
||||
}else if(jm.isPlayerJailed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.CURRENTLYJAILEDHANDCUFF.get(player.getName()));
|
||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
|
||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
|
||||
player.sendMessage(Lang.UNHANDCUFFED.get());
|
||||
}else {
|
||||
jm.getPlugin().getHandCuffManager().addHandCuffs(player.getUniqueId(), player.getLocation());
|
||||
sender.sendMessage(Lang.HANDCUFFSON.get(player.getName()));
|
||||
player.sendMessage(Lang.HANDCUFFED.get());
|
||||
}
|
||||
if(player == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
|
||||
}else if(player.hasPermission("jail.cantbehandcuffed")) {
|
||||
sender.sendMessage(Lang.CANTBEHANDCUFFED.get(player.getName()));
|
||||
}else if(jm.isPlayerJailed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.CURRENTLYJAILEDHANDCUFF.get(player.getName()));
|
||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
|
||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
|
||||
player.sendMessage(Lang.UNHANDCUFFED.get());
|
||||
}else {
|
||||
jm.getPlugin().getHandCuffManager().addHandCuffs(player.getUniqueId(), player.getLocation());
|
||||
sender.sendMessage(Lang.HANDCUFFSON.get(player.getName()));
|
||||
player.sendMessage(Lang.HANDCUFFED.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8,17 +8,17 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "togglejaildebug|tjd",
|
||||
permission = "jail.command.toggledebug",
|
||||
usage = "/togglejaildebug"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "togglejaildebug|tjd",
|
||||
permission = "jail.command.toggledebug",
|
||||
usage = "/togglejaildebug"
|
||||
)
|
||||
public class ToggleJailDebugCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean debug = jm.getPlugin().setDebugging(!jm.getPlugin().inDebug());
|
||||
sender.sendMessage("Jail debugging is now: " + (debug ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled"));
|
||||
return true;
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean debug = jm.getPlugin().setDebugging(!jm.getPlugin().inDebug());
|
||||
sender.sendMessage("Jail debugging is now: " + (debug ? ChatColor.GREEN + "enabled" : ChatColor.RED + "disabled"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,27 +9,27 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unhandcuff|uhc",
|
||||
permission = "jail.command.handcuff",
|
||||
usage = "/unhandcuff [player]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unhandcuff|uhc",
|
||||
permission = "jail.command.handcuff",
|
||||
usage = "/unhandcuff [player]"
|
||||
)
|
||||
public class UnHandCuffCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||
|
||||
if(player == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
|
||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
|
||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
|
||||
player.sendMessage(Lang.UNHANDCUFFED.get());
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTHANDCUFFED.get(player.getName()));
|
||||
}
|
||||
if(player == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
|
||||
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
|
||||
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
|
||||
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
|
||||
player.sendMessage(Lang.UNHANDCUFFED.get());
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTHANDCUFFED.get(player.getName()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,51 +13,51 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unjail|uj",
|
||||
permission = "jail.command.unjail",
|
||||
usage = "/unjail [player]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unjail|uj",
|
||||
permission = "jail.command.unjail",
|
||||
usage = "/unjail [player]"
|
||||
)
|
||||
public class UnJailCommand implements Command {
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
Jail j = jm.getJailPlayerIsInByLastKnownName(args[0]);
|
||||
Prisoner pris = j.getPrisonerByLastKnownName(args[0]);
|
||||
Player p = jm.getPlugin().getServer().getPlayer(pris.getUUID());
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
Jail j = jm.getJailPlayerIsInByLastKnownName(args[0]);
|
||||
Prisoner pris = j.getPrisonerByLastKnownName(args[0]);
|
||||
Player p = jm.getPlugin().getServer().getPlayer(pris.getUUID());
|
||||
|
||||
//Check if the player is on the server or not
|
||||
if(p == null) {
|
||||
//Check if the player has offline pending and their remaining time is above 0, if so then
|
||||
//forceably unjail them
|
||||
if(pris.isOfflinePending() && pris.getRemainingTime() != 0L) {
|
||||
jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
|
||||
}else {
|
||||
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
||||
pris.setRemainingTime(0L);
|
||||
pris.setOfflinePending(true);
|
||||
sender.sendMessage(Lang.WILLBEUNJAILED.get(args[0]));
|
||||
}
|
||||
}else {
|
||||
//Player is online, so let's try unjailing them
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
//Check if the player is on the server or not
|
||||
if(p == null) {
|
||||
//Check if the player has offline pending and their remaining time is above 0, if so then
|
||||
//forceably unjail them
|
||||
if(pris.isOfflinePending() && pris.getRemainingTime() != 0L) {
|
||||
jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
|
||||
}else {
|
||||
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
||||
pris.setRemainingTime(0L);
|
||||
pris.setOfflinePending(true);
|
||||
sender.sendMessage(Lang.WILLBEUNJAILED.get(args[0]));
|
||||
}
|
||||
}else {
|
||||
//Player is online, so let's try unjailing them
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(pris.getUUID()), p, pris, sender);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
}
|
||||
}else {
|
||||
//The player is not currently jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
|
||||
}
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
}
|
||||
}else {
|
||||
//The player is not currently jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,28 +10,28 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unjailforce|ujf",
|
||||
permission = "jail.command.unjailforce",
|
||||
usage = "/unjailforce [player]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "unjailforce|ujf",
|
||||
permission = "jail.command.unjailforce",
|
||||
usage = "/unjailforce [player]"
|
||||
)
|
||||
public class UnJailForceCommand implements Command {
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]), sender);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[0])) {
|
||||
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]), sender);
|
||||
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
}
|
||||
}else {
|
||||
//The player is not currently jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
|
||||
}
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
|
||||
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
|
||||
}
|
||||
}else {
|
||||
//The player is not currently jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -6,31 +6,31 @@ import com.lexicalscope.jewel.cli.Option;
|
||||
|
||||
public interface Jailing {
|
||||
|
||||
@Option(longName={"player", "pl"}, shortName="p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
@Option(longName={"player", "pl"}, shortName="p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
|
||||
@Option(longName={"time", "length"}, shortName="t", description = "the amount of time")
|
||||
public String getTime();
|
||||
@Option(longName={"time", "length"}, shortName="t", description = "the amount of time")
|
||||
public String getTime();
|
||||
|
||||
@Option(longName={"jail", "prison"}, shortName="j", description = "the jail")
|
||||
public String getJail();
|
||||
@Option(longName={"jail", "prison"}, shortName="j", description = "the jail")
|
||||
public String getJail();
|
||||
|
||||
@Option(longName={"cell"}, shortName="c", description = "the cell")
|
||||
public String getCell();
|
||||
@Option(longName={"cell"}, shortName="c", description = "the cell")
|
||||
public String getCell();
|
||||
|
||||
@Option(longName={"anycell"}, shortName="a", description = "decides whether the plugin will pick any open cell")
|
||||
public boolean getAnyCell();
|
||||
@Option(longName={"anycell"}, shortName="a", description = "decides whether the plugin will pick any open cell")
|
||||
public boolean getAnyCell();
|
||||
|
||||
@Option(longName={"muted", "canttalk"}, shortName="m", description = "whether the prisoner is muted or not")
|
||||
public boolean getMuted();
|
||||
@Option(longName={"muted", "canttalk"}, shortName="m", description = "whether the prisoner is muted or not")
|
||||
public boolean getMuted();
|
||||
|
||||
@Option(longName={"reason"}, shortName="r", description = "the reason this player is being jailed")
|
||||
public List<String> getReason();
|
||||
@Option(longName={"reason"}, shortName="r", description = "the reason this player is being jailed")
|
||||
public List<String> getReason();
|
||||
|
||||
public boolean isTime();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
public boolean isAnyCell();
|
||||
public boolean isMuted();
|
||||
public boolean isReason();
|
||||
public boolean isTime();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
public boolean isAnyCell();
|
||||
public boolean isMuted();
|
||||
public boolean isReason();
|
||||
}
|
||||
|
@ -4,16 +4,16 @@ import com.lexicalscope.jewel.cli.Option;
|
||||
|
||||
public interface Transfer {
|
||||
|
||||
@Option(longName={"player", "pl"}, shortName="p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
@Option(longName={"player", "pl"}, shortName="p", description = "the player's name")
|
||||
public String getPlayer();
|
||||
|
||||
@Option(longName={"jail", "prison"}, shortName="j", description = "the jail")
|
||||
public String getJail();
|
||||
@Option(longName={"jail", "prison"}, shortName="j", description = "the jail")
|
||||
public String getJail();
|
||||
|
||||
@Option(longName={"cell"}, shortName="c", description = "the cell")
|
||||
public String getCell();
|
||||
@Option(longName={"cell"}, shortName="c", description = "the cell")
|
||||
public String getCell();
|
||||
|
||||
public boolean isPlayer();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
public boolean isPlayer();
|
||||
public boolean isJail();
|
||||
public boolean isCell();
|
||||
}
|
||||
|
@ -10,29 +10,29 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "check",
|
||||
permission = "jail.command.jailcheck",
|
||||
usage = "/jail check [name]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "check",
|
||||
permission = "jail.command.jailcheck",
|
||||
usage = "/jail check [name]"
|
||||
)
|
||||
public class JailCheckCommand implements Command{
|
||||
|
||||
// Checks the status of the specified prisoner
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Otherwise let's check the first argument
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[1]);
|
||||
// Checks the status of the specified prisoner
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Otherwise let's check the first argument
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[1]);
|
||||
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//prisoner: reason; jailer (time in minutes)
|
||||
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
||||
}
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//prisoner: reason; jailer (time in minutes)
|
||||
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,32 +10,32 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "clear|clearforce",
|
||||
permission = "jail.command.jailclear",
|
||||
usage = "/jail clear (-f) (jail)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "clear|clearforce",
|
||||
permission = "jail.command.jailclear",
|
||||
usage = "/jail clear (-f) (jail)"
|
||||
)
|
||||
public class JailClearCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean force = false;
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean force = false;
|
||||
|
||||
//Check if we need to forcefully clear something
|
||||
for(String s : args)
|
||||
if(s.equalsIgnoreCase("-f") || s.equalsIgnoreCase("-force"))
|
||||
force = true;
|
||||
//Check if we need to forcefully clear something
|
||||
for(String s : args)
|
||||
if(s.equalsIgnoreCase("-f") || s.equalsIgnoreCase("-force"))
|
||||
force = true;
|
||||
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else if(force && sender.hasPermission("jail.command.jailclearforce")) {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else if(force && sender.hasPermission("jail.command.jailclearforce")) {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEAR));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEAR));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -23,213 +23,213 @@ import com.lexicalscope.jewel.cli.ArgumentValidationException;
|
||||
import com.lexicalscope.jewel.cli.CliFactory;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = -1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jail|j",
|
||||
permission = "jail.command.jail",
|
||||
usage = "/jail [name] (-t time) (-j JailName) (-c CellName) (-a AnyCell) (-m Muted) (-r A reason for jailing)"
|
||||
)
|
||||
maxArgs = -1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jail|j",
|
||||
permission = "jail.command.jail",
|
||||
usage = "/jail [name] (-t time) (-j JailName) (-c CellName) (-a AnyCell) (-m Muted) (-r A reason for jailing)"
|
||||
)
|
||||
public class JailCommand implements Command {
|
||||
|
||||
/*
|
||||
* Executes the command. Checks the following:
|
||||
*
|
||||
* - If there are any jails.
|
||||
* - If the command can be parsed correctly.
|
||||
* - If the player is already jailed.
|
||||
* - If the given time can be parsed correctly, defaults to what is defined in the config
|
||||
* - If the jail is reasonable or not, else sets the one from the config
|
||||
* - If the cell is not empty then checks to be sure that cell exists
|
||||
* - If the prisoner is online or not.
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
/*
|
||||
* Executes the command. Checks the following:
|
||||
*
|
||||
* - If there are any jails.
|
||||
* - If the command can be parsed correctly.
|
||||
* - If the player is already jailed.
|
||||
* - If the given time can be parsed correctly, defaults to what is defined in the config
|
||||
* - If the jail is reasonable or not, else sets the one from the config
|
||||
* - If the cell is not empty then checks to be sure that cell exists
|
||||
* - If the prisoner is online or not.
|
||||
*/
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
//This is just to add the -p param so CliFactory doesn't blow up
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
//Only add the "-p" if it doesn't already contain it, this way people can do `/jail -p check` in the event someone
|
||||
//has a name which is one of our subcommands
|
||||
if(!arguments.contains("-p")) arguments.add(0, "-p");
|
||||
//This is just to add the -p param so CliFactory doesn't blow up
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
//Only add the "-p" if it doesn't already contain it, this way people can do `/jail -p check` in the event someone
|
||||
//has a name which is one of our subcommands
|
||||
if(!arguments.contains("-p")) arguments.add(0, "-p");
|
||||
|
||||
Jailing params = null;
|
||||
Jailing params = null;
|
||||
|
||||
try {
|
||||
params = CliFactory.parseArguments(Jailing.class, arguments.toArray(new String[arguments.size()]));
|
||||
}catch(ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
params = CliFactory.parseArguments(Jailing.class, arguments.toArray(new String[arguments.size()]));
|
||||
}catch(ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check if they've actually given us a player to jail
|
||||
if(params.getPlayer() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.JAILING));
|
||||
return true;
|
||||
}else {
|
||||
jm.getPlugin().debug("We are getting ready to handle jailing: " + params.getPlayer());
|
||||
}
|
||||
//Check if they've actually given us a player to jail
|
||||
if(params.getPlayer() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.JAILING));
|
||||
return true;
|
||||
}else {
|
||||
jm.getPlugin().debug("We are getting ready to handle jailing: " + params.getPlayer());
|
||||
}
|
||||
|
||||
//Check if the given player is already jailed or not
|
||||
if(jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(Lang.ALREADYJAILED.get(params.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
//Check if the given player is already jailed or not
|
||||
if(jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(Lang.ALREADYJAILED.get(params.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
|
||||
//Try to parse the time, if they give us nothing in the time parameter then we get the default time
|
||||
//from the config and if that isn't there then we default to thirty minutes.
|
||||
Long time = 10L;
|
||||
try {
|
||||
if(!params.isTime()) {
|
||||
time = Util.getTime(jm.getPlugin().getConfig().getString(Settings.DEFAULTTIME.getPath(), "30m"));
|
||||
}else if(params.getTime() == String.valueOf(-1)) {
|
||||
time = -1L;
|
||||
}else {
|
||||
time = Util.getTime(params.getTime());
|
||||
}
|
||||
}catch(Exception e) {
|
||||
sender.sendMessage(Lang.NUMBERFORMATINCORRECT.get());
|
||||
return true;
|
||||
}
|
||||
//Try to parse the time, if they give us nothing in the time parameter then we get the default time
|
||||
//from the config and if that isn't there then we default to thirty minutes.
|
||||
Long time = 10L;
|
||||
try {
|
||||
if(!params.isTime()) {
|
||||
time = Util.getTime(jm.getPlugin().getConfig().getString(Settings.DEFAULTTIME.getPath(), "30m"));
|
||||
}else if(params.getTime() == String.valueOf(-1)) {
|
||||
time = -1L;
|
||||
}else {
|
||||
time = Util.getTime(params.getTime());
|
||||
}
|
||||
}catch(Exception e) {
|
||||
sender.sendMessage(Lang.NUMBERFORMATINCORRECT.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Check the jail params. If it is empty, let's get the default jail
|
||||
//from the config. If that is nearest, let's make a call to getting the nearest jail to
|
||||
//the sender but otherwise if it isn't nearest then let's set it to the default jail
|
||||
//which is defined in the config.
|
||||
String jailName = "";
|
||||
if(!params.isJail()) {
|
||||
String dJail = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath());
|
||||
//Check the jail params. If it is empty, let's get the default jail
|
||||
//from the config. If that is nearest, let's make a call to getting the nearest jail to
|
||||
//the sender but otherwise if it isn't nearest then let's set it to the default jail
|
||||
//which is defined in the config.
|
||||
String jailName = "";
|
||||
if(!params.isJail()) {
|
||||
String dJail = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath());
|
||||
|
||||
if(dJail.equalsIgnoreCase("nearest")) {
|
||||
jailName = jm.getNearestJail(sender).getName();
|
||||
}else {
|
||||
jailName = dJail;
|
||||
}
|
||||
}else if(!jm.isValidJail(params.getJail())) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
|
||||
return true;
|
||||
}else {
|
||||
jailName = params.getJail();
|
||||
}
|
||||
if(dJail.equalsIgnoreCase("nearest")) {
|
||||
jailName = jm.getNearestJail(sender).getName();
|
||||
}else {
|
||||
jailName = dJail;
|
||||
}
|
||||
}else if(!jm.isValidJail(params.getJail())) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
|
||||
return true;
|
||||
}else {
|
||||
jailName = params.getJail();
|
||||
}
|
||||
|
||||
//Get the jail instance from the name of jail in the params.
|
||||
//Get the jail instance from the name of jail in the params.
|
||||
Jail j = jm.getJail(jailName);
|
||||
if(!j.isEnabled()) {
|
||||
sender.sendMessage(Lang.WORLDUNLOADED.get(j.getName()));
|
||||
return true;
|
||||
}
|
||||
|
||||
Cell c = null;
|
||||
//Check if the cell is defined
|
||||
if(params.isCell()) {
|
||||
//Check if it is a valid cell
|
||||
if(!jm.getJail(jailName).isValidCell(params.getCell())) {
|
||||
//There is no cell by that name
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), jailName }));
|
||||
return true;
|
||||
}else if(jm.getJail(jailName).getCell(params.getCell()).hasPrisoner()) {
|
||||
//If the cell has a prisoner, don't allow jailing them to that particular cell but suggest another one
|
||||
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
|
||||
Cell suggestedCell = jm.getJail(jailName).getFirstEmptyCell();
|
||||
if(suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { jailName, suggestedCell.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
|
||||
}
|
||||
Cell c = null;
|
||||
//Check if the cell is defined
|
||||
if(params.isCell()) {
|
||||
//Check if it is a valid cell
|
||||
if(!jm.getJail(jailName).isValidCell(params.getCell())) {
|
||||
//There is no cell by that name
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), jailName }));
|
||||
return true;
|
||||
}else if(jm.getJail(jailName).getCell(params.getCell()).hasPrisoner()) {
|
||||
//If the cell has a prisoner, don't allow jailing them to that particular cell but suggest another one
|
||||
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
|
||||
Cell suggestedCell = jm.getJail(jailName).getFirstEmptyCell();
|
||||
if(suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { jailName, suggestedCell.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
|
||||
}
|
||||
|
||||
return true;
|
||||
}else {
|
||||
c = jm.getJail(jailName).getCell(params.getCell());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else {
|
||||
c = jm.getJail(jailName).getCell(params.getCell());
|
||||
}
|
||||
}
|
||||
|
||||
//If they want just any open cell, then let's find the first empty one
|
||||
if(params.isAnyCell()) {
|
||||
c = jm.getJail(jailName).getFirstEmptyCell();
|
||||
if(c == null) {
|
||||
//If there wasn't an empty cell, then tell them so.
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//If they want just any open cell, then let's find the first empty one
|
||||
if(params.isAnyCell()) {
|
||||
c = jm.getJail(jailName).getFirstEmptyCell();
|
||||
if(c == null) {
|
||||
//If there wasn't an empty cell, then tell them so.
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(jailName));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//If the jailer gave no reason, then let's get the default reason
|
||||
String reason = "";
|
||||
if(!params.isReason()) {
|
||||
reason = Lang.DEFAULTJAILEDREASON.get();
|
||||
}else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(String s : params.getReason()) {
|
||||
sb.append(s).append(' ');
|
||||
}
|
||||
//If the jailer gave no reason, then let's get the default reason
|
||||
String reason = "";
|
||||
if(!params.isReason()) {
|
||||
reason = Lang.DEFAULTJAILEDREASON.get();
|
||||
}else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(String s : params.getReason()) {
|
||||
sb.append(s).append(' ');
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
reason = sb.toString();
|
||||
}
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
reason = sb.toString();
|
||||
}
|
||||
|
||||
//If the config has automatic muting, then let's set them as muted
|
||||
boolean muted = params.getMuted();
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath())) {
|
||||
muted = true;
|
||||
}
|
||||
//If the config has automatic muting, then let's set them as muted
|
||||
boolean muted = params.getMuted();
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath())) {
|
||||
muted = true;
|
||||
}
|
||||
|
||||
Player p = jm.getPlugin().getServer().getPlayer(params.getPlayer());
|
||||
Player p = jm.getPlugin().getServer().getPlayer(params.getPlayer());
|
||||
|
||||
//If the player instance is not null and the player has the permission
|
||||
//'jail.cantbejailed' then don't allow this to happen
|
||||
if(p != null && p.hasPermission("jail.cantbejailed")) {
|
||||
sender.sendMessage(Lang.CANTBEJAILED.get());
|
||||
return true;
|
||||
}
|
||||
//If the player instance is not null and the player has the permission
|
||||
//'jail.cantbejailed' then don't allow this to happen
|
||||
if(p != null && p.hasPermission("jail.cantbejailed")) {
|
||||
sender.sendMessage(Lang.CANTBEJAILED.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
String uuid = "";
|
||||
if(p == null) {
|
||||
//TODO: Make this whole jail command non-blocking
|
||||
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||
}else {
|
||||
uuid = p.getUniqueId().toString();
|
||||
}
|
||||
String uuid = "";
|
||||
if(p == null) {
|
||||
//TODO: Make this whole jail command non-blocking
|
||||
uuid = jm.getPlugin().getServer().getOfflinePlayer(params.getPlayer()).getUniqueId().toString();
|
||||
}else {
|
||||
uuid = p.getUniqueId().toString();
|
||||
}
|
||||
|
||||
Prisoner pris = new Prisoner(uuid, params.getPlayer(), muted, time, sender.getName(), reason);
|
||||
Prisoner pris = new Prisoner(uuid, params.getPlayer(), muted, time, sender.getName(), reason);
|
||||
|
||||
//call the event
|
||||
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, pris.getJailer());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
//call the event
|
||||
PrePrisonerJailedEvent event = new PrePrisonerJailedEvent(j, c, pris, p, p == null, pris.getJailer());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//check if the event is cancelled
|
||||
if(event.isCancelled()) {
|
||||
if(event.getCancelledMessage().isEmpty())
|
||||
sender.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
||||
else
|
||||
sender.sendMessage(event.getCancelledMessage());
|
||||
//check if the event is cancelled
|
||||
if(event.isCancelled()) {
|
||||
if(event.getCancelledMessage().isEmpty())
|
||||
sender.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
||||
else
|
||||
sender.sendMessage(event.getCancelledMessage());
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//recall data from the event
|
||||
j = event.getJail();
|
||||
c = event.getCell();
|
||||
pris = event.getPrisoner();
|
||||
p = event.getPlayer();
|
||||
//recall data from the event
|
||||
j = event.getJail();
|
||||
c = event.getCell();
|
||||
pris = event.getPrisoner();
|
||||
p = event.getPlayer();
|
||||
|
||||
//Player is not online
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.OFFLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
sender.sendMessage(Lang.ONLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
//Player is not online
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.OFFLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
sender.sendMessage(Lang.ONLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().prepareJail(j, c, p, pris);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().prepareJail(j, c, p, pris);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8,84 +8,84 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "confirm|con",
|
||||
permission = "",
|
||||
usage = "/jail confirm"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "confirm|con",
|
||||
permission = "",
|
||||
usage = "/jail confirm"
|
||||
)
|
||||
public class JailConfirmCommand implements Command{
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the sender is actually confirming something.
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
if(jm.confirmingHasExpired(sender.getName())) {
|
||||
//Their confirmation time frame has closed
|
||||
sender.sendMessage(Lang.EXPIRED.get());
|
||||
}else {
|
||||
switch(jm.getWhatIsConfirming(sender.getName())) {
|
||||
case CLEAR:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs = jm.getOriginalArgs(sender.getName());
|
||||
//Clear a jail if the args length is two, else send null
|
||||
String msg = jm.clearJailOfPrisoners(cArgs.length == 2 ? cArgs[1] : null);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg);
|
||||
//Remove them from confirming so they can't do it again
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case CLEARFORCE:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs2 = jm.getOriginalArgs(sender.getName());
|
||||
//Forcefully clear a jail if the args length is two, else send null to clear all
|
||||
String msg2 = jm.forcefullyClearJailOrJails(cArgs2.length == 2 ? cArgs2[1] : null);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg2);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELL:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs3 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg3 = jm.deleteJailCell(cArgs3[1], cArgs3[2]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg3);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELLS:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs4 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String[] msgs4 = jm.deleteAllJailCells(cArgs4[1]);
|
||||
//Send the messages we got back
|
||||
for(String s : msgs4) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
//Check if the sender is actually confirming something.
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
if(jm.confirmingHasExpired(sender.getName())) {
|
||||
//Their confirmation time frame has closed
|
||||
sender.sendMessage(Lang.EXPIRED.get());
|
||||
}else {
|
||||
switch(jm.getWhatIsConfirming(sender.getName())) {
|
||||
case CLEAR:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs = jm.getOriginalArgs(sender.getName());
|
||||
//Clear a jail if the args length is two, else send null
|
||||
String msg = jm.clearJailOfPrisoners(cArgs.length == 2 ? cArgs[1] : null);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg);
|
||||
//Remove them from confirming so they can't do it again
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case CLEARFORCE:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs2 = jm.getOriginalArgs(sender.getName());
|
||||
//Forcefully clear a jail if the args length is two, else send null to clear all
|
||||
String msg2 = jm.forcefullyClearJailOrJails(cArgs2.length == 2 ? cArgs2[1] : null);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg2);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELL:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs3 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg3 = jm.deleteJailCell(cArgs3[1], cArgs3[2]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg3);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETECELLS:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs4 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String[] msgs4 = jm.deleteAllJailCells(cArgs4[1]);
|
||||
//Send the messages we got back
|
||||
for(String s : msgs4) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETE:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs5 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg5 = jm.deleteJail(cArgs5[1]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg5);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(Lang.NOTHING.get());
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//They aren't confirming anything right now.
|
||||
sender.sendMessage(Lang.NOTHING.get());
|
||||
}
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
case DELETE:
|
||||
//Copy the original arguments for easy access
|
||||
String[] cArgs5 = jm.getOriginalArgs(sender.getName());
|
||||
//delete a cell from a jail with the given arguments
|
||||
String msg5 = jm.deleteJail(cArgs5[1]);
|
||||
//Send the message we got back
|
||||
sender.sendMessage(msg5);
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(Lang.NOTHING.get());
|
||||
jm.removeConfirming(sender.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//They aren't confirming anything right now.
|
||||
sender.sendMessage(Lang.NOTHING.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,57 +10,57 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "createcell|createcells|cellcreate|cellscreate|cc",
|
||||
permission = "jail.command.jailcreatecells",
|
||||
usage = "/jail createcell [jail] (cellname)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "createcell|createcells|cellcreate|cellscreate|cc",
|
||||
permission = "jail.command.jailcreatecells",
|
||||
usage = "/jail createcell [jail] (cellname)"
|
||||
)
|
||||
public class JailCreateCellCommand implements Command {
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName();
|
||||
String jail = args[1].toLowerCase();
|
||||
String cell = "";
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName();
|
||||
String jail = args[1].toLowerCase();
|
||||
String cell = "";
|
||||
|
||||
//Only get the cell name they provide if they provide it
|
||||
if(args.length >= 3) {
|
||||
cell = args[2];
|
||||
}
|
||||
//Only get the cell name they provide if they provide it
|
||||
if(args.length >= 3) {
|
||||
cell = args[2];
|
||||
}
|
||||
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
//Not creating anything, so let them create some cells.
|
||||
if(jm.isValidJail(jail)) {
|
||||
Jail j = jm.getJail(jail);
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
//Not creating anything, so let them create some cells.
|
||||
if(jm.isValidJail(jail)) {
|
||||
Jail j = jm.getJail(jail);
|
||||
|
||||
//If they didn't provide a cell name, let's provide one ourself.
|
||||
if(cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1);
|
||||
//If they didn't provide a cell name, let's provide one ourself.
|
||||
if(cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1);
|
||||
|
||||
if(j.getCell(cell) == null) {
|
||||
if(jm.addCreatingCell(name, jail, cell)) {
|
||||
jm.getCellCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "There's already a cell with the name '" + cell + "', please pick a new one or remove that cell.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "No such jail found by the name of '" + jail + "'.");
|
||||
}
|
||||
}
|
||||
if(j.getCell(cell) == null) {
|
||||
if(jm.addCreatingCell(name, jail, cell)) {
|
||||
jm.getCellCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "There's already a cell with the name '" + cell + "', please pick a new one or remove that cell.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "No such jail found by the name of '" + jail + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,40 +9,40 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "create",
|
||||
permission = "jail.command.jailcreate",
|
||||
usage = "/jail create [name]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "create",
|
||||
permission = "jail.command.jailcreate",
|
||||
usage = "/jail create [name]"
|
||||
)
|
||||
public class JailCreateCommand implements Command {
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName();
|
||||
String jail = args[1];
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
String name = player.getName();
|
||||
String jail = args[1];
|
||||
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
if(jm.isValidJail(jail)) {
|
||||
player.sendMessage(ChatColor.RED + "Jail by the name of '" + jail + "' already exist!");
|
||||
}else {
|
||||
if(jm.addCreatingJail(name, jail)) {
|
||||
jm.getJailCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Seems like you're already creating a Jail or something went wrong on our side.");
|
||||
}
|
||||
}
|
||||
}
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
if(jm.isValidJail(jail)) {
|
||||
player.sendMessage(ChatColor.RED + "Jail by the name of '" + jail + "' already exist!");
|
||||
}else {
|
||||
if(jm.addCreatingJail(name, jail)) {
|
||||
jm.getJailCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Seems like you're already creating a Jail or something went wrong on our side.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,22 +10,22 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "deletecell|dc",
|
||||
permission = "jail.command.jaildeletecell",
|
||||
usage = "/jail deletecell [jail] [cell]"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "deletecell|dc",
|
||||
permission = "jail.command.jaildeletecell",
|
||||
usage = "/jail deletecell [jail] [cell]"
|
||||
)
|
||||
public class JailDeleteCellCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELL));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELL));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,22 +10,22 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "deletecells|dcs",
|
||||
permission = "jail.command.jaildeletecell",
|
||||
usage = "/jail deletecells [jail]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "deletecells|dcs",
|
||||
permission = "jail.command.jaildeletecell",
|
||||
usage = "/jail deletecells [jail]"
|
||||
)
|
||||
public class JailDeleteCellsCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELLS));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELLS));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,22 +10,22 @@ import com.graywolf336.jail.enums.Confirmation;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "delete|d",
|
||||
permission = "jail.command.jaildelete",
|
||||
usage = "/jail delete [jail]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "delete|d",
|
||||
permission = "jail.command.jaildelete",
|
||||
usage = "/jail delete [jail]"
|
||||
)
|
||||
public class JailDeleteCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETE));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isConfirming(sender.getName())) {
|
||||
sender.sendMessage(Lang.ALREADY.get());
|
||||
}else {
|
||||
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETE));
|
||||
sender.sendMessage(Lang.START.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,44 +11,44 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "listcells|lc",
|
||||
permission = "jail.command.jaillistcell",
|
||||
usage = "/jail listcells [jail]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "listcells|lc",
|
||||
permission = "jail.command.jaillistcell",
|
||||
usage = "/jail listcells [jail]"
|
||||
)
|
||||
public class JailListCellsCommand implements Command {
|
||||
@Override
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
|
||||
@Override
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
|
||||
|
||||
if(!jm.getJails().isEmpty()) {
|
||||
if(jm.getJail(args[1]) != null) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
if(!jm.getJails().isEmpty()) {
|
||||
if(jm.getJail(args[1]) != null) {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
String message = "";
|
||||
for(Cell c : j.getCells()) {
|
||||
if(message.isEmpty()) {
|
||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||
}else {
|
||||
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||
}
|
||||
}
|
||||
String message = "";
|
||||
for(Cell c : j.getCells()) {
|
||||
if(message.isEmpty()) {
|
||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||
}else {
|
||||
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if(message.isEmpty()) {
|
||||
sender.sendMessage(Lang.NOCELLS.get(j.getName()));
|
||||
}else {
|
||||
sender.sendMessage(ChatColor.GREEN + message);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
}
|
||||
if(message.isEmpty()) {
|
||||
sender.sendMessage(Lang.NOCELLS.get(j.getName()));
|
||||
}else {
|
||||
sender.sendMessage(ChatColor.GREEN + message);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-------------------------");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "-------------------------");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -13,52 +13,52 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "list|l",
|
||||
permission = "jail.command.jaillist",
|
||||
usage = "/jail list (jail)"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "list|l",
|
||||
permission = "jail.command.jaillist",
|
||||
usage = "/jail list (jail)"
|
||||
)
|
||||
public class JailListCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "----------" + (args.length == 1 ? "Jails" : "Prisoners") + "----------");
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "----------" + (args.length == 1 ? "Jails" : "Prisoners") + "----------");
|
||||
|
||||
//Check if there are any jails
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(" " + Lang.NOJAILS.get());
|
||||
}else {
|
||||
//Check if they have provided a jail to list or not
|
||||
if(args.length == 1) {
|
||||
//No jail provided, so give them a list of the jails
|
||||
for(Jail j : jm.getJails()) {
|
||||
if(j.isEnabled()) sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
||||
else sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
||||
}
|
||||
}else {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
//Check if there are any jails
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(" " + Lang.NOJAILS.get());
|
||||
}else {
|
||||
//Check if they have provided a jail to list or not
|
||||
if(args.length == 1) {
|
||||
//No jail provided, so give them a list of the jails
|
||||
for(Jail j : jm.getJails()) {
|
||||
if(j.isEnabled()) sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
||||
else sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
||||
}
|
||||
}else {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
if(j == null) {
|
||||
//No jail was found
|
||||
sender.sendMessage(" " + Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
Collection<Prisoner> pris = j.getAllPrisoners().values();
|
||||
if(j == null) {
|
||||
//No jail was found
|
||||
sender.sendMessage(" " + Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
Collection<Prisoner> pris = j.getAllPrisoners().values();
|
||||
|
||||
if(pris.isEmpty()) {
|
||||
//If there are no prisoners, then send that message
|
||||
sender.sendMessage(" " + Lang.NOPRISONERS.get(j.getName()));
|
||||
}else {
|
||||
for(Prisoner p : pris) {
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//prisoner: reason; jailer (time in minutes)
|
||||
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pris.isEmpty()) {
|
||||
//If there are no prisoners, then send that message
|
||||
sender.sendMessage(" " + Lang.NOPRISONERS.get(j.getName()));
|
||||
}else {
|
||||
for(Prisoner p : pris) {
|
||||
//graywolf663: Being gray's evil twin; CONSOLE (10)
|
||||
//prisoner: reason; jailer (time in minutes)
|
||||
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-------------------------");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "-------------------------");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8,31 +8,31 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "mute|m",
|
||||
permission = "jail.command.jailmute",
|
||||
usage = "/jail mute [name]"
|
||||
)
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "mute|m",
|
||||
permission = "jail.command.jailmute",
|
||||
usage = "/jail mute [name]"
|
||||
)
|
||||
public class JailMuteCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//Let's check if the player they're sending us is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
//They are, so let's toggle whether they are muted or not
|
||||
boolean muted = !jm.getPrisonerByLastKnownName(args[1]).isMuted();
|
||||
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
//Let's check if the player they're sending us is jailed
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[1])) {
|
||||
//They are, so let's toggle whether they are muted or not
|
||||
boolean muted = !jm.getPrisonerByLastKnownName(args[1]).isMuted();
|
||||
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
||||
|
||||
//Send the message to the sender based upon whether they are muted or unmuted
|
||||
if(muted)
|
||||
sender.sendMessage(Lang.NOWMUTED.get(args[1]));
|
||||
else
|
||||
sender.sendMessage(Lang.NOWUNMUTED.get(args[1]));
|
||||
}else {
|
||||
//The player provided is not jailed, so let's tell the sender that
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
||||
}
|
||||
//Send the message to the sender based upon whether they are muted or unmuted
|
||||
if(muted)
|
||||
sender.sendMessage(Lang.NOWMUTED.get(args[1]));
|
||||
else
|
||||
sender.sendMessage(Lang.NOWUNMUTED.get(args[1]));
|
||||
}else {
|
||||
//The player provided is not jailed, so let's tell the sender that
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -15,195 +15,195 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "pay",
|
||||
permission = "jail.usercmd.jailpay",
|
||||
usage = "/jail pay (amount) (name)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "pay",
|
||||
permission = "jail.usercmd.jailpay",
|
||||
usage = "/jail pay (amount) (name)"
|
||||
)
|
||||
public class JailPayCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
JailPayManager pm = jm.getPlugin().getJailPayManager();
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||
JailPayManager pm = jm.getPlugin().getJailPayManager();
|
||||
|
||||
switch(args.length) {
|
||||
case 1:
|
||||
// `/jail pay`
|
||||
//send how much it costs to get out
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
String amt = "";
|
||||
switch(args.length) {
|
||||
case 1:
|
||||
// `/jail pay`
|
||||
//send how much it costs to get out
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
String amt = "";
|
||||
|
||||
if(pm.usingItemsForPayment()) {
|
||||
amt = String.valueOf((int) Math.ceil(pm.calculateBill(p)));
|
||||
}else {
|
||||
amt = String.valueOf(pm.calculateBill(p));
|
||||
}
|
||||
if(pm.usingItemsForPayment()) {
|
||||
amt = String.valueOf((int) Math.ceil(pm.calculateBill(p)));
|
||||
}else {
|
||||
amt = String.valueOf(pm.calculateBill(p));
|
||||
}
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'timed' paying is not enabled (config has 0 as the cost).");
|
||||
}
|
||||
}else {
|
||||
if(pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { amt, pm.getCurrencyName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'infinite' paying is not enabled (config has 0 as the cost).");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'timed' paying is not enabled (config has 0 as the cost).");
|
||||
}
|
||||
}else {
|
||||
if(pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYCOST.get(new String[] { amt, pm.getCurrencyName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
jm.getPlugin().debug("Jail pay 'infinite' paying is not enabled (config has 0 as the cost).");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
|
||||
break;
|
||||
case 2:
|
||||
// `/jail pay <amount>`
|
||||
//They are trying to pay for their self
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
break;
|
||||
case 2:
|
||||
// `/jail pay <amount>`
|
||||
//They are trying to pay for their self
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(sender.getName());
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
if(!pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
if(!pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
}else {
|
||||
double amt = 0;
|
||||
if(args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
}else {
|
||||
double amt = 0;
|
||||
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
}catch(NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
}catch(NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
if(pm.hasEnoughToPay((Player) sender, amt)) {
|
||||
double bill = pm.calculateBill(p);
|
||||
if(pm.hasEnoughToPay((Player) sender, amt)) {
|
||||
double bill = pm.calculateBill(p);
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
//timed sentence
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASED.get(String.valueOf(bill)));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIME.get(new String[] { String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
}
|
||||
}else {
|
||||
//infinite jailing
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASED.get(String.valueOf(bill)));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
//You haven't provided enough money to get them out
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// `/jail pay <amount> <person>
|
||||
//they are trying to pay for someone else
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
//When they are jailed they can not pay for someone else
|
||||
sender.sendMessage(Lang.PAYCANTPAYWHILEJAILED.get());
|
||||
}else {
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
if(p.getRemainingTime() > 0) {
|
||||
//timed sentence
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASED.get(String.valueOf(bill)));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIME.get(new String[] { String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
}
|
||||
}else {
|
||||
//infinite jailing
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASED.get(String.valueOf(bill)));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
//You haven't provided enough money to get them out
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// `/jail pay <amount> <person>
|
||||
//they are trying to pay for someone else
|
||||
if(jm.isPlayerJailedByLastKnownUsername(sender.getName())) {
|
||||
//When they are jailed they can not pay for someone else
|
||||
sender.sendMessage(Lang.PAYCANTPAYWHILEJAILED.get());
|
||||
}else {
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
if(!pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(p.getRemainingTime() > 0) {
|
||||
if(!pm.isTimedEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}else {
|
||||
if(!pm.isInfiniteEnabled()) {
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if(args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
}else {
|
||||
double amt = 0;
|
||||
if(args[1].startsWith("-")) {
|
||||
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
|
||||
}else {
|
||||
double amt = 0;
|
||||
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
}catch(NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
|
||||
throw e;
|
||||
}
|
||||
try {
|
||||
amt = Double.parseDouble(args[1]);
|
||||
}catch(NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "<amount> must be a number.");
|
||||
throw e;
|
||||
}
|
||||
|
||||
|
||||
if(pm.hasEnoughToPay((Player) sender, amt)) {
|
||||
double bill = pm.calculateBill(p);
|
||||
if(pm.hasEnoughToPay((Player) sender, amt)) {
|
||||
double bill = pm.calculateBill(p);
|
||||
|
||||
if(p.getRemainingTime() > 0) {
|
||||
//timed sentence
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIMEELSE.get(new String[] { String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
}
|
||||
}else {
|
||||
//infinite jailing
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
//You haven't provided enough money to get them out
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//Person they're trying to pay for is not jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
jm.getPlugin().debug("Jail pay not enabled.");
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
}
|
||||
if(p.getRemainingTime() > 0) {
|
||||
//timed sentence
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
long minutes = pm.getMinutesPayingFor(amt);
|
||||
pm.pay((Player) sender, amt);
|
||||
long remain = p.subtractTime(TimeUnit.MILLISECONDS.convert(minutes, TimeUnit.MINUTES));
|
||||
sender.sendMessage(Lang.PAYPAIDLOWEREDTIMEELSE.get(new String[] { String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
|
||||
}
|
||||
}else {
|
||||
//infinite jailing
|
||||
if(amt >= bill) {
|
||||
pm.pay((Player) sender, bill);
|
||||
sender.sendMessage(Lang.PAYPAIDRELEASEDELSE.get(new String[] { String.valueOf(bill), p.getLastKnownName() }));
|
||||
jm.getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else {
|
||||
//You haven't provided enough money to get them out
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
//Person they're trying to pay for is not jailed
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
jm.getPlugin().debug("Jail pay not enabled.");
|
||||
sender.sendMessage(Lang.PAYNOTENABLED.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,36 +10,36 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "record|r",
|
||||
permission = "jail.command.jailrecord",
|
||||
usage = "/jail record [name] (display)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "record|r",
|
||||
permission = "jail.command.jailrecord",
|
||||
usage = "/jail record [name] (display)"
|
||||
)
|
||||
public class JailRecordCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if(args.length == 2) {
|
||||
// /jail record <username>
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
if(args.length == 2) {
|
||||
// /jail record <username>
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
}else if(args.length == 3) {
|
||||
// /jail record <username> something
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
}else if(args.length == 3) {
|
||||
// /jail record <username> something
|
||||
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
|
||||
|
||||
//Send all the record entries
|
||||
for(String s : entries) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
//Send all the record entries
|
||||
for(String s : entries) {
|
||||
sender.sendMessage(s);
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
}else {
|
||||
//They didn't do the command right
|
||||
//send them back to get the usage
|
||||
return false;
|
||||
}
|
||||
sender.sendMessage(Lang.RECORDTIMESJAILED.get(new String[] { args[1], String.valueOf(entries.size()) }));
|
||||
}else {
|
||||
//They didn't do the command right
|
||||
//send them back to get the usage
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -9,29 +9,29 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "reload",
|
||||
permission = "jail.command.jailreload",
|
||||
usage = "/jail reload"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "reload",
|
||||
permission = "jail.command.jailreload",
|
||||
usage = "/jail reload"
|
||||
)
|
||||
public class JailReloadCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
try {
|
||||
jm.getPlugin().reloadConfig();
|
||||
jm.getPlugin().getJailIO().loadLanguage();
|
||||
jm.getPlugin().getJailIO().loadJails();
|
||||
jm.getPlugin().reloadScoreBoardManager();
|
||||
jm.getPlugin().reloadJailSticks();
|
||||
jm.getPlugin().reloadJailPayManager();
|
||||
jm.getPlugin().reloadUpdateCheck();
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
try {
|
||||
jm.getPlugin().reloadConfig();
|
||||
jm.getPlugin().getJailIO().loadLanguage();
|
||||
jm.getPlugin().getJailIO().loadJails();
|
||||
jm.getPlugin().reloadScoreBoardManager();
|
||||
jm.getPlugin().reloadJailSticks();
|
||||
jm.getPlugin().reloadJailPayManager();
|
||||
jm.getPlugin().reloadUpdateCheck();
|
||||
|
||||
sender.sendMessage(Lang.PLUGINRELOADED.get());
|
||||
}catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to reload due to: " + e.getMessage());
|
||||
}
|
||||
sender.sendMessage(Lang.PLUGINRELOADED.get());
|
||||
}catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Failed to reload due to: " + e.getMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,28 +10,28 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "status|s",
|
||||
permission = "jail.usercmd.jailstatus",
|
||||
usage = "/jail status"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "status|s",
|
||||
permission = "jail.usercmd.jailstatus",
|
||||
usage = "/jail status"
|
||||
)
|
||||
public class JailStatusCommand implements Command{
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player pl = (Player) sender;
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
Player pl = (Player) sender;
|
||||
|
||||
if(jm.isPlayerJailed(pl.getUniqueId())) {
|
||||
Prisoner p = jm.getPrisoner(pl.getUniqueId());
|
||||
//They are jailed, so let's tell them some information
|
||||
sender.sendMessage(Lang.STATUS.get(new String[] { p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//the sender of the command is not jailed, tell them that
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
if(jm.isPlayerJailed(pl.getUniqueId())) {
|
||||
Prisoner p = jm.getPrisoner(pl.getUniqueId());
|
||||
//They are jailed, so let's tell them some information
|
||||
sender.sendMessage(Lang.STATUS.get(new String[] { p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//the sender of the command is not jailed, tell them that
|
||||
sender.sendMessage(Lang.YOUARENOTJAILED.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,27 +10,27 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "stick",
|
||||
permission = "jail.usercmd.jailstick",
|
||||
usage = "/jail stick"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "stick",
|
||||
permission = "jail.usercmd.jailstick",
|
||||
usage = "/jail stick"
|
||||
)
|
||||
public class JailStickCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(((Player) sender).getUniqueId());
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(((Player) sender).getUniqueId());
|
||||
|
||||
if(using) {
|
||||
sender.sendMessage(Lang.JAILSTICKENABLED.get());
|
||||
}else {
|
||||
sender.sendMessage(Lang.JAILSTICKDISABLED.get());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.JAILSTICKUSAGEDISABLED.get());
|
||||
}
|
||||
if(using) {
|
||||
sender.sendMessage(Lang.JAILSTICKENABLED.get());
|
||||
}else {
|
||||
sender.sendMessage(Lang.JAILSTICKDISABLED.get());
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.JAILSTICKUSAGEDISABLED.get());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -8,33 +8,33 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "stop",
|
||||
permission = "jail.command.jailstop",
|
||||
usage = "/jail stop"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = true,
|
||||
pattern = "stop",
|
||||
permission = "jail.command.jailstop",
|
||||
usage = "/jail stop"
|
||||
)
|
||||
public class JailStopCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean nothing = true;
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
boolean nothing = true;
|
||||
|
||||
if(jm.isCreatingACell(sender.getName())) {
|
||||
jm.removeCellCreationPlayer(sender.getName());
|
||||
sender.sendMessage(ChatColor.RED + "You have stopped creating cells.");
|
||||
nothing = false;
|
||||
}
|
||||
if(jm.isCreatingACell(sender.getName())) {
|
||||
jm.removeCellCreationPlayer(sender.getName());
|
||||
sender.sendMessage(ChatColor.RED + "You have stopped creating cells.");
|
||||
nothing = false;
|
||||
}
|
||||
|
||||
if(jm.isCreatingAJail(sender.getName())) {
|
||||
jm.removeJailCreationPlayer(sender.getName());
|
||||
sender.sendMessage(ChatColor.RED + "You have stopped creating a jail.");
|
||||
nothing = false;
|
||||
}
|
||||
if(jm.isCreatingAJail(sender.getName())) {
|
||||
jm.removeJailCreationPlayer(sender.getName());
|
||||
sender.sendMessage(ChatColor.RED + "You have stopped creating a jail.");
|
||||
nothing = false;
|
||||
}
|
||||
|
||||
if(nothing) {
|
||||
sender.sendMessage(ChatColor.RED + "You've stopped creating....nothing.");
|
||||
}
|
||||
if(nothing) {
|
||||
sender.sendMessage(ChatColor.RED + "You've stopped creating....nothing.");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -10,45 +10,45 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "telein|teleportin",
|
||||
permission = "jail.command.jailtelein",
|
||||
usage = "/jail telein [jail] (name)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "telein|teleportin",
|
||||
permission = "jail.command.jailtelein",
|
||||
usage = "/jail telein [jail] (name)"
|
||||
)
|
||||
public class JailTeleInCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
//The jail doesn't exist
|
||||
if(j == null) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
//The jail does exist
|
||||
//now let's check the size of the command
|
||||
//if it has two args then someone is sending someone else in
|
||||
//otherwise it is just the sender going in
|
||||
if(args.length == 3) {
|
||||
Player p = jm.getPlugin().getServer().getPlayer(args[2]);
|
||||
//The jail doesn't exist
|
||||
if(j == null) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
//The jail does exist
|
||||
//now let's check the size of the command
|
||||
//if it has two args then someone is sending someone else in
|
||||
//otherwise it is just the sender going in
|
||||
if(args.length == 3) {
|
||||
Player p = jm.getPlugin().getServer().getPlayer(args[2]);
|
||||
|
||||
//If the player they're trying to send is offline, don't do anything
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
}else {
|
||||
p.teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { args[2], args[1] }));
|
||||
}
|
||||
}else {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { sender.getName(), args[1] }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
//If the player they're trying to send is offline, don't do anything
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
}else {
|
||||
p.teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { args[2], args[1] }));
|
||||
}
|
||||
}else {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportIn());
|
||||
sender.sendMessage(Lang.TELEIN.get(new String[] { sender.getName(), args[1] }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,45 +10,45 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "teleout|teleportout",
|
||||
permission = "jail.command.jailteleout",
|
||||
usage = "/jail teleout [jail] (name)"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "teleout|teleportout",
|
||||
permission = "jail.command.jailteleout",
|
||||
usage = "/jail teleout [jail] (name)"
|
||||
)
|
||||
public class JailTeleOutCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
Jail j = jm.getJail(args[1]);
|
||||
|
||||
//The jail doesn't exist
|
||||
if(j == null) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
//The jail does exist
|
||||
//now let's check the size of the command
|
||||
//if it has two args then someone is sending someone else in
|
||||
//otherwise it is just the sender going in
|
||||
if(args.length == 3) {
|
||||
Player p = jm.getPlugin().getServer().getPlayer(args[2]);
|
||||
//The jail doesn't exist
|
||||
if(j == null) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
}else {
|
||||
//The jail does exist
|
||||
//now let's check the size of the command
|
||||
//if it has two args then someone is sending someone else in
|
||||
//otherwise it is just the sender going in
|
||||
if(args.length == 3) {
|
||||
Player p = jm.getPlugin().getServer().getPlayer(args[2]);
|
||||
|
||||
//If the player they're trying to send is offline, don't do anything
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
}else {
|
||||
p.teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { args[2], args[1] }));
|
||||
}
|
||||
}else {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { sender.getName(), args[1] }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
//If the player they're trying to send is offline, don't do anything
|
||||
if(p == null) {
|
||||
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
|
||||
}else {
|
||||
p.teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { args[2], args[1] }));
|
||||
}
|
||||
}else {
|
||||
if(sender instanceof Player) {
|
||||
((Player) sender).teleport(j.getTeleportFree());
|
||||
sender.sendMessage(Lang.TELEOUT.get(new String[] { sender.getName(), args[1] }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,44 +10,44 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 3,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "time|t",
|
||||
permission = "jail.command.jailtime",
|
||||
usage = "/jail time [add|remove|show] [name] <time>"
|
||||
)
|
||||
maxArgs = 3,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "time|t",
|
||||
permission = "jail.command.jailtime",
|
||||
usage = "/jail time [add|remove|show] [name] <time>"
|
||||
)
|
||||
public class JailTimeCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.isPlayerJailedByLastKnownUsername(args[2])) {
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(args[2]);
|
||||
|
||||
switch(args.length) {
|
||||
case 3:
|
||||
if(args[1].equalsIgnoreCase("show")) {
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
p.addTime(Util.getTime(args[3]));
|
||||
}else if(args[1].equalsIgnoreCase("remove")) {
|
||||
p.subtractTime(Util.getTime(args[3]));
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
switch(args.length) {
|
||||
case 3:
|
||||
if(args[1].equalsIgnoreCase("show")) {
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
p.addTime(Util.getTime(args[3]));
|
||||
}else if(args[1].equalsIgnoreCase("remove")) {
|
||||
p.subtractTime(Util.getTime(args[3]));
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
|
||||
}
|
||||
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -12,45 +12,45 @@ import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.Lang;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "transferall|transall",
|
||||
permission = "jail.command.jailtransferall",
|
||||
usage = "/jail transferall [current] [target]"
|
||||
)
|
||||
maxArgs = 2,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "transferall|transall",
|
||||
permission = "jail.command.jailtransferall",
|
||||
usage = "/jail transferall [current] [target]"
|
||||
)
|
||||
public class JailTransferAllCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
jm.getPlugin().debug("Starting to transfer everyone from '" + args[1] + "' into '" + args[2] + "'.");
|
||||
jm.getPlugin().debug("Starting to transfer everyone from '" + args[1] + "' into '" + args[2] + "'.");
|
||||
|
||||
//Check if the oldjail is not a valid jail
|
||||
if(!jm.isValidJail(args[1])) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
return true;
|
||||
}else if(!jm.isValidJail(args[2])) {
|
||||
//Check if the targetjail is a valid jail as well
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[2]));
|
||||
return true;
|
||||
}
|
||||
//Check if the oldjail is not a valid jail
|
||||
if(!jm.isValidJail(args[1])) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||
return true;
|
||||
}else if(!jm.isValidJail(args[2])) {
|
||||
//Check if the targetjail is a valid jail as well
|
||||
sender.sendMessage(Lang.NOJAIL.get(args[2]));
|
||||
return true;
|
||||
}
|
||||
|
||||
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]);
|
||||
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners().values());
|
||||
Jail old = jm.getJail(args[1]);
|
||||
HashSet<Prisoner> oldPrisoners = new HashSet<Prisoner>(old.getAllPrisoners().values());
|
||||
|
||||
//Transfer all the prisoners
|
||||
for(Prisoner p : oldPrisoners) {
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(old, old.getCellPrisonerIsIn(p.getUUID()), jm.getJail(args[2]), null, p);
|
||||
}
|
||||
//Transfer all the prisoners
|
||||
for(Prisoner p : oldPrisoners) {
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(old, old.getCellPrisonerIsIn(p.getUUID()), jm.getJail(args[2]), null, p);
|
||||
}
|
||||
|
||||
//Send the messages to the sender when completed
|
||||
sender.sendMessage(Lang.TRANSFERALLCOMPLETE.get(new String[] { old.getName(), args[2] }));
|
||||
//Send the messages to the sender when completed
|
||||
sender.sendMessage(Lang.TRANSFERALLCOMPLETE.get(new String[] { old.getName(), args[2] }));
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,120 +20,120 @@ import com.lexicalscope.jewel.cli.ArgumentValidationException;
|
||||
import com.lexicalscope.jewel.cli.CliFactory;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 6,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "transfer|trans",
|
||||
permission = "jail.command.jailtransfer",
|
||||
usage = "/jail transfer [-p player] (-j jail) (-c cell)"
|
||||
)
|
||||
maxArgs = 6,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "transfer|trans",
|
||||
permission = "jail.command.jailtransfer",
|
||||
usage = "/jail transfer [-p player] (-j jail) (-c cell)"
|
||||
)
|
||||
public class JailTransferCommand implements Command {
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||
if(jm.getJails().isEmpty()) {
|
||||
sender.sendMessage(Lang.NOJAILS.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Convert to a List<String> so we can edit the list
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
//remove the first argument of "transfer"
|
||||
arguments.remove(0);
|
||||
//Convert to a List<String> so we can edit the list
|
||||
List<String> arguments = new LinkedList<String>(Arrays.asList(args));
|
||||
//remove the first argument of "transfer"
|
||||
arguments.remove(0);
|
||||
|
||||
//Parse the command
|
||||
Transfer params = null;
|
||||
//Parse the command
|
||||
Transfer params = null;
|
||||
|
||||
try {
|
||||
params = CliFactory.parseArguments(Transfer.class, arguments.toArray(new String[arguments.size()]));
|
||||
}catch(ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
params = CliFactory.parseArguments(Transfer.class, arguments.toArray(new String[arguments.size()]));
|
||||
}catch(ArgumentValidationException e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
//Verify they gave us a player and if so check if they're jailed
|
||||
if(params.getPlayer() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.TRANSFERRING));
|
||||
return true;
|
||||
}else if(!jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(params.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
//Verify they gave us a player and if so check if they're jailed
|
||||
if(params.getPlayer() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.TRANSFERRING));
|
||||
return true;
|
||||
}else if(!jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
|
||||
sender.sendMessage(Lang.NOTJAILED.get(params.getPlayer()));
|
||||
return true;
|
||||
}
|
||||
|
||||
jm.getPlugin().debug("Checking everything before we transfer: " + params.getPlayer());
|
||||
jm.getPlugin().debug("Checking everything before we transfer: " + params.getPlayer());
|
||||
|
||||
//If they didn't provide a jail, tell them we need one
|
||||
if(params.getJail() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAJAIL.get(Lang.TRANSFERRING));
|
||||
return true;
|
||||
}else {
|
||||
//Check if the jail they did provided is not a valid jail
|
||||
if(!jm.isValidJail(params.getJail())) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//If they didn't provide a jail, tell them we need one
|
||||
if(params.getJail() == null) {
|
||||
sender.sendMessage(Lang.PROVIDEAJAIL.get(Lang.TRANSFERRING));
|
||||
return true;
|
||||
}else {
|
||||
//Check if the jail they did provided is not a valid jail
|
||||
if(!jm.isValidJail(params.getJail())) {
|
||||
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
jm.getPlugin().debug("They provided a valid jail, so let's check the target cell.");
|
||||
jm.getPlugin().debug("They provided a valid jail, so let's check the target cell.");
|
||||
|
||||
Jail target = jm.getJail(params.getJail());
|
||||
Cell targetCell = null;
|
||||
Jail target = jm.getJail(params.getJail());
|
||||
Cell targetCell = null;
|
||||
|
||||
//Check if they provided a cell and if so does it exist
|
||||
if(params.getCell() != null) {
|
||||
if(target.getCell(params.getCell()) == null) {
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), params.getJail() }));
|
||||
return true;
|
||||
}else {
|
||||
//Store the cell for easy of access and also check if it already is full
|
||||
targetCell = target.getCell(params.getCell());
|
||||
if(targetCell.hasPrisoner()) {
|
||||
//If the cell has a prisoner, don't allow jailing them to that particular cell
|
||||
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
|
||||
//Check if they provided a cell and if so does it exist
|
||||
if(params.getCell() != null) {
|
||||
if(target.getCell(params.getCell()) == null) {
|
||||
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), params.getJail() }));
|
||||
return true;
|
||||
}else {
|
||||
//Store the cell for easy of access and also check if it already is full
|
||||
targetCell = target.getCell(params.getCell());
|
||||
if(targetCell.hasPrisoner()) {
|
||||
//If the cell has a prisoner, don't allow jailing them to that particular cell
|
||||
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
|
||||
|
||||
//But suggest the first empty cell we find
|
||||
Cell suggestedCell = jm.getJail(params.getCell()).getFirstEmptyCell();
|
||||
if(suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { params.getCell(), suggestedCell.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(params.getCell()));
|
||||
}
|
||||
//But suggest the first empty cell we find
|
||||
Cell suggestedCell = jm.getJail(params.getCell()).getFirstEmptyCell();
|
||||
if(suggestedCell != null) {
|
||||
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { params.getCell(), suggestedCell.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.NOEMPTYCELLS.get(params.getCell()));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jm.getPlugin().debug("Calling the PrePrisonerTransferredEvent, jail and cell check all came out clean.");
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(params.getPlayer());
|
||||
jm.getPlugin().debug("Calling the PrePrisonerTransferredEvent, jail and cell check all came out clean.");
|
||||
Prisoner p = jm.getPrisonerByLastKnownName(params.getPlayer());
|
||||
|
||||
//Throw the custom event before transferring them, allowing another plugin to cancel it.
|
||||
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p, jm.getPlugin().getServer().getPlayer(p.getUUID()), sender.getName());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
//Throw the custom event before transferring them, allowing another plugin to cancel it.
|
||||
PrePrisonerTransferredEvent event = new PrePrisonerTransferredEvent(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p, jm.getPlugin().getServer().getPlayer(p.getUUID()), sender.getName());
|
||||
jm.getPlugin().getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if(event.isCancelled()) {
|
||||
if(event.getCancelledMessage().isEmpty()) {
|
||||
//The plugin didn't provide a cancel message/reason so send the default one
|
||||
sender.sendMessage(Lang.TRANSFERCANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
||||
}else {
|
||||
sender.sendMessage(event.getCancelledMessage());
|
||||
}
|
||||
if(event.isCancelled()) {
|
||||
if(event.getCancelledMessage().isEmpty()) {
|
||||
//The plugin didn't provide a cancel message/reason so send the default one
|
||||
sender.sendMessage(Lang.TRANSFERCANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
||||
}else {
|
||||
sender.sendMessage(event.getCancelledMessage());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//Start the transferring of the prisoner
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p);
|
||||
//Start the transferring of the prisoner
|
||||
jm.getPlugin().getPrisonerManager().transferPrisoner(jm.getJailPlayerIsIn(p.getUUID()),
|
||||
jm.getJailPlayerIsIn(p.getUUID()).getCellPrisonerIsIn(p.getUUID()),
|
||||
target, targetCell, p);
|
||||
|
||||
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
||||
if(targetCell == null) {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETENOCELL.get(new String[] { params.getPlayer(), target.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETECELL.get(new String[] { params.getPlayer(), target.getName(), targetCell.getName() }));
|
||||
}
|
||||
//Send the messages to the sender, if no cell then say that but if cell send that as well
|
||||
if(targetCell == null) {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETENOCELL.get(new String[] { params.getPlayer(), target.getName() }));
|
||||
}else {
|
||||
sender.sendMessage(Lang.TRANSFERCOMPLETECELL.get(new String[] { params.getPlayer(), target.getName(), targetCell.getName() }));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,20 @@ import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "version|ver|v",
|
||||
permission = "jail.command.jailversion",
|
||||
usage = "/jail version"
|
||||
)
|
||||
maxArgs = 0,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "version|ver|v",
|
||||
permission = "jail.command.jailversion",
|
||||
usage = "/jail version"
|
||||
)
|
||||
public class JailVersionCommand implements Command{
|
||||
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
// Sends the version number to the sender
|
||||
sender.sendMessage("Jail Version: " + jm.getPlugin().getDescription().getVersion());
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
// Sends the version number to the sender
|
||||
sender.sendMessage("Jail Version: " + jm.getPlugin().getDescription().getVersion());
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum Confirmation {
|
||||
/** When they are clearing a jail from all their prisoner's with releasing properly. */
|
||||
CLEAR,
|
||||
/** When they are clearing a jail from all their prisoner's by force. */
|
||||
CLEARFORCE,
|
||||
/** When they are deleting a cell from a jail. */
|
||||
DELETECELL,
|
||||
/** When they are deleting all a jail's cells. */
|
||||
DELETECELLS,
|
||||
/** When they are deleting a jail. */
|
||||
DELETE;
|
||||
/** When they are clearing a jail from all their prisoner's with releasing properly. */
|
||||
CLEAR,
|
||||
/** When they are clearing a jail from all their prisoner's by force. */
|
||||
CLEARFORCE,
|
||||
/** When they are deleting a cell from a jail. */
|
||||
DELETECELL,
|
||||
/** When they are deleting all a jail's cells. */
|
||||
DELETECELLS,
|
||||
/** When they are deleting a jail. */
|
||||
DELETE;
|
||||
}
|
||||
|
@ -1,80 +1,80 @@
|
||||
package com.graywolf336.jail.enums;
|
||||
|
||||
public enum Settings {
|
||||
AUTOMATICMUTE("jailing.jail.automaticMute"),
|
||||
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
||||
BLOCKBREAKPENALTY("jailing.during.blockBreakPenalty"),
|
||||
BLOCKBREAKPROTECTION("jailing.during.blockBreakProtection"),
|
||||
BLOCKBREAKWHITELIST("jailing.during.blockBreakWhiteList"),
|
||||
BLOCKPLACEPENALTY("jailing.during.blockPlacePenalty"),
|
||||
BLOCKPLACEPROTECTION("jailing.during.blockPlaceProtection"),
|
||||
BLOCKPLACEWHITELIST("jailing.during.blockPlaceWhiteList"),
|
||||
CLOTHINGENABLED("jailing.jail.clothing.enabled"),
|
||||
CLOTHINGHELMET("jailing.jail.clothing.helmet"),
|
||||
CLOTHINGCHEST("jailing.jail.clothing.chest"),
|
||||
CLOTHINGLEGS("jailing.jail.clothing.legs"),
|
||||
CLOTHINGBOOTS("jailing.jail.clothing.boots"),
|
||||
COMMANDSONJAIL("jailing.jail.commands"),
|
||||
COMMANDSONRELEASE("jailing.release.commands"),
|
||||
COMMANDPENALTY("jailing.during.commandPenalty"),
|
||||
COMMANDPROTECTION("jailing.during.commandProtection"),
|
||||
COMMANDWHITELIST("jailing.during.commandWhitelist"),
|
||||
CONFIGVERSION("system.version"),
|
||||
COUNTDOWNTIMEOFFLINE("jailing.during.countDownTimeWhileOffline"),
|
||||
CROPTRAMPLINGPENALTY("jailing.during.cropTramplingPenalty"),
|
||||
CROPTRAMPLINGPROTECTION("jailing.during.cropTramplingProtection"),
|
||||
DEBUG("system.debug"),
|
||||
DEFAULTJAIL("jailing.jail.default.jail"),
|
||||
DEFAULTTIME("jailing.jail.default.time"),
|
||||
ENDERMENPROTECTION("jails.endermenProtection"),
|
||||
EXPLOSIONPROTECTION("jails.explosionProtection"),
|
||||
FOODCONTROL("jailing.during.foodControl.enabled"),
|
||||
FOODCONTROLMAX("jailing.during.foodControl.max"),
|
||||
FOODCONTROLMIN("jailing.during.foodControl.min"),
|
||||
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
|
||||
JAILSTICKENABLED("jailstick.enabled"),
|
||||
JAILSTICKSTICKS("jailstick.sticks"),
|
||||
JAILEDGAMEMODE("jailing.jail.gameMode"),
|
||||
JAILEDINVENTORYBLACKLIST("jailing.jail.inventory.blacklist"),
|
||||
JAILEDSTOREINVENTORY("jailing.jail.inventory.store"),
|
||||
JAILPAYENABLED("jailpay.enabled"),
|
||||
JAILPAYITEM("jailpay.item"),
|
||||
JAILPAYPRICEPERMINUTE ("jailpay.pricePerMinute"),
|
||||
JAILPAYPRICEINFINITE ("jailpay.priceInfinite"),
|
||||
LANGUAGE("system.language"),
|
||||
LOGJAILINGTOCONSOLE("jailing.jail.log.console"),
|
||||
LOGJAILINGTOPROFILE("jailing.jail.log.profile"),
|
||||
MAXAFKTIME("jailing.during.maxAFKTime"),
|
||||
MOVEPENALTY("jailing.during.movePenalty"),
|
||||
MOVEPROTECTION("jailing.during.moveProtection"),
|
||||
PREVENTINTERACTIONBLOCKS("jailing.during.preventInteractionBlocks"),
|
||||
PREVENTINTERACTIONBLOCKSPENALTY("jailing.during.preventInteractionBlocksPenalty"),
|
||||
PREVENTINTERACTIONITEMS("jailing.during.preventInteractionItems"),
|
||||
PREVENTINTERACTIONITEMSPENALTY("jailing.during.preventInteractionItemsPenalty"),
|
||||
PRISONEROPENCHEST("jailing.during.openChest"),
|
||||
RECIEVEMESSAGES("jailing.during.recieveMessages"),
|
||||
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
||||
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
|
||||
SCOREBOARDENABLED("jailing.during.scoreboard.enabled"),
|
||||
SCOREBOARDTITLE("jailing.during.scoreboard.title"),
|
||||
SCOREBOARDTIME("jailing.during.scoreboard.time"),
|
||||
TELEPORTONRELEASE("jailing.release.teleport"),
|
||||
UPDATECHANNEL("system.updates.channel"),
|
||||
UPDATENOTIFICATIONS("system.updates.notification"),
|
||||
UPDATETIME("system.updates.time"),
|
||||
USEBUKKITTIMER("system.useBukkitTimer");
|
||||
AUTOMATICMUTE("jailing.jail.automaticMute"),
|
||||
BROADCASTJAILING("jailing.jail.broadcastJailing"),
|
||||
BLOCKBREAKPENALTY("jailing.during.blockBreakPenalty"),
|
||||
BLOCKBREAKPROTECTION("jailing.during.blockBreakProtection"),
|
||||
BLOCKBREAKWHITELIST("jailing.during.blockBreakWhiteList"),
|
||||
BLOCKPLACEPENALTY("jailing.during.blockPlacePenalty"),
|
||||
BLOCKPLACEPROTECTION("jailing.during.blockPlaceProtection"),
|
||||
BLOCKPLACEWHITELIST("jailing.during.blockPlaceWhiteList"),
|
||||
CLOTHINGENABLED("jailing.jail.clothing.enabled"),
|
||||
CLOTHINGHELMET("jailing.jail.clothing.helmet"),
|
||||
CLOTHINGCHEST("jailing.jail.clothing.chest"),
|
||||
CLOTHINGLEGS("jailing.jail.clothing.legs"),
|
||||
CLOTHINGBOOTS("jailing.jail.clothing.boots"),
|
||||
COMMANDSONJAIL("jailing.jail.commands"),
|
||||
COMMANDSONRELEASE("jailing.release.commands"),
|
||||
COMMANDPENALTY("jailing.during.commandPenalty"),
|
||||
COMMANDPROTECTION("jailing.during.commandProtection"),
|
||||
COMMANDWHITELIST("jailing.during.commandWhitelist"),
|
||||
CONFIGVERSION("system.version"),
|
||||
COUNTDOWNTIMEOFFLINE("jailing.during.countDownTimeWhileOffline"),
|
||||
CROPTRAMPLINGPENALTY("jailing.during.cropTramplingPenalty"),
|
||||
CROPTRAMPLINGPROTECTION("jailing.during.cropTramplingProtection"),
|
||||
DEBUG("system.debug"),
|
||||
DEFAULTJAIL("jailing.jail.default.jail"),
|
||||
DEFAULTTIME("jailing.jail.default.time"),
|
||||
ENDERMENPROTECTION("jails.endermenProtection"),
|
||||
EXPLOSIONPROTECTION("jails.explosionProtection"),
|
||||
FOODCONTROL("jailing.during.foodControl.enabled"),
|
||||
FOODCONTROLMAX("jailing.during.foodControl.max"),
|
||||
FOODCONTROLMIN("jailing.during.foodControl.min"),
|
||||
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
|
||||
JAILSTICKENABLED("jailstick.enabled"),
|
||||
JAILSTICKSTICKS("jailstick.sticks"),
|
||||
JAILEDGAMEMODE("jailing.jail.gameMode"),
|
||||
JAILEDINVENTORYBLACKLIST("jailing.jail.inventory.blacklist"),
|
||||
JAILEDSTOREINVENTORY("jailing.jail.inventory.store"),
|
||||
JAILPAYENABLED("jailpay.enabled"),
|
||||
JAILPAYITEM("jailpay.item"),
|
||||
JAILPAYPRICEPERMINUTE ("jailpay.pricePerMinute"),
|
||||
JAILPAYPRICEINFINITE ("jailpay.priceInfinite"),
|
||||
LANGUAGE("system.language"),
|
||||
LOGJAILINGTOCONSOLE("jailing.jail.log.console"),
|
||||
LOGJAILINGTOPROFILE("jailing.jail.log.profile"),
|
||||
MAXAFKTIME("jailing.during.maxAFKTime"),
|
||||
MOVEPENALTY("jailing.during.movePenalty"),
|
||||
MOVEPROTECTION("jailing.during.moveProtection"),
|
||||
PREVENTINTERACTIONBLOCKS("jailing.during.preventInteractionBlocks"),
|
||||
PREVENTINTERACTIONBLOCKSPENALTY("jailing.during.preventInteractionBlocksPenalty"),
|
||||
PREVENTINTERACTIONITEMS("jailing.during.preventInteractionItems"),
|
||||
PREVENTINTERACTIONITEMSPENALTY("jailing.during.preventInteractionItemsPenalty"),
|
||||
PRISONEROPENCHEST("jailing.during.openChest"),
|
||||
RECIEVEMESSAGES("jailing.during.recieveMessages"),
|
||||
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
|
||||
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),
|
||||
SCOREBOARDENABLED("jailing.during.scoreboard.enabled"),
|
||||
SCOREBOARDTITLE("jailing.during.scoreboard.title"),
|
||||
SCOREBOARDTIME("jailing.during.scoreboard.time"),
|
||||
TELEPORTONRELEASE("jailing.release.teleport"),
|
||||
UPDATECHANNEL("system.updates.channel"),
|
||||
UPDATENOTIFICATIONS("system.updates.notification"),
|
||||
UPDATETIME("system.updates.time"),
|
||||
USEBUKKITTIMER("system.useBukkitTimer");
|
||||
|
||||
private String path;
|
||||
private String path;
|
||||
|
||||
private Settings(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
private Settings(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path this setting is in config.
|
||||
* @return The path where this setting resides in the config.
|
||||
*/
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
/**
|
||||
* Gets the path this setting is in config.
|
||||
* @return The path where this setting resides in the config.
|
||||
*/
|
||||
public String getPath() {
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
|
@ -22,104 +22,104 @@ import com.graywolf336.jail.beans.Stick;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrePrisonerJailedByJailStickEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String jailer, cancelMsg;
|
||||
private Stick stick;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String jailer, cancelMsg;
|
||||
private Stick stick;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerJailedByJailStickEvent prisoner jailed by a jail stick event} for the given player before they get sent to jail.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param jailer The name of what jailed this prisoner.
|
||||
* @param stick The {@link Stick jail stick} used.
|
||||
*/
|
||||
public PrePrisonerJailedByJailStickEvent(Jail jail, Cell cell, Prisoner prisoner, Player player, String jailer, Stick stick) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.jailer = jailer;
|
||||
this.stick = stick;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerJailedByJailStickEvent prisoner jailed by a jail stick event} for the given player before they get sent to jail.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param jailer The name of what jailed this prisoner.
|
||||
* @param stick The {@link Stick jail stick} used.
|
||||
*/
|
||||
public PrePrisonerJailedByJailStickEvent(Jail jail, Cell cell, Prisoner prisoner, Player player, String jailer, Stick stick) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.jailer = jailer;
|
||||
this.stick = stick;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being jailed. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets who jailed this prisoner.
|
||||
*
|
||||
* @param jailer The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
/**
|
||||
* Sets who jailed this prisoner.
|
||||
*
|
||||
* @param jailer The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
|
||||
/** Gets the jail stick used. */
|
||||
public Stick getJailStick() {
|
||||
return this.stick;
|
||||
}
|
||||
/** Gets the jail stick used. */
|
||||
public Stick getJailStick() {
|
||||
return this.stick;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -21,104 +21,104 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private boolean online;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String jailer, cancelMsg;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private boolean online;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String jailer, cancelMsg;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerJailedEvent prisoner jailed event} for the given player before they get sent to jail.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param online Whether the player is online or not.
|
||||
* @param jailer The name of what jailed this prisoner.
|
||||
*/
|
||||
public PrePrisonerJailedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player, boolean online, String jailer) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.online = online;
|
||||
this.jailer = jailer;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerJailedEvent prisoner jailed event} for the given player before they get sent to jail.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param online Whether the player is online or not.
|
||||
* @param jailer The name of what jailed this prisoner.
|
||||
*/
|
||||
public PrePrisonerJailedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player, boolean online, String jailer) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.online = online;
|
||||
this.jailer = jailer;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell we're going to be sending the prisoner to. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
/** Sets the cell we're going to be sending the prisoner to. */
|
||||
public void setCell(Cell cell) {
|
||||
this.cell = cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being jailed <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner being jailed is online or not. */
|
||||
public boolean isOnline() {
|
||||
return this.online;
|
||||
}
|
||||
/** Gets whether the prisoner being jailed is online or not. */
|
||||
public boolean isOnline() {
|
||||
return this.online;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.jailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets who jailed this prisoner.
|
||||
*
|
||||
* @param jailer The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
/**
|
||||
* Sets who jailed this prisoner.
|
||||
*
|
||||
* @param jailer The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setJailer(String jailer) {
|
||||
this.jailer = jailer;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -22,52 +22,52 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrePrisonerReleasedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerReleasedEvent pre-prisoner released event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrePrisonerReleasedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerReleasedEvent pre-prisoner released event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrePrisonerReleasedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being released. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being released. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -21,132 +21,132 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String transferor, cancelMsg;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private String transferor, cancelMsg;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerTransferredEvent prisoner transferred event} for the given player before they get transferred to their jail and cell.
|
||||
*
|
||||
* @param originalJail The jail the prisoner is coming from.
|
||||
* @param originalCell The cell the prisoner is coming from, can be null.
|
||||
* @param targetJail The jail the prisoner is going to.
|
||||
* @param targetCell The cell the prisoner is going to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param transferor The name of what is transferring this prisoner.
|
||||
*/
|
||||
public PrePrisonerTransferredEvent(Jail originalJail, Cell originalCell, Jail targetJail, Cell targetCell, Prisoner prisoner, Player player, String transferor) {
|
||||
this.originalJail = originalJail;
|
||||
this.originalCell = originalCell;
|
||||
this.targetJail = targetJail;
|
||||
this.targetCell = targetCell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.transferor = transferor;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrePrisonerTransferredEvent prisoner transferred event} for the given player before they get transferred to their jail and cell.
|
||||
*
|
||||
* @param originalJail The jail the prisoner is coming from.
|
||||
* @param originalCell The cell the prisoner is coming from, can be null.
|
||||
* @param targetJail The jail the prisoner is going to.
|
||||
* @param targetCell The cell the prisoner is going to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
* @param transferor The name of what is transferring this prisoner.
|
||||
*/
|
||||
public PrePrisonerTransferredEvent(Jail originalJail, Cell originalCell, Jail targetJail, Cell targetCell, Prisoner prisoner, Player player, String transferor) {
|
||||
this.originalJail = originalJail;
|
||||
this.originalCell = originalCell;
|
||||
this.targetJail = targetJail;
|
||||
this.targetCell = targetCell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
this.transferor = transferor;
|
||||
this.cancelMsg = "";
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target jail where this prisoner is being sent to.
|
||||
*
|
||||
* @param jail The {@link Jail} this prisoner should be sent to instead of what it was.
|
||||
*/
|
||||
public void setTargetJail(Jail jail) {
|
||||
this.targetJail = jail;
|
||||
}
|
||||
/**
|
||||
* Sets the target jail where this prisoner is being sent to.
|
||||
*
|
||||
* @param jail The {@link Jail} this prisoner should be sent to instead of what it was.
|
||||
*/
|
||||
public void setTargetJail(Jail jail) {
|
||||
this.targetJail = jail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
if(this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
||||
else return null;
|
||||
}
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
if(this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
||||
else return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the target {@link Cell} this prisoner is being sent to.
|
||||
*
|
||||
* @param cell The {@link Cell} this prisoner should be sent to instead of what it was.
|
||||
*/
|
||||
public void setTargetCell(Cell cell) {
|
||||
this.targetCell = cell;
|
||||
}
|
||||
/**
|
||||
* Sets the target {@link Cell} this prisoner is being sent to.
|
||||
*
|
||||
* @param cell The {@link Cell} this prisoner should be sent to instead of what it was.
|
||||
*/
|
||||
public void setTargetCell(Cell cell) {
|
||||
this.targetCell = cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner being transferred is online or not. */
|
||||
public boolean isOnline() {
|
||||
return player == null;
|
||||
}
|
||||
/** Gets whether the prisoner being transferred is online or not. */
|
||||
public boolean isOnline() {
|
||||
return player == null;
|
||||
}
|
||||
|
||||
/** Gets the name of what is transferring this prisoner. */
|
||||
public String getTransferor() {
|
||||
return this.transferor;
|
||||
}
|
||||
/** Gets the name of what is transferring this prisoner. */
|
||||
public String getTransferor() {
|
||||
return this.transferor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the prisoner whom the data should say jailed this prisoner.
|
||||
*
|
||||
* @param transferor The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setTransferor(String transferor) {
|
||||
this.transferor = transferor;
|
||||
}
|
||||
/**
|
||||
* Sets the prisoner whom the data should say jailed this prisoner.
|
||||
*
|
||||
* @param transferor The name to put who is the jailer for this prisoner.
|
||||
*/
|
||||
public void setTransferor(String transferor) {
|
||||
this.transferor = transferor;
|
||||
}
|
||||
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
/** Checks whether this event is cancelled or not. */
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
/** Sets whether this event should be cancelled. */
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
/** Returns the cancelled message. */
|
||||
public String getCancelledMessage() {
|
||||
return this.cancelMsg;
|
||||
}
|
||||
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
/** Sets the cancelled message. */
|
||||
public void setCancelledMessage(String msg) {
|
||||
this.cancelMsg = msg;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -17,60 +17,60 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrisonerDeathEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private PlayerDeathEvent event;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private PlayerDeathEvent event;
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerDeathEvent prisoner death event} for the given player.
|
||||
*
|
||||
* @param event The {@link PlayerDeathEvent} which triggered this event.
|
||||
* @param jail The jail the prisoner is in.
|
||||
* @param cell The cell the prisoner is in, can be null.
|
||||
* @param prisoner The prisoner's data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerDeathEvent(PlayerDeathEvent event, Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.event = event;
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrisonerDeathEvent prisoner death event} for the given player.
|
||||
*
|
||||
* @param event The {@link PlayerDeathEvent} which triggered this event.
|
||||
* @param jail The jail the prisoner is in.
|
||||
* @param cell The cell the prisoner is in, can be null.
|
||||
* @param prisoner The prisoner's data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerDeathEvent(PlayerDeathEvent event, Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.event = event;
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link PlayerDeathEvent} which triggered this PrisonerDeathEvent. */
|
||||
public PlayerDeathEvent getPlayerDeathEvent() {
|
||||
return this.event;
|
||||
}
|
||||
/** Gets the {@link PlayerDeathEvent} which triggered this PrisonerDeathEvent. */
|
||||
public PlayerDeathEvent getPlayerDeathEvent() {
|
||||
return this.event;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is in. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is in. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell the prisoner is in, can be null. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell the prisoner is in, can be null. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner}'s data. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner}'s data. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player who died. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player who died. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -22,57 +22,57 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrisonerJailedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerJailedEvent prisoner jailed event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerJailedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrisonerJailedEvent prisoner jailed event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerJailedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is being sent to. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell we're going to be sending the prisoner to, can be null. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell we're going to be sending the prisoner to, can be null. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being jailed. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being jailed. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.prisoner.getJailer();
|
||||
}
|
||||
/** Gets the jailer who jailed this prisoner. */
|
||||
public String getJailer() {
|
||||
return this.prisoner.getJailer();
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -22,52 +22,52 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrisonerReleasedEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail jail;
|
||||
private Cell cell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerReleasedEvent prisoner released event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerReleasedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrisonerReleasedEvent prisoner released event} for the given player.
|
||||
*
|
||||
* @param jail The jail the prisoner will be jailed at.
|
||||
* @param cell The cell we're going to be sending the prisoner to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerReleasedEvent(Jail jail, Cell cell, Prisoner prisoner, Player player) {
|
||||
this.jail = jail;
|
||||
this.cell = cell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getJail() {
|
||||
return this.jail;
|
||||
}
|
||||
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
/** Gets the cell where the prisoner was jailed in, null if they weren't in one. */
|
||||
public Cell getCell() {
|
||||
return this.cell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being released. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being released. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -20,75 +20,75 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class PrisonerTransferredEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Jail originalJail, targetJail;
|
||||
private Cell originalCell, targetCell;
|
||||
private Prisoner prisoner;
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PrisonerTransferredEvent prisoner transferred event} for the given player after they get transferred to their new jail and cell.
|
||||
*
|
||||
* @param originalJail The jail the prisoner is coming from.
|
||||
* @param originalCell The cell the prisoner is coming from, can be null.
|
||||
* @param targetJail The jail the prisoner went to.
|
||||
* @param targetCell The cell the prisoner went to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerTransferredEvent(Jail originalJail, Cell originalCell, Jail targetJail, Cell targetCell, Prisoner prisoner, Player player) {
|
||||
this.originalJail = originalJail;
|
||||
this.originalCell = originalCell;
|
||||
this.targetJail = targetJail;
|
||||
this.targetCell = targetCell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
/**
|
||||
* Creates a new {@link PrisonerTransferredEvent prisoner transferred event} for the given player after they get transferred to their new jail and cell.
|
||||
*
|
||||
* @param originalJail The jail the prisoner is coming from.
|
||||
* @param originalCell The cell the prisoner is coming from, can be null.
|
||||
* @param targetJail The jail the prisoner went to.
|
||||
* @param targetCell The cell the prisoner went to, can be null.
|
||||
* @param prisoner The prisoner data.
|
||||
* @param player The player being jailed.
|
||||
*/
|
||||
public PrisonerTransferredEvent(Jail originalJail, Cell originalCell, Jail targetJail, Cell targetCell, Prisoner prisoner, Player player) {
|
||||
this.originalJail = originalJail;
|
||||
this.originalCell = originalCell;
|
||||
this.targetJail = targetJail;
|
||||
this.targetCell = targetCell;
|
||||
this.prisoner = prisoner;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is coming from. */
|
||||
public Jail getOriginalJail() {
|
||||
return this.originalJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
/** Gets the {@link Cell} this prisoner is coming from, can be null. */
|
||||
public Cell getOriginalCell() {
|
||||
return this.originalCell;
|
||||
}
|
||||
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
/** Gets the {@link Jail} this prisoner is being transferred to. */
|
||||
public Jail getTargetJail() {
|
||||
return this.targetJail;
|
||||
}
|
||||
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
if(this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
||||
else return null;
|
||||
}
|
||||
/** Gets the {@link Cell} this prisoner is being sent to, can be null.
|
||||
*
|
||||
* Will return null if the cell is not in the targetJail.
|
||||
*/
|
||||
public Cell getTargetCell() {
|
||||
if(this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
||||
else return null;
|
||||
}
|
||||
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
/** Gets the {@link Prisoner} data for this prisoner. */
|
||||
public Prisoner getPrisoner() {
|
||||
return this.prisoner;
|
||||
}
|
||||
|
||||
/** Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
/** Gets the instance of the player being transferred <strong>but will return null if {@link #isOnline()} returns false</strong>. */
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/** Gets whether the prisoner being transferred is online or not. */
|
||||
public boolean isOnline() {
|
||||
return player == null;
|
||||
}
|
||||
/** Gets whether the prisoner being transferred is online or not. */
|
||||
public boolean isOnline() {
|
||||
return player == null;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -25,420 +25,420 @@ import com.graywolf336.jail.enums.Settings;
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class LegacyManager {
|
||||
private JailMain pl;
|
||||
private YamlConfiguration global;
|
||||
private boolean wasConverted;
|
||||
private JailMain pl;
|
||||
private YamlConfiguration global;
|
||||
private boolean wasConverted;
|
||||
|
||||
public LegacyManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.wasConverted = false;
|
||||
}
|
||||
public LegacyManager(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.wasConverted = false;
|
||||
}
|
||||
|
||||
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
|
||||
public boolean doWeNeedToConvert() {
|
||||
return new File(pl.getDataFolder(), "global.yml").exists();
|
||||
}
|
||||
/** Returns true/false if the old config, global.yml, exists and needs to be converted. */
|
||||
public boolean doWeNeedToConvert() {
|
||||
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;
|
||||
}
|
||||
/**
|
||||
* 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() {
|
||||
File f = new File(pl.getDataFolder(), "global.yml");
|
||||
public boolean convertOldData() {
|
||||
File f = new File(pl.getDataFolder(), "global.yml");
|
||||
|
||||
if(f.exists()) {
|
||||
global = new YamlConfiguration();
|
||||
try {
|
||||
global.load(f);
|
||||
} catch (FileNotFoundException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config, file not found.");
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||
} catch (InvalidConfigurationException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||
}
|
||||
}else {
|
||||
pl.debug("The old config file, global.yml, was not found so not loading anything.");
|
||||
return false;
|
||||
}
|
||||
if(f.exists()) {
|
||||
global = new YamlConfiguration();
|
||||
try {
|
||||
global.load(f);
|
||||
} catch (FileNotFoundException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config, file not found.");
|
||||
} catch (IOException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||
} catch (InvalidConfigurationException e) {
|
||||
//e.printStackTrace();
|
||||
pl.getLogger().severe("Unable to load the old global config: " + e.getMessage());
|
||||
}
|
||||
}else {
|
||||
pl.debug("The old config file, global.yml, was not found so not loading anything.");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
pl.getLogger().info("Starting to convert Jail 2.x data to Jail 3.0, this does use a blocking call (getOfflinePlayer) so expect the server to be held up until we are finished...");
|
||||
loadOldConfig();
|
||||
loadOldData();
|
||||
moveOldConfigs();
|
||||
this.wasConverted = true;
|
||||
pl.getLogger().info("...finished converting configs and data.");
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
if(pl.inDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
pl.getLogger().info("Starting to convert Jail 2.x data to Jail 3.0, this does use a blocking call (getOfflinePlayer) so expect the server to be held up until we are finished...");
|
||||
loadOldConfig();
|
||||
loadOldData();
|
||||
moveOldConfigs();
|
||||
this.wasConverted = true;
|
||||
pl.getLogger().info("...finished converting configs and data.");
|
||||
return true;
|
||||
}catch (Exception e) {
|
||||
if(pl.inDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
pl.debug(e.getMessage());
|
||||
pl.getLogger().severe("Failed to load the old configuration for some reason.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
pl.debug(e.getMessage());
|
||||
pl.getLogger().severe("Failed to load the old configuration for some reason.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void loadOldConfig() {
|
||||
FileConfiguration c = pl.getConfig();
|
||||
@SuppressWarnings("deprecation")
|
||||
private void loadOldConfig() {
|
||||
FileConfiguration c = pl.getConfig();
|
||||
|
||||
int count = 0;
|
||||
for(OldSetting s : OldSetting.values()) {
|
||||
switch(s) {
|
||||
case Debug:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.DEBUG.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
//Only set it true if the old config had true, this way we can still hold the debuggin over
|
||||
//if the old config had it set to false but the new one has it set to true (until a restart/reload)
|
||||
if(c.getBoolean(Settings.DEBUG.getPath())) pl.setDebugging(true);
|
||||
pl.debug(Settings.DEBUG.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BroadcastJailMessage:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BROADCASTJAILING.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BROADCASTJAILING.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case AllowUpdateNotifications:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.UPDATENOTIFICATIONS.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.UPDATENOTIFICATIONS.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ExecutedCommandsOnJail:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDSONJAIL.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDSONJAIL.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ExecutedCommandsOnRelease:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDSONRELEASE.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDSONRELEASE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case AutomaticMute:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.AUTOMATICMUTE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.AUTOMATICMUTE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case StoreInventory:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.JAILEDSTOREINVENTORY.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.JAILEDSTOREINVENTORY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CanPrisonerOpenHisChest:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.PRISONEROPENCHEST.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.PRISONEROPENCHEST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case LogJailingIntoConsole:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.LOGJAILINGTOCONSOLE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.LOGJAILINGTOCONSOLE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CountdownTimeWhenOffline:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COUNTDOWNTIMEOFFLINE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.COUNTDOWNTIMEOFFLINE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ReleaseBackToPreviousPosition:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.RELEASETOPREVIOUSPOSITION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.RELEASETOPREVIOUSPOSITION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case IgnorePrisonersSleepingState:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.IGNORESLEEPINGSTATE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.IGNORESLEEPINGSTATE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case TeleportPrisonerOnRelease:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.TELEPORTONRELEASE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.TELEPORTONRELEASE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case DefaultJailTime:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.DEFAULTTIME.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.DEFAULTTIME.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case UseBukkitSchedulerTimer:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.USEBUKKITTIMER.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.USEBUKKITTIMER.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableJailStick:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.JAILSTICKENABLED.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.JAILSTICKENABLED.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case JailStickParameters:
|
||||
if(global.contains(s.getString())) {
|
||||
LinkedList<String> sticks = new LinkedList<String>();
|
||||
for (String i : OldSettings.getGlobalString(global, s).split(";")) {
|
||||
String[] info = i.split(",");
|
||||
//item id,range,time,jail name,reason
|
||||
Material m = Material.getMaterial(Integer.valueOf(info[0]).intValue());
|
||||
int count = 0;
|
||||
for(OldSetting s : OldSetting.values()) {
|
||||
switch(s) {
|
||||
case Debug:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.DEBUG.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
//Only set it true if the old config had true, this way we can still hold the debuggin over
|
||||
//if the old config had it set to false but the new one has it set to true (until a restart/reload)
|
||||
if(c.getBoolean(Settings.DEBUG.getPath())) pl.setDebugging(true);
|
||||
pl.debug(Settings.DEBUG.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BroadcastJailMessage:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BROADCASTJAILING.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BROADCASTJAILING.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case AllowUpdateNotifications:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.UPDATENOTIFICATIONS.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.UPDATENOTIFICATIONS.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ExecutedCommandsOnJail:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDSONJAIL.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDSONJAIL.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ExecutedCommandsOnRelease:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDSONRELEASE.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDSONRELEASE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case AutomaticMute:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.AUTOMATICMUTE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.AUTOMATICMUTE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case StoreInventory:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.JAILEDSTOREINVENTORY.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.JAILEDSTOREINVENTORY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CanPrisonerOpenHisChest:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.PRISONEROPENCHEST.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.PRISONEROPENCHEST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case LogJailingIntoConsole:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.LOGJAILINGTOCONSOLE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.LOGJAILINGTOCONSOLE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CountdownTimeWhenOffline:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COUNTDOWNTIMEOFFLINE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.COUNTDOWNTIMEOFFLINE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case ReleaseBackToPreviousPosition:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.RELEASETOPREVIOUSPOSITION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.RELEASETOPREVIOUSPOSITION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case IgnorePrisonersSleepingState:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.IGNORESLEEPINGSTATE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.IGNORESLEEPINGSTATE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case TeleportPrisonerOnRelease:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.TELEPORTONRELEASE.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.TELEPORTONRELEASE.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case DefaultJailTime:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.DEFAULTTIME.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.DEFAULTTIME.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case UseBukkitSchedulerTimer:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.USEBUKKITTIMER.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.USEBUKKITTIMER.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableJailStick:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.JAILSTICKENABLED.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.JAILSTICKENABLED.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case JailStickParameters:
|
||||
if(global.contains(s.getString())) {
|
||||
LinkedList<String> sticks = new LinkedList<String>();
|
||||
for (String i : OldSettings.getGlobalString(global, s).split(";")) {
|
||||
String[] info = i.split(",");
|
||||
//item id,range,time,jail name,reason
|
||||
Material m = Material.getMaterial(Integer.valueOf(info[0]).intValue());
|
||||
|
||||
//item name,time,jail name,reason
|
||||
sticks.push(m.toString().toLowerCase() + "," + info[2] + "," + info[3] + "," + info[4]);
|
||||
}
|
||||
c.set(Settings.JAILSTICKSTICKS.getPath(), sticks);
|
||||
pl.debug(Settings.JAILSTICKSTICKS.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableBlockDestroyProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKBREAKPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BLOCKBREAKPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockDestroyPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKBREAKPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.BLOCKBREAKPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockDestroyProtectionExceptions:
|
||||
if(global.contains(s.getString())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
|
||||
LinkedList<String> whitelist = new LinkedList<String>();
|
||||
for(String e : exceptions) {
|
||||
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
|
||||
}
|
||||
//item name,time,jail name,reason
|
||||
sticks.push(m.toString().toLowerCase() + "," + info[2] + "," + info[3] + "," + info[4]);
|
||||
}
|
||||
c.set(Settings.JAILSTICKSTICKS.getPath(), sticks);
|
||||
pl.debug(Settings.JAILSTICKSTICKS.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableBlockDestroyProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKBREAKPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BLOCKBREAKPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockDestroyPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKBREAKPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.BLOCKBREAKPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockDestroyProtectionExceptions:
|
||||
if(global.contains(s.getString())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
|
||||
LinkedList<String> whitelist = new LinkedList<String>();
|
||||
for(String e : exceptions) {
|
||||
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
|
||||
}
|
||||
|
||||
c.set(Settings.BLOCKBREAKWHITELIST.getPath(), whitelist);
|
||||
pl.debug(Settings.BLOCKBREAKWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableBlockPlaceProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKPLACEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BLOCKPLACEPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockPlacePenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKPLACEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.BLOCKPLACEPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockPlaceProtectionExceptions:
|
||||
if(global.contains(s.getString())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
|
||||
LinkedList<String> whitelist = new LinkedList<String>();
|
||||
for(String e : exceptions) {
|
||||
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
|
||||
}
|
||||
c.set(Settings.BLOCKBREAKWHITELIST.getPath(), whitelist);
|
||||
pl.debug(Settings.BLOCKBREAKWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableBlockPlaceProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKPLACEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.BLOCKPLACEPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockPlacePenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.BLOCKPLACEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.BLOCKPLACEPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case BlockPlaceProtectionExceptions:
|
||||
if(global.contains(s.getString())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<String> exceptions = (List<String>) OldSettings.getGlobalList(global, s);
|
||||
LinkedList<String> whitelist = new LinkedList<String>();
|
||||
for(String e : exceptions) {
|
||||
whitelist.add(Material.getMaterial(Integer.valueOf(e).intValue()).toString().toLowerCase());
|
||||
}
|
||||
|
||||
c.set(Settings.BLOCKPLACEWHITELIST.getPath(), whitelist);
|
||||
pl.debug(Settings.BLOCKPLACEWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnablePlayerMoveProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.MOVEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.MOVEPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case PlayerMoveProtectionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.MOVEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.MOVEPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case WhitelistedCommands:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDWHITELIST.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CommandProtectionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.COMMANDPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case InteractionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableExplosionProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.EXPLOSIONPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.EXPLOSIONPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableFoodControl:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROL.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.FOODCONTROL.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case FoodControlMinimumFood:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROLMIN.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.FOODCONTROLMIN.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case FoodControlMaximumFood:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROLMAX.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.FOODCONTROLMAX.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case PrisonersRecieveMessages:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.RECIEVEMESSAGES.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case UseMySQL:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.type", OldSettings.getGlobalBoolean(global, s) ? "mysql" : "sqlite");
|
||||
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLConn:
|
||||
if(global.contains(s.getString())) {
|
||||
//jdbc:mysql://localhost:3306/minecraft
|
||||
String con = OldSettings.getGlobalString(global, s);
|
||||
String a = con.split("//")[1];
|
||||
//localhost 3306/minecraft
|
||||
String[] b1 = a.split(":");
|
||||
//3306 minecraft
|
||||
String[] b2 = b1[1].split("/");
|
||||
c.set(Settings.BLOCKPLACEWHITELIST.getPath(), whitelist);
|
||||
pl.debug(Settings.BLOCKPLACEWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnablePlayerMoveProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.MOVEPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.MOVEPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case PlayerMoveProtectionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.MOVEPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.MOVEPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case WhitelistedCommands:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDWHITELIST.getPath(), OldSettings.getGlobalList(global, s));
|
||||
pl.debug(Settings.COMMANDWHITELIST.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case CommandProtectionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.COMMANDPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.COMMANDPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case InteractionPenalty:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableExplosionProtection:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.EXPLOSIONPROTECTION.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.EXPLOSIONPROTECTION.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case EnableFoodControl:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROL.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.FOODCONTROL.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case FoodControlMinimumFood:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROLMIN.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.FOODCONTROLMIN.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case FoodControlMaximumFood:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.FOODCONTROLMAX.getPath(), OldSettings.getGlobalInt(global, s));
|
||||
pl.debug(Settings.FOODCONTROLMAX.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case PrisonersRecieveMessages:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set(Settings.RECIEVEMESSAGES.getPath(), OldSettings.getGlobalBoolean(global, s));
|
||||
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case UseMySQL:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.type", OldSettings.getGlobalBoolean(global, s) ? "mysql" : "sqlite");
|
||||
pl.debug(Settings.RECIEVEMESSAGES.getPath() + " <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLConn:
|
||||
if(global.contains(s.getString())) {
|
||||
//jdbc:mysql://localhost:3306/minecraft
|
||||
String con = OldSettings.getGlobalString(global, s);
|
||||
String a = con.split("//")[1];
|
||||
//localhost 3306/minecraft
|
||||
String[] b1 = a.split(":");
|
||||
//3306 minecraft
|
||||
String[] b2 = b1[1].split("/");
|
||||
|
||||
c.set("storage.mysql.host", b1[0]);
|
||||
c.set("storage.mysql.port", b2[0]);
|
||||
c.set("storage.mysql.database", b2[1]);
|
||||
c.set("storage.mysql.host", b1[0]);
|
||||
c.set("storage.mysql.port", b2[0]);
|
||||
c.set("storage.mysql.database", b2[1]);
|
||||
|
||||
pl.debug("storage.mysql <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLUsername:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.mysql.username", OldSettings.getGlobalString(global, s));
|
||||
pl.debug("storage.mysql.username <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLPassword:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.mysql.password", OldSettings.getGlobalString(global, s));
|
||||
pl.debug("storage.mysql.password <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
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:
|
||||
break;
|
||||
}
|
||||
}
|
||||
pl.debug("storage.mysql <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLUsername:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.mysql.username", OldSettings.getGlobalString(global, s));
|
||||
pl.debug("storage.mysql.username <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
break;
|
||||
case MySQLPassword:
|
||||
if(global.contains(s.getString())) {
|
||||
c.set("storage.mysql.password", OldSettings.getGlobalString(global, s));
|
||||
pl.debug("storage.mysql.password <-- " + s.getString());
|
||||
count++;
|
||||
}
|
||||
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:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pl.saveConfig();
|
||||
pl.getLogger().info("Converted " + count + " old config value" + (count == 1 ? "" : "s") + ".");
|
||||
}
|
||||
pl.saveConfig();
|
||||
pl.getLogger().info("Converted " + count + " old config value" + (count == 1 ? "" : "s") + ".");
|
||||
}
|
||||
|
||||
private void loadOldData() throws SQLException {
|
||||
OldInputOutput o = new OldInputOutput(pl, global);
|
||||
private void loadOldData() throws SQLException {
|
||||
OldInputOutput o = new OldInputOutput(pl, global);
|
||||
|
||||
o.LoadJails();
|
||||
o.LoadPrisoners();
|
||||
o.LoadCells();
|
||||
o.freeConnection();
|
||||
}
|
||||
o.LoadJails();
|
||||
o.LoadPrisoners();
|
||||
o.LoadCells();
|
||||
o.freeConnection();
|
||||
}
|
||||
|
||||
private void moveOldConfigs() throws IOException {
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "global.yml"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "jails.yml"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "jailLog.txt"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
private void moveOldConfigs() throws IOException {
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "global.yml"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "jails.yml"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
FileUtils.moveFileToDirectory(new File(pl.getDataFolder(), "jailLog.txt"), new File(pl.getDataFolder() + File.separator + "preJail3Data"), true);
|
||||
|
||||
File sqlite = new File(pl.getDataFolder(), "jail.sqlite");
|
||||
if(sqlite.exists()) {
|
||||
FileUtils.moveFileToDirectory(sqlite, new File(pl.getDataFolder() + File.separator + "oldData"), true);
|
||||
}
|
||||
}
|
||||
File sqlite = new File(pl.getDataFolder(), "jail.sqlite");
|
||||
if(sqlite.exists()) {
|
||||
FileUtils.moveFileToDirectory(sqlite, new File(pl.getDataFolder() + File.separator + "oldData"), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,21 +18,21 @@ import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.beans.SimpleLocation;
|
||||
|
||||
public class OldInputOutput {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
private Connection connection;
|
||||
private YamlConfiguration global;
|
||||
|
||||
public OldInputOutput(JailMain plugin, YamlConfiguration global) {
|
||||
this.pl = plugin;
|
||||
this.global = global;
|
||||
this.pl = plugin;
|
||||
this.global = global;
|
||||
}
|
||||
|
||||
public synchronized Connection getConnection() throws SQLException {
|
||||
if (connection == null) connection = createConnection();
|
||||
if(OldSettings.getGlobalBoolean(global, OldSetting.UseMySQL)) {
|
||||
if(!connection.isValid(10)) connection = createConnection();
|
||||
if (connection == null) connection = createConnection();
|
||||
if(OldSettings.getGlobalBoolean(global, OldSetting.UseMySQL)) {
|
||||
if(!connection.isValid(10)) connection = createConnection();
|
||||
}
|
||||
return connection;
|
||||
return connection;
|
||||
}
|
||||
|
||||
private Connection createConnection() {
|
||||
@ -57,12 +57,12 @@ public class OldInputOutput {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void freeConnection() throws SQLException {
|
||||
Connection conn = getConnection();
|
||||
public synchronized void freeConnection() throws SQLException {
|
||||
Connection conn = getConnection();
|
||||
if(conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
conn = null;
|
||||
conn.close();
|
||||
conn = null;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -70,178 +70,178 @@ public class OldInputOutput {
|
||||
}
|
||||
|
||||
public void LoadJails() throws SQLException {
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_zones");
|
||||
ResultSet set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
String name = set.getString("name").toLowerCase();
|
||||
double X1 = set.getDouble("X1");
|
||||
double Y1 = set.getDouble("Y1");
|
||||
double Z1 = set.getDouble("Z1");
|
||||
double X2 = set.getDouble("X2");
|
||||
double Y2 = set.getDouble("Y2");
|
||||
double Z2 = set.getDouble("Z2");
|
||||
double teleX = set.getDouble("teleX");
|
||||
double teleY = set.getDouble("teleY");
|
||||
double teleZ = set.getDouble("teleZ");
|
||||
double freeX = set.getDouble("freeX");
|
||||
double freeY = set.getDouble("freeY");
|
||||
double freeZ = set.getDouble("freeZ");
|
||||
String teleWorld = set.getString("teleWorld");
|
||||
String freeWorld = set.getString("freeWorld");
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_zones");
|
||||
ResultSet set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
String name = set.getString("name").toLowerCase();
|
||||
double X1 = set.getDouble("X1");
|
||||
double Y1 = set.getDouble("Y1");
|
||||
double Z1 = set.getDouble("Z1");
|
||||
double X2 = set.getDouble("X2");
|
||||
double Y2 = set.getDouble("Y2");
|
||||
double Z2 = set.getDouble("Z2");
|
||||
double teleX = set.getDouble("teleX");
|
||||
double teleY = set.getDouble("teleY");
|
||||
double teleZ = set.getDouble("teleZ");
|
||||
double freeX = set.getDouble("freeX");
|
||||
double freeY = set.getDouble("freeY");
|
||||
double freeZ = set.getDouble("freeZ");
|
||||
String teleWorld = set.getString("teleWorld");
|
||||
String freeWorld = set.getString("freeWorld");
|
||||
|
||||
Jail j = new Jail(pl, name);
|
||||
j.setWorld(teleWorld);
|
||||
j.setMaxPoint(new Location(pl.getServer().getWorld(teleWorld), X1, Y1, Z1));
|
||||
j.setMinPoint(new Location(pl.getServer().getWorld(teleWorld), X2, Y2, Z2));
|
||||
j.setTeleportIn(new Location(pl.getServer().getWorld(teleWorld), teleX, teleY, teleZ));
|
||||
j.setTeleportFree(new Location(pl.getServer().getWorld(freeWorld), freeX, freeY, freeZ));
|
||||
Jail j = new Jail(pl, name);
|
||||
j.setWorld(teleWorld);
|
||||
j.setMaxPoint(new Location(pl.getServer().getWorld(teleWorld), X1, Y1, Z1));
|
||||
j.setMinPoint(new Location(pl.getServer().getWorld(teleWorld), X2, Y2, Z2));
|
||||
j.setTeleportIn(new Location(pl.getServer().getWorld(teleWorld), teleX, teleY, teleZ));
|
||||
j.setTeleportFree(new Location(pl.getServer().getWorld(freeWorld), freeX, freeY, freeZ));
|
||||
|
||||
pl.getJailManager().addJail(j, false);
|
||||
}
|
||||
pl.getJailManager().addJail(j, false);
|
||||
}
|
||||
|
||||
set.close();
|
||||
ps.close();
|
||||
set.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public void LoadPrisoners() throws SQLException {
|
||||
if(pl.getJailManager().getJails().size() != 0) {
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
|
||||
ResultSet set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
Jail j = pl.getJailManager().getJail(set.getString("JailName"));
|
||||
String name = set.getString("PlayerName").toLowerCase();
|
||||
if(pl.getJailManager().getJails().size() != 0) {
|
||||
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM jail_prisoners");
|
||||
ResultSet set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
Jail j = pl.getJailManager().getJail(set.getString("JailName"));
|
||||
String name = set.getString("PlayerName").toLowerCase();
|
||||
|
||||
String transferDest = set.getString("TransferDest");
|
||||
boolean transfer = false;
|
||||
if(!transferDest.isEmpty()) {
|
||||
j = pl.getJailManager().getJail(transferDest);
|
||||
transfer = true;
|
||||
}
|
||||
String transferDest = set.getString("TransferDest");
|
||||
boolean transfer = false;
|
||||
if(!transferDest.isEmpty()) {
|
||||
j = pl.getJailManager().getJail(transferDest);
|
||||
transfer = true;
|
||||
}
|
||||
|
||||
//In the event the jail is null (jail didn't transfer or the prisoner was jailed offline and no jail specified)
|
||||
//set their jail to the first one we have
|
||||
if(j == null) {
|
||||
j = pl.getJailManager().getJails().iterator().next();
|
||||
}
|
||||
//In the event the jail is null (jail didn't transfer or the prisoner was jailed offline and no jail specified)
|
||||
//set their jail to the first one we have
|
||||
if(j == null) {
|
||||
j = pl.getJailManager().getJails().iterator().next();
|
||||
}
|
||||
|
||||
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), TimeUnit.MILLISECONDS.convert(set.getInt("RemainTime") / 6, TimeUnit.MINUTES), set.getString("Jailer"), set.getString("reason"));
|
||||
p.setOfflinePending(set.getBoolean("Offline"));
|
||||
p.setToBeTransferred(transfer);
|
||||
Prisoner p = new Prisoner(pl.getServer().getOfflinePlayer(name).getUniqueId().toString(), name, set.getBoolean("muted"), TimeUnit.MILLISECONDS.convert(set.getInt("RemainTime") / 6, TimeUnit.MINUTES), set.getString("Jailer"), set.getString("reason"));
|
||||
p.setOfflinePending(set.getBoolean("Offline"));
|
||||
p.setToBeTransferred(transfer);
|
||||
|
||||
String previousLoc = set.getString("PreviousPosition");
|
||||
if(!previousLoc.isEmpty()) {
|
||||
String[] l = previousLoc.split(",");
|
||||
p.setPreviousPosition(new Location(pl.getServer().getWorld(l[0]), Integer.parseInt(l[1]), Integer.parseInt(l[2]), Integer.parseInt(l[3])));
|
||||
}
|
||||
String previousLoc = set.getString("PreviousPosition");
|
||||
if(!previousLoc.isEmpty()) {
|
||||
String[] l = previousLoc.split(",");
|
||||
p.setPreviousPosition(new Location(pl.getServer().getWorld(l[0]), Integer.parseInt(l[1]), Integer.parseInt(l[2]), Integer.parseInt(l[3])));
|
||||
}
|
||||
|
||||
j.addPrisoner(p);
|
||||
//String permissions = set.getString("Permissions"); TODO
|
||||
}
|
||||
j.addPrisoner(p);
|
||||
//String permissions = set.getString("Permissions"); TODO
|
||||
}
|
||||
|
||||
set.close();
|
||||
ps.close();
|
||||
}else {
|
||||
pl.getLogger().warning("No prisoners were transferred from the old database since there aren't any jails defined.");
|
||||
}
|
||||
set.close();
|
||||
ps.close();
|
||||
}else {
|
||||
pl.getLogger().warning("No prisoners were transferred from the old database since there aren't any jails defined.");
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadCells() throws SQLException {
|
||||
Connection conn;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet set = null;
|
||||
Connection conn;
|
||||
PreparedStatement ps = null;
|
||||
ResultSet set = null;
|
||||
|
||||
conn = getConnection();
|
||||
ps = conn.prepareStatement("SELECT * FROM jail_cells");
|
||||
set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
String jailname = set.getString("JailName");
|
||||
String teleport = set.getString("Teleport");
|
||||
String sign = set.getString("Sign");
|
||||
String chest = set.getString("Chest");
|
||||
String player = set.getString("Player");
|
||||
String name = set.getString("Name");
|
||||
conn = getConnection();
|
||||
ps = conn.prepareStatement("SELECT * FROM jail_cells");
|
||||
set = ps.executeQuery();
|
||||
while (set.next()) {
|
||||
String jailname = set.getString("JailName");
|
||||
String teleport = set.getString("Teleport");
|
||||
String sign = set.getString("Sign");
|
||||
String chest = set.getString("Chest");
|
||||
String player = set.getString("Player");
|
||||
String name = set.getString("Name");
|
||||
|
||||
if(name.isEmpty()) {
|
||||
pl.getLogger().warning("We need a cell name in Jail 3.0, refusing to load a cell due to this.");
|
||||
}else if(jailname.isEmpty()) {
|
||||
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it does not contain a reference to a valid Jail.");
|
||||
}else {
|
||||
Jail j = pl.getJailManager().getJail(jailname);
|
||||
if(name.isEmpty()) {
|
||||
pl.getLogger().warning("We need a cell name in Jail 3.0, refusing to load a cell due to this.");
|
||||
}else if(jailname.isEmpty()) {
|
||||
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it does not contain a reference to a valid Jail.");
|
||||
}else {
|
||||
Jail j = pl.getJailManager().getJail(jailname);
|
||||
|
||||
if(j == null) {
|
||||
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it references a Jail which doesn't exist.");
|
||||
}else if(j.isValidCell(name)) {
|
||||
pl.getLogger().warning("Refusing to load a duplicate named cell, " + name + ", as another one exists with that same name.");
|
||||
} else {
|
||||
Cell c = new Cell(name);
|
||||
if(j == null) {
|
||||
pl.getLogger().warning("Refusing to load a cell (" + name + ") as it references a Jail which doesn't exist.");
|
||||
}else if(j.isValidCell(name)) {
|
||||
pl.getLogger().warning("Refusing to load a duplicate named cell, " + name + ", as another one exists with that same name.");
|
||||
} else {
|
||||
Cell c = new Cell(name);
|
||||
|
||||
if(!teleport.isEmpty()) {
|
||||
String[] l = teleport.split(",");
|
||||
c.setTeleport(new SimpleLocation(j.getWorldName(), l[0], l[1], l[2]));
|
||||
}else {
|
||||
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has an empty teleport spot, might be buggy.");
|
||||
}
|
||||
if(!teleport.isEmpty()) {
|
||||
String[] l = teleport.split(",");
|
||||
c.setTeleport(new SimpleLocation(j.getWorldName(), l[0], l[1], l[2]));
|
||||
}else {
|
||||
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has an empty teleport spot, might be buggy.");
|
||||
}
|
||||
|
||||
if(!chest.isEmpty()) {
|
||||
String[] ch = chest.split(",");
|
||||
c.setChestLocation(new Location(j.getWorld(), Double.valueOf(ch[0]), Double.valueOf(ch[1]), Double.valueOf(ch[2])));
|
||||
}else {
|
||||
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has no chest.");
|
||||
}
|
||||
if(!chest.isEmpty()) {
|
||||
String[] ch = chest.split(",");
|
||||
c.setChestLocation(new Location(j.getWorld(), Double.valueOf(ch[0]), Double.valueOf(ch[1]), Double.valueOf(ch[2])));
|
||||
}else {
|
||||
pl.getLogger().warning("Cell " + c.getName() + " in " + j.getName() + " has no chest.");
|
||||
}
|
||||
|
||||
if(!sign.isEmpty()) {
|
||||
for(String s : sign.split(";")) {
|
||||
pl.debug(s);
|
||||
String[] si = s.split(",");
|
||||
c.addSign(new SimpleLocation(j.getWorldName(), si[0], si[1], si[2]));
|
||||
}
|
||||
}
|
||||
if(!sign.isEmpty()) {
|
||||
for(String s : sign.split(";")) {
|
||||
pl.debug(s);
|
||||
String[] si = s.split(",");
|
||||
c.addSign(new SimpleLocation(j.getWorldName(), si[0], si[1], si[2]));
|
||||
}
|
||||
}
|
||||
|
||||
//Load the prisoner if he is a valid prisoner
|
||||
if(!player.isEmpty()) {
|
||||
Prisoner p = j.getPrisonerByLastKnownName(player);
|
||||
//Load the prisoner if he is a valid prisoner
|
||||
if(!player.isEmpty()) {
|
||||
Prisoner p = j.getPrisonerByLastKnownName(player);
|
||||
|
||||
if(p != null) {
|
||||
j.removePrisoner(p);
|
||||
c.setPrisoner(p);
|
||||
}
|
||||
}
|
||||
if(p != null) {
|
||||
j.removePrisoner(p);
|
||||
c.setPrisoner(p);
|
||||
}
|
||||
}
|
||||
|
||||
j.addCell(c, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
j.addCell(c, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set.close();
|
||||
ps.close();
|
||||
set.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public void DeleteZone(String z) throws SQLException {
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_zones WHERE name = ?");
|
||||
ps.setString(1, z);
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
ps.close();
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_zones WHERE name = ?");
|
||||
ps.setString(1, z);
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public void DeleteCell(int x, int y, int z) throws SQLException {
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_cells WHERE Teleport = ?");
|
||||
ps.setString(1, String.valueOf(x) + "," + String.valueOf(y) + "," + String.valueOf(z));
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_cells WHERE Teleport = ?");
|
||||
ps.setString(1, String.valueOf(x) + "," + String.valueOf(y) + "," + String.valueOf(z));
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
ps.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public void DeletePrisoner(String p) throws SQLException {
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_prisoners WHERE PlayerName = ?");
|
||||
ps.setString(1, p);
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
Connection conn = getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement("DELETE FROM jail_prisoners WHERE PlayerName = ?");
|
||||
ps.setString(1, p);
|
||||
ps.executeUpdate();
|
||||
conn.commit();
|
||||
|
||||
ps.close();
|
||||
ps.close();
|
||||
}
|
||||
}
|
||||
|
@ -5,98 +5,98 @@ import java.util.Arrays;
|
||||
|
||||
public enum OldSetting {
|
||||
|
||||
Debug("Debug", false),//done
|
||||
BroadcastJailMessage("Broadcast Jail Message", false),//done
|
||||
AllowUpdateNotifications("AllowUpdateNotifications", true),//done
|
||||
ExecutedCommandsOnJail("ExecutedCommandsOnJail", new ArrayList<String>()),//done
|
||||
ExecutedCommandsOnRelease("ExecutedCommandsOnRelease", new ArrayList<String>()),//done
|
||||
AutomaticMute("AutomaticMute", false),//done
|
||||
StoreInventory("StoreInventory", true),//done
|
||||
CanPrisonerOpenHisChest("CanPrisonerOpenHisChest", true),//done
|
||||
LogJailingIntoConsole("LogJailingIntoConsole", false),//done
|
||||
CountdownTimeWhenOffline("CountdownTimeWhenOffline", false),//done
|
||||
ReleaseBackToPreviousPosition("ReleaseBackToPreviousPosition", false),//done
|
||||
IgnorePrisonersSleepingState("IgnorePrisonersSleepingState", true),//done
|
||||
TeleportPrisonerOnRelease("TeleportPrisonerOnRelease", true),//done
|
||||
DefaultJailTime("DefaultJailTime", -1),//done
|
||||
UseBukkitSchedulerTimer("UseBukkitSchedulerTimer", true),//done
|
||||
JailCheckPrisonersPerPage("JailCheckPrisonersPerPage", 15),//TODO
|
||||
Debug("Debug", false),//done
|
||||
BroadcastJailMessage("Broadcast Jail Message", false),//done
|
||||
AllowUpdateNotifications("AllowUpdateNotifications", true),//done
|
||||
ExecutedCommandsOnJail("ExecutedCommandsOnJail", new ArrayList<String>()),//done
|
||||
ExecutedCommandsOnRelease("ExecutedCommandsOnRelease", new ArrayList<String>()),//done
|
||||
AutomaticMute("AutomaticMute", false),//done
|
||||
StoreInventory("StoreInventory", true),//done
|
||||
CanPrisonerOpenHisChest("CanPrisonerOpenHisChest", true),//done
|
||||
LogJailingIntoConsole("LogJailingIntoConsole", false),//done
|
||||
CountdownTimeWhenOffline("CountdownTimeWhenOffline", false),//done
|
||||
ReleaseBackToPreviousPosition("ReleaseBackToPreviousPosition", false),//done
|
||||
IgnorePrisonersSleepingState("IgnorePrisonersSleepingState", true),//done
|
||||
TeleportPrisonerOnRelease("TeleportPrisonerOnRelease", true),//done
|
||||
DefaultJailTime("DefaultJailTime", -1),//done
|
||||
UseBukkitSchedulerTimer("UseBukkitSchedulerTimer", true),//done
|
||||
JailCheckPrisonersPerPage("JailCheckPrisonersPerPage", 15),//TODO
|
||||
|
||||
//JailStick
|
||||
EnableJailStick("EnableJailStick", false),//done
|
||||
JailStickParameters("JailStickParameters", "280,5,10,,police;50,5,20,,admin"),//done
|
||||
//JailStick
|
||||
EnableJailStick("EnableJailStick", false),//done
|
||||
JailStickParameters("JailStickParameters", "280,5,10,,police;50,5,20,,admin"),//done
|
||||
|
||||
//Protections
|
||||
EnableBlockDestroyProtection("Protections.EnableBlockDestroyProtection", true),//done
|
||||
BlockDestroyPenalty("Protections.BlockDestroyPenalty", 15),//done
|
||||
BlockDestroyProtectionExceptions("Protections.BlockDestroyProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
|
||||
EnableBlockPlaceProtection("Protections.EnableBlockPlaceProtection", true),//done
|
||||
BlockPlacePenalty("Protections.BlockPlacePenalty", 10),//done
|
||||
BlockPlaceProtectionExceptions("Protections.BlockPlaceProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
|
||||
EnablePlayerMoveProtection("Protections.EnablePlayerMoveProtection", true),//done
|
||||
PlayerMoveProtectionPenalty("Protections.PlayerMoveProtectionPenalty", 30),//done
|
||||
PlayerMoveProtectionAction("Protections.PlayerMoveProtectionAction", "teleport"),//TODO
|
||||
WhitelistedCommands("Protections.WhitelistedCommands", new ArrayList<String>()),//done
|
||||
CommandProtectionPenalty("Protections.CommandProtectionPenalty", 10),//done
|
||||
InteractionPenalty("Protections.InteractionPenalty", 10),//done
|
||||
EnableExplosionProtection("Protections.EnableExplosionProtection", true),//done
|
||||
EnablePVPProtection("Protections.EnablePVPProtection", true),//TODO: ??? I haven't even tested this out!!!!
|
||||
EnableChangingPermissions("Protections.EnableChangingPermissions", false),//TODO
|
||||
PrisonersPermissionsGroups("Protections.PrisonersPermissionsGroups", Arrays.asList("prisoners")),//TODO
|
||||
RestorePermissionsToEscapedPrisoners("Protections.RestorePermissionsToEscapedPrisoners", true),//TODO
|
||||
EnableFoodControl("Protections.EnableFoodControl", true),//done
|
||||
FoodControlMinimumFood("Protections.FoodControlMinimumFood", 10),//done
|
||||
FoodControlMaximumFood("Protections.FoodControlMaximumFood", 20),//done
|
||||
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
|
||||
//Protections
|
||||
EnableBlockDestroyProtection("Protections.EnableBlockDestroyProtection", true),//done
|
||||
BlockDestroyPenalty("Protections.BlockDestroyPenalty", 15),//done
|
||||
BlockDestroyProtectionExceptions("Protections.BlockDestroyProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
|
||||
EnableBlockPlaceProtection("Protections.EnableBlockPlaceProtection", true),//done
|
||||
BlockPlacePenalty("Protections.BlockPlacePenalty", 10),//done
|
||||
BlockPlaceProtectionExceptions("Protections.BlockPlaceProtectionExceptions", Arrays.asList(new String[]{"59"})),//done
|
||||
EnablePlayerMoveProtection("Protections.EnablePlayerMoveProtection", true),//done
|
||||
PlayerMoveProtectionPenalty("Protections.PlayerMoveProtectionPenalty", 30),//done
|
||||
PlayerMoveProtectionAction("Protections.PlayerMoveProtectionAction", "teleport"),//TODO
|
||||
WhitelistedCommands("Protections.WhitelistedCommands", new ArrayList<String>()),//done
|
||||
CommandProtectionPenalty("Protections.CommandProtectionPenalty", 10),//done
|
||||
InteractionPenalty("Protections.InteractionPenalty", 10),//done
|
||||
EnableExplosionProtection("Protections.EnableExplosionProtection", true),//done
|
||||
EnablePVPProtection("Protections.EnablePVPProtection", true),//TODO: ??? I haven't even tested this out!!!!
|
||||
EnableChangingPermissions("Protections.EnableChangingPermissions", false),//TODO
|
||||
PrisonersPermissionsGroups("Protections.PrisonersPermissionsGroups", Arrays.asList("prisoners")),//TODO
|
||||
RestorePermissionsToEscapedPrisoners("Protections.RestorePermissionsToEscapedPrisoners", true),//TODO
|
||||
EnableFoodControl("Protections.EnableFoodControl", true),//done
|
||||
FoodControlMinimumFood("Protections.FoodControlMinimumFood", 10),//done
|
||||
FoodControlMaximumFood("Protections.FoodControlMaximumFood", 20),//done
|
||||
PrisonersRecieveMessages("Protections.PlayerRecievesMessages", true), //done
|
||||
|
||||
//JailPay
|
||||
PricePerMinute("JailPay.PricePerMinute", 10),//done
|
||||
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//done
|
||||
JailPayCurrency("JailPay.Currency", 0),//done
|
||||
//JailPay
|
||||
PricePerMinute("JailPay.PricePerMinute", 10),//done
|
||||
PriceForInfiniteJail("JailPay.PriceForInfiniteJail", 9999),//done
|
||||
JailPayCurrency("JailPay.Currency", 0),//done
|
||||
|
||||
//Guards
|
||||
GuardHealth("Guards.GuardHealth", 8),//TODO
|
||||
GuardArmor("Guards.GuardArmor", 0),//TODO
|
||||
GuardDamage("Guards.GuardDamage", 2),//TODO
|
||||
NumbefOfGuards("Guards.NumberOfGuards", 3),//TODO
|
||||
GuardInvincibility("Guards.GuardInvincibility", false),//TODO
|
||||
GuardAttackSpeedPercent("Guards.GuardAttackSpeedPercent", 100),//TODO
|
||||
RespawnGuards("Guards.RespawnGuards", true),//TODO
|
||||
GuardTeleportDistance("Guards.GuardTeleportDistance", 10),//TODO
|
||||
GuardTypes("Guards.GuardTypes", Arrays.asList(new String[] { "Zombie", "Silverfish" })),//TODO
|
||||
//Guards
|
||||
GuardHealth("Guards.GuardHealth", 8),//TODO
|
||||
GuardArmor("Guards.GuardArmor", 0),//TODO
|
||||
GuardDamage("Guards.GuardDamage", 2),//TODO
|
||||
NumbefOfGuards("Guards.NumberOfGuards", 3),//TODO
|
||||
GuardInvincibility("Guards.GuardInvincibility", false),//TODO
|
||||
GuardAttackSpeedPercent("Guards.GuardAttackSpeedPercent", 100),//TODO
|
||||
RespawnGuards("Guards.RespawnGuards", true),//TODO
|
||||
GuardTeleportDistance("Guards.GuardTeleportDistance", 10),//TODO
|
||||
GuardTypes("Guards.GuardTypes", Arrays.asList(new String[] { "Zombie", "Silverfish" })),//TODO
|
||||
|
||||
//Database
|
||||
UseMySQL("Database.UseMySQL", false),//done
|
||||
MySQLConn("Database.MySQLConn", "jdbc:mysql://localhost:3306/minecraft"),//done
|
||||
MySQLUsername("Database.MySQLUSername", "root"),//done
|
||||
MySQLPassword("Database.MySQLPassword", "password"),//done
|
||||
//Database
|
||||
UseMySQL("Database.UseMySQL", false),//done
|
||||
MySQLConn("Database.MySQLConn", "jdbc:mysql://localhost:3306/minecraft"),//done
|
||||
MySQLUsername("Database.MySQLUSername", "root"),//done
|
||||
MySQLPassword("Database.MySQLPassword", "password"),//done
|
||||
|
||||
//Jail Vote
|
||||
VoteJailEnabled("Jail Vote.Enabled", true),//TODO
|
||||
VoteJailTime("Jail Vote.Time", 5),//TODO
|
||||
VoteJailReason("Jail Vote.Reason", "Jailed by players"),//TODO
|
||||
VoteJailVoteTime("Jail Vote.Vote Time", 60),//TODO
|
||||
//Jail Vote
|
||||
VoteJailEnabled("Jail Vote.Enabled", true),//TODO
|
||||
VoteJailTime("Jail Vote.Time", 5),//TODO
|
||||
VoteJailReason("Jail Vote.Reason", "Jailed by players"),//TODO
|
||||
VoteJailVoteTime("Jail Vote.Vote Time", 60),//TODO
|
||||
|
||||
//Jail swearing
|
||||
//Jail swearing
|
||||
EnableJailSwear("Jail Swear.Enabled", false),//TODO
|
||||
JailSwearTime("Jail Swear.Time", 10),//TODO
|
||||
BannedWords("Jail Swear.Banned Words", Arrays.asList(new String[] {"shit", "crap", "fuck", "cunt"}));//TODO
|
||||
|
||||
private String name;
|
||||
private Object def;
|
||||
private String name;
|
||||
private Object def;
|
||||
|
||||
private OldSetting(String Name, Object Def) {
|
||||
name = Name;
|
||||
def = Def;
|
||||
}
|
||||
private OldSetting(String Name, Object Def) {
|
||||
name = Name;
|
||||
def = Def;
|
||||
}
|
||||
|
||||
/** The string of the node the value is stored at in the config. */
|
||||
public String getString() {
|
||||
return name;
|
||||
}
|
||||
/** The string of the node the value is stored at in the config. */
|
||||
public String getString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/** The default value for this config. */
|
||||
public Object getDefault() {
|
||||
return def;
|
||||
}
|
||||
/** The default value for this config. */
|
||||
public Object getDefault() {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
@ -6,28 +6,28 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
public class OldSettings {
|
||||
|
||||
public static Object getGlobalProperty(YamlConfiguration config, OldSetting setting) {
|
||||
Object property = config.get(setting.getString());
|
||||
if (property == null) {
|
||||
property = setting.getDefault();
|
||||
}
|
||||
public static Object getGlobalProperty(YamlConfiguration config, OldSetting setting) {
|
||||
Object property = config.get(setting.getString());
|
||||
if (property == null) {
|
||||
property = setting.getDefault();
|
||||
}
|
||||
|
||||
return property;
|
||||
}
|
||||
return property;
|
||||
}
|
||||
|
||||
public static Boolean getGlobalBoolean(YamlConfiguration config, OldSetting setting) {
|
||||
return (Boolean) getGlobalProperty(config, setting);
|
||||
}
|
||||
public static Boolean getGlobalBoolean(YamlConfiguration config, OldSetting setting) {
|
||||
return (Boolean) getGlobalProperty(config, setting);
|
||||
}
|
||||
|
||||
public static Integer getGlobalInt(YamlConfiguration config, OldSetting setting) {
|
||||
return (Integer) getGlobalProperty(config, setting);
|
||||
}
|
||||
public static Integer getGlobalInt(YamlConfiguration config, OldSetting setting) {
|
||||
return (Integer) getGlobalProperty(config, setting);
|
||||
}
|
||||
|
||||
public static String getGlobalString(YamlConfiguration config, OldSetting setting) {
|
||||
return (String) getGlobalProperty(config, setting);
|
||||
}
|
||||
public static String getGlobalString(YamlConfiguration config, OldSetting setting) {
|
||||
return (String) getGlobalProperty(config, setting);
|
||||
}
|
||||
|
||||
public static List<?> getGlobalList(YamlConfiguration config, OldSetting setting) {
|
||||
return (List<?>) getGlobalProperty(config, setting);
|
||||
}
|
||||
public static List<?> getGlobalList(YamlConfiguration config, OldSetting setting) {
|
||||
return (List<?>) getGlobalProperty(config, setting);
|
||||
}
|
||||
}
|
||||
|
@ -10,51 +10,51 @@ import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public BlockListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public BlockListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
//If we're in debugging mode, let's send the player what block they're breaking.
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
//If we're in debugging mode, let's send the player what block they're breaking.
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());
|
||||
|
||||
//If we are protecting against block breaking, then let's do the action.
|
||||
//If we're not, let's not use any processing power to get the jail
|
||||
//where this block was broke at
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath())) {
|
||||
//If there is no jail let's skedaddle
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
||||
//If we are protecting against block breaking, then let's do the action.
|
||||
//If we're not, let's not use any processing power to get the jail
|
||||
//where this block was broke at
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath())) {
|
||||
//If there is no jail let's skedaddle
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
||||
|
||||
//If the player doesn't have permission to modify the jail,
|
||||
//then we stop it here. We won't be doing any of the additions to
|
||||
//a prisoner's sentence here as that's for the protections listener
|
||||
if(!event.getPlayer().hasPermission("jail.modifyjail")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
//If the player doesn't have permission to modify the jail,
|
||||
//then we stop it here. We won't be doing any of the additions to
|
||||
//a prisoner's sentence here as that's for the protections listener
|
||||
if(!event.getPlayer().hasPermission("jail.modifyjail")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
|
||||
public void blockPlace(BlockPlaceEvent event) {
|
||||
//If we're in debugging mode, let's send the player what block they're placing.
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.HIGHEST)
|
||||
public void blockPlace(BlockPlaceEvent event) {
|
||||
//If we're in debugging mode, let's send the player what block they're placing.
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: " + event.getBlock().getType().toString());
|
||||
|
||||
//If we are protecting against block placing, then let's do the action.
|
||||
//If we're not, let's not use any processing power to get the jail
|
||||
//where this block was placed at
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath())) {
|
||||
//If there is no jail let's skedaddle
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
||||
//If we are protecting against block placing, then let's do the action.
|
||||
//If we're not, let's not use any processing power to get the jail
|
||||
//where this block was placed at
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath())) {
|
||||
//If there is no jail let's skedaddle
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
||||
|
||||
//If the player doesn't have permission to modify the jail,
|
||||
//then we stop it here. We won't be doing any of the additions to
|
||||
//a prisoner's sentence here as that's for the protections listener
|
||||
if(!event.getPlayer().hasPermission("jail.modifyjail")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
//If the player doesn't have permission to modify the jail,
|
||||
//then we stop it here. We won't be doing any of the additions to
|
||||
//a prisoner's sentence here as that's for the protections listener
|
||||
if(!event.getPlayer().hasPermission("jail.modifyjail")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,57 +31,57 @@ import com.graywolf336.jail.events.PrisonerTransferredEvent;
|
||||
*
|
||||
*/
|
||||
public class CacheListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public CacheListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public CacheListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void joinListener(PlayerJoinEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void joinListener(PlayerJoinEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(j, p));
|
||||
}
|
||||
}
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(j, p));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void leaveListener(PlayerQuitEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void leaveListener(PlayerQuitEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void kickListener(PlayerKickEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void kickListener(PlayerKickEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void jailListener(PrisonerJailedEvent event) {
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(event.getJail(), event.getPrisoner()));
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void jailListener(PrisonerJailedEvent event) {
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(event.getJail(), event.getPrisoner()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void beforeReleaseListener(PrePrisonerReleasedEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void beforeReleaseListener(PrePrisonerReleasedEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void beforeTransferringListener(PrePrisonerTransferredEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void beforeTransferringListener(PrePrisonerTransferredEvent event) {
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
pl.getJailManager().removeCacheObject(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void transferListener(PrisonerTransferredEvent event) {
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(event.getTargetJail(), event.getPrisoner()));
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void transferListener(PrisonerTransferredEvent event) {
|
||||
pl.getJailManager().addCacheObject(new CachePrisoner(event.getTargetJail(), event.getPrisoner()));
|
||||
}
|
||||
}
|
||||
|
@ -10,39 +10,39 @@ import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class EntityListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public EntityListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public EntityListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
//Only do the checking if plugin has it enabled
|
||||
//otherwise let's not go through all the blocks
|
||||
if(pl.getConfig().getBoolean(Settings.EXPLOSIONPROTECTION.getPath())) {
|
||||
//Loop through the blocklist and do stuff
|
||||
for(Block b : event.blockList()) {
|
||||
//Check the current block and if it is inside a jail,
|
||||
//then let's do something else
|
||||
if(pl.getJailManager().getJailFromLocation(b.getLocation()) != null) {
|
||||
//Clear the blocklist, this way the explosion effect still happens
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
//Only do the checking if plugin has it enabled
|
||||
//otherwise let's not go through all the blocks
|
||||
if(pl.getConfig().getBoolean(Settings.EXPLOSIONPROTECTION.getPath())) {
|
||||
//Loop through the blocklist and do stuff
|
||||
for(Block b : event.blockList()) {
|
||||
//Check the current block and if it is inside a jail,
|
||||
//then let's do something else
|
||||
if(pl.getJailManager().getJailFromLocation(b.getLocation()) != null) {
|
||||
//Clear the blocklist, this way the explosion effect still happens
|
||||
event.blockList().clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void protectFromEndermen(EntityChangeBlockEvent event) {
|
||||
//If we are protecting the jails from endermen protection
|
||||
if(pl.getConfig().getBoolean(Settings.ENDERMENPROTECTION.getPath())) {
|
||||
//Check if there are any jails where the block's location is
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) != null) {
|
||||
//Let's cancel the event so it doesn't happen
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void protectFromEndermen(EntityChangeBlockEvent event) {
|
||||
//If we are protecting the jails from endermen protection
|
||||
if(pl.getConfig().getBoolean(Settings.ENDERMENPROTECTION.getPath())) {
|
||||
//Check if there are any jails where the block's location is
|
||||
if(pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) != null) {
|
||||
//Let's cancel the event so it doesn't happen
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,97 +16,97 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import com.graywolf336.jail.JailMain;
|
||||
|
||||
public class HandCuffListener implements Listener {
|
||||
private JailMain pl;
|
||||
private HashMap<String, Location> tos;
|
||||
private JailMain pl;
|
||||
private HashMap<String, Location> tos;
|
||||
|
||||
public HandCuffListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.tos = new HashMap<String, Location>();
|
||||
}
|
||||
public HandCuffListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.tos = new HashMap<String, Location>();
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
to.setPitch(event.getTo().getPitch());
|
||||
to.setYaw(event.getTo().getYaw());
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
to.setPitch(event.getTo().getPitch());
|
||||
to.setYaw(event.getTo().getYaw());
|
||||
|
||||
tos.put(event.getPlayer().getName(), to);
|
||||
event.getPlayer().teleport(to);
|
||||
tos.put(event.getPlayer().getName(), to);
|
||||
event.getPlayer().teleport(to);
|
||||
|
||||
if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(event.getTo() != tos.get(event.getPlayer().getName())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
to.setPitch(event.getTo().getPitch());
|
||||
to.setYaw(event.getTo().getYaw());
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(event.getTo() != tos.get(event.getPlayer().getName())) {
|
||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||
to.setPitch(event.getTo().getPitch());
|
||||
to.setYaw(event.getTo().getYaw());
|
||||
|
||||
tos.put(event.getPlayer().getName(), to);
|
||||
event.getPlayer().teleport(to);
|
||||
tos.put(event.getPlayer().getName(), to);
|
||||
event.getPlayer().teleport(to);
|
||||
|
||||
if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void playerChat(AsyncPlayerChatEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void playerChat(AsyncPlayerChatEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(!event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to talk!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(!event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to talk!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void blockBreak(BlockBreakEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to break blocks!");
|
||||
}
|
||||
}
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to break blocks!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void blockPlace(BlockPlaceEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void blockPlace(BlockPlaceEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to place blocks!");
|
||||
}
|
||||
}
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to place blocks!");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preCommands(PlayerCommandPreprocessEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preCommands(PlayerCommandPreprocessEvent event) {
|
||||
if(event.isCancelled()) return;
|
||||
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(!event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||
if(!event.getMessage().startsWith("/r") || !event.getMessage().startsWith("/reply")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to use commands!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||
if(!event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||
if(!event.getMessage().startsWith("/r") || !event.getMessage().startsWith("/reply")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to use commands!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,100 +19,100 @@ import com.graywolf336.jail.events.PrePrisonerJailedEvent;
|
||||
import com.graywolf336.jail.events.PrisonerJailedEvent;
|
||||
|
||||
public class JailingListener implements Listener {
|
||||
private JailMain pl;
|
||||
private DateFormat dateFormat;
|
||||
private JailMain pl;
|
||||
private DateFormat dateFormat;
|
||||
|
||||
public JailingListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.dateFormat = new SimpleDateFormat(Lang.TIMEFORMAT.get());
|
||||
}
|
||||
public JailingListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
this.dateFormat = new SimpleDateFormat(Lang.TIMEFORMAT.get());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath())) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath())) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath())) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void preJailingListener(PrePrisonerJailedByJailStickEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath())) {
|
||||
pl.getJailIO().addRecordEntry(event.getPrisoner().getUUID().toString(),
|
||||
event.getPrisoner().getLastKnownName(),
|
||||
event.getPrisoner().getJailer(), dateFormat.format(new Date()),
|
||||
event.getPrisoner().getRemainingTimeInMinutes(), event.getPrisoner().getReason());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void setInmatesClothing(PrisonerJailedEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath())) {
|
||||
String[] helmet = pl.getConfig().getString(Settings.CLOTHINGHELMET.getPath()).toUpperCase().split("~");
|
||||
switch(helmet.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.valueOf(helmet[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(helmet[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = helmet[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setHelmet(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@EventHandler
|
||||
public void setInmatesClothing(PrisonerJailedEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath())) {
|
||||
String[] helmet = pl.getConfig().getString(Settings.CLOTHINGHELMET.getPath()).toUpperCase().split("~");
|
||||
switch(helmet.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.valueOf(helmet[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(helmet[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = helmet[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setHelmet(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
String[] chest = pl.getConfig().getString(Settings.CLOTHINGCHEST.getPath()).toUpperCase().split("~");
|
||||
switch(chest.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.valueOf(chest[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(chest[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = chest[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setChestplate(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String[] chest = pl.getConfig().getString(Settings.CLOTHINGCHEST.getPath()).toUpperCase().split("~");
|
||||
switch(chest.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.valueOf(chest[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(chest[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = chest[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setChestplate(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
String[] legs = pl.getConfig().getString(Settings.CLOTHINGLEGS.getPath()).toUpperCase().split("~");
|
||||
switch(legs.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.valueOf(legs[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(legs[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = legs[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setLeggings(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
String[] legs = pl.getConfig().getString(Settings.CLOTHINGLEGS.getPath()).toUpperCase().split("~");
|
||||
switch(legs.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.valueOf(legs[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(legs[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = legs[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setLeggings(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
String[] boots = pl.getConfig().getString(Settings.CLOTHINGBOOTS.getPath()).toUpperCase().split("~");
|
||||
switch(boots.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setBoots(new ItemStack(Material.valueOf(boots[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(boots[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = boots[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setBoots(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] boots = pl.getConfig().getString(Settings.CLOTHINGBOOTS.getPath()).toUpperCase().split("~");
|
||||
switch(boots.length) {
|
||||
case 1:
|
||||
event.getPlayer().getInventory().setBoots(new ItemStack(Material.valueOf(boots[0])));
|
||||
break;
|
||||
case 2:
|
||||
ItemStack item = new ItemStack(Material.valueOf(boots[0]));
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) item.getItemMeta();
|
||||
String[] colors = boots[1].split(",");
|
||||
meta.setColor(Color.fromBGR(Integer.parseInt(colors[2]), Integer.parseInt(colors[1]), Integer.parseInt(colors[0])));
|
||||
item.setItemMeta(meta);
|
||||
event.getPlayer().getInventory().setBoots(item);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,72 +16,72 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class MoveProtectionListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public MoveProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public MoveProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void moveProtection(PlayerMoveEvent event) {
|
||||
//If we have the move protection enabled, then let's do it.
|
||||
//Other wise we don't need to deal with it.
|
||||
if(pl.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
||||
//Let's be sure the player we're dealing with is in jail
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void moveProtection(PlayerMoveEvent event) {
|
||||
//If we have the move protection enabled, then let's do it.
|
||||
//Other wise we don't need to deal with it.
|
||||
if(pl.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
|
||||
//Let's be sure the player we're dealing with is in jail
|
||||
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
CachePrisoner cp = pl.getJailManager().getCacheObject(event.getPlayer().getUniqueId());
|
||||
Jail j = cp.getJail();
|
||||
Prisoner p = cp.getPrisoner();
|
||||
if(pl.getJailManager().inCache(event.getPlayer().getUniqueId())) {
|
||||
CachePrisoner cp = pl.getJailManager().getCacheObject(event.getPlayer().getUniqueId());
|
||||
Jail j = cp.getJail();
|
||||
Prisoner p = cp.getPrisoner();
|
||||
|
||||
//If the player is being teleported, let's ignore it
|
||||
if(p.isTeleporting()) {
|
||||
return;
|
||||
}
|
||||
//If the player is being teleported, let's ignore it
|
||||
if(p.isTeleporting()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//They moved, so they're no longer afk
|
||||
p.setAFKTime(0L);
|
||||
//They moved, so they're no longer afk
|
||||
p.setAFKTime(0L);
|
||||
|
||||
//If the event's to location is NOT inside the jail, then let's do some action.
|
||||
//For right now, we're only going to apply the time. Later we're going to do
|
||||
//the guards, but first get a beta version out.
|
||||
if (!j.isInside(event.getTo())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.MOVEPENALTY.getPath()));
|
||||
p.addTime(add);
|
||||
//If the event's to location is NOT inside the jail, then let's do some action.
|
||||
//For right now, we're only going to apply the time. Later we're going to do
|
||||
//the guards, but first get a beta version out.
|
||||
if (!j.isInside(event.getTo())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.MOVEPENALTY.getPath()));
|
||||
p.addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.MOVING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.MOVING.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.MOVING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.MOVING.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Moving (escaping) outside a jail penalty time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Moving (escaping) outside a jail penalty time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
//If the prisoner is in a cell, then let's teleport them to the cell's in location
|
||||
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
event.setTo(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport());
|
||||
}else {
|
||||
//Otherwise let's teleport them to the in location of the jail
|
||||
event.setTo(j.getTeleportIn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//If the prisoner is in a cell, then let's teleport them to the cell's in location
|
||||
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
event.setTo(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport());
|
||||
}else {
|
||||
//Otherwise let's teleport them to the in location of the jail
|
||||
event.setTo(j.getTeleportIn());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
PlayerMoveEvent move = new PlayerMoveEvent(event.getPlayer(), event.getFrom(), event.getTo());
|
||||
moveProtection(move);
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
PlayerMoveEvent move = new PlayerMoveEvent(event.getPlayer(), event.getFrom(), event.getTo());
|
||||
moveProtection(move);
|
||||
}
|
||||
}
|
||||
|
@ -33,252 +33,252 @@ import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
|
||||
import com.graywolf336.jail.events.PrisonerDeathEvent;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public PlayerListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public PlayerListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void jailOrCellCreation(PlayerInteractEvent event) {
|
||||
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Player p = event.getPlayer();
|
||||
Location loc = event.getClickedBlock() == null ? p.getLocation() : event.getClickedBlock().getLocation();
|
||||
JailManager jm = pl.getJailManager();
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void jailOrCellCreation(PlayerInteractEvent event) {
|
||||
if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Player p = event.getPlayer();
|
||||
Location loc = event.getClickedBlock() == null ? p.getLocation() : event.getClickedBlock().getLocation();
|
||||
JailManager jm = pl.getJailManager();
|
||||
|
||||
if(p.getItemInHand().isSimilar(Util.getWand())) {
|
||||
if(jm.isCreatingSomething(p.getName())) {
|
||||
if(jm.isCreatingAJail(p.getName())) {
|
||||
pl.debug("Stepping into creating a jail.");
|
||||
jm.getJailCreationSteps().step(jm, p, jm.getJailCreationPlayer(p.getName()), loc);
|
||||
}else if(jm.isCreatingACell(p.getName())) {
|
||||
pl.debug("Stepping into creating a cell.");
|
||||
jm.getCellCreationSteps().step(jm, p, jm.getCellCreationPlayer(p.getName()), loc);
|
||||
}
|
||||
if(p.getItemInHand().isSimilar(Util.getWand())) {
|
||||
if(jm.isCreatingSomething(p.getName())) {
|
||||
if(jm.isCreatingAJail(p.getName())) {
|
||||
pl.debug("Stepping into creating a jail.");
|
||||
jm.getJailCreationSteps().step(jm, p, jm.getJailCreationPlayer(p.getName()), loc);
|
||||
}else if(jm.isCreatingACell(p.getName())) {
|
||||
pl.debug("Stepping into creating a cell.");
|
||||
jm.getCellCreationSteps().step(jm, p, jm.getCellCreationPlayer(p.getName()), loc);
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void chatting(AsyncPlayerChatEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
if(pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).isMuted()) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(Lang.MUTED.get());
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void chatting(AsyncPlayerChatEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
if(pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).isMuted()) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(Lang.MUTED.get());
|
||||
}
|
||||
}
|
||||
|
||||
//If the config has receive messages set to false, let's remove all the prisoners
|
||||
//from getting the chat messages.
|
||||
if(!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
||||
Set<Player> rec = new HashSet<Player>(event.getRecipients());
|
||||
//If the config has receive messages set to false, let's remove all the prisoners
|
||||
//from getting the chat messages.
|
||||
if(!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
||||
Set<Player> rec = new HashSet<Player>(event.getRecipients());
|
||||
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
for(Prisoner p : j.getAllPrisoners().values())
|
||||
rec.remove(pl.getServer().getPlayer(p.getUUID()));
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
for(Prisoner p : j.getAllPrisoners().values())
|
||||
rec.remove(pl.getServer().getPlayer(p.getUUID()));
|
||||
|
||||
event.getRecipients().clear();
|
||||
event.getRecipients().addAll(rec);
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
||||
}
|
||||
}
|
||||
event.getRecipients().clear();
|
||||
event.getRecipients().addAll(rec);
|
||||
if(pl.inDebug()) pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void checkForOfflineJailStuff(PlayerJoinEvent event) {
|
||||
//Let's check if the player is jailed
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the prisoner object
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void checkForOfflineJailStuff(PlayerJoinEvent event) {
|
||||
//Let's check if the player is jailed
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the prisoner object
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
|
||||
if(!j.isEnabled()) {
|
||||
event.getPlayer().kickPlayer(Lang.WORLDUNLOADEDKICK.get());
|
||||
pl.getLogger().warning(j.getName() + " is located in a world which is unloaded and " + event.getPlayer().getName() + " (" + event.getPlayer().getUniqueId() + ") tried to join while jailed in it.");
|
||||
return;
|
||||
}
|
||||
if(!j.isEnabled()) {
|
||||
event.getPlayer().kickPlayer(Lang.WORLDUNLOADEDKICK.get());
|
||||
pl.getLogger().warning(j.getName() + " is located in a world which is unloaded and " + event.getPlayer().getName() + " (" + event.getPlayer().getUniqueId() + ") tried to join while jailed in it.");
|
||||
return;
|
||||
}
|
||||
|
||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||
//update their last known username when they login
|
||||
p.setLastKnownName(event.getPlayer().getName());
|
||||
Prisoner p = j.getPrisoner(event.getPlayer().getUniqueId());
|
||||
//update their last known username when they login
|
||||
p.setLastKnownName(event.getPlayer().getName());
|
||||
|
||||
//Check if they're offline pending, as if this is true then they were jailed offline
|
||||
if(p.isOfflinePending()) {
|
||||
if(p.getRemainingTime() == 0L) {
|
||||
//If their remaining time is 0, let's unjail them
|
||||
pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else if(p.isToBeTransferred()) {
|
||||
Cell c = j.getCellPrisonerIsIn(event.getPlayer().getUniqueId());
|
||||
//Check if they're offline pending, as if this is true then they were jailed offline
|
||||
if(p.isOfflinePending()) {
|
||||
if(p.getRemainingTime() == 0L) {
|
||||
//If their remaining time is 0, let's unjail them
|
||||
pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||
}else if(p.isToBeTransferred()) {
|
||||
Cell c = j.getCellPrisonerIsIn(event.getPlayer().getUniqueId());
|
||||
|
||||
//If the player is not jailed in a cell, teleport them to the jail's in
|
||||
if(c == null) {
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(j.getTeleportIn());
|
||||
p.setTeleporting(false);
|
||||
}else {
|
||||
//If they are in a cell, teleport them into that cell
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(c.getTeleport());
|
||||
p.setTeleporting(false);
|
||||
}
|
||||
//If the player is not jailed in a cell, teleport them to the jail's in
|
||||
if(c == null) {
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(j.getTeleportIn());
|
||||
p.setTeleporting(false);
|
||||
}else {
|
||||
//If they are in a cell, teleport them into that cell
|
||||
p.setTeleporting(true);
|
||||
event.getPlayer().teleport(c.getTeleport());
|
||||
p.setTeleporting(false);
|
||||
}
|
||||
|
||||
p.setToBeTransferred(false);
|
||||
} else {
|
||||
//Their remaining time isn't 0 so let's proceed with jailing of the prisoner
|
||||
pl.getPrisonerManager().jailPlayer(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
p.setToBeTransferred(false);
|
||||
} else {
|
||||
//Their remaining time isn't 0 so let's proceed with jailing of the prisoner
|
||||
pl.getPrisonerManager().jailPlayer(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
//Add the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), p);
|
||||
}
|
||||
//Add the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), p);
|
||||
}
|
||||
|
||||
//if we are ignoring a prisoner's sleeping state, then let's set that
|
||||
if(pl.getConfig().getBoolean(Settings.IGNORESLEEPINGSTATE.getPath())) {
|
||||
event.getPlayer().setSleepingIgnored(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
//if we are ignoring a prisoner's sleeping state, then let's set that
|
||||
if(pl.getConfig().getBoolean(Settings.IGNORESLEEPINGSTATE.getPath())) {
|
||||
event.getPlayer().setSleepingIgnored(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void notifyUpdate(PlayerJoinEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||
if(event.getPlayer().isOp() && pl.getUpdate().isAvailable()) {
|
||||
event.getPlayer().sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "An update for Jail is available: " + pl.getUpdate().getNewVersion());
|
||||
event.getPlayer().sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + pl.getUpdate().getFileUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void notifyUpdate(PlayerJoinEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath())) {
|
||||
if(event.getPlayer().isOp() && pl.getUpdate().isAvailable()) {
|
||||
event.getPlayer().sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + "An update for Jail is available: " + pl.getUpdate().getNewVersion());
|
||||
event.getPlayer().sendMessage(ChatColor.BLUE + "" + ChatColor.BOLD + pl.getUpdate().getFileUrl());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleGoingOffline(PlayerQuitEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Remove the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void handleGoingOffline(PlayerQuitEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Remove the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void handleGettingKicked(PlayerKickEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Remove the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void handleGettingKicked(PlayerKickEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Remove the scoreboard to them if it is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||
pl.getScoreBoardManager().removeScoreBoard(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void foodControl(FoodLevelChangeEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
|
||||
int min = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath());
|
||||
int max = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath());
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void foodControl(FoodLevelChangeEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
|
||||
int min = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath());
|
||||
int max = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath());
|
||||
|
||||
if (event.getFoodLevel() < min) {
|
||||
event.setFoodLevel(min);
|
||||
}else {
|
||||
event.setFoodLevel(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.getFoodLevel() < min) {
|
||||
event.setFoodLevel(min);
|
||||
}else {
|
||||
event.setFoodLevel(max);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getEntity().getUniqueId());
|
||||
@EventHandler
|
||||
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getEntity().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getEntity().getUniqueId());
|
||||
|
||||
PrisonerDeathEvent prisonerEvent = new PrisonerDeathEvent(event, j, j.getCellPrisonerIsIn(event.getEntity().getUniqueId()), j.getPrisoner(event.getEntity().getUniqueId()), event.getEntity());
|
||||
pl.getServer().getPluginManager().callEvent(prisonerEvent);
|
||||
}
|
||||
}
|
||||
PrisonerDeathEvent prisonerEvent = new PrisonerDeathEvent(event, j, j.getCellPrisonerIsIn(event.getEntity().getUniqueId()), j.getPrisoner(event.getEntity().getUniqueId()), event.getEntity());
|
||||
pl.getServer().getPluginManager().callEvent(prisonerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
|
||||
|
||||
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport());
|
||||
}else {
|
||||
event.setRespawnLocation(j.getTeleportIn());
|
||||
}
|
||||
}
|
||||
}
|
||||
if(j.isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
event.setRespawnLocation(j.getCellPrisonerIsIn(event.getPlayer().getUniqueId()).getTeleport());
|
||||
}else {
|
||||
event.setRespawnLocation(j.getTeleportIn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void jailStickHandling(EntityDamageByEntityEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
//If the damager and the entity getting damage is not a player,
|
||||
//we don't want to handle it in this method
|
||||
if(!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player)) return;
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void jailStickHandling(EntityDamageByEntityEvent event) {
|
||||
if(pl.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||
//If the damager and the entity getting damage is not a player,
|
||||
//we don't want to handle it in this method
|
||||
if(!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player)) return;
|
||||
|
||||
Player attacker = (Player) event.getDamager();
|
||||
Player player = (Player) event.getEntity();
|
||||
Player attacker = (Player) event.getDamager();
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if(pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) {
|
||||
if(pl.getJailStickManager().isValidStick(attacker.getItemInHand().getType())) {
|
||||
if(attacker.hasPermission("jail.usejailstick." + attacker.getItemInHand().getType().toString().toLowerCase())) {
|
||||
//The person the attacker is trying to jail stick is already jailed, don't handle that
|
||||
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
||||
}else {
|
||||
if(player.hasPermission("jail.cantbejailed")) {
|
||||
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
||||
}else {
|
||||
Stick s = pl.getJailStickManager().getStick(attacker.getItemInHand().getType());
|
||||
if(pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) {
|
||||
if(pl.getJailStickManager().isValidStick(attacker.getItemInHand().getType())) {
|
||||
if(attacker.hasPermission("jail.usejailstick." + attacker.getItemInHand().getType().toString().toLowerCase())) {
|
||||
//The person the attacker is trying to jail stick is already jailed, don't handle that
|
||||
if(pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
|
||||
}else {
|
||||
if(player.hasPermission("jail.cantbejailed")) {
|
||||
attacker.sendMessage(Lang.CANTBEJAILED.get());
|
||||
}else {
|
||||
Stick s = pl.getJailStickManager().getStick(attacker.getItemInHand().getType());
|
||||
|
||||
if(player.getHealth() <= s.getHealth() || s.getHealth() == -1) {
|
||||
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
||||
s.getTime(), attacker.getName(), s.getReason());
|
||||
if(player.getHealth() <= s.getHealth() || s.getHealth() == -1) {
|
||||
Prisoner p = new Prisoner(player.getUniqueId().toString(), player.getName(),
|
||||
pl.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()),
|
||||
s.getTime(), attacker.getName(), s.getReason());
|
||||
|
||||
PrePrisonerJailedByJailStickEvent jEvent = new PrePrisonerJailedByJailStickEvent(
|
||||
pl.getJailManager().getJail(s.getJail()), null, p, player, attacker.getName(), s);
|
||||
PrePrisonerJailedByJailStickEvent jEvent = new PrePrisonerJailedByJailStickEvent(
|
||||
pl.getJailManager().getJail(s.getJail()), null, p, player, attacker.getName(), s);
|
||||
|
||||
pl.getServer().getPluginManager().callEvent(jEvent);
|
||||
pl.getServer().getPluginManager().callEvent(jEvent);
|
||||
|
||||
if(jEvent.isCancelled()) {
|
||||
if(jEvent.getCancelledMessage().isEmpty())
|
||||
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
||||
else
|
||||
attacker.sendMessage(jEvent.getCancelledMessage());
|
||||
}else {
|
||||
//recall data from the event
|
||||
Jail j = jEvent.getJail();
|
||||
Cell c = jEvent.getCell();
|
||||
p = jEvent.getPrisoner();
|
||||
player = jEvent.getPlayer();
|
||||
if(jEvent.isCancelled()) {
|
||||
if(jEvent.getCancelledMessage().isEmpty())
|
||||
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
||||
else
|
||||
attacker.sendMessage(jEvent.getCancelledMessage());
|
||||
}else {
|
||||
//recall data from the event
|
||||
Jail j = jEvent.getJail();
|
||||
Cell c = jEvent.getCell();
|
||||
p = jEvent.getPrisoner();
|
||||
player = jEvent.getPlayer();
|
||||
|
||||
//Player is not online
|
||||
if(player == null) {
|
||||
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
//Player is not online
|
||||
if(player == null) {
|
||||
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}else {
|
||||
//Player *is* online
|
||||
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
|
||||
}
|
||||
|
||||
try {
|
||||
pl.getPrisonerManager().prepareJail(j, c, player, p);
|
||||
} catch (Exception e) {
|
||||
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
||||
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
pl.getPrisonerManager().prepareJail(j, c, player, p);
|
||||
} catch (Exception e) {
|
||||
attacker.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
|
||||
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,290 +18,290 @@ import com.graywolf336.jail.enums.Lang;
|
||||
import com.graywolf336.jail.enums.Settings;
|
||||
|
||||
public class ProtectionListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public ProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public ProtectionListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void protectionBlockBreaking(BlockBreakEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath())) {
|
||||
//Let's check if the player is jailed, otherwise the other listener
|
||||
//in the BlockListener class will take care of protecting inside
|
||||
//of the jails.
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the breaking whitelist, check if the current item is in there
|
||||
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKBREAKWHITELIST.getPath()),
|
||||
event.getBlock().getType().toString().toLowerCase())) {
|
||||
//As our Util.getTime throws an exception when the time is in an
|
||||
//incorrect format, we catch the exception and don't add any time
|
||||
//as a fail safe, don't want us to go crazy adding tons of time.
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void protectionBlockBreaking(BlockBreakEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath())) {
|
||||
//Let's check if the player is jailed, otherwise the other listener
|
||||
//in the BlockListener class will take care of protecting inside
|
||||
//of the jails.
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the breaking whitelist, check if the current item is in there
|
||||
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKBREAKWHITELIST.getPath()),
|
||||
event.getBlock().getType().toString().toLowerCase())) {
|
||||
//As our Util.getTime throws an exception when the time is in an
|
||||
//incorrect format, we catch the exception and don't add any time
|
||||
//as a fail safe, don't want us to go crazy adding tons of time.
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.BLOCKBREAKING.get());
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKBREAKING.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.BLOCKBREAKING.get());
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKBREAKING.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Block break penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Block break penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
//Stop the event from happening, as the block wasn't in the whitelist
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Stop the event from happening, as the block wasn't in the whitelist
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void protectionBlockPlacing(BlockPlaceEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath())) {
|
||||
//Let's check if the player is jailed, otherwise the other listener
|
||||
//in the BlockListener class will take care of protecting inside
|
||||
//of the jails.
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the placing whitelist, check if the current item is in there
|
||||
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKPLACEWHITELIST.getPath()),
|
||||
event.getBlock().getType().toString().toLowerCase())) {
|
||||
//As our Util.getTime throws an exception when the time is in an
|
||||
//incorrect format, we catch the exception and don't add any time
|
||||
//as a fail safe, don't want us to go crazy adding tons of time.
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void protectionBlockPlacing(BlockPlaceEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath())) {
|
||||
//Let's check if the player is jailed, otherwise the other listener
|
||||
//in the BlockListener class will take care of protecting inside
|
||||
//of the jails.
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Get the placing whitelist, check if the current item is in there
|
||||
if(!Util.isStringInsideList(pl.getConfig().getStringList(Settings.BLOCKPLACEWHITELIST.getPath()),
|
||||
event.getBlock().getType().toString().toLowerCase())) {
|
||||
//As our Util.getTime throws an exception when the time is in an
|
||||
//incorrect format, we catch the exception and don't add any time
|
||||
//as a fail safe, don't want us to go crazy adding tons of time.
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.BLOCKPLACING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKPLACING.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.BLOCKPLACING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKPLACING.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Block place penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Block place penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
//Stop the event from happening, as the block wasn't in the whitelist
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Stop the event from happening, as the block wasn't in the whitelist
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void commandProtection(PlayerCommandPreprocessEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.COMMANDPROTECTION.getPath())) {
|
||||
//Let's check if this player is jailed, if so then we continue
|
||||
//otherwise we don't care about commands in here
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
boolean match = false;
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void commandProtection(PlayerCommandPreprocessEvent event) {
|
||||
//Before we check if the player is jailed, let's save a
|
||||
//tiny bit of resources and check if this protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.COMMANDPROTECTION.getPath())) {
|
||||
//Let's check if this player is jailed, if so then we continue
|
||||
//otherwise we don't care about commands in here
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
boolean match = false;
|
||||
|
||||
for(String whited : pl.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath()))
|
||||
if(event.getMessage().toLowerCase().startsWith(whited.toLowerCase()))
|
||||
match = true;
|
||||
for(String whited : pl.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath()))
|
||||
if(event.getMessage().toLowerCase().startsWith(whited.toLowerCase()))
|
||||
match = true;
|
||||
|
||||
//If no match found in the whitelist, then let's block this command.
|
||||
if(!match) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
//If no match found in the whitelist, then let's block this command.
|
||||
if(!match) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.COMMAND);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.COMMAND.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.COMMAND);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.COMMAND.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Command Protection penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Command Protection penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
//Stop the command from happening, as it wasn't whitelisted
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Stop the command from happening, as it wasn't whitelisted
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void chestProtection(PlayerInteractEvent event) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Next, let's check if it is a chest and if they're in a cell
|
||||
//If they are in a cell and are opening a chest, then we check
|
||||
//the config to see if they can open the chests
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) {
|
||||
//Let's get the cell the player is in, then check if it is null or not.
|
||||
if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId()).isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
if(pl.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath())) {
|
||||
//The prisoner is in a cell, so let's check if it is a couple chest.
|
||||
Material bpos1 = event.getClickedBlock().getLocation().add(-1, 0, 0).getBlock().getType();
|
||||
Material bpos2 = event.getClickedBlock().getLocation().add(+1, 0, 0).getBlock().getType();
|
||||
Material bpos3 = event.getClickedBlock().getLocation().add(0, 0, -1).getBlock().getType();
|
||||
Material bpos4 = event.getClickedBlock().getLocation().add(0, 0, +1).getBlock().getType();
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void chestProtection(PlayerInteractEvent event) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Next, let's check if it is a chest and if they're in a cell
|
||||
//If they are in a cell and are opening a chest, then we check
|
||||
//the config to see if they can open the chests
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == Material.CHEST) {
|
||||
//Let's get the cell the player is in, then check if it is null or not.
|
||||
if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId()).isJailedInACell(event.getPlayer().getUniqueId())) {
|
||||
if(pl.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath())) {
|
||||
//The prisoner is in a cell, so let's check if it is a couple chest.
|
||||
Material bpos1 = event.getClickedBlock().getLocation().add(-1, 0, 0).getBlock().getType();
|
||||
Material bpos2 = event.getClickedBlock().getLocation().add(+1, 0, 0).getBlock().getType();
|
||||
Material bpos3 = event.getClickedBlock().getLocation().add(0, 0, -1).getBlock().getType();
|
||||
Material bpos4 = event.getClickedBlock().getLocation().add(0, 0, +1).getBlock().getType();
|
||||
|
||||
boolean pos1 = bpos1 == Material.CHEST || bpos1 == Material.TRAPPED_CHEST;
|
||||
boolean pos2 = bpos2 == Material.CHEST || bpos2 == Material.TRAPPED_CHEST;
|
||||
boolean pos3 = bpos3 == Material.CHEST || bpos3 == Material.TRAPPED_CHEST;
|
||||
boolean pos4 = bpos4 == Material.CHEST || bpos4 == Material.TRAPPED_CHEST;
|
||||
boolean pos1 = bpos1 == Material.CHEST || bpos1 == Material.TRAPPED_CHEST;
|
||||
boolean pos2 = bpos2 == Material.CHEST || bpos2 == Material.TRAPPED_CHEST;
|
||||
boolean pos3 = bpos3 == Material.CHEST || bpos3 == Material.TRAPPED_CHEST;
|
||||
boolean pos4 = bpos4 == Material.CHEST || bpos4 == Material.TRAPPED_CHEST;
|
||||
|
||||
if(pos1 || pos2 || pos3 || pos4) {
|
||||
//it is a double chest, so they're free to go!
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
||||
}else {
|
||||
//it is not a double chest, so we won't be allowing it.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
//the config has opening chests disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
//The prisoner is not in a cell, so let's not allow it. IF we get feedback from people who
|
||||
//use the plugin, this might get removed or permission node might be added.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pos1 || pos2 || pos3 || pos4) {
|
||||
//it is a double chest, so they're free to go!
|
||||
if(pl.inDebug()) event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
||||
}else {
|
||||
//it is not a double chest, so we won't be allowing it.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
//the config has opening chests disabled
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
//The prisoner is not in a cell, so let's not allow it. IF we get feedback from people who
|
||||
//use the plugin, this might get removed or permission node might be added.
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOWEST)
|
||||
public void cropTramplingProtection(PlayerInteractEvent event) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Next, check if crap trampling protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath())) {
|
||||
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL) {
|
||||
if(pl.getJailManager().getJailFromLocation(event.getClickedBlock().getLocation()) != null) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOWEST)
|
||||
public void cropTramplingProtection(PlayerInteractEvent event) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
//Next, check if crap trampling protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath())) {
|
||||
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL) {
|
||||
if(pl.getJailManager().getJailFromLocation(event.getClickedBlock().getLocation()) != null) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.CROPTRAMPLING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.CROPTRAMPLING.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.CROPTRAMPLING);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.CROPTRAMPLING.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Crop Trampling penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Crop Trampling penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void interactionProtection(PlayerInteractEvent event) {
|
||||
//As the old version didn't do anything with Physical interactions, we won't either
|
||||
if (event.getAction() != Action.PHYSICAL) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void interactionProtection(PlayerInteractEvent event) {
|
||||
//As the old version didn't do anything with Physical interactions, we won't either
|
||||
if (event.getAction() != Action.PHYSICAL) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
|
||||
|
||||
//Let's check if they've interacted with a block
|
||||
if (event.getClickedBlock() != null) {
|
||||
//Get the interaction blacklist, check if the current block is in there
|
||||
//if it is, then let's take action
|
||||
if(Util.isStringInsideList(pl.getConfig().getStringList(Settings.PREVENTINTERACTIONBLOCKS.getPath()),
|
||||
event.getClickedBlock().getType().toString().toLowerCase())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
//Let's check if they've interacted with a block
|
||||
if (event.getClickedBlock() != null) {
|
||||
//Get the interaction blacklist, check if the current block is in there
|
||||
//if it is, then let's take action
|
||||
if(Util.isStringInsideList(pl.getConfig().getStringList(Settings.PREVENTINTERACTIONBLOCKS.getPath()),
|
||||
event.getClickedBlock().getType().toString().toLowerCase())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.INTERACTIONBLOCKS);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONBLOCKS.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.INTERACTIONBLOCKS);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONBLOCKS.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Prevent Interaction with Blocks penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Prevent Interaction with Blocks penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}else if (event.getPlayer().getItemInHand() != null) {
|
||||
//Otherwise let's check if they have something in hand
|
||||
//Get the interaction blacklist, check if the current item is in there
|
||||
//if it is, then let's take action
|
||||
if(Util.isStringInsideList(pl.getConfig().getStringList(Settings.PREVENTINTERACTIONITEMS.getPath()),
|
||||
event.getClickedBlock().getType().toString().toLowerCase())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}else if (event.getPlayer().getItemInHand() != null) {
|
||||
//Otherwise let's check if they have something in hand
|
||||
//Get the interaction blacklist, check if the current item is in there
|
||||
//if it is, then let's take action
|
||||
if(Util.isStringInsideList(pl.getConfig().getStringList(Settings.PREVENTINTERACTIONITEMS.getPath()),
|
||||
event.getClickedBlock().getType().toString().toLowerCase())) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.PREVENTINTERACTIONITEMSPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
|
||||
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.INTERACTIONITEMS);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONITEMS.get() });
|
||||
}
|
||||
String msg = "";
|
||||
if(add == 0L) {
|
||||
//Generate the protection message, provide the method with one argument
|
||||
//which is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGENOPENALTY.get(Lang.INTERACTIONITEMS);
|
||||
}else {
|
||||
//Generate the protection message, provide the method with two arguments
|
||||
//First is the time in minutes and second is the thing we are protecting against
|
||||
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONITEMS.get() });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Prevent Interaction with Items penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch(Exception e) {
|
||||
pl.getLogger().severe("Prevent Interaction with Items penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,21 +10,21 @@ import com.graywolf336.jail.JailMain;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
|
||||
public class WorldListener implements Listener {
|
||||
private JailMain pl;
|
||||
private JailMain pl;
|
||||
|
||||
public WorldListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
public WorldListener(JailMain plugin) {
|
||||
this.pl = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void worldLoaded(WorldLoadEvent event) {
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
if(j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(true);
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void worldLoaded(WorldLoadEvent event) {
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
if(j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(true);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void worldUnload(WorldUnloadEvent event) {
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
if(j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(false);
|
||||
}
|
||||
@EventHandler(ignoreCancelled=true, priority = EventPriority.LOW)
|
||||
public void worldUnload(WorldUnloadEvent event) {
|
||||
for(Jail j : pl.getJailManager().getJails())
|
||||
if(j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
@ -24,134 +24,134 @@ import com.graywolf336.jail.beans.SimpleLocation;
|
||||
*/
|
||||
public class CellCreationSteps {
|
||||
|
||||
/** Sends the Cell Creation message for starting out. */
|
||||
public void startStepping(Player player){
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (tp) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select a teleport point for the cell! Move to the teleport point and then click anywhere with your wooden sword to set it.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
/** Sends the Cell Creation message for starting out. */
|
||||
public void startStepping(Player player){
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (tp) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select a teleport point for the cell! Move to the teleport point and then click anywhere with your wooden sword to set it.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
|
||||
ItemStack wand = Util.getWand();
|
||||
if(player.getInventory().contains(wand)) {
|
||||
int i = player.getInventory().first(wand);
|
||||
if(i != -1) {
|
||||
player.getInventory().setItem(i, player.getItemInHand());
|
||||
player.setItemInHand(wand);
|
||||
}
|
||||
}else {
|
||||
player.getInventory().addItem(wand);
|
||||
}
|
||||
}
|
||||
ItemStack wand = Util.getWand();
|
||||
if(player.getInventory().contains(wand)) {
|
||||
int i = player.getInventory().first(wand);
|
||||
if(i != -1) {
|
||||
player.getInventory().setItem(i, player.getItemInHand());
|
||||
player.setItemInHand(wand);
|
||||
}
|
||||
}else {
|
||||
player.getInventory().addItem(wand);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the next step in the Cell Creation process that involves a location, null if no location is needed.
|
||||
*
|
||||
* @param jm The {@link JailManager} instance.
|
||||
* @param player The player who is doing the creating.
|
||||
* @param cp The {@link CreationPlayer} instance
|
||||
* @param location The location, null if none, being set.
|
||||
*/
|
||||
public void step(JailManager jm, Player player, CreationPlayer cp, Location location) {
|
||||
jm.getPlugin().debug("Stepping into step #" + cp.getStep());
|
||||
switch(cp.getStep()) {
|
||||
case 1:
|
||||
firstStep(jm, cp, player);
|
||||
break;
|
||||
case 2:
|
||||
secondStep(cp, player, location.getBlock());
|
||||
break;
|
||||
case 3:
|
||||
thirdStep(jm, cp, player, location.getBlock());
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(ChatColor.RED + "Something went wrong with the creation of the Jail, please start over");
|
||||
jm.removeJailCreationPlayer(player.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Applies the next step in the Cell Creation process that involves a location, null if no location is needed.
|
||||
*
|
||||
* @param jm The {@link JailManager} instance.
|
||||
* @param player The player who is doing the creating.
|
||||
* @param cp The {@link CreationPlayer} instance
|
||||
* @param location The location, null if none, being set.
|
||||
*/
|
||||
public void step(JailManager jm, Player player, CreationPlayer cp, Location location) {
|
||||
jm.getPlugin().debug("Stepping into step #" + cp.getStep());
|
||||
switch(cp.getStep()) {
|
||||
case 1:
|
||||
firstStep(jm, cp, player);
|
||||
break;
|
||||
case 2:
|
||||
secondStep(cp, player, location.getBlock());
|
||||
break;
|
||||
case 3:
|
||||
thirdStep(jm, cp, player, location.getBlock());
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(ChatColor.RED + "Something went wrong with the creation of the Jail, please start over");
|
||||
jm.removeJailCreationPlayer(player.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the first step, which is setting the teleport in location. */
|
||||
private void firstStep(JailManager jm, CreationPlayer cp, Player player) {
|
||||
Vector v1 = jm.getJail(cp.getJailName()).getMinPoint().toVector().clone();
|
||||
Vector v2 = jm.getJail(cp.getJailName()).getMaxPoint().toVector().clone();
|
||||
Vector point = player.getLocation().toVector().clone();
|
||||
/** Applies the first step, which is setting the teleport in location. */
|
||||
private void firstStep(JailManager jm, CreationPlayer cp, Player player) {
|
||||
Vector v1 = jm.getJail(cp.getJailName()).getMinPoint().toVector().clone();
|
||||
Vector v2 = jm.getJail(cp.getJailName()).getMaxPoint().toVector().clone();
|
||||
Vector point = player.getLocation().toVector().clone();
|
||||
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (signs) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Teleport point selected. Now select signs associated with this cell. You may select multiple signs. After you are done with the sign selection, right click on any non-sign block.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (signs) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Teleport point selected. Now select signs associated with this cell. You may select multiple signs. After you are done with the sign selection, right click on any non-sign block.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
|
||||
cp.setTeleportIn(player.getLocation());
|
||||
cp.nextStep();
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "---------- Jail Cell Creation (tp) ----------");
|
||||
player.sendMessage(ChatColor.RED + "Teleport point NOT selected. Please make sure that you are setting the teleport point inside the Jail's corners.");
|
||||
player.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}
|
||||
}
|
||||
cp.setTeleportIn(player.getLocation());
|
||||
cp.nextStep();
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "---------- Jail Cell Creation (tp) ----------");
|
||||
player.sendMessage(ChatColor.RED + "Teleport point NOT selected. Please make sure that you are setting the teleport point inside the Jail's corners.");
|
||||
player.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the second step, which is adding signs to the cell. */
|
||||
private void secondStep(CreationPlayer cp, Player player, Block block) {
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
|
||||
cp.addSign(new SimpleLocation(block.getLocation()));
|
||||
player.sendMessage(ChatColor.GREEN + "Sign added, if you want to select another go ahead otherwise right click on any non-sign block.");
|
||||
}else {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (chest) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + (cp.getSigns().size() != 0 ? "Sign selection completed. " : "") + "Now select a double chest associated with this cell. If there is no chest click on any non-chest block. (Please note that having no chest may result in players items being lost.)");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
cp.nextStep();
|
||||
}
|
||||
}
|
||||
/** Applies the second step, which is adding signs to the cell. */
|
||||
private void secondStep(CreationPlayer cp, Player player, Block block) {
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) {
|
||||
cp.addSign(new SimpleLocation(block.getLocation()));
|
||||
player.sendMessage(ChatColor.GREEN + "Sign added, if you want to select another go ahead otherwise right click on any non-sign block.");
|
||||
}else {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation (chest) ----------");
|
||||
player.sendMessage(ChatColor.GREEN + (cp.getSigns().size() != 0 ? "Sign selection completed. " : "") + "Now select a double chest associated with this cell. If there is no chest click on any non-chest block. (Please note that having no chest may result in players items being lost.)");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
cp.nextStep();
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the third step, which is adding a chest or select not to have a chest. */
|
||||
private void thirdStep(JailManager jm, CreationPlayer cp, Player player, Block block) {
|
||||
Material bpos1 = block.getLocation().add(-1, 0, 0).getBlock().getType();
|
||||
Material bpos2 = block.getLocation().add(+1, 0, 0).getBlock().getType();
|
||||
Material bpos3 = block.getLocation().add(0, 0, -1).getBlock().getType();
|
||||
Material bpos4 = block.getLocation().add(0, 0, +1).getBlock().getType();
|
||||
/** Applies the third step, which is adding a chest or select not to have a chest. */
|
||||
private void thirdStep(JailManager jm, CreationPlayer cp, Player player, Block block) {
|
||||
Material bpos1 = block.getLocation().add(-1, 0, 0).getBlock().getType();
|
||||
Material bpos2 = block.getLocation().add(+1, 0, 0).getBlock().getType();
|
||||
Material bpos3 = block.getLocation().add(0, 0, -1).getBlock().getType();
|
||||
Material bpos4 = block.getLocation().add(0, 0, +1).getBlock().getType();
|
||||
|
||||
boolean pos1 = bpos1 == Material.CHEST || bpos1 == Material.TRAPPED_CHEST;
|
||||
boolean pos2 = bpos2 == Material.CHEST || bpos2 == Material.TRAPPED_CHEST;
|
||||
boolean pos3 = bpos3 == Material.CHEST || bpos3 == Material.TRAPPED_CHEST;
|
||||
boolean pos4 = bpos4 == Material.CHEST || bpos4 == Material.TRAPPED_CHEST;
|
||||
boolean pos1 = bpos1 == Material.CHEST || bpos1 == Material.TRAPPED_CHEST;
|
||||
boolean pos2 = bpos2 == Material.CHEST || bpos2 == Material.TRAPPED_CHEST;
|
||||
boolean pos3 = bpos3 == Material.CHEST || bpos3 == Material.TRAPPED_CHEST;
|
||||
boolean pos4 = bpos4 == Material.CHEST || bpos4 == Material.TRAPPED_CHEST;
|
||||
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST) {
|
||||
if(pos1 || pos2 || pos3 || pos4) {
|
||||
cp.setChestLocation(block.getLocation());
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Chest selected.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "---------- Jail Cell Creation (chest) ----------");
|
||||
player.sendMessage(ChatColor.RED + "Chest must be a double chest, chest not selected");
|
||||
player.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.RED + "No chest selected.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}
|
||||
if (block.getType() == Material.CHEST || block.getType() == Material.TRAPPED_CHEST) {
|
||||
if(pos1 || pos2 || pos3 || pos4) {
|
||||
cp.setChestLocation(block.getLocation());
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Chest selected.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "---------- Jail Cell Creation (chest) ----------");
|
||||
player.sendMessage(ChatColor.RED + "Chest must be a double chest, chest not selected");
|
||||
player.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.RED + "No chest selected.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}
|
||||
|
||||
finalStep(jm, cp, player);
|
||||
}
|
||||
finalStep(jm, cp, player);
|
||||
}
|
||||
|
||||
private void finalStep(JailManager jm, CreationPlayer cp, Player player) {
|
||||
Jail j = jm.getJail(cp.getJailName());
|
||||
Cell c = new Cell(cp.getCellName());
|
||||
private void finalStep(JailManager jm, CreationPlayer cp, Player player) {
|
||||
Jail j = jm.getJail(cp.getJailName());
|
||||
Cell c = new Cell(cp.getCellName());
|
||||
|
||||
c.addAllSigns(cp.getSigns());
|
||||
c.setTeleport(cp.getTeleportInSL());
|
||||
c.addAllSigns(cp.getSigns());
|
||||
c.setTeleport(cp.getTeleportInSL());
|
||||
|
||||
if(cp.getChestLocation() != null)
|
||||
c.setChestLocation(cp.getChestLocation());
|
||||
if(cp.getChestLocation() != null)
|
||||
c.setChestLocation(cp.getChestLocation());
|
||||
|
||||
j.addCell(c, true);
|
||||
j.addCell(c, true);
|
||||
|
||||
jm.removeCellCreationPlayer(player.getName());
|
||||
jm.addCreatingCell(player.getName(), j.getName(), "cell_n" + (j.getCellCount() + 1));
|
||||
jm.removeCellCreationPlayer(player.getName());
|
||||
jm.addCreatingCell(player.getName(), j.getName(), "cell_n" + (j.getCellCount() + 1));
|
||||
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Cell created. Now select the teleport point of the next cell, which is going to be named '" + jm.getCellCreationPlayer(player.getName()).getCellName() + "'. If you wish to stop creating cells, type /jail stop.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}
|
||||
player.sendMessage(ChatColor.AQUA + "---------- Jail Cell Creation ----------");
|
||||
player.sendMessage(ChatColor.GREEN + "Cell created. Now select the teleport point of the next cell, which is going to be named '" + jm.getCellCreationPlayer(player.getName()).getCellName() + "'. If you wish to stop creating cells, type /jail stop.");
|
||||
player.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
}
|
||||
}
|
||||
|
@ -20,127 +20,127 @@ import com.graywolf336.jail.beans.Jail;
|
||||
*/
|
||||
public class JailCreationSteps {
|
||||
|
||||
/** Sends the Jail Creation message for starting out. */
|
||||
public void startStepping(Player player) {
|
||||
player.sendMessage(ChatColor.AQUA + "----------Jail Zone Creation----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select jail cuboid. Select the first point of the cuboid by right clicking on the block with your wooden sword. DO NOT FORGET TO MARK THE FLOOR AND CEILING TOO!");
|
||||
player.sendMessage(ChatColor.AQUA + "--------------------------------------");
|
||||
/** Sends the Jail Creation message for starting out. */
|
||||
public void startStepping(Player player) {
|
||||
player.sendMessage(ChatColor.AQUA + "----------Jail Zone Creation----------");
|
||||
player.sendMessage(ChatColor.GREEN + "First, you must select jail cuboid. Select the first point of the cuboid by right clicking on the block with your wooden sword. DO NOT FORGET TO MARK THE FLOOR AND CEILING TOO!");
|
||||
player.sendMessage(ChatColor.AQUA + "--------------------------------------");
|
||||
|
||||
ItemStack wand = Util.getWand();
|
||||
if(player.getInventory().contains(wand)) {
|
||||
int i = player.getInventory().first(wand);
|
||||
if(i != -1) {
|
||||
player.getInventory().setItem(i, player.getItemInHand());
|
||||
player.setItemInHand(wand);
|
||||
}
|
||||
}else {
|
||||
player.getInventory().addItem(wand);
|
||||
}
|
||||
}
|
||||
ItemStack wand = Util.getWand();
|
||||
if(player.getInventory().contains(wand)) {
|
||||
int i = player.getInventory().first(wand);
|
||||
if(i != -1) {
|
||||
player.getInventory().setItem(i, player.getItemInHand());
|
||||
player.setItemInHand(wand);
|
||||
}
|
||||
}else {
|
||||
player.getInventory().addItem(wand);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the next step in the Jail Creation process that involves a location, null if no location is needed.
|
||||
*
|
||||
* @param jm The {@link JailManager} instance.
|
||||
* @param player The player who is doing the creating.
|
||||
* @param cp The {@link CreationPlayer} instance
|
||||
* @param location The location, null if none, being set.
|
||||
*/
|
||||
public void step(JailManager jm, Player player, CreationPlayer cp, Location location) {
|
||||
jm.getPlugin().debug("Stepping into step #" + cp.getStep());
|
||||
switch(cp.getStep()) {
|
||||
case 1:
|
||||
firstStep(cp, player, location);
|
||||
break;
|
||||
case 2:
|
||||
secondStep(cp, player, location);
|
||||
break;
|
||||
case 3:
|
||||
thirdStep(cp, player);
|
||||
break;
|
||||
case 4:
|
||||
fourthStep(jm, cp, player);
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(ChatColor.RED + "Something went wrong with the creation of the Jail, please start over");
|
||||
jm.removeJailCreationPlayer(player.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Applies the next step in the Jail Creation process that involves a location, null if no location is needed.
|
||||
*
|
||||
* @param jm The {@link JailManager} instance.
|
||||
* @param player The player who is doing the creating.
|
||||
* @param cp The {@link CreationPlayer} instance
|
||||
* @param location The location, null if none, being set.
|
||||
*/
|
||||
public void step(JailManager jm, Player player, CreationPlayer cp, Location location) {
|
||||
jm.getPlugin().debug("Stepping into step #" + cp.getStep());
|
||||
switch(cp.getStep()) {
|
||||
case 1:
|
||||
firstStep(cp, player, location);
|
||||
break;
|
||||
case 2:
|
||||
secondStep(cp, player, location);
|
||||
break;
|
||||
case 3:
|
||||
thirdStep(cp, player);
|
||||
break;
|
||||
case 4:
|
||||
fourthStep(jm, cp, player);
|
||||
break;
|
||||
default:
|
||||
player.sendMessage(ChatColor.RED + "Something went wrong with the creation of the Jail, please start over");
|
||||
jm.removeJailCreationPlayer(player.getName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** Applies the first step, which is setting the first corner. */
|
||||
private void firstStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation----------");
|
||||
p.sendMessage(ChatColor.GREEN + "First point selected. Now select the second point.");
|
||||
p.sendMessage(ChatColor.AQUA + "---------------------------------------");
|
||||
/** Applies the first step, which is setting the first corner. */
|
||||
private void firstStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation----------");
|
||||
p.sendMessage(ChatColor.GREEN + "First point selected. Now select the second point.");
|
||||
p.sendMessage(ChatColor.AQUA + "---------------------------------------");
|
||||
|
||||
cp.setCornerOne(location);
|
||||
cp.nextStep();
|
||||
}
|
||||
cp.setCornerOne(location);
|
||||
cp.nextStep();
|
||||
}
|
||||
|
||||
/** Applies the second step, which is setting the second corner. */
|
||||
private void secondStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.GREEN + "Second point selected. Now go inside the jail and right click anywhere to select your current position as the teleport location for the jail.");
|
||||
p.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
/** Applies the second step, which is setting the second corner. */
|
||||
private void secondStep(CreationPlayer cp, Player p, Location location) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.GREEN + "Second point selected. Now go inside the jail and right click anywhere to select your current position as the teleport location for the jail.");
|
||||
p.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
|
||||
cp.setCornerTwo(location);
|
||||
cp.nextStep();
|
||||
}
|
||||
cp.setCornerTwo(location);
|
||||
cp.nextStep();
|
||||
}
|
||||
|
||||
/** Applies the third step, which is setting the teleport in location. */
|
||||
private void thirdStep(CreationPlayer cp, Player p) {
|
||||
/** Applies the third step, which is setting the teleport in location. */
|
||||
private void thirdStep(CreationPlayer cp, Player p) {
|
||||
|
||||
int[] p1 = cp.getCornerOne();
|
||||
int[] p2 = cp.getCornerTwo();
|
||||
Vector v1 = new Vector(p1[0], p1[1], p1[2]);
|
||||
Vector v2 = new Vector(p2[0], p2[1], p2[2]);
|
||||
Vector point = p.getLocation().toVector().clone();
|
||||
int[] p1 = cp.getCornerOne();
|
||||
int[] p2 = cp.getCornerTwo();
|
||||
Vector v1 = new Vector(p1[0], p1[1], p1[2]);
|
||||
Vector v2 = new Vector(p2[0], p2[1], p2[2]);
|
||||
Vector point = p.getLocation().toVector().clone();
|
||||
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.GREEN + "Teleport point selected. Now go outside of the jail and right click anywhere to select your current position as the location where people will be teleported after they are released from this jail.");
|
||||
p.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
p.sendMessage(ChatColor.AQUA + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.GREEN + "Teleport point selected. Now go outside of the jail and right click anywhere to select your current position as the location where people will be teleported after they are released from this jail.");
|
||||
p.sendMessage(ChatColor.AQUA + "----------------------------------------");
|
||||
|
||||
cp.setTeleportIn(p.getLocation());
|
||||
cp.nextStep();
|
||||
} else {
|
||||
p.sendMessage(ChatColor.RED + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.RED + "Teleport point NOT selected. Now go inside the jail and right click anywhere to select your current position as the teleport location for the jail. Point must be INSIDE the points selected for the Jail.");
|
||||
p.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}
|
||||
}
|
||||
cp.setTeleportIn(p.getLocation());
|
||||
cp.nextStep();
|
||||
} else {
|
||||
p.sendMessage(ChatColor.RED + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.RED + "Teleport point NOT selected. Now go inside the jail and right click anywhere to select your current position as the teleport location for the jail. Point must be INSIDE the points selected for the Jail.");
|
||||
p.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}
|
||||
}
|
||||
|
||||
private void fourthStep(JailManager jm, CreationPlayer cp, Player p) {
|
||||
int[] p1 = cp.getCornerOne();
|
||||
int[] p2 = cp.getCornerTwo();
|
||||
Vector v1 = new Vector(p1[0], p1[1], p1[2]);
|
||||
Vector v2 = new Vector(p2[0], p2[1], p2[2]);
|
||||
Vector point = p.getLocation().toVector().clone();
|
||||
private void fourthStep(JailManager jm, CreationPlayer cp, Player p) {
|
||||
int[] p1 = cp.getCornerOne();
|
||||
int[] p2 = cp.getCornerTwo();
|
||||
Vector v1 = new Vector(p1[0], p1[1], p1[2]);
|
||||
Vector v2 = new Vector(p2[0], p2[1], p2[2]);
|
||||
Vector point = p.getLocation().toVector().clone();
|
||||
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
p.sendMessage(ChatColor.RED + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.RED + "Teleport out point NOT selected. Go outside of the jail and right click anywhere to select your current position as the location where people will be teleported after they are released from this jail.");
|
||||
p.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}else {
|
||||
cp.setTeleportFree(p.getLocation());
|
||||
if(Util.isInsideAB(point, v1, v2)) {
|
||||
p.sendMessage(ChatColor.RED + "---------- Jail Zone Creation ----------");
|
||||
p.sendMessage(ChatColor.RED + "Teleport out point NOT selected. Go outside of the jail and right click anywhere to select your current position as the location where people will be teleported after they are released from this jail.");
|
||||
p.sendMessage(ChatColor.RED + "----------------------------------------");
|
||||
}else {
|
||||
cp.setTeleportFree(p.getLocation());
|
||||
|
||||
finalStep(jm, cp, p);
|
||||
}
|
||||
}
|
||||
finalStep(jm, cp, p);
|
||||
}
|
||||
}
|
||||
|
||||
private void finalStep(JailManager jm, CreationPlayer cp, Player p) {
|
||||
Jail jail = new Jail(jm.getPlugin(), cp.getJailName());
|
||||
private void finalStep(JailManager jm, CreationPlayer cp, Player p) {
|
||||
Jail jail = new Jail(jm.getPlugin(), cp.getJailName());
|
||||
|
||||
jail.setMinPoint(cp.getCornerOne());
|
||||
jail.setMaxPoint(cp.getCornerTwo());
|
||||
jail.setTeleportIn(cp.getTeleportInSL().getLocation());
|
||||
jail.setTeleportFree(cp.getTeleportFreeSL().getLocation());
|
||||
jail.setMinPoint(cp.getCornerOne());
|
||||
jail.setMaxPoint(cp.getCornerTwo());
|
||||
jail.setTeleportIn(cp.getTeleportInSL().getLocation());
|
||||
jail.setTeleportFree(cp.getTeleportFreeSL().getLocation());
|
||||
|
||||
jm.addJail(jail, true);
|
||||
jm.addJail(jail, true);
|
||||
|
||||
p.sendMessage(ChatColor.GREEN + "Jail (" + jail.getName() + ") created successfully!");
|
||||
p.sendMessage(ChatColor.GREEN + "Jail (" + jail.getName() + ") created successfully!");
|
||||
|
||||
jm.removeJailCreationPlayer(p.getName());
|
||||
}
|
||||
jm.removeJailCreationPlayer(p.getName());
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Matchers.any;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
@ -22,6 +22,8 @@ import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import test.java.com.graywolf336.jail.util.TestInstanceCreator;
|
||||
|
||||
import com.carrotsearch.junitbenchmarks.AbstractBenchmark;
|
||||
import com.carrotsearch.junitbenchmarks.BenchmarkOptions;
|
||||
import com.graywolf336.jail.JailMain;
|
||||
@ -29,71 +31,69 @@ import com.graywolf336.jail.beans.CachePrisoner;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
|
||||
import test.java.com.graywolf336.jail.util.TestInstanceCreator;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class BenchmarkTest extends AbstractBenchmark {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static UUID use;
|
||||
private static Random r;
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static UUID use;
|
||||
private static Random r;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
|
||||
Jail j = new Jail(main, "testingJail");
|
||||
j.setWorld("world");
|
||||
j.setMaxPoint(new int[] { 9, 63, -238 });
|
||||
j.setMinPoint(new int[] { 23, 70, -242 });
|
||||
j.setTeleportIn(new Location(main.getServer().getWorld("world"), 11.469868464778077, 65.0, -239.27944647045672, Float.valueOf("38.499817"), Float.valueOf("2.0000453")));
|
||||
j.setTeleportFree(new Location(main.getServer().getWorld("world"), 27.947015843504765, 65.0, -218.8108042076112, Float.valueOf("90.54981"), Float.valueOf("12.500043")));
|
||||
main.getJailManager().addJail(j, false);
|
||||
Jail j = new Jail(main, "testingJail");
|
||||
j.setWorld("world");
|
||||
j.setMaxPoint(new int[] { 9, 63, -238 });
|
||||
j.setMinPoint(new int[] { 23, 70, -242 });
|
||||
j.setTeleportIn(new Location(main.getServer().getWorld("world"), 11.469868464778077, 65.0, -239.27944647045672, Float.valueOf("38.499817"), Float.valueOf("2.0000453")));
|
||||
j.setTeleportFree(new Location(main.getServer().getWorld("world"), 27.947015843504765, 65.0, -218.8108042076112, Float.valueOf("90.54981"), Float.valueOf("12.500043")));
|
||||
main.getJailManager().addJail(j, false);
|
||||
|
||||
assertFalse("There are no jails.", main.getJailManager().getJails().isEmpty());
|
||||
assertFalse("There are no jails.", main.getJailManager().getJails().isEmpty());
|
||||
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
if(i == 555)
|
||||
use = UUID.randomUUID();
|
||||
main.getPrisonerManager().prepareJail(main.getJailManager().getJail("testingJail"), null, null, new Prisoner(i == 555 ? use.toString() : UUID.randomUUID().toString(), "mockPlayer" + i, true, 100000L, "testJailer", "Test jailing " + i));
|
||||
}
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
if(i == 555)
|
||||
use = UUID.randomUUID();
|
||||
main.getPrisonerManager().prepareJail(main.getJailManager().getJail("testingJail"), null, null, new Prisoner(i == 555 ? use.toString() : UUID.randomUUID().toString(), "mockPlayer" + i, true, 100000L, "testJailer", "Test jailing " + i));
|
||||
}
|
||||
|
||||
//This puts the cache object into the cache for the move event and others to use (move in this test)
|
||||
main.getJailManager().addCacheObject(new CachePrisoner(main.getJailManager().getJailPlayerIsIn(use), main.getJailManager().getPrisoner(use)));
|
||||
r = new Random();
|
||||
}
|
||||
//This puts the cache object into the cache for the move event and others to use (move in this test)
|
||||
main.getJailManager().addCacheObject(new CachePrisoner(main.getJailManager().getJailPlayerIsIn(use), main.getJailManager().getPrisoner(use)));
|
||||
r = new Random();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@BenchmarkOptions(benchmarkRounds = 1000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPrisonerSizeAndJailed() {
|
||||
assertEquals("Prisoners not jailed?", 1000, main.getJailManager().getAllPrisoners().size());
|
||||
assertTrue("Prisoner 555 is not jailed", main.getJailManager().isPlayerJailed(use));
|
||||
}
|
||||
@BenchmarkOptions(benchmarkRounds = 1000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPrisonerSizeAndJailed() {
|
||||
assertEquals("Prisoners not jailed?", 1000, main.getJailManager().getAllPrisoners().size());
|
||||
assertTrue("Prisoner 555 is not jailed", main.getJailManager().isPlayerJailed(use));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@BenchmarkOptions(benchmarkRounds = 5000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPlayerMoveEvent() {
|
||||
Player p = mock(Player.class);
|
||||
when(p.getUniqueId()).thenReturn(use);
|
||||
when(p.getName()).thenReturn("mockPlayer555");
|
||||
when(p.teleport(any(Location.class))).thenReturn(true);
|
||||
@SuppressWarnings("deprecation")
|
||||
@BenchmarkOptions(benchmarkRounds = 5000, warmupRounds = 0)
|
||||
@Test
|
||||
public void testPlayerMoveEvent() {
|
||||
Player p = mock(Player.class);
|
||||
when(p.getUniqueId()).thenReturn(use);
|
||||
when(p.getName()).thenReturn("mockPlayer555");
|
||||
when(p.teleport(any(Location.class))).thenReturn(true);
|
||||
|
||||
Location from = new Location(main.getServer().getWorld("world"), 15, 64, -239);
|
||||
Location to = new Location(main.getServer().getWorld("world"), r.nextInt(), r.nextInt(), r.nextInt());
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(p, from, to);
|
||||
Location from = new Location(main.getServer().getWorld("world"), 15, 64, -239);
|
||||
Location to = new Location(main.getServer().getWorld("world"), r.nextInt(), r.nextInt(), r.nextInt());
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(p, from, to);
|
||||
|
||||
main.getPlayerMoveListener().moveProtection(e);
|
||||
}
|
||||
main.getPlayerMoveListener().moveProtection(e);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -26,44 +26,44 @@ import com.graywolf336.jail.JailsAPI;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class TestJailAPI {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testManagersAreThere() {
|
||||
assertNotNull(main.getHandCuffManager());
|
||||
assertNotNull(main.getJailManager());
|
||||
assertNotNull(main.getPrisonerManager());
|
||||
}
|
||||
@Test
|
||||
public void testManagersAreThere() {
|
||||
assertNotNull(main.getHandCuffManager());
|
||||
assertNotNull(main.getJailManager());
|
||||
assertNotNull(main.getPrisonerManager());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHandCuffManagerAPI() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Location loc = new Location(main.getServer().getWorld("world"), 11.469868464778077, 65.0, -239.27944647045672, Float.valueOf("38.499817"), Float.valueOf("2.0000453"));
|
||||
assertThat("The HandCuff Managers are different.", JailsAPI.getHandCuffManager(), is(main.getHandCuffManager()));
|
||||
assertFalse("The test id of someone is already handcuffed.", JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
@Test
|
||||
public void testHandCuffManagerAPI() {
|
||||
UUID id = UUID.randomUUID();
|
||||
Location loc = new Location(main.getServer().getWorld("world"), 11.469868464778077, 65.0, -239.27944647045672, Float.valueOf("38.499817"), Float.valueOf("2.0000453"));
|
||||
assertThat("The HandCuff Managers are different.", JailsAPI.getHandCuffManager(), is(main.getHandCuffManager()));
|
||||
assertFalse("The test id of someone is already handcuffed.", JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
|
||||
JailsAPI.getHandCuffManager().addHandCuffs(id, loc);
|
||||
assertTrue(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertThat(JailsAPI.getHandCuffManager().getLocation(id), is(loc));
|
||||
JailsAPI.getHandCuffManager().addHandCuffs(id, loc);
|
||||
assertTrue(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertThat(JailsAPI.getHandCuffManager().getLocation(id), is(loc));
|
||||
|
||||
JailsAPI.getHandCuffManager().removeHandCuffs(id);
|
||||
assertFalse(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertNull(JailsAPI.getHandCuffManager().getLocation(id));
|
||||
}
|
||||
JailsAPI.getHandCuffManager().removeHandCuffs(id);
|
||||
assertFalse(JailsAPI.getHandCuffManager().isHandCuffed(id));
|
||||
assertNull(JailsAPI.getHandCuffManager().getLocation(id));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,10 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@ -27,116 +31,116 @@ import com.lexicalscope.jewel.cli.CliFactory;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class TestJailCommandInfo {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("thisisnotavalidcommand");
|
||||
String[] args = {};
|
||||
@Test
|
||||
public void testInvalidCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("thisisnotavalidcommand");
|
||||
String[] args = {};
|
||||
|
||||
CommandSender sender = creator.getCommandSender();
|
||||
CommandSender sender = creator.getCommandSender();
|
||||
|
||||
assertTrue(main.onCommand(sender, command, "thisisnotavalidcommand", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "No commands registered by the name of thisisnotavalidcommand.");
|
||||
}
|
||||
assertTrue(main.onCommand(sender, command, "thisisnotavalidcommand", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "No commands registered by the name of thisisnotavalidcommand.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForPlayerContext() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testJail" };
|
||||
@Test
|
||||
public void testForPlayerContext() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testJail" };
|
||||
|
||||
CommandSender sender = creator.getCommandSender();
|
||||
CommandSender sender = creator.getCommandSender();
|
||||
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "A player context is required for this.");
|
||||
}
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "A player context is required for this.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMinimumArgs() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create" };
|
||||
@Test
|
||||
public void testMinimumArgs() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create" };
|
||||
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender, atLeast(1)).sendMessage("/jail create [name]"); // If you change which command we test against, then change this
|
||||
}
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender, atLeast(1)).sendMessage("/jail create [name]"); // If you change which command we test against, then change this
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaximumArgs() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testing", "badarg", "reallyterribleone" };
|
||||
@Test
|
||||
public void testMaximumArgs() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testing", "badarg", "reallyterribleone" };
|
||||
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender, atLeast(1)).sendMessage("/jail create [name]"); // If you change which command we test against, then change this
|
||||
}
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender, atLeast(1)).sendMessage("/jail create [name]"); // If you change which command we test against, then change this
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccessfulJailCreateCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testJail" };
|
||||
@Test
|
||||
public void testSuccessfulJailCreateCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "create", "testJail" };
|
||||
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.AQUA + "----------Jail Zone Creation----------");
|
||||
verify(sender).sendMessage(ChatColor.GREEN + "First, you must select jail cuboid. Select the first point of the cuboid by right clicking on the block with your wooden sword. DO NOT FORGET TO MARK THE FLOOR AND CEILING TOO!");
|
||||
verify(sender).sendMessage(ChatColor.AQUA + "--------------------------------------");
|
||||
}
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.AQUA + "----------Jail Zone Creation----------");
|
||||
verify(sender).sendMessage(ChatColor.GREEN + "First, you must select jail cuboid. Select the first point of the cuboid by right clicking on the block with your wooden sword. DO NOT FORGET TO MARK THE FLOOR AND CEILING TOO!");
|
||||
verify(sender).sendMessage(ChatColor.AQUA + "--------------------------------------");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailingCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "graywolf336", "-t", "30", "-j", "den", "-c", "cell_01", "-m", "-r", "He", "was", "a", "very", "bad", "boy." };
|
||||
@Test
|
||||
public void testJailingCommand() {
|
||||
Command command = mock(Command.class);
|
||||
when(command.getName()).thenReturn("jail");
|
||||
String[] args = { "graywolf336", "-t", "30", "-j", "den", "-c", "cell_01", "-m", "-r", "He", "was", "a", "very", "bad", "boy." };
|
||||
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "There are currently no jails.");
|
||||
}
|
||||
CommandSender sender = creator.getPlayerCommandSender();
|
||||
assertTrue(main.onCommand(sender, command, "jail", args));
|
||||
verify(sender).sendMessage(ChatColor.RED + "There are currently no jails.");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailJewel() {
|
||||
String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" };
|
||||
Jailing j = CliFactory.parseArguments(Jailing.class, args);
|
||||
@Test
|
||||
public void testJailJewel() {
|
||||
String[] args = { "--player", "graywolf336", "-c", "testing", "-r", "This", "is", "a", "reason" };
|
||||
Jailing j = CliFactory.parseArguments(Jailing.class, args);
|
||||
|
||||
assertEquals("graywolf336", j.getPlayer());
|
||||
assertTrue("The cell wasn't provided.", j.isCell());
|
||||
assertEquals("testing", j.getCell());
|
||||
assertEquals("graywolf336", j.getPlayer());
|
||||
assertTrue("The cell wasn't provided.", j.isCell());
|
||||
assertEquals("testing", j.getCell());
|
||||
|
||||
assertTrue("A reason wasn't provided.", j.isReason());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(String s : j.getReason()) {
|
||||
sb.append(s).append(' ');
|
||||
}
|
||||
assertTrue("A reason wasn't provided.", j.isReason());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(String s : j.getReason()) {
|
||||
sb.append(s).append(' ');
|
||||
}
|
||||
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
sb.deleteCharAt(sb.length() - 1);
|
||||
|
||||
assertEquals("This is a reason", sb.toString());
|
||||
}
|
||||
assertEquals("This is a reason", sb.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailWithAnyCellJewel() {
|
||||
@ -158,29 +162,29 @@ public class TestJailCommandInfo {
|
||||
assertEquals("This is a reason", sb.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferForJailAndCell() {
|
||||
String[] args = { "-p", "graywolf336", "-j", "hardcore", "-c", "cell_n01" };
|
||||
Transfer t = CliFactory.parseArguments(Transfer.class, args);
|
||||
@Test
|
||||
public void testTransferForJailAndCell() {
|
||||
String[] args = { "-p", "graywolf336", "-j", "hardcore", "-c", "cell_n01" };
|
||||
Transfer t = CliFactory.parseArguments(Transfer.class, args);
|
||||
|
||||
assertTrue("The player wasn't provided.", t.isPlayer());
|
||||
assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer());
|
||||
assertTrue("The jail wasn't provided.", t.isJail());
|
||||
assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail());
|
||||
assertTrue("The cell wasn't provided.", t.isCell());
|
||||
assertEquals("The cell parsed is not what we expected.", "cell_n01", t.getCell());
|
||||
}
|
||||
assertTrue("The player wasn't provided.", t.isPlayer());
|
||||
assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer());
|
||||
assertTrue("The jail wasn't provided.", t.isJail());
|
||||
assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail());
|
||||
assertTrue("The cell wasn't provided.", t.isCell());
|
||||
assertEquals("The cell parsed is not what we expected.", "cell_n01", t.getCell());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransferForNoCell() {
|
||||
String[] args = { "-p", "graywolf336", "-j", "hardcore" };
|
||||
Transfer t = CliFactory.parseArguments(Transfer.class, args);
|
||||
@Test
|
||||
public void testTransferForNoCell() {
|
||||
String[] args = { "-p", "graywolf336", "-j", "hardcore" };
|
||||
Transfer t = CliFactory.parseArguments(Transfer.class, args);
|
||||
|
||||
assertTrue("The player wasn't provided.", t.isPlayer());
|
||||
assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer());
|
||||
assertTrue("The jail wasn't provided.", t.isJail());
|
||||
assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail());
|
||||
assertFalse("The cell was provided?", t.isCell());
|
||||
assertNull("The cell is not null?", t.getCell());
|
||||
}
|
||||
assertTrue("The player wasn't provided.", t.isPlayer());
|
||||
assertEquals("The player parsed is not what we expected.", "graywolf336", t.getPlayer());
|
||||
assertTrue("The jail wasn't provided.", t.isJail());
|
||||
assertEquals("The jail parsed is not what we expected.", "hardcore", t.getJail());
|
||||
assertFalse("The cell was provided?", t.isCell());
|
||||
assertNull("The cell is not null?", t.getCell());
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -23,150 +23,150 @@ import com.graywolf336.jail.enums.Settings;
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest({ JailMain.class, PluginDescriptionFile.class })
|
||||
public class TestJailDefaultConfig {
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
private static TestInstanceCreator creator;
|
||||
private static JailMain main;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
creator = new TestInstanceCreator();
|
||||
assertNotNull("The instance creator is null.", creator);
|
||||
assertTrue(creator.setup());
|
||||
main = creator.getMain();
|
||||
assertNotNull("The JailMain class is null.", main);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
creator.tearDown();
|
||||
main = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSystemDefaultConfig() {
|
||||
assertEquals("The config version is not 3.", 3, main.getConfig().getInt(Settings.CONFIGVERSION.getPath()));
|
||||
assertTrue("Default debugging is off.", main.getConfig().getBoolean(Settings.DEBUG.getPath()));
|
||||
assertEquals("Default language is not 'en'.", "en", main.getConfig().getString(Settings.LANGUAGE.getPath()));
|
||||
assertEquals("Default updating channel is not bukkit.", "bukkit", main.getConfig().getString(Settings.UPDATECHANNEL.getPath()));
|
||||
assertTrue("Default updating notifications is false.", main.getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath()));
|
||||
assertEquals("Default updating time checking is not 1h.", "1h", main.getConfig().getString(Settings.UPDATETIME.getPath()));
|
||||
assertTrue("Default usage of bukkit timer is false.", main.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath()));
|
||||
}
|
||||
@Test
|
||||
public void testSystemDefaultConfig() {
|
||||
assertEquals("The config version is not 3.", 3, main.getConfig().getInt(Settings.CONFIGVERSION.getPath()));
|
||||
assertTrue("Default debugging is off.", main.getConfig().getBoolean(Settings.DEBUG.getPath()));
|
||||
assertEquals("Default language is not 'en'.", "en", main.getConfig().getString(Settings.LANGUAGE.getPath()));
|
||||
assertEquals("Default updating channel is not bukkit.", "bukkit", main.getConfig().getString(Settings.UPDATECHANNEL.getPath()));
|
||||
assertTrue("Default updating notifications is false.", main.getConfig().getBoolean(Settings.UPDATENOTIFICATIONS.getPath()));
|
||||
assertEquals("Default updating time checking is not 1h.", "1h", main.getConfig().getString(Settings.UPDATETIME.getPath()));
|
||||
assertTrue("Default usage of bukkit timer is false.", main.getConfig().getBoolean(Settings.USEBUKKITTIMER.getPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStorageDefaultConfig() {
|
||||
assertEquals("The default storage system is not flatfile.", "flatfile", main.getConfig().getString("storage.type"));
|
||||
assertEquals("The default mysql host is not localhost.", "localhost", main.getConfig().getString("storage.mysql.host"));
|
||||
assertEquals("The default mysql port is not 3306.", 3306, main.getConfig().getInt("storage.mysql.port"));
|
||||
assertEquals("The default mysql username is not root.", "root", main.getConfig().getString("storage.mysql.username"));
|
||||
assertEquals("The default mysql password is not password.", "password", main.getConfig().getString("storage.mysql.password"));
|
||||
assertEquals("The default mysql database is not jailDatabase.", "jailDatabase", main.getConfig().getString("storage.mysql.database"));
|
||||
assertEquals("The default mysql prefix is not j3_.", "j3_", main.getConfig().getString("storage.mysql.prefix"));
|
||||
}
|
||||
@Test
|
||||
public void testStorageDefaultConfig() {
|
||||
assertEquals("The default storage system is not flatfile.", "flatfile", main.getConfig().getString("storage.type"));
|
||||
assertEquals("The default mysql host is not localhost.", "localhost", main.getConfig().getString("storage.mysql.host"));
|
||||
assertEquals("The default mysql port is not 3306.", 3306, main.getConfig().getInt("storage.mysql.port"));
|
||||
assertEquals("The default mysql username is not root.", "root", main.getConfig().getString("storage.mysql.username"));
|
||||
assertEquals("The default mysql password is not password.", "password", main.getConfig().getString("storage.mysql.password"));
|
||||
assertEquals("The default mysql database is not jailDatabase.", "jailDatabase", main.getConfig().getString("storage.mysql.database"));
|
||||
assertEquals("The default mysql prefix is not j3_.", "j3_", main.getConfig().getString("storage.mysql.prefix"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDuringJailingDefaultConfig() {
|
||||
// block breaking section
|
||||
assertEquals("Default setting for block break penalty is not 5m.", "5m", main.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
|
||||
assertTrue("Default setting for block break proection is false.", main.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath()));
|
||||
@Test
|
||||
public void testDuringJailingDefaultConfig() {
|
||||
// block breaking section
|
||||
assertEquals("Default setting for block break penalty is not 5m.", "5m", main.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
|
||||
assertTrue("Default setting for block break proection is false.", main.getConfig().getBoolean(Settings.BLOCKBREAKPROTECTION.getPath()));
|
||||
|
||||
List<String> blockbreakwhite = main.getConfig().getStringList(Settings.BLOCKBREAKWHITELIST.getPath());
|
||||
assertTrue("Default block breaking doesn't contain crops.", blockbreakwhite.contains("crops"));
|
||||
assertTrue("Default block breaking doesn't contain carrot.", blockbreakwhite.contains("carrot"));
|
||||
assertTrue("Default block breaking doesn't contain potato.", blockbreakwhite.contains("potato"));
|
||||
List<String> blockbreakwhite = main.getConfig().getStringList(Settings.BLOCKBREAKWHITELIST.getPath());
|
||||
assertTrue("Default block breaking doesn't contain crops.", blockbreakwhite.contains("crops"));
|
||||
assertTrue("Default block breaking doesn't contain carrot.", blockbreakwhite.contains("carrot"));
|
||||
assertTrue("Default block breaking doesn't contain potato.", blockbreakwhite.contains("potato"));
|
||||
|
||||
// block placing section
|
||||
assertEquals("Default setting for block place penalty is not 5m.", "5m", main.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
|
||||
assertTrue("Default setting for block place proection is false.", main.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath()));
|
||||
// block placing section
|
||||
assertEquals("Default setting for block place penalty is not 5m.", "5m", main.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
|
||||
assertTrue("Default setting for block place proection is false.", main.getConfig().getBoolean(Settings.BLOCKPLACEPROTECTION.getPath()));
|
||||
|
||||
List<String> blockplacewhite = main.getConfig().getStringList(Settings.BLOCKPLACEWHITELIST.getPath());
|
||||
assertTrue("Default block placing whitelist doesn't contain crops.", blockplacewhite.contains("crops"));
|
||||
assertTrue("Default block placing whitelist doesn't contain carrot.", blockplacewhite.contains("carrot"));
|
||||
assertTrue("Default block placing whitelist doesn't contain potato.", blockplacewhite.contains("potato"));
|
||||
List<String> blockplacewhite = main.getConfig().getStringList(Settings.BLOCKPLACEWHITELIST.getPath());
|
||||
assertTrue("Default block placing whitelist doesn't contain crops.", blockplacewhite.contains("crops"));
|
||||
assertTrue("Default block placing whitelist doesn't contain carrot.", blockplacewhite.contains("carrot"));
|
||||
assertTrue("Default block placing whitelist doesn't contain potato.", blockplacewhite.contains("potato"));
|
||||
|
||||
// command protection section
|
||||
assertEquals("Default setting for command penalty is not 5m.", "5m", main.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
|
||||
assertTrue("Default setting for command proection is false.", main.getConfig().getBoolean(Settings.COMMANDPROTECTION.getPath()));
|
||||
// command protection section
|
||||
assertEquals("Default setting for command penalty is not 5m.", "5m", main.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
|
||||
assertTrue("Default setting for command proection is false.", main.getConfig().getBoolean(Settings.COMMANDPROTECTION.getPath()));
|
||||
|
||||
List<String> commandwhite = main.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath());
|
||||
assertTrue("Default command whitelist doesn't contain /ping.", commandwhite.contains("/ping"));
|
||||
assertTrue("Default command whitelist doesn't contain /list.", commandwhite.contains("/list"));
|
||||
assertTrue("Default command whitelist doesn't contain /jail status.", commandwhite.contains("/jail status"));
|
||||
assertTrue("Default command whitelist doesn't contain /jail pay.", commandwhite.contains("/jail pay"));
|
||||
List<String> commandwhite = main.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath());
|
||||
assertTrue("Default command whitelist doesn't contain /ping.", commandwhite.contains("/ping"));
|
||||
assertTrue("Default command whitelist doesn't contain /list.", commandwhite.contains("/list"));
|
||||
assertTrue("Default command whitelist doesn't contain /jail status.", commandwhite.contains("/jail status"));
|
||||
assertTrue("Default command whitelist doesn't contain /jail pay.", commandwhite.contains("/jail pay"));
|
||||
|
||||
assertFalse("Default setting for counting down time while prisoner is offline is true.", main.getConfig().getBoolean(Settings.COUNTDOWNTIMEOFFLINE.getPath()));
|
||||
assertEquals("Default setting for crop trampling penalty is not 5m.", "5m", main.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
assertTrue("Default setting for crop trampling proection is false.", main.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath()));
|
||||
assertTrue("Default setting for food control enabled is false.", main.getConfig().getBoolean(Settings.FOODCONTROL.getPath()));
|
||||
assertEquals("Default setting for food control max is not 20.", 20, main.getConfig().getInt(Settings.FOODCONTROLMAX.getPath()));
|
||||
assertEquals("Default setting for food control min is not 10.", 10, main.getConfig().getInt(Settings.FOODCONTROLMIN.getPath()));
|
||||
assertTrue("Default setting for ignoring sleeping is false.", main.getConfig().getBoolean(Settings.IGNORESLEEPINGSTATE.getPath()));
|
||||
assertEquals("Default setting max afk time is not 10 minutes.", "10m", main.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
||||
assertEquals("Default setting move penalty is not 10 minutes.", "10m", main.getConfig().getString(Settings.MOVEPENALTY.getPath()));
|
||||
assertTrue("Default setting for move protection is false.", main.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath()));
|
||||
assertTrue("Default setting for opening a chest is false.", main.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath()));
|
||||
assertFalse("Default setting for counting down time while prisoner is offline is true.", main.getConfig().getBoolean(Settings.COUNTDOWNTIMEOFFLINE.getPath()));
|
||||
assertEquals("Default setting for crop trampling penalty is not 5m.", "5m", main.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
assertTrue("Default setting for crop trampling proection is false.", main.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath()));
|
||||
assertTrue("Default setting for food control enabled is false.", main.getConfig().getBoolean(Settings.FOODCONTROL.getPath()));
|
||||
assertEquals("Default setting for food control max is not 20.", 20, main.getConfig().getInt(Settings.FOODCONTROLMAX.getPath()));
|
||||
assertEquals("Default setting for food control min is not 10.", 10, main.getConfig().getInt(Settings.FOODCONTROLMIN.getPath()));
|
||||
assertTrue("Default setting for ignoring sleeping is false.", main.getConfig().getBoolean(Settings.IGNORESLEEPINGSTATE.getPath()));
|
||||
assertEquals("Default setting max afk time is not 10 minutes.", "10m", main.getConfig().getString(Settings.MAXAFKTIME.getPath()));
|
||||
assertEquals("Default setting move penalty is not 10 minutes.", "10m", main.getConfig().getString(Settings.MOVEPENALTY.getPath()));
|
||||
assertTrue("Default setting for move protection is false.", main.getConfig().getBoolean(Settings.MOVEPROTECTION.getPath()));
|
||||
assertTrue("Default setting for opening a chest is false.", main.getConfig().getBoolean(Settings.PRISONEROPENCHEST.getPath()));
|
||||
|
||||
// interaction blocks protection section
|
||||
List<String> interactionBlocks = main.getConfig().getStringList(Settings.PREVENTINTERACTIONBLOCKS.getPath());
|
||||
assertTrue("Default interaction blocks whitelist doesn't contain wooden_door.", interactionBlocks.contains("wooden_door"));
|
||||
assertTrue("Default interaction blocks whitelist doesn't contain iron_door_block.", interactionBlocks.contains("iron_door_block"));
|
||||
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
// interaction blocks protection section
|
||||
List<String> interactionBlocks = main.getConfig().getStringList(Settings.PREVENTINTERACTIONBLOCKS.getPath());
|
||||
assertTrue("Default interaction blocks whitelist doesn't contain wooden_door.", interactionBlocks.contains("wooden_door"));
|
||||
assertTrue("Default interaction blocks whitelist doesn't contain iron_door_block.", interactionBlocks.contains("iron_door_block"));
|
||||
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
|
||||
// interaction items protection section
|
||||
assertTrue("Default interaction items whitelist isn't empty.", main.getConfig().getStringList(Settings.PREVENTINTERACTIONITEMS.getPath()).isEmpty());
|
||||
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
// interaction items protection section
|
||||
assertTrue("Default interaction items whitelist isn't empty.", main.getConfig().getStringList(Settings.PREVENTINTERACTIONITEMS.getPath()).isEmpty());
|
||||
assertEquals("Default setting for preventing interaction blocks penalty is not 5m.", "5m", main.getConfig().getString(Settings.PREVENTINTERACTIONBLOCKSPENALTY.getPath()));
|
||||
|
||||
assertTrue("Default setting for recieving messages is false.", main.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath()));
|
||||
assertFalse("Default setting for scoreboard being enabled is true.", main.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath()));
|
||||
assertEquals("Default setting for the scoreboard title is not Jail Info.", "Jail Info", main.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()));
|
||||
assertEquals("Default setting for the scoreboard time language is not &aTime:", "&aTime:", main.getConfig().getString(Settings.SCOREBOARDTIME.getPath()));
|
||||
}
|
||||
assertTrue("Default setting for recieving messages is false.", main.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath()));
|
||||
assertFalse("Default setting for scoreboard being enabled is true.", main.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath()));
|
||||
assertEquals("Default setting for the scoreboard title is not Jail Info.", "Jail Info", main.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()));
|
||||
assertEquals("Default setting for the scoreboard time language is not &aTime:", "&aTime:", main.getConfig().getString(Settings.SCOREBOARDTIME.getPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailingDefaultConfig() {
|
||||
assertTrue("Default setting for automatically muting is false.", main.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()));
|
||||
assertFalse("Default setting for broadcasting a jailing is true.", main.getConfig().getBoolean(Settings.BROADCASTJAILING.getPath()));
|
||||
assertTrue("Default setting for jail clothing is not enabled.", main.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath()));
|
||||
assertEquals("Default setting for jail clothing's helmet is not leather_helmet~175,105,33.", "leather_helmet~175,105,33", main.getConfig().getString(Settings.CLOTHINGHELMET.getPath()));
|
||||
assertEquals("Default setting for jail clothing's chestplate is not leather_chestplate~175,105,33.", "leather_chestplate~175,105,33", main.getConfig().getString(Settings.CLOTHINGCHEST.getPath()));
|
||||
assertEquals("Default setting for jail clothing's legs is not leather_leggings~175,105,33.", "leather_leggings~175,105,33", main.getConfig().getString(Settings.CLOTHINGLEGS.getPath()));
|
||||
assertEquals("Default setting for jail clothing's boots is not leather_boots~175,105,33.", "leather_boots~175,105,33", main.getConfig().getString(Settings.CLOTHINGBOOTS.getPath()));
|
||||
assertTrue("Default setting for commands is not empty.", main.getConfig().getStringList(Settings.COMMANDSONJAIL.getPath()).isEmpty());
|
||||
assertEquals("Default setting for default jail is not 'nearest' but something else.", "nearest", main.getConfig().getString(Settings.DEFAULTJAIL.getPath()));
|
||||
assertEquals("Default setting for time is not 30 minutes.", "30m", main.getConfig().getString(Settings.DEFAULTTIME.getPath()));
|
||||
assertEquals("Default setting for the prisoner's default gamemode is not adventure.", "adventure", main.getConfig().getString(Settings.JAILEDGAMEMODE.getPath()));
|
||||
assertTrue("Default setting for inventory storing blacklist is not empty.", main.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath()).isEmpty());
|
||||
assertTrue("Default setting for inventory storing is false.", main.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath()));
|
||||
assertTrue("Default setting for logging to console when someone is jailed is false.", main.getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath()));
|
||||
assertTrue("Default setting for logging to prisoner's profile is false.", main.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath()));
|
||||
}
|
||||
@Test
|
||||
public void testJailingDefaultConfig() {
|
||||
assertTrue("Default setting for automatically muting is false.", main.getConfig().getBoolean(Settings.AUTOMATICMUTE.getPath()));
|
||||
assertFalse("Default setting for broadcasting a jailing is true.", main.getConfig().getBoolean(Settings.BROADCASTJAILING.getPath()));
|
||||
assertTrue("Default setting for jail clothing is not enabled.", main.getConfig().getBoolean(Settings.CLOTHINGENABLED.getPath()));
|
||||
assertEquals("Default setting for jail clothing's helmet is not leather_helmet~175,105,33.", "leather_helmet~175,105,33", main.getConfig().getString(Settings.CLOTHINGHELMET.getPath()));
|
||||
assertEquals("Default setting for jail clothing's chestplate is not leather_chestplate~175,105,33.", "leather_chestplate~175,105,33", main.getConfig().getString(Settings.CLOTHINGCHEST.getPath()));
|
||||
assertEquals("Default setting for jail clothing's legs is not leather_leggings~175,105,33.", "leather_leggings~175,105,33", main.getConfig().getString(Settings.CLOTHINGLEGS.getPath()));
|
||||
assertEquals("Default setting for jail clothing's boots is not leather_boots~175,105,33.", "leather_boots~175,105,33", main.getConfig().getString(Settings.CLOTHINGBOOTS.getPath()));
|
||||
assertTrue("Default setting for commands is not empty.", main.getConfig().getStringList(Settings.COMMANDSONJAIL.getPath()).isEmpty());
|
||||
assertEquals("Default setting for default jail is not 'nearest' but something else.", "nearest", main.getConfig().getString(Settings.DEFAULTJAIL.getPath()));
|
||||
assertEquals("Default setting for time is not 30 minutes.", "30m", main.getConfig().getString(Settings.DEFAULTTIME.getPath()));
|
||||
assertEquals("Default setting for the prisoner's default gamemode is not adventure.", "adventure", main.getConfig().getString(Settings.JAILEDGAMEMODE.getPath()));
|
||||
assertTrue("Default setting for inventory storing blacklist is not empty.", main.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath()).isEmpty());
|
||||
assertTrue("Default setting for inventory storing is false.", main.getConfig().getBoolean(Settings.JAILEDSTOREINVENTORY.getPath()));
|
||||
assertTrue("Default setting for logging to console when someone is jailed is false.", main.getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath()));
|
||||
assertTrue("Default setting for logging to prisoner's profile is false.", main.getConfig().getBoolean(Settings.LOGJAILINGTOPROFILE.getPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReleaseDefaultConfig() {
|
||||
assertFalse("Default setting for releasing back to previous position is true.", main.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath()));
|
||||
assertTrue("Default setting for commands is not empty.", main.getConfig().getStringList(Settings.COMMANDSONRELEASE.getPath()).isEmpty());
|
||||
assertFalse("Default setting for restoring previous gamemode is true.", main.getConfig().getBoolean(Settings.RESTOREPREVIOUSGAMEMODE.getPath()));
|
||||
assertTrue("Default setting for teleporting them out of the jail is false.", main.getConfig().getBoolean(Settings.TELEPORTONRELEASE.getPath()));
|
||||
}
|
||||
@Test
|
||||
public void testReleaseDefaultConfig() {
|
||||
assertFalse("Default setting for releasing back to previous position is true.", main.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath()));
|
||||
assertTrue("Default setting for commands is not empty.", main.getConfig().getStringList(Settings.COMMANDSONRELEASE.getPath()).isEmpty());
|
||||
assertFalse("Default setting for restoring previous gamemode is true.", main.getConfig().getBoolean(Settings.RESTOREPREVIOUSGAMEMODE.getPath()));
|
||||
assertTrue("Default setting for teleporting them out of the jail is false.", main.getConfig().getBoolean(Settings.TELEPORTONRELEASE.getPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailsDefaultConfig() {
|
||||
assertTrue("Default setting for protecting jails from endermen is false.", main.getConfig().getBoolean(Settings.ENDERMENPROTECTION.getPath()));
|
||||
assertTrue("Default setting for protecting jails from explosions is false.", main.getConfig().getBoolean(Settings.EXPLOSIONPROTECTION.getPath()));
|
||||
}
|
||||
@Test
|
||||
public void testJailsDefaultConfig() {
|
||||
assertTrue("Default setting for protecting jails from endermen is false.", main.getConfig().getBoolean(Settings.ENDERMENPROTECTION.getPath()));
|
||||
assertTrue("Default setting for protecting jails from explosions is false.", main.getConfig().getBoolean(Settings.EXPLOSIONPROTECTION.getPath()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailPayDefaultConfig() {
|
||||
assertFalse("Default setting for jail pay enabled is true, meaning Jail Pay somehow got enabled in testing.", main.getConfig().getBoolean(Settings.JAILPAYENABLED.getPath()));
|
||||
assertEquals("Default setting for jail pay item is not air.", "air", main.getConfig().getString(Settings.JAILPAYITEM.getPath()));
|
||||
assertEquals("Default setting for jail pay price per minute is not 1.5.", 1.5, main.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath()), 0);
|
||||
assertEquals("Default setting for jail pay price for infinite is not 10000.", 10000, main.getConfig().getDouble(Settings.JAILPAYPRICEINFINITE.getPath()), 0);
|
||||
}
|
||||
@Test
|
||||
public void testJailPayDefaultConfig() {
|
||||
assertFalse("Default setting for jail pay enabled is true, meaning Jail Pay somehow got enabled in testing.", main.getConfig().getBoolean(Settings.JAILPAYENABLED.getPath()));
|
||||
assertEquals("Default setting for jail pay item is not air.", "air", main.getConfig().getString(Settings.JAILPAYITEM.getPath()));
|
||||
assertEquals("Default setting for jail pay price per minute is not 1.5.", 1.5, main.getConfig().getDouble(Settings.JAILPAYPRICEPERMINUTE.getPath()), 0);
|
||||
assertEquals("Default setting for jail pay price for infinite is not 10000.", 10000, main.getConfig().getDouble(Settings.JAILPAYPRICEINFINITE.getPath()), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJailStickDefaultConfig() {
|
||||
assertTrue("Default setting for jail stick enabled is false.", main.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath()));
|
||||
List<String> jailSticks = main.getConfig().getStringList(Settings.JAILSTICKSTICKS.getPath());
|
||||
assertTrue("Default setting for jail sticks doesn't contain a stick with item of stick.", jailSticks.contains("stick,30m,,Running away,-1"));
|
||||
assertTrue("Default setting for jail sticks doesn't contain a stick with item of blaze_rod.", jailSticks.contains("blaze_rod,15m,,Having too much fun,6"));
|
||||
}
|
||||
@Test
|
||||
public void testJailStickDefaultConfig() {
|
||||
assertTrue("Default setting for jail stick enabled is false.", main.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath()));
|
||||
List<String> jailSticks = main.getConfig().getStringList(Settings.JAILSTICKSTICKS.getPath());
|
||||
assertTrue("Default setting for jail sticks doesn't contain a stick with item of stick.", jailSticks.contains("stick,30m,,Running away,-1"));
|
||||
assertTrue("Default setting for jail sticks doesn't contain a stick with item of blaze_rod.", jailSticks.contains("blaze_rod,15m,,Having too much fun,6"));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
package test.java.com.graywolf336.jail;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -15,96 +17,96 @@ import org.junit.Test;
|
||||
import com.graywolf336.jail.Util;
|
||||
|
||||
public class TestUtilClass {
|
||||
private static List<String> list;
|
||||
private static Vector bottomCorner;
|
||||
private static Vector topCorner;
|
||||
private static List<String> list;
|
||||
private static Vector bottomCorner;
|
||||
private static Vector topCorner;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
list = new ArrayList<String>();
|
||||
list.add(Material.SEEDS.toString());
|
||||
list.add("coal_ore");
|
||||
list.add("torch");
|
||||
bottomCorner = new Vector(-10.50, 50.25, 100.00);
|
||||
topCorner = new Vector(50, 100, 250);
|
||||
}
|
||||
@BeforeClass
|
||||
public static void setUp() throws Exception {
|
||||
list = new ArrayList<String>();
|
||||
list.add(Material.SEEDS.toString());
|
||||
list.add("coal_ore");
|
||||
list.add("torch");
|
||||
bottomCorner = new Vector(-10.50, 50.25, 100.00);
|
||||
topCorner = new Vector(50, 100, 250);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
bottomCorner = null;
|
||||
topCorner = null;
|
||||
list = null;
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
bottomCorner = null;
|
||||
topCorner = null;
|
||||
list = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsInsideAB() {
|
||||
Vector inside = new Vector(35, 64, 110);
|
||||
assertTrue(Util.isInsideAB(inside, bottomCorner, topCorner));
|
||||
}
|
||||
@Test
|
||||
public void testIsInsideAB() {
|
||||
Vector inside = new Vector(35, 64, 110);
|
||||
assertTrue(Util.isInsideAB(inside, bottomCorner, topCorner));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsOutsideAB() {
|
||||
Vector outside = new Vector(350, 15, 350);
|
||||
assertFalse(Util.isInsideAB(outside, bottomCorner, topCorner));
|
||||
}
|
||||
@Test
|
||||
public void testIsOutsideAB() {
|
||||
Vector outside = new Vector(350, 15, 350);
|
||||
assertFalse(Util.isInsideAB(outside, bottomCorner, topCorner));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHalfInHalfOutsideAB() {
|
||||
Vector halfAndHalf = new Vector(25, 75, 99);
|
||||
assertFalse(Util.isInsideAB(halfAndHalf, bottomCorner, topCorner));
|
||||
}
|
||||
@Test
|
||||
public void testHalfInHalfOutsideAB() {
|
||||
Vector halfAndHalf = new Vector(25, 75, 99);
|
||||
assertFalse(Util.isInsideAB(halfAndHalf, bottomCorner, topCorner));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInList() {
|
||||
assertTrue(Util.isStringInsideList(list, "seeds"));
|
||||
assertTrue(Util.isStringInsideList(list, Material.COAL_ORE.toString()));
|
||||
assertTrue(Util.isStringInsideList(list, "tOrCh"));
|
||||
}
|
||||
@Test
|
||||
public void testInList() {
|
||||
assertTrue(Util.isStringInsideList(list, "seeds"));
|
||||
assertTrue(Util.isStringInsideList(list, Material.COAL_ORE.toString()));
|
||||
assertTrue(Util.isStringInsideList(list, "tOrCh"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNotInList() {
|
||||
assertFalse(Util.isStringInsideList(list, "dirt"));
|
||||
assertFalse(Util.isStringInsideList(list, "SAND"));
|
||||
assertFalse(Util.isStringInsideList(list, Material.BEDROCK.toString()));
|
||||
}
|
||||
@Test
|
||||
public void testNotInList() {
|
||||
assertFalse(Util.isStringInsideList(list, "dirt"));
|
||||
assertFalse(Util.isStringInsideList(list, "SAND"));
|
||||
assertFalse(Util.isStringInsideList(list, Material.BEDROCK.toString()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoFormat() throws Exception {
|
||||
assertEquals(60000L, Util.getTime("1"), 0);
|
||||
assertEquals(360000L, Util.getTime("6"), 0);
|
||||
}
|
||||
@Test
|
||||
public void testNoFormat() throws Exception {
|
||||
assertEquals(60000L, Util.getTime("1"), 0);
|
||||
assertEquals(360000L, Util.getTime("6"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeSeconds() throws Exception {
|
||||
assertEquals(2000L, Util.getTime("2s"), 0);
|
||||
assertEquals(2000L, Util.getTime("2second"), 0);
|
||||
assertEquals(2000L, Util.getTime("2seconds"), 0);
|
||||
}
|
||||
@Test
|
||||
public void testTimeSeconds() throws Exception {
|
||||
assertEquals(2000L, Util.getTime("2s"), 0);
|
||||
assertEquals(2000L, Util.getTime("2second"), 0);
|
||||
assertEquals(2000L, Util.getTime("2seconds"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeMinutes() throws Exception {
|
||||
assertEquals(60000L, Util.getTime("1m"), 0);
|
||||
assertEquals(60000L, Util.getTime("1minute"), 0);
|
||||
assertEquals(60000L, Util.getTime("1minutes"), 0);
|
||||
}
|
||||
@Test
|
||||
public void testTimeMinutes() throws Exception {
|
||||
assertEquals(60000L, Util.getTime("1m"), 0);
|
||||
assertEquals(60000L, Util.getTime("1minute"), 0);
|
||||
assertEquals(60000L, Util.getTime("1minutes"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeHours() throws Exception {
|
||||
assertEquals(3600000L, Util.getTime("1h"), 0);
|
||||
assertEquals(3600000L, Util.getTime("1hours"), 0);
|
||||
}
|
||||
@Test
|
||||
public void testTimeHours() throws Exception {
|
||||
assertEquals(3600000L, Util.getTime("1h"), 0);
|
||||
assertEquals(3600000L, Util.getTime("1hours"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeDays() throws Exception {
|
||||
assertEquals(86400000L, Util.getTime("1d"), 0);
|
||||
assertEquals(86400000L, Util.getTime("1days"), 0);
|
||||
}
|
||||
@Test
|
||||
public void testTimeDays() throws Exception {
|
||||
assertEquals(86400000L, Util.getTime("1d"), 0);
|
||||
assertEquals(86400000L, Util.getTime("1days"), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeSecondsPassed() throws Exception {
|
||||
assertEquals(60L, Util.getTime("60", TimeUnit.MINUTES), 0);
|
||||
assertEquals(1L, Util.getTime("60s", TimeUnit.MINUTES), 0);
|
||||
assertEquals(1L, Util.getTime("60m", TimeUnit.HOURS), 0);
|
||||
assertEquals(6L, Util.getTime("6d", TimeUnit.DAYS), 0);
|
||||
}
|
||||
@Test
|
||||
public void testTimeSecondsPassed() throws Exception {
|
||||
assertEquals(60L, Util.getTime("60", TimeUnit.MINUTES), 0);
|
||||
assertEquals(1L, Util.getTime("60s", TimeUnit.MINUTES), 0);
|
||||
assertEquals(1L, Util.getTime("60m", TimeUnit.HOURS), 0);
|
||||
assertEquals(6L, Util.getTime("6d", TimeUnit.DAYS), 0);
|
||||
}
|
||||
}
|
||||
|
@ -1,301 +1,301 @@
|
||||
package test.java.com.graywolf336.jail.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
public class MockPlayerInventory implements PlayerInventory {
|
||||
|
||||
private int armorSize = 4, inventorySize = 36;
|
||||
ItemStack[] armorContents = new ItemStack[armorSize];
|
||||
ItemStack[] inventoryContents = new ItemStack[inventorySize];
|
||||
private int armorSize = 4, inventorySize = 36;
|
||||
ItemStack[] armorContents = new ItemStack[armorSize];
|
||||
ItemStack[] inventoryContents = new ItemStack[inventorySize];
|
||||
|
||||
@Override
|
||||
public ItemStack[] getArmorContents() {
|
||||
return armorContents;
|
||||
}
|
||||
@Override
|
||||
public ItemStack[] getArmorContents() {
|
||||
return armorContents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
return armorContents[0];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getHelmet() {
|
||||
return armorContents[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
return armorContents[1];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getChestplate() {
|
||||
return armorContents[1];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
return armorContents[2];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getLeggings() {
|
||||
return armorContents[2];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
return armorContents[3];
|
||||
}
|
||||
@Override
|
||||
public ItemStack getBoots() {
|
||||
return armorContents[3];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setArmorContents(ItemStack[] itemStacks) {
|
||||
this.armorContents = itemStacks;
|
||||
}
|
||||
@Override
|
||||
public void setArmorContents(ItemStack[] itemStacks) {
|
||||
this.armorContents = itemStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHelmet(ItemStack itemStack) {
|
||||
this.armorContents[0] = itemStack;
|
||||
}
|
||||
@Override
|
||||
public void setHelmet(ItemStack itemStack) {
|
||||
this.armorContents[0] = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChestplate(ItemStack itemStack) {
|
||||
this.armorContents[1] = itemStack;
|
||||
}
|
||||
@Override
|
||||
public void setChestplate(ItemStack itemStack) {
|
||||
this.armorContents[1] = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLeggings(ItemStack itemStack) {
|
||||
this.armorContents[2] = itemStack;
|
||||
}
|
||||
@Override
|
||||
public void setLeggings(ItemStack itemStack) {
|
||||
this.armorContents[2] = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoots(ItemStack itemStack) {
|
||||
this.armorContents[3] = itemStack;
|
||||
}
|
||||
@Override
|
||||
public void setBoots(ItemStack itemStack) {
|
||||
this.armorContents[3] = itemStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItemInHand() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack itemStack) {
|
||||
@Override
|
||||
public void setItemInHand(ItemStack itemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeldItemSlot() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getHeldItemSlot() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clear(int i, int i2) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int clear(int i, int i2) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HumanEntity getHolder() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HumanEntity getHolder() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return inventoryContents.length + armorContents.length;
|
||||
}
|
||||
@Override
|
||||
public int getSize() {
|
||||
return inventoryContents.length + armorContents.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItem(int i) {
|
||||
if (i >= 0 && i < inventorySize) {
|
||||
return inventoryContents[i];
|
||||
} else if (i >= inventorySize
|
||||
&& i < inventorySize + armorSize) {
|
||||
return armorContents[i - inventorySize];
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public ItemStack getItem(int i) {
|
||||
if (i >= 0 && i < inventorySize) {
|
||||
return inventoryContents[i];
|
||||
} else if (i >= inventorySize
|
||||
&& i < inventorySize + armorSize) {
|
||||
return armorContents[i - inventorySize];
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(int i, ItemStack itemStack) {
|
||||
if (i >= 0 && i < inventorySize) {
|
||||
inventoryContents[i] = itemStack;
|
||||
} else if (i >= inventorySize
|
||||
&& i < inventorySize + armorSize) {
|
||||
armorContents[i - inventorySize] = itemStack;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setItem(int i, ItemStack itemStack) {
|
||||
if (i >= 0 && i < inventorySize) {
|
||||
inventoryContents[i] = itemStack;
|
||||
} else if (i >= inventorySize
|
||||
&& i < inventorySize + armorSize) {
|
||||
armorContents[i - inventorySize] = itemStack;
|
||||
} else {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> addItem(ItemStack... itemStacks) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HashMap<Integer, ItemStack> removeItem(ItemStack... itemStacks) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getContents() {
|
||||
return this.inventoryContents;
|
||||
}
|
||||
@Override
|
||||
public ItemStack[] getContents() {
|
||||
return this.inventoryContents;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContents(ItemStack[] itemStacks) {
|
||||
this.inventoryContents = itemStacks;
|
||||
}
|
||||
@Override
|
||||
public void setContents(ItemStack[] itemStacks) {
|
||||
this.inventoryContents = itemStacks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int i) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material material) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(ItemStack itemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(int i, int i1) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(int i, int i1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Material material, int i) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(Material material, int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(ItemStack itemStack, int i) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean contains(ItemStack itemStack, int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(int i) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(Material material) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public HashMap<Integer, ? extends ItemStack> all(ItemStack itemStack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(int i) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int first(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(Material material) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int first(Material material) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int first(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int first(ItemStack itemStack) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int firstEmpty() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int firstEmpty() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(int i) {
|
||||
@Override
|
||||
public void remove(int i) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Material material) {
|
||||
@Override
|
||||
public void remove(Material material) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(ItemStack itemStack) {
|
||||
@Override
|
||||
public void remove(ItemStack itemStack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(int i) {
|
||||
inventoryContents[i] = null;
|
||||
}
|
||||
@Override
|
||||
public void clear(int i) {
|
||||
inventoryContents[i] = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
@Override
|
||||
public void clear() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HumanEntity> getViewers() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public List<HumanEntity> getViewers() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryType getType() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public InventoryType getType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxStackSize(int i) {
|
||||
@Override
|
||||
public void setMaxStackSize(int i) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator(int i) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public ListIterator<ItemStack> iterator(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAtLeast(final ItemStack itemStack, final int i) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean containsAtLeast(final ItemStack itemStack, final int i) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Map<String, Object> makeMap(ItemStack[] items) {
|
||||
Map<String, Object> contents = new LinkedHashMap<String, Object>(
|
||||
items.length);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getTypeId() != 0) {
|
||||
contents.put(Integer.valueOf(i).toString(), items[i]);
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Map<String, Object> makeMap(ItemStack[] items) {
|
||||
Map<String, Object> contents = new LinkedHashMap<String, Object>(
|
||||
items.length);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i] != null && items[i].getTypeId() != 0) {
|
||||
contents.put(Integer.valueOf(i).toString(), items[i]);
|
||||
}
|
||||
}
|
||||
return contents;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "{\"inventoryContents\":" + makeMap(getContents())
|
||||
+ ",\"armorContents\":" + makeMap(getArmorContents()) + "}";
|
||||
}
|
||||
public String toString() {
|
||||
return "{\"inventoryContents\":" + makeMap(getContents())
|
||||
+ ",\"armorContents\":" + makeMap(getArmorContents()) + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHeldItemSlot(int slot) {
|
||||
@Override
|
||||
public void setHeldItemSlot(int slot) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,11 @@
|
||||
package test.java.com.graywolf336.jail.util;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@ -18,8 +24,6 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class MockWorldFactory {
|
||||
|
||||
private static final Map<String, World> createdWorlds = new HashMap<String, World>();
|
||||
@ -97,7 +101,7 @@ public class MockWorldFactory {
|
||||
});
|
||||
when(mockWorld.getBlockAt(any(Location.class))).thenAnswer(new Answer<Block>() {
|
||||
@SuppressWarnings("deprecation")
|
||||
public Block answer(InvocationOnMock invocation) throws Throwable {
|
||||
public Block answer(InvocationOnMock invocation) throws Throwable {
|
||||
Location loc;
|
||||
try {
|
||||
loc = (Location) invocation.getArguments()[0];
|
||||
@ -142,7 +146,7 @@ public class MockWorldFactory {
|
||||
});
|
||||
when(mockWorld.getBlockAt(any(Location.class))).thenAnswer(new Answer<Block>() {
|
||||
@SuppressWarnings("deprecation")
|
||||
public Block answer(InvocationOnMock invocation) throws Throwable {
|
||||
public Block answer(InvocationOnMock invocation) throws Throwable {
|
||||
Location loc;
|
||||
try {
|
||||
loc = (Location) invocation.getArguments()[0];
|
||||
|
@ -1,5 +1,16 @@
|
||||
package test.java.com.graywolf336.jail.util;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyBoolean;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.powermock.api.support.membermodification.MemberMatcher.constructor;
|
||||
import static org.powermock.api.support.membermodification.MemberModifier.suppress;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
@ -12,9 +23,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.inventory.CraftItemFactory;
|
||||
@ -26,90 +37,82 @@ import org.bukkit.plugin.PluginLogger;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.core.MockGateway;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.powermock.api.support.membermodification.MemberMatcher.constructor;
|
||||
import static org.powermock.api.support.membermodification.MemberModifier.suppress;
|
||||
|
||||
import com.graywolf336.jail.JailMain;
|
||||
|
||||
@PrepareForTest({ CraftItemFactory.class })
|
||||
public class TestInstanceCreator {
|
||||
private JailMain main;
|
||||
private Server mockServer;
|
||||
private Player mockPlayer;
|
||||
private CommandSender mockSender, mockPlayerSender;
|
||||
private ConsoleCommandSender consoleSender;
|
||||
private JailMain main;
|
||||
private Server mockServer;
|
||||
private Player mockPlayer;
|
||||
private CommandSender mockSender, mockPlayerSender;
|
||||
private ConsoleCommandSender consoleSender;
|
||||
|
||||
public static final File serverDirectory = new File("bin" + File.separator + "test" + File.separator + "server");
|
||||
public static final File worldsDirectory = new File("bin" + File.separator + "test" + File.separator + "server");
|
||||
public static final File pluginDirectory = new File(serverDirectory + File.separator + "plugins" + File.separator + "JailTest");
|
||||
public static final File serverDirectory = new File("bin" + File.separator + "test" + File.separator + "server");
|
||||
public static final File worldsDirectory = new File("bin" + File.separator + "test" + File.separator + "server");
|
||||
public static final File pluginDirectory = new File(serverDirectory + File.separator + "plugins" + File.separator + "JailTest");
|
||||
|
||||
public boolean setup() {
|
||||
try {
|
||||
pluginDirectory.mkdirs();
|
||||
Assert.assertTrue(pluginDirectory.exists());
|
||||
public boolean setup() {
|
||||
try {
|
||||
pluginDirectory.mkdirs();
|
||||
Assert.assertTrue(pluginDirectory.exists());
|
||||
|
||||
MockGateway.MOCK_STANDARD_METHODS = false;
|
||||
MockGateway.MOCK_STANDARD_METHODS = false;
|
||||
|
||||
// Initialize the Mock server.
|
||||
mockServer = mock(Server.class);
|
||||
when(mockServer.getName()).thenReturn("TestBukkit");
|
||||
when(mockServer.getVersion()).thenReturn("Jail-Testing-0.0.1");
|
||||
when(mockServer.getBukkitVersion()).thenReturn("0.0.1");
|
||||
Logger.getLogger("Minecraft").setParent(Util.logger);
|
||||
when(mockServer.getLogger()).thenReturn(Util.logger);
|
||||
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
||||
when(mockServer.getItemFactory()).thenReturn(CraftItemFactory.instance());
|
||||
// Initialize the Mock server.
|
||||
mockServer = mock(Server.class);
|
||||
when(mockServer.getName()).thenReturn("TestBukkit");
|
||||
when(mockServer.getVersion()).thenReturn("Jail-Testing-0.0.1");
|
||||
when(mockServer.getBukkitVersion()).thenReturn("0.0.1");
|
||||
Logger.getLogger("Minecraft").setParent(Util.logger);
|
||||
when(mockServer.getLogger()).thenReturn(Util.logger);
|
||||
when(mockServer.getWorldContainer()).thenReturn(worldsDirectory);
|
||||
when(mockServer.getItemFactory()).thenReturn(CraftItemFactory.instance());
|
||||
|
||||
MockWorldFactory.makeNewMockWorld("world", Environment.NORMAL, WorldType.NORMAL);
|
||||
MockWorldFactory.makeNewMockWorld("world", Environment.NORMAL, WorldType.NORMAL);
|
||||
|
||||
suppress(constructor(JailMain.class));
|
||||
main = PowerMockito.spy(new JailMain());
|
||||
suppress(constructor(JailMain.class));
|
||||
main = PowerMockito.spy(new JailMain());
|
||||
|
||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Jail", "3.0.0-Test", "com.graywolf336.jail.JailMain"));
|
||||
when(pdf.getPrefix()).thenReturn("Jail");
|
||||
List<String> authors = new ArrayList<String>();
|
||||
authors.add("matejdro");
|
||||
authors.add("multidude");
|
||||
authors.add("graywolf336");
|
||||
when(pdf.getAuthors()).thenReturn(authors);
|
||||
when(main.getDescription()).thenReturn(pdf);
|
||||
when(main.getDataFolder()).thenReturn(pluginDirectory);
|
||||
when(main.isEnabled()).thenReturn(true);
|
||||
when(main.getLogger()).thenReturn(Util.logger);
|
||||
when(main.getServer()).thenReturn(mockServer);
|
||||
PluginDescriptionFile pdf = PowerMockito.spy(new PluginDescriptionFile("Jail", "3.0.0-Test", "com.graywolf336.jail.JailMain"));
|
||||
when(pdf.getPrefix()).thenReturn("Jail");
|
||||
List<String> authors = new ArrayList<String>();
|
||||
authors.add("matejdro");
|
||||
authors.add("multidude");
|
||||
authors.add("graywolf336");
|
||||
when(pdf.getAuthors()).thenReturn(authors);
|
||||
when(main.getDescription()).thenReturn(pdf);
|
||||
when(main.getDataFolder()).thenReturn(pluginDirectory);
|
||||
when(main.isEnabled()).thenReturn(true);
|
||||
when(main.getLogger()).thenReturn(Util.logger);
|
||||
when(main.getServer()).thenReturn(mockServer);
|
||||
|
||||
Field configFile = JavaPlugin.class.getDeclaredField("configFile");
|
||||
configFile.setAccessible(true);
|
||||
configFile.set(main, new File(pluginDirectory, "config.yml"));
|
||||
Field configFile = JavaPlugin.class.getDeclaredField("configFile");
|
||||
configFile.setAccessible(true);
|
||||
configFile.set(main, new File(pluginDirectory, "config.yml"));
|
||||
|
||||
Field logger = JavaPlugin.class.getDeclaredField("logger");
|
||||
logger.setAccessible(true);
|
||||
logger.set(main, new PluginLogger(main));
|
||||
Field logger = JavaPlugin.class.getDeclaredField("logger");
|
||||
logger.setAccessible(true);
|
||||
logger.set(main, new PluginLogger(main));
|
||||
|
||||
doReturn(getClass().getClassLoader().getResourceAsStream("config.yml")).when(main).getResource("config.yml");
|
||||
doReturn(getClass().getClassLoader().getResourceAsStream("en.yml")).when(main).getResource("en.yml");
|
||||
doReturn(getClass().getClassLoader().getResourceAsStream("config.yml")).when(main).getResource("config.yml");
|
||||
doReturn(getClass().getClassLoader().getResourceAsStream("en.yml")).when(main).getResource("en.yml");
|
||||
|
||||
// Add Jail to the list of loaded plugins
|
||||
JavaPlugin[] plugins = new JavaPlugin[] { main };
|
||||
// Add Jail to the list of loaded plugins
|
||||
JavaPlugin[] plugins = new JavaPlugin[] { main };
|
||||
|
||||
// Mock the Plugin Manager
|
||||
PluginManager mockPluginManager = PowerMockito.mock(PluginManager.class);
|
||||
when(mockPluginManager.getPlugins()).thenReturn(plugins);
|
||||
when(mockPluginManager.getPlugin("Jail")).thenReturn(main);
|
||||
when(mockPluginManager.getPermission(anyString())).thenReturn(null);
|
||||
// Mock the Plugin Manager
|
||||
PluginManager mockPluginManager = PowerMockito.mock(PluginManager.class);
|
||||
when(mockPluginManager.getPlugins()).thenReturn(plugins);
|
||||
when(mockPluginManager.getPlugin("Jail")).thenReturn(main);
|
||||
when(mockPluginManager.getPermission(anyString())).thenReturn(null);
|
||||
|
||||
// Give the server some worlds
|
||||
when(mockServer.getWorld(anyString())).thenAnswer(new Answer<World>() {
|
||||
@ -142,25 +145,25 @@ public class TestInstanceCreator {
|
||||
}
|
||||
});
|
||||
|
||||
when(mockServer.getPluginManager()).thenReturn(mockPluginManager);
|
||||
when(mockServer.getPluginManager()).thenReturn(mockPluginManager);
|
||||
|
||||
when(mockServer.createWorld(Matchers.isA(WorldCreator.class))).thenAnswer(
|
||||
new Answer<World>() {
|
||||
public World answer(InvocationOnMock invocation) throws Throwable {
|
||||
WorldCreator arg;
|
||||
try {
|
||||
arg = (WorldCreator) invocation.getArguments()[0];
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
// Add special case for creating null worlds.
|
||||
// Not sure I like doing it this way, but this is a special case
|
||||
if (arg.name().equalsIgnoreCase("nullworld")) {
|
||||
return MockWorldFactory.makeNewNullMockWorld(arg.name(), arg.environment(), arg.type());
|
||||
}
|
||||
return MockWorldFactory.makeNewMockWorld(arg.name(), arg.environment(), arg.type());
|
||||
}
|
||||
});
|
||||
when(mockServer.createWorld(Matchers.isA(WorldCreator.class))).thenAnswer(
|
||||
new Answer<World>() {
|
||||
public World answer(InvocationOnMock invocation) throws Throwable {
|
||||
WorldCreator arg;
|
||||
try {
|
||||
arg = (WorldCreator) invocation.getArguments()[0];
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
// Add special case for creating null worlds.
|
||||
// Not sure I like doing it this way, but this is a special case
|
||||
if (arg.name().equalsIgnoreCase("nullworld")) {
|
||||
return MockWorldFactory.makeNewNullMockWorld(arg.name(), arg.environment(), arg.type());
|
||||
}
|
||||
return MockWorldFactory.makeNewMockWorld(arg.name(), arg.environment(), arg.type());
|
||||
}
|
||||
});
|
||||
|
||||
when(mockServer.unloadWorld(anyString(), anyBoolean())).thenReturn(true);
|
||||
|
||||
@ -204,144 +207,144 @@ public class TestInstanceCreator {
|
||||
}});
|
||||
when(mockServer.getScheduler()).thenReturn(mockScheduler);
|
||||
|
||||
// Set server
|
||||
Field serverField = JavaPlugin.class.getDeclaredField("server");
|
||||
serverField.setAccessible(true);
|
||||
serverField.set(main, mockServer);
|
||||
// Set server
|
||||
Field serverField = JavaPlugin.class.getDeclaredField("server");
|
||||
serverField.setAccessible(true);
|
||||
serverField.set(main, mockServer);
|
||||
|
||||
// Init our command sender
|
||||
final Logger consoleSenderLogger = Logger.getLogger("ConsoleCommandSender");
|
||||
consoleSenderLogger.setParent(Util.logger);
|
||||
consoleSender = mock(ConsoleCommandSender.class);
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
consoleSenderLogger.info(ChatColor.stripColor((String) invocation.getArguments()[0]));
|
||||
return null;
|
||||
}
|
||||
}).when(consoleSender).sendMessage(anyString());
|
||||
when(consoleSender.getServer()).thenReturn(mockServer);
|
||||
when(consoleSender.getName()).thenReturn("MockCommandSender");
|
||||
when(consoleSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(consoleSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(consoleSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(consoleSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(consoleSender.addAttachment(main)).thenReturn(null);
|
||||
when(consoleSender.isOp()).thenReturn(true);
|
||||
when(mockServer.getConsoleSender()).thenReturn(consoleSender);
|
||||
// Init our command sender
|
||||
final Logger consoleSenderLogger = Logger.getLogger("ConsoleCommandSender");
|
||||
consoleSenderLogger.setParent(Util.logger);
|
||||
consoleSender = mock(ConsoleCommandSender.class);
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
consoleSenderLogger.info(ChatColor.stripColor((String) invocation.getArguments()[0]));
|
||||
return null;
|
||||
}
|
||||
}).when(consoleSender).sendMessage(anyString());
|
||||
when(consoleSender.getServer()).thenReturn(mockServer);
|
||||
when(consoleSender.getName()).thenReturn("MockCommandSender");
|
||||
when(consoleSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(consoleSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(consoleSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(consoleSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(consoleSender.addAttachment(main)).thenReturn(null);
|
||||
when(consoleSender.isOp()).thenReturn(true);
|
||||
when(mockServer.getConsoleSender()).thenReturn(consoleSender);
|
||||
|
||||
// Init our command sender
|
||||
final Logger commandSenderLogger = Logger.getLogger("CommandSender");
|
||||
commandSenderLogger.setParent(Util.logger);
|
||||
mockSender = mock(CommandSender.class);
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
commandSenderLogger.info(ChatColor.stripColor((String) invocation.getArguments()[0]));
|
||||
return null;
|
||||
}
|
||||
}).when(mockSender).sendMessage(anyString());
|
||||
when(mockSender.getServer()).thenReturn(mockServer);
|
||||
when(mockSender.getName()).thenReturn("MockCommandSender");
|
||||
when(mockSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockSender.addAttachment(main)).thenReturn(null);
|
||||
when(mockSender.isOp()).thenReturn(true);
|
||||
// Init our command sender
|
||||
final Logger commandSenderLogger = Logger.getLogger("CommandSender");
|
||||
commandSenderLogger.setParent(Util.logger);
|
||||
mockSender = mock(CommandSender.class);
|
||||
doAnswer(new Answer<Void>() {
|
||||
public Void answer(InvocationOnMock invocation) throws Throwable {
|
||||
commandSenderLogger.info(ChatColor.stripColor((String) invocation.getArguments()[0]));
|
||||
return null;
|
||||
}
|
||||
}).when(mockSender).sendMessage(anyString());
|
||||
when(mockSender.getServer()).thenReturn(mockServer);
|
||||
when(mockSender.getName()).thenReturn("MockCommandSender");
|
||||
when(mockSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockSender.addAttachment(main)).thenReturn(null);
|
||||
when(mockSender.isOp()).thenReturn(true);
|
||||
|
||||
// Init our player, who is op and who has all permissions (with name of graywolf336)
|
||||
mockPlayer = mock(Player.class);
|
||||
when(mockPlayer.getUniqueId()).thenReturn(UUID.fromString("062c14ba-4c47-4757-911b-bbf9a60dab7b"));
|
||||
when(mockPlayer.getName()).thenReturn("graywolf336");
|
||||
when(mockPlayer.getDisplayName()).thenReturn("TheGrayWolf");
|
||||
when(mockPlayer.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockPlayer.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayer.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockPlayer.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayer.isOp()).thenReturn(true);
|
||||
when(mockPlayer.getInventory()).thenReturn(new MockPlayerInventory());
|
||||
// Init our player, who is op and who has all permissions (with name of graywolf336)
|
||||
mockPlayer = mock(Player.class);
|
||||
when(mockPlayer.getUniqueId()).thenReturn(UUID.fromString("062c14ba-4c47-4757-911b-bbf9a60dab7b"));
|
||||
when(mockPlayer.getName()).thenReturn("graywolf336");
|
||||
when(mockPlayer.getDisplayName()).thenReturn("TheGrayWolf");
|
||||
when(mockPlayer.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockPlayer.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayer.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockPlayer.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayer.isOp()).thenReturn(true);
|
||||
when(mockPlayer.getInventory()).thenReturn(new MockPlayerInventory());
|
||||
|
||||
// Init our second command sender, but this time is an instance of a player
|
||||
mockPlayerSender = (CommandSender) mockPlayer;
|
||||
when(mockPlayerSender.getServer()).thenReturn(mockServer);
|
||||
when(mockPlayerSender.getName()).thenReturn("graywolf336");
|
||||
when(mockPlayerSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockPlayerSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayerSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockPlayerSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayerSender.addAttachment(main)).thenReturn(null);
|
||||
when(mockPlayerSender.isOp()).thenReturn(true);
|
||||
// Init our second command sender, but this time is an instance of a player
|
||||
mockPlayerSender = mockPlayer;
|
||||
when(mockPlayerSender.getServer()).thenReturn(mockServer);
|
||||
when(mockPlayerSender.getName()).thenReturn("graywolf336");
|
||||
when(mockPlayerSender.isPermissionSet(anyString())).thenReturn(true);
|
||||
when(mockPlayerSender.isPermissionSet(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayerSender.hasPermission(anyString())).thenReturn(true);
|
||||
when(mockPlayerSender.hasPermission(Matchers.isA(Permission.class))).thenReturn(true);
|
||||
when(mockPlayerSender.addAttachment(main)).thenReturn(null);
|
||||
when(mockPlayerSender.isOp()).thenReturn(true);
|
||||
|
||||
Bukkit.setServer(mockServer);
|
||||
Bukkit.setServer(mockServer);
|
||||
|
||||
// Load Jail
|
||||
main.onLoad();
|
||||
// Load Jail
|
||||
main.onLoad();
|
||||
|
||||
// Enable it and turn on debugging
|
||||
main.onEnable();
|
||||
main.setDebugging(true);
|
||||
// Enable it and turn on debugging
|
||||
main.onEnable();
|
||||
main.setDebugging(true);
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean tearDown() {
|
||||
try {
|
||||
Field serverField = Bukkit.class.getDeclaredField("server");
|
||||
serverField.setAccessible(true);
|
||||
serverField.set(Class.forName("org.bukkit.Bukkit"), null);
|
||||
} catch (Exception e) {
|
||||
Util.log(Level.SEVERE, "Error while trying to unregister the server from Bukkit. Has Bukkit changed?");
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
public boolean tearDown() {
|
||||
try {
|
||||
Field serverField = Bukkit.class.getDeclaredField("server");
|
||||
serverField.setAccessible(true);
|
||||
serverField.set(Class.forName("org.bukkit.Bukkit"), null);
|
||||
} catch (Exception e) {
|
||||
Util.log(Level.SEVERE, "Error while trying to unregister the server from Bukkit. Has Bukkit changed?");
|
||||
e.printStackTrace();
|
||||
Assert.fail(e.getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
main.onDisable();
|
||||
main.onDisable();
|
||||
|
||||
MockWorldFactory.clearWorlds();
|
||||
MockWorldFactory.clearWorlds();
|
||||
|
||||
deleteFolder(pluginDirectory);
|
||||
deleteFolder(worldsDirectory);
|
||||
deleteFolder(serverDirectory);
|
||||
return true;
|
||||
}
|
||||
deleteFolder(pluginDirectory);
|
||||
deleteFolder(worldsDirectory);
|
||||
deleteFolder(serverDirectory);
|
||||
return true;
|
||||
}
|
||||
|
||||
public JailMain getMain() {
|
||||
return this.main;
|
||||
}
|
||||
public JailMain getMain() {
|
||||
return this.main;
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
return this.mockServer;
|
||||
}
|
||||
public Server getServer() {
|
||||
return this.mockServer;
|
||||
}
|
||||
|
||||
public CommandSender getCommandSender() {
|
||||
return this.mockSender;
|
||||
}
|
||||
public CommandSender getCommandSender() {
|
||||
return this.mockSender;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.mockPlayer;
|
||||
}
|
||||
public Player getPlayer() {
|
||||
return this.mockPlayer;
|
||||
}
|
||||
|
||||
public CommandSender getPlayerCommandSender() {
|
||||
return this.mockPlayerSender;
|
||||
}
|
||||
public CommandSender getPlayerCommandSender() {
|
||||
return this.mockPlayerSender;
|
||||
}
|
||||
|
||||
private void deleteFolder(File folder) {
|
||||
File[] files = folder.listFiles();
|
||||
if(files != null) {
|
||||
for(File f: files) {
|
||||
if(f.isDirectory()) {
|
||||
deleteFolder(f);
|
||||
}else {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void deleteFolder(File folder) {
|
||||
File[] files = folder.listFiles();
|
||||
if(files != null) {
|
||||
for(File f: files) {
|
||||
if(f.isDirectory()) {
|
||||
deleteFolder(f);
|
||||
}else {
|
||||
f.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
folder.delete();
|
||||
}
|
||||
folder.delete();
|
||||
}
|
||||
}
|
||||
|
@ -15,8 +15,8 @@ public class TestLogFormatter extends Formatter {
|
||||
StringBuilder ret = new StringBuilder();
|
||||
|
||||
ret.append("[").append(df.format(record.getMillis())).append("] [")
|
||||
.append(record.getLoggerName()).append("] [")
|
||||
.append(record.getLevel().getLocalizedName()).append("] ");
|
||||
.append(record.getLoggerName()).append("] [")
|
||||
.append(record.getLevel().getLocalizedName()).append("] ");
|
||||
ret.append(record.getMessage());
|
||||
ret.append('\n');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user