Simplify the language system and the language calls, also fix the

language system not copying over the new values when new values were
added.
This commit is contained in:
graywolf336 2014-07-24 21:16:57 -05:00
parent bf59a57ea7
commit 1898121643
39 changed files with 515 additions and 519 deletions

View File

@ -2,7 +2,7 @@
====
This plugins adds Jail to your Minecraft server. Admins can define several jails and then jail/unjail people or jail them on time basis. Plugin also offers wide variety of protections, so players won't escape out of your jail.
[![Build Status](http://ci.graywolf336.com/job/Jail/badge/icon)](http://ci.graywolf336.com/job/Jail/)
[![Build Status](http://ci.graywolf336.com/job/Jail/badge/icon)](http://ci.graywolf336.com/job/Jail/) **|** [Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
Beta 3 Changes
===
@ -13,6 +13,7 @@ Beta 3 Changes
* Make the timer async, this helps performance when you have a ton of prisoners
* Lots of work on unit testing
* Changed the encoding of the project in maven to utf8
* Fixed the language system not copying over new values
Beta 2 Changes
===
@ -66,6 +67,3 @@ Notice
* MaximumAFKTime setting will not convert over, the format isn't clear and the old version didn't provide a way to get values with decimal places
* EnableLogging has been removed, we are always going to be logging (unless major request to control this)
* Prisoner's old inventory strings in the database are lost, we can not convert those
[Jail 3.0 JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc)
====

View File

@ -23,7 +23,7 @@ import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.beans.SimpleLocation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
/**
@ -36,7 +36,7 @@ import com.graywolf336.jail.enums.Settings;
*/
public class JailIO {
private JailMain pl;
private FileConfiguration flat, lang, records;
private FileConfiguration flat, records;
private Connection con;
private int storage; //0 = flatfile, 1 = sqlite, 2 = mysql
private String prefix;
@ -69,60 +69,34 @@ public class JailIO {
//File or folder already exists, let's check
if(langFile.exists()) {
if(langFile.isFile()) {
lang = YamlConfiguration.loadConfiguration(langFile);
Lang.setFile(YamlConfiguration.loadConfiguration(langFile));
pl.getLogger().info("Loaded the language: " + language);
}else {
pl.getLogger().severe("The language file can not be a folder.");
pl.getLogger().severe("As a result, we are reverting back to English as the language.");
lang = YamlConfiguration.loadConfiguration(pl.getResource("en.yml"));
Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("en.yml")));
save = true;
}
}else {
pl.getLogger().warning("Loading the default language of: en");
pl.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file.");
lang = YamlConfiguration.loadConfiguration(pl.getResource("en.yml"));
Lang.setFile(YamlConfiguration.loadConfiguration(pl.getResource("en.yml")));
save = true;
}
//Make sure we have all the new language settings loaded
if(!save) save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(pl.getResource("en.yml")));
//If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded.
if(save) {
try {
lang.save(new File(pl.getDataFolder(), "en.yml"));
Lang.getFile().save(new File(pl.getDataFolder(), "en.yml"));
} catch (IOException e) {
pl.getLogger().severe("Unable to save the language file: " + e.getMessage());
}
}
}
/** Returns the message in the language, no variables are replaced.*/
public String getLanguageString(LangString langString) {
return getLanguageString(langString, new String[] {});
}
/** Returns the message in the language, no variables are replaced.*/
public String getLanguageString(LangString langString, LangString langString2) {
return getLanguageString(langString, getLanguageString(langString2, new String[] {}));
}
/**
* Returns the message in the language, with the provided variables being replaced.
*
* @param langString Which {@link LangString} we should be getting to send.
* @param variables All the variables to replace, in order from 0 to however many.
* @return The message as a colorful message or an empty message if that isn't defined in the language file.
*/
public String getLanguageString(LangString langString, String... variables) {
String message = lang.getString("language." + langString.getSection() + "." + langString.getName());
if(message == null) return "";
for (int i = 0; i < variables.length; i++) {
message = message.replaceAll("%" + i + "%", variables[i]);
}
return Util.getColorfulMessage(message);
}
/** Prepares the storage engine to be used, returns true if everything went good. */
public boolean prepareStorage(boolean doInitialCreations) {
switch(storage) {
@ -1130,7 +1104,7 @@ public class JailIO {
if(records == null) records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
List<String> previous = records.getStringList(uuid);
previous.add(this.getLanguageString(LangString.RECORDENTRY, new String[] { date, username, jailer, String.valueOf(time), reason, uuid }));
previous.add(Lang.RECORDENTRY.get(new String[] { date, username, jailer, String.valueOf(time), reason, uuid }));
records.set(username, previous);
@ -1166,8 +1140,7 @@ public class JailIO {
ResultSet set = ps.executeQuery();
while(set.next()) {
entries.add(this.getLanguageString(LangString.RECORDENTRY,
new String[] { set.getString("date"), set.getString("username"), set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason") }));
entries.add(Lang.RECORDENTRY.get(new String[] { set.getString("date"), set.getString("username"), set.getString("jailer"), String.valueOf(set.getLong("time")), set.getString("reason") }));
}
set.close();

View File

@ -16,7 +16,7 @@ import com.graywolf336.jail.beans.CreationPlayer;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.steps.CellCreationSteps;
import com.graywolf336.jail.steps.JailCreationSteps;
@ -339,9 +339,9 @@ public class JailManager {
getPlugin().getPrisonerManager().schedulePrisonerRelease(p);
}
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName());
return Lang.PRISONERSCLEARED.get(j.getName());
}else {
return getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, jail);
return Lang.NOJAIL.get(jail);
}
}else {
return clearAllJailsOfAllPrisoners();
@ -356,7 +356,7 @@ public class JailManager {
public String clearAllJailsOfAllPrisoners() {
//No name of a jail has been passed, so release all of the prisoners in all the jails
if(getJails().size() == 0) {
return getPlugin().getJailIO().getLanguageString(LangString.NOJAILS);
return Lang.NOJAILS.get();
}else {
for(Jail j : getJails()) {
for(Prisoner p : j.getAllPrisoners().values()) {
@ -364,7 +364,7 @@ public class JailManager {
}
}
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS));
return Lang.PRISONERSCLEARED.get(Lang.ALLJAILS);
}
}
@ -381,22 +381,22 @@ public class JailManager {
public String forcefullyClearJailOrJails(String name) {
if(name == null) {
if(getJails().size() == 0) {
return getPlugin().getJailIO().getLanguageString(LangString.NOJAILS);
return Lang.NOJAILS.get();
}else {
for(Jail j : getJails()) {
j.clearPrisoners();
}
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS));
return Lang.PRISONERSCLEARED.get(Lang.ALLJAILS);
}
}else {
Jail j = getJail(name);
if(j != null) {
j.clearPrisoners();
return getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName());
return Lang.PRISONERSCLEARED.get(j.getName());
}else {
return getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, name);
return Lang.NOJAIL.get(name);
}
}
}
@ -418,18 +418,18 @@ public class JailManager {
if(j.getCell(cell).hasPrisoner()) {
//The cell has a prisoner, so tell them to first transfer the prisoner
//or release the prisoner
return getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVALUNSUCCESSFUL, new String[] { cell, jail });
return Lang.CELLREMOVALUNSUCCESSFUL.get(new String[] { cell, jail });
}else {
j.removeCell(cell);
return getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, new String[] { cell, jail });
return Lang.CELLREMOVED.get(new String[] { cell, jail });
}
}else {
//No cell found by the provided name in the stated jail
return getPlugin().getJailIO().getLanguageString(LangString.NOCELL, new String[] { cell, jail });
return Lang.NOCELL.get(new String[] { cell, jail });
}
}else {
//No jail found by the provided name
return getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, jail);
return Lang.NOJAIL.get(jail);
}
}
@ -448,7 +448,7 @@ public class JailManager {
if(j.getCellCount() == 0) {
//There are no cells in this jail, thus we can't delete them.
msgs.add(getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, j.getName()));
msgs.add(Lang.NOCELLS.get(j.getName()));
}else {
//Keep a local copy of the hashset so that we don't get any CMEs.
HashSet<Cell> cells = new HashSet<Cell>(j.getCells());
@ -457,16 +457,16 @@ public class JailManager {
if(c.hasPrisoner()) {
//The cell has a prisoner, so tell them to first transfer the prisoner
//or release the prisoner
msgs.add(getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVALUNSUCCESSFUL, new String[] { c.getName(), j.getName() }));
msgs.add(Lang.CELLREMOVALUNSUCCESSFUL.get(new String[] { c.getName(), j.getName() }));
}else {
j.removeCell(c.getName());
msgs.add(getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, new String[] { c.getName(), j.getName() }));
msgs.add(Lang.CELLREMOVED.get(new String[] { c.getName(), j.getName() }));
}
}
}
}else {
//No jail found by the provided name
msgs.add(getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, jail));
msgs.add(Lang.NOJAIL.get(jail));
}
return msgs.toArray(new String[msgs.size()]);
@ -485,14 +485,14 @@ public class JailManager {
if(getJail(jail).getAllPrisoners().size() == 0) {
//There are no prisoners, so we can delete it
removeJail(jail);
return getPlugin().getJailIO().getLanguageString(LangString.JAILREMOVED, jail);
return Lang.JAILREMOVED.get(jail);
}else {
//The jail has prisoners, they need to release them first
return getPlugin().getJailIO().getLanguageString(LangString.JAILREMOVALUNSUCCESSFUL, jail);
return Lang.JAILREMOVALUNSUCCESSFUL.get(jail);
}
}else {
//No jail found by the provided name
return getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, jail);
return Lang.NOJAIL.get(jail);
}
}

View File

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
/**
@ -90,7 +90,7 @@ public class JailTimer {
p.setAFKTime(p.getAFKTime() + timePassed);
if(p.getAFKTime() > afkTime) {
p.setAFKTime(0);
player.kickPlayer(pl.getJailIO().getLanguageString(LangString.AFKKICKMESSAGE));
player.kickPlayer(Lang.AFKKICKMESSAGE.get());
}
}

View File

@ -14,7 +14,7 @@ import org.bukkit.inventory.ItemStack;
import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.PrePrisonerReleasedEvent;
import com.graywolf336.jail.events.PrisonerJailedEvent;
@ -107,9 +107,9 @@ public class PrisonerManager {
String msg = "";
if(prisoner.getRemainingTime() < 0L)
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFOREVER, new String[] { prisoner.getLastKnownName() });
msg = Lang.BROADCASTMESSAGEFOREVER.get(prisoner.getLastKnownName());
else
msg = pl.getJailIO().getLanguageString(LangString.BROADCASTMESSAGEFORMINUTES, new String[] { prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()) });
msg = Lang.BROADCASTMESSAGEFORMINUTES.get(new String[] { prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()) });
boolean broadcasted = false;
//Broadcast the message, if it is enabled
@ -158,9 +158,9 @@ public class PrisonerManager {
//If their reason is empty send proper message, else send other proper message
if(prisoner.getReason().isEmpty()) {
player.sendMessage(pl.getJailIO().getLanguageString(LangString.JAILED));
player.sendMessage(Lang.JAILED.get());
}else {
player.sendMessage(pl.getJailIO().getLanguageString(LangString.JAILEDWITHREASON, new String[] { prisoner.getReason() }));
player.sendMessage(Lang.JAILEDWITHREASON.get(prisoner.getReason()));
}
//If the config has releasing them back to their previous position,
@ -495,8 +495,8 @@ public class PrisonerManager {
PrisonerReleasedEvent event = new PrisonerReleasedEvent(jail, cell, prisoner, player);
pl.getServer().getPluginManager().callEvent(event);
player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED));
if(sender != null) sender.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILSUCCESS, player.getName()));
player.sendMessage(Lang.UNJAILED.get());
if(sender != null) sender.sendMessage(Lang.UNJAILSUCCESS.get(player.getName()));
}
/**
@ -559,7 +559,7 @@ public class PrisonerManager {
cell.removePrisoner();
}
if(sender != null) sender.sendMessage(pl.getJailIO().getLanguageString(LangString.FORCEUNJAILED, prisoner.getLastKnownName()));
if(sender != null) sender.sendMessage(Lang.FORCEUNJAILED.get(prisoner.getLastKnownName()));
}else {
try {
unJail(jail, cell, player, prisoner, sender);
@ -602,7 +602,7 @@ public class PrisonerManager {
prisoner.setTeleporting(true);
player.teleport(targetJail.getTeleportIn());
prisoner.setTeleporting(false);
player.sendMessage(pl.getJailIO().getLanguageString(LangString.TRANSFERRED, targetJail.getName()));
player.sendMessage(Lang.TRANSFERRED.get(targetJail.getName()));
}
}else {
//They are set to go to the targetCell, so handle accordingly
@ -619,7 +619,7 @@ public class PrisonerManager {
prisoner.setTeleporting(true);
player.teleport(targetCell.getTeleport());
prisoner.setTeleporting(false);
player.sendMessage(pl.getJailIO().getLanguageString(LangString.TRANSFERRED, targetJail.getName()));
player.sendMessage(Lang.TRANSFERRED.get(targetJail.getName()));
}
}
}else {

View File

@ -15,7 +15,7 @@ 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.enums.LangString;
import com.graywolf336.jail.enums.Lang;
/**
* Where all the commands are registered at and handled, processed, at.
@ -74,7 +74,7 @@ public class CommandHandler {
return;
}
sender.sendMessage(jailmanager.getPlugin().getJailIO().getLanguageString(LangString.UNKNOWNCOMMAND, commandLine));
sender.sendMessage(Lang.UNKNOWNCOMMAND.get(commandLine));
return;
}
@ -90,13 +90,13 @@ public class CommandHandler {
// First, let's check if the sender has permission for the command.
if(!sender.hasPermission(i.permission())) {
sender.sendMessage(jailmanager.getPlugin().getJailIO().getLanguageString(LangString.NOPERMISSION));
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(jailmanager.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
return;
}

View File

@ -35,7 +35,7 @@ import com.graywolf336.jail.command.subcommands.JailTimeCommand;
import com.graywolf336.jail.command.subcommands.JailTransferAllCommand;
import com.graywolf336.jail.command.subcommands.JailTransferCommand;
import com.graywolf336.jail.command.subcommands.JailVersionCommand;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
public class JailHandler {
private LinkedHashMap<String, Command> commands;
@ -100,7 +100,7 @@ public class JailHandler {
if(!i.permission().isEmpty()) {
if(!sender.hasPermission(i.permission())) {
jailmanager.getPlugin().debug("Sender has no permission.");
sender.sendMessage(jailmanager.getPlugin().getJailIO().getLanguageString(LangString.NOPERMISSION));
sender.sendMessage(Lang.NOPERMISSION.get());
return true;
}
}
@ -108,7 +108,7 @@ public class JailHandler {
// 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(jailmanager.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
return true;
}

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -21,19 +21,19 @@ public class HandCuffCommand implements Command {
Player player = jm.getPlugin().getServer().getPlayer(args[0]);
if(player == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
}else if(player.hasPermission("jail.cantbehandcuffed")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEHANDCUFFED, new String[] { player.getName() }));
sender.sendMessage(Lang.CANTBEHANDCUFFED.get(player.getName()));
}else if(jm.isPlayerJailed(player.getUniqueId())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CURRENTLYJAILEDHANDCUFF, new String[] { player.getName() }));
sender.sendMessage(Lang.CURRENTLYJAILEDHANDCUFF.get(player.getName()));
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.UNHANDCUFFED));
player.sendMessage(Lang.UNHANDCUFFED.get());
}else {
jm.getPlugin().getHandCuffManager().addHandCuffs(player.getUniqueId(), player.getLocation());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSON, new String[] { player.getName() }));
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFED));
sender.sendMessage(Lang.HANDCUFFSON.get(player.getName()));
player.sendMessage(Lang.HANDCUFFED.get());
}
return true;

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -21,13 +21,13 @@ public class UnHandCuffCommand implements Command {
Player player = jm.getPlugin().getServer().getPlayerExact(args[0]);
if(player == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE));
sender.sendMessage(Lang.PLAYERNOTONLINE.get());
}else if(jm.getPlugin().getHandCuffManager().isHandCuffed(player.getUniqueId())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.HANDCUFFSRELEASED, new String[] { player.getName() }));
sender.sendMessage(Lang.HANDCUFFSRELEASED.get(player.getName()));
jm.getPlugin().getHandCuffManager().removeHandCuffs(player.getUniqueId());
player.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.UNHANDCUFFED));
player.sendMessage(Lang.UNHANDCUFFED.get());
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHANDCUFFED, new String[] { player.getName() }));
sender.sendMessage(Lang.NOTHANDCUFFED.get(player.getName()));
}
return true;

View File

@ -9,7 +9,7 @@ import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
@CommandInfo(
@ -39,7 +39,7 @@ public class UnJailCommand implements Command {
//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(jm.getPlugin().getJailIO().getLanguageString(LangString.WILLBEUNJAILED, args[0]));
sender.sendMessage(Lang.WILLBEUNJAILED.get(args[0]));
}
}else {
//Player is online, so let's try unjailing them
@ -51,11 +51,11 @@ public class UnJailCommand implements Command {
}
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
jm.getPlugin().getLogger().info(ChatColor.stripColor(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() })));
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
}
}else {
//The player is not currently jailed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0]));
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
}
return true;

View File

@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
@CommandInfo(
@ -25,11 +25,11 @@ public class UnJailForceCommand implements Command {
jm.getPlugin().getPrisonerManager().forceRelease(jm.getPrisonerByLastKnownName(args[0]), sender);
if(jm.getPlugin().getConfig().getBoolean(Settings.LOGJAILINGTOCONSOLE.getPath())) {
jm.getPlugin().getLogger().info(ChatColor.stripColor(jm.getPlugin().getJailIO().getLanguageString(LangString.BROADCASTUNJAILING, new String[] { args[0], sender.getName() })));
jm.getPlugin().getLogger().info(ChatColor.stripColor(Lang.BROADCASTUNJAILING.get(new String[] { args[0], sender.getName() })));
}
}else {
//The player is not currently jailed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0]));
sender.sendMessage(Lang.NOTJAILED.get(args[0]));
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -29,7 +29,7 @@ public class JailCheckCommand implements Command{
//prisoner: reason; jailer (time in minutes)
sender.sendMessage(ChatColor.BLUE + " " + p.getLastKnownName() + ": " + p.getReason() + "; " + p.getJailer() + " (" + p.getRemainingTimeInMinutes() + " mins)");
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1]));
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -22,10 +22,10 @@ public class JailClearCommand implements Command {
// If Jail is specified unjails all the prisoners from that Jail (new feature) otherwise it unjails all the prisoners from all the jails
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEAR));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
sender.sendMessage(Lang.START.get());
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -22,10 +22,10 @@ public class JailClearForceCommand implements Command {
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.CLEARFORCE));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
sender.sendMessage(Lang.START.get());
}
return true; //If they made it this far, the command is intact and ready to be processed. :)

View File

@ -16,7 +16,7 @@ import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.command.commands.jewels.Jailing;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.PrePrisonerJailedEvent;
import com.lexicalscope.jewel.cli.ArgumentValidationException;
@ -46,7 +46,7 @@ public class JailCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(jm.getJails().isEmpty()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
sender.sendMessage(Lang.NOJAILS.get());
return true;
}
@ -67,7 +67,7 @@ public class JailCommand implements Command {
//Check if they've actually given us a player to jail
if(params.getPlayer() == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAPLAYER, LangString.JAILING));
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.JAILING));
return true;
}else {
jm.getPlugin().debug("We are getting ready to handle jailing: " + params.getPlayer());
@ -75,7 +75,7 @@ public class JailCommand implements Command {
//Check if the given player is already jailed or not
if(jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADYJAILED, params.getPlayer()));
sender.sendMessage(Lang.ALREADYJAILED.get(params.getPlayer()));
return true;
}
@ -91,7 +91,7 @@ public class JailCommand implements Command {
time = Util.getTime(params.getTime());
}
}catch(Exception e) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NUMBERFORMATINCORRECT));
sender.sendMessage(Lang.NUMBERFORMATINCORRECT.get());
return true;
}
@ -109,7 +109,7 @@ public class JailCommand implements Command {
jailName = jm.getPlugin().getConfig().getString(Settings.DEFAULTJAIL.getPath());
}
}else if(jm.getJail(params.getJail()) == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, params.getJail()));
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
return true;
}else {
jailName = params.getJail();
@ -119,16 +119,16 @@ public class JailCommand implements Command {
if(params.getCell() != null) {
if(jm.getJail(params.getJail()).getCell(params.getCell()) == null) {
//There is no cell by that name
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, new String[] { params.getCell(), params.getJail() }));
sender.sendMessage(Lang.NOCELL.get(new String[] { params.getCell(), params.getJail() }));
return true;
}else if(jm.getJail(params.getJail()).getCell(params.getCell()).hasPrisoner()) {
//If the cell has a prisoner, don't allow jailing them to that particular cell
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLNOTEMPTY, params.getCell()));
sender.sendMessage(Lang.CELLNOTEMPTY.get(params.getCell()));
Cell suggestedCell = jm.getJail(params.getJail()).getFirstEmptyCell();
if(suggestedCell != null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.SUGGESTEDCELL, new String[] { params.getJail(), suggestedCell.getName() }));
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { params.getJail(), suggestedCell.getName() }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOEMPTYCELLS, params.getJail()));
sender.sendMessage(Lang.NOEMPTYCELLS.get(params.getJail()));
}
return true;
@ -138,7 +138,7 @@ public class JailCommand implements Command {
//If the jailer gave no reason, then let's get the default reason
String reason = "";
if(params.getReason() == null) {
reason = jm.getPlugin().getJailIO().getLanguageString(LangString.DEFAULTJAILEDREASON);
reason = Lang.DEFAULTJAILEDREASON.get();
}else {
StringBuilder sb = new StringBuilder();
for(String s : params.getReason()) {
@ -160,7 +160,7 @@ public class JailCommand implements Command {
//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(jm.getPlugin().getJailIO().getLanguageString(LangString.CANTBEJAILED));
sender.sendMessage(Lang.CANTBEJAILED.get());
return true;
}
@ -175,7 +175,7 @@ public class JailCommand implements Command {
//Get the jail instance from the name of jail in the params.
Jail j = jm.getJail(jailName);
if(!j.isEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.WORLDUNLOADED, j.getName()));
sender.sendMessage(Lang.WORLDUNLOADED.get(j.getName()));
return true;
}
@ -189,7 +189,7 @@ public class JailCommand implements Command {
//check if the event is cancelled
if(event.isCancelled()) {
if(event.getCancelledMessage().isEmpty())
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CANCELLEDBYANOTHERPLUGIN, params.getPlayer()));
sender.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
else
sender.sendMessage(event.getCancelledMessage());
@ -204,10 +204,10 @@ public class JailCommand implements Command {
//Player is not online
if(p == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.OFFLINEJAIL, new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
sender.sendMessage(Lang.OFFLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
}else {
//Player *is* online
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ONLINEJAIL, new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
sender.sendMessage(Lang.ONLINEJAIL.get(new String[] { pris.getLastKnownName(), String.valueOf(pris.getRemainingTimeInMinutes()) }));
}
try {

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 0,
@ -22,7 +22,7 @@ public class JailConfirmCommand implements Command{
if(jm.isConfirming(sender.getName())) {
if(jm.confirmingHasExpired(sender.getName())) {
//Their confirmation time frame has closed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.EXPIRED));
sender.sendMessage(Lang.EXPIRED.get());
}else {
switch(jm.getWhatIsConfirming(sender.getName())) {
case CLEAR:
@ -75,14 +75,14 @@ public class JailConfirmCommand implements Command{
jm.removeConfirming(sender.getName());
break;
default:
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHING));
sender.sendMessage(Lang.NOTHING.get());
jm.removeConfirming(sender.getName());
break;
}
}
}else {
//They aren't confirming anything right now.
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTHING));
sender.sendMessage(Lang.NOTHING.get());
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 2,
@ -20,10 +20,10 @@ import com.graywolf336.jail.enums.LangString;
public class JailDeleteCellCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELL));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
sender.sendMessage(Lang.START.get());
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -20,10 +20,10 @@ import com.graywolf336.jail.enums.LangString;
public class JailDeleteCellsCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETECELLS));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
sender.sendMessage(Lang.START.get());
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.beans.ConfirmPlayer;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.Confirmation;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -20,10 +20,10 @@ import com.graywolf336.jail.enums.LangString;
public class JailDeleteCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.isConfirming(sender.getName())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.ALREADY));
sender.sendMessage(Lang.ALREADY.get());
}else {
jm.addConfirming(sender.getName(), new ConfirmPlayer(sender.getName(), args, Confirmation.DELETE));
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.START));
sender.sendMessage(Lang.START.get());
}
return true;

View File

@ -8,7 +8,7 @@ import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -37,15 +37,15 @@ public class JailListCellsCommand implements Command {
}
if(message.isEmpty()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, j.getName()));
sender.sendMessage(Lang.NOCELLS.get(j.getName()));
}else {
sender.sendMessage(ChatColor.GREEN + message);
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
sender.sendMessage(Lang.NOJAIL.get(args[1]));
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
sender.sendMessage(Lang.NOJAILS.get());
}
sender.sendMessage(ChatColor.AQUA + "-------------------------");

View File

@ -10,7 +10,7 @@ import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -26,7 +26,7 @@ public class JailListCommand implements Command {
//Check if there are any jails
if(jm.getJails().isEmpty()) {
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
sender.sendMessage(" " + Lang.NOJAILS.get());
}else {
//Check if they have provided a jail to list or not
if(args.length == 1) {
@ -40,13 +40,13 @@ public class JailListCommand implements Command {
if(j == null) {
//No jail was found
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
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(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOPRISONERS, j.getName()));
sender.sendMessage(" " + Lang.NOPRISONERS.get(j.getName()));
}else {
for(Prisoner p : pris) {
//graywolf663: Being gray's evil twin; CONSOLE (10)

View File

@ -5,7 +5,7 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 1,
@ -25,12 +25,12 @@ public class JailMuteCommand implements Command {
//Send the message to the sender based upon whether they are muted or unmuted
if(muted)
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOWMUTED, args[1]));
sender.sendMessage(Lang.NOWMUTED.get(args[1]));
else
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOWUNMUTED, args[1]));
sender.sendMessage(Lang.NOWUNMUTED.get(args[1]));
}else {
//The player provided is not jailed, so let's tell the sender that
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1]));
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
}
return true;

View File

@ -11,7 +11,7 @@ import com.graywolf336.jail.JailPayManager;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
@CommandInfo(
@ -43,21 +43,21 @@ public class JailPayCommand implements Command {
if(p.getRemainingTime() > 0) {
if(pm.isTimedEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCOST, new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
sender.sendMessage(Lang.PAYCOST.get(new String[] { pm.getCostPerMinute(), pm.getCurrencyName(), amt }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCOST, new String[] { amt, pm.getCurrencyName() }));
sender.sendMessage(Lang.PAYCOST.get(new String[] { amt, pm.getCurrencyName() }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
jm.getPlugin().debug("Jail pay 'infinite' paying is not enabled (config has 0 as the cost).");
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.YOUARENOTJAILED));
sender.sendMessage(Lang.YOUARENOTJAILED.get());
}
break;
@ -69,18 +69,18 @@ public class JailPayCommand implements Command {
if(p.getRemainingTime() > 0) {
if(!pm.isTimedEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
return true;
}
}else {
if(!pm.isInfiniteEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
return true;
}
}
if(args[1].startsWith("-")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNONEGATIVEAMOUNTS));
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
}else {
double amt = 0;
@ -98,32 +98,31 @@ public class JailPayCommand implements Command {
//timed sentence
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIME,
new String[] { String.valueOf(amt), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASED, String.valueOf(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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEY));
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.YOUARENOTJAILED));
sender.sendMessage(Lang.YOUARENOTJAILED.get());
}
break;
case 3:
@ -131,25 +130,25 @@ public class JailPayCommand implements Command {
//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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYCANTPAYWHILEJAILED));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
return true;
}
}else {
if(!pm.isInfiniteEnabled()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
return true;
}
}
if(args[1].startsWith("-")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNONEGATIVEAMOUNTS));
sender.sendMessage(Lang.PAYNONEGATIVEAMOUNTS.get());
}else {
double amt = 0;
@ -168,33 +167,32 @@ public class JailPayCommand implements Command {
//timed sentence
if(amt >= bill) {
pm.pay((Player) sender, bill);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDLOWEREDTIMEELSE,
new String[] { String.valueOf(amt), p.getLastKnownName(), String.valueOf(TimeUnit.MINUTES.convert(remain, TimeUnit.MILLISECONDS)) }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYPAIDRELEASEDELSE, new String[] { String.valueOf(bill), p.getLastKnownName() }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEYPROVIDED));
sender.sendMessage(Lang.PAYNOTENOUGHMONEYPROVIDED.get());
}
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENOUGHMONEY));
sender.sendMessage(Lang.PAYNOTENOUGHMONEY.get());
}
}
}else {
//Person they're trying to pay for is not jailed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[2]));
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
}
}
break;
@ -203,27 +201,9 @@ public class JailPayCommand implements Command {
}
}else {
jm.getPlugin().debug("Jail pay not enabled.");
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PAYNOTENABLED));
sender.sendMessage(Lang.PAYNOTENABLED.get());
}
return true;
}
}
/*
*
Messages:
MessageJailPayAmountForever: To get out of this mess, you will have to pay <Amount>.
JailPayCannotPay: Sorry, money won't help you this time.
JailPayCannotPayHim: Sorry, money won't help him this time.
JailPayNotEnoughMoney: You don't have that much money!
JailPayCost: 1 minute of your sentence will cost you <MinutePrice>. That means that cost for releasing you out of the jail is <WholePrice>.
JailPayPaidReleased: You have just payed <Amount> and saved yourself from the jail!
JailPayPaidReleasedHim: You have just payed <Amount> and saved <Prisoner> from the jail!
JailPayLoweredTime: You have just payed <Amount> and lowered your sentence to <NewTime> minutes!
JailPayLoweredTimeHim: You have just payed <Amount> and lowered <Prisoner>'s sentence to <NewTime> minutes!
JailPay:
PricePerMinute: 10
PriceForInfiniteJail: 9999
Currency: 0
*/

View File

@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 2,
@ -23,7 +23,7 @@ public class JailRecordCommand implements Command {
// /jail record <username>
List<String> entries = jm.getPlugin().getJailIO().getRecordEntries(args[1]);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.RECORDTIMESJAILED, new String[] { args[1], String.valueOf(entries.size()) }));
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]);
@ -33,7 +33,7 @@ public class JailRecordCommand implements Command {
sender.sendMessage(s);
}
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.RECORDTIMESJAILED, new String[] { args[1], String.valueOf(entries.size()) }));
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

View File

@ -6,7 +6,7 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 0,
@ -27,7 +27,7 @@ public class JailReloadCommand implements Command {
jm.getPlugin().reloadJailPayManager();
jm.getPlugin().reloadUpdateCheck();
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLUGINRELOADED));
sender.sendMessage(Lang.PLUGINRELOADED.get());
}catch (Exception e) {
sender.sendMessage(ChatColor.RED + e.getMessage());
}

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 0,
@ -25,10 +25,10 @@ public class JailStatusCommand implements Command{
if(jm.isPlayerJailed(pl.getUniqueId())) {
Prisoner p = jm.getPrisoner(pl.getUniqueId());
//They are jailed, so let's tell them some information
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.STATUS, new String[] { p.getReason(), p.getJailer(), String.valueOf(p.getRemainingTimeInMinutes()) }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.YOUARENOTJAILED));
sender.sendMessage(Lang.YOUARENOTJAILED.get());
}
return true;

View File

@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
@CommandInfo(
@ -23,12 +23,12 @@ public class JailStickCommand implements Command {
boolean using = jm.getPlugin().getJailStickManager().toggleUsingStick(((Player) sender).getUniqueId());
if(using) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKENABLED));
sender.sendMessage(Lang.JAILSTICKENABLED.get());
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKDISABLED));
sender.sendMessage(Lang.JAILSTICKDISABLED.get());
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.JAILSTICKUSAGEDISABLED));
sender.sendMessage(Lang.JAILSTICKUSAGEDISABLED.get());
}
return true;

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 2,
@ -23,7 +23,7 @@ public class JailTeleInCommand implements Command {
//The jail doesn't exist
if(j == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
sender.sendMessage(Lang.NOJAIL.get(args[1]));
}else {
//The jail does exist
//now let's check the size of the command
@ -34,17 +34,17 @@ public class JailTeleInCommand implements Command {
//If the player they're trying to send is offline, don't do anything
if(p == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE, args[2]));
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
}else {
p.teleport(j.getTeleportIn());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEIN, new String[] { args[2], args[1] }));
sender.sendMessage(Lang.TELEIN.get(new String[] { args[2], args[1] }));
}
}else {
if(sender instanceof Player) {
((Player) sender).teleport(j.getTeleportIn());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEIN, new String[] { sender.getName(), args[1] }));
sender.sendMessage(Lang.TELEIN.get(new String[] { sender.getName(), args[1] }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
}
}
}

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 2,
@ -23,7 +23,7 @@ public class JailTeleOutCommand implements Command {
//The jail doesn't exist
if(j == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
sender.sendMessage(Lang.NOJAIL.get(args[1]));
}else {
//The jail does exist
//now let's check the size of the command
@ -34,17 +34,17 @@ public class JailTeleOutCommand implements Command {
//If the player they're trying to send is offline, don't do anything
if(p == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERNOTONLINE, args[2]));
sender.sendMessage(Lang.PLAYERNOTONLINE.get(args[2]));
}else {
p.teleport(j.getTeleportFree());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEOUT, new String[] { args[2], args[1] }));
sender.sendMessage(Lang.TELEOUT.get(new String[] { args[2], args[1] }));
}
}else {
if(sender instanceof Player) {
((Player) sender).teleport(j.getTeleportFree());
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TELEOUT, new String[] { sender.getName(), args[1] }));
sender.sendMessage(Lang.TELEOUT.get(new String[] { sender.getName(), args[1] }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PLAYERCONTEXTREQUIRED));
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
}
}
}

View File

@ -7,7 +7,7 @@ import com.graywolf336.jail.Util;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 3,
@ -25,8 +25,7 @@ public class JailTimeCommand implements Command {
switch(args.length) {
case 3:
if(args[1].equalsIgnoreCase("show")) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
}else {
return false;
}
@ -40,14 +39,13 @@ public class JailTimeCommand implements Command {
return false;
}
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSTIME,
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
sender.sendMessage(Lang.PRISONERSTIME.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
break;
default:
return false;
}
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[2]));
sender.sendMessage(Lang.NOTJAILED.get(args[2]));
}
return true;

View File

@ -9,7 +9,7 @@ import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
@CommandInfo(
maxArgs = 2,
@ -22,7 +22,7 @@ import com.graywolf336.jail.enums.LangString;
public class JailTransferAllCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.getJails().isEmpty()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
sender.sendMessage(Lang.NOJAILS.get());
return true;
}
@ -30,11 +30,11 @@ public class JailTransferAllCommand implements Command {
//Check if the oldjail is not a valid jail
if(!jm.isValidJail(args[1])) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, 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(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[2]));
sender.sendMessage(Lang.NOJAIL.get(args[2]));
return true;
}
@ -49,7 +49,7 @@ public class JailTransferAllCommand implements Command {
}
//Send the messages to the sender when completed
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TRANSFERALLCOMPLETE, new String[] { old.getName(), args[2] }));
sender.sendMessage(Lang.TRANSFERALLCOMPLETE.get(new String[] { old.getName(), args[2] }));
return true;
}

View File

@ -14,7 +14,7 @@ import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.command.commands.jewels.Transfer;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.events.PrePrisonerTransferredEvent;
import com.lexicalscope.jewel.cli.ArgumentValidationException;
import com.lexicalscope.jewel.cli.CliFactory;
@ -30,7 +30,7 @@ import com.lexicalscope.jewel.cli.CliFactory;
public class JailTransferCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {
if(jm.getJails().isEmpty()) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
sender.sendMessage(Lang.NOJAILS.get());
return true;
}
@ -51,10 +51,10 @@ public class JailTransferCommand implements Command {
//Verify they gave us a player and if so check if they're jailed
if(params.getPlayer() == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAPLAYER, LangString.TRANSFERRING));
sender.sendMessage(Lang.PROVIDEAPLAYER.get(Lang.TRANSFERRING));
return true;
}else if(!jm.isPlayerJailedByLastKnownUsername(params.getPlayer())) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, params.getPlayer()));
sender.sendMessage(Lang.NOTJAILED.get(params.getPlayer()));
return true;
}
@ -62,12 +62,12 @@ public class JailTransferCommand implements Command {
//If they didn't provide a jail, tell them we need one
if(params.getJail() == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PROVIDEAJAIL, LangString.TRANSFERRING));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, params.getJail()));
sender.sendMessage(Lang.NOJAIL.get(params.getJail()));
return true;
}
}
@ -80,21 +80,21 @@ public class JailTransferCommand implements Command {
//Check if they provided a cell and if so does it exist
if(params.getCell() != null) {
if(target.getCell(params.getCell()) == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, new String[] { params.getCell(), params.getJail() }));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLNOTEMPTY, params.getCell()));
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(jm.getPlugin().getJailIO().getLanguageString(LangString.SUGGESTEDCELL, new String[] { params.getCell(), suggestedCell.getName() }));
sender.sendMessage(Lang.SUGGESTEDCELL.get(new String[] { params.getCell(), suggestedCell.getName() }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOEMPTYCELLS, params.getCell()));
sender.sendMessage(Lang.NOEMPTYCELLS.get(params.getCell()));
}
return true;
@ -114,7 +114,7 @@ public class JailTransferCommand implements Command {
if(event.isCancelled()) {
if(event.getCancelledMessage().isEmpty()) {
//The plugin didn't provide a cancel message/reason so send the default one
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TRANSFERCANCELLEDBYANOTHERPLUGIN, params.getPlayer()));
sender.sendMessage(Lang.TRANSFERCANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
}else {
sender.sendMessage(event.getCancelledMessage());
}
@ -129,9 +129,9 @@ public class JailTransferCommand implements Command {
//Send the messages to the sender, if no cell then say that but if cell send that as well
if(targetCell == null) {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TRANSFERCOMPLETENOCELL, new String[] { params.getPlayer(), target.getName() }));
sender.sendMessage(Lang.TRANSFERCOMPLETENOCELL.get(new String[] { params.getPlayer(), target.getName() }));
}else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.TRANSFERCOMPLETECELL, new String[] { params.getPlayer(), target.getName(), targetCell.getName() }));
sender.sendMessage(Lang.TRANSFERCOMPLETECELL.get(new String[] { params.getPlayer(), target.getName(), targetCell.getName() }));
}
return true;

View File

@ -0,0 +1,282 @@
package com.graywolf336.jail.enums;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.YamlConfiguration;
public enum Lang {
// actions section
/** Section for when they break a block. */
BLOCKBREAKING("actions"),
/** Section for when they place a block. */
BLOCKPLACING("actions"),
/** Section for when they try to do a command that isn't whitelisted. */
COMMAND("actions"),
/** Section for when a player tramples a crop and protection is enabled. */
CROPTRAMPLING("actions"),
/** Section for when a player interacts with a block that is blacklisted. */
INTERACTIONBLOCKS("actions"),
/** Section for when a player interacts with an item that is blacklisted. */
INTERACTIONITEMS("actions"),
/** Section for when a player moves outside of the jail. */
MOVING("actions"),
// Jailing section
/** The message displayed when players are kicked for being afk. */
AFKKICKMESSAGE("jailing"),
/** The message sent when jailing someone that is already jailed. */
ALREADYJAILED("jailing"),
/** The message sent when we broadcast/log the message for time below -1. */
BROADCASTMESSAGEFOREVER("jailing"),
/** The message sent when we broadcast/log the message for any time above -1. */
BROADCASTMESSAGEFORMINUTES("jailing"),
/** The message sent to the broadcast/log the unjailing of someone. */
BROADCASTUNJAILING("jailing"),
/** The message sent to the sender when trying to jail someone and a plugin cancels it but doesn't leave a message why. */
CANCELLEDBYANOTHERPLUGIN("jailing"),
/** The message sent when trying to jail someone who can't be jailed by permission. */
CANTBEJAILED("jailing"),
/** The message sent to the sender when they are trying to jail into a cell which is not empty. */
CELLNOTEMPTY("jailing"),
/** The message sent when someone is jailed without a reason. */
DEFAULTJAILEDREASON("jailing"),
/** The message sent when someone is unjailed yet they never came online and so they were forcefully unjailed. */
FORCEUNJAILED("jailing"),
/** The message sent when players are jailed without a reason. */
JAILED("jailing"),
/** The message sent when players are jailed with a reason. */
JAILEDWITHREASON("jailing"),
/** The message sent when players are jailed and they try to talk. */
MUTED("jailing"),
/** The message sent when the sender tries to jail someone in a cell and there aren't any cells to suggest. */
NOEMPTYCELLS("jailing"),
/** The message sent to the sender when they list all the prisoners in a jail which has no prisoners. */
NOPRISONERS("jailing"),
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
NOTJAILED("jailing"),
/** The message sent to the sender when they mute a prisoner. */
NOWMUTED("jailing"),
/** The message sent to the sender when they unmute a prisoner. */
NOWUNMUTED("jailing"),
/** The message sent to the jailer when they jail someone offline. */
OFFLINEJAIL("jailing"),
/** The message sent to the jailer when they jail someone who is online. */
ONLINEJAIL("jailing"),
/** The message sent when finding out how much time a prisoner has. */
PRISONERSTIME("jailing"),
/** The message sent to the prisoner when they try to do something but it is protected. */
PROTECTIONMESSAGE("jailing"),
/** The message sent to the prisoner when they try to do something and it is protected, but no penalty. */
PROTECTIONMESSAGENOPENALTY("jailing"),
/** The message sent to the sender when they need to provide a player. */
PROVIDEAPLAYER("jailing"),
/** The message sent to the sender when they need to provide a jail. */
PROVIDEAJAIL("jailing"),
/** The message sent to someone trying to jail someone else with a jail stick that requires health below a certain amount. */
RESISTEDARRESTJAILER("jailing"),
/** The message sent to the person someone else is trying to jail that requires their health below a certain amount. */
RESISTEDARRESTPLAYER("jailing"),
/** The message sent when to a prisoner about their status in jail. */
STATUS("jailing"),
/** The message sent to the sender of a command when suggesting a cell. */
SUGGESTEDCELL("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport in location. */
TELEIN("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
TELEOUT("jailing"),
/** The message sent to the sender when they transfer all a jail's prisoners to another jail. */
TRANSFERALLCOMPLETE("jailing"),
/** The message sent when another plugin cancels the transferring but doesn't provide a reason why. */
TRANSFERCANCELLEDBYANOTHERPLUGIN("jailing"),
/** The message sent to the sender when they transfer someone to a jail and a cell. */
TRANSFERCOMPLETECELL("jailing"),
/** The message sent to the sender when they transfer someone to a jail. */
TRANSFERCOMPLETENOCELL("jailing"),
/** The message sent to the player when they get transferred to a new jail. */
TRANSFERRED("jailing"),
/** The message sent when players are released from jail. */
UNJAILED("jailing"),
/** The message sent to the person who released a prisoner from jail. */
UNJAILSUCCESS("jailing"),
/** The message went when an offline player is unjailed. */
WILLBEUNJAILED("jailing"),
/** The message sent when trying to jail a player in an unloaded world. */
WORLDUNLOADED("jailing"),
/** The message sent when a player joins and is jailed in a world that is unloaded. */
WORLDUNLOADEDKICK("jailing"),
/** The message sent to the sender when they check their jail status and they aren't jailed. */
YOUARENOTJAILED("jailing"),
// Handcuffing section
/** The message sent to the sender when trying to handcuff someone who can't be. */
CANTBEHANDCUFFED("handcuffing"),
/** The message sent to the sender whenever they try to handcuff someone who is in jail. */
CURRENTLYJAILEDHANDCUFF("handcuffing", "currentlyjailed"),
/** The message sent to the sender when the player doesn't have any handcuffs. */
NOTHANDCUFFED("handcuffing"),
/** The message sent to the handcuff on a successful handcuffing. */
HANDCUFFSON("handcuffing"),
/** The message sent when players are handcuffed. */
HANDCUFFED("handcuffing"),
/** The message sent to the player who has release handcuffs. */
HANDCUFFSRELEASED("handcuffing"),
/** The message sent when the player has his/her handcuffs removed. */
UNHANDCUFFED("handcuffing"),
// General section, used by different parts
/** Part message of any messages which require 'all the jails' or such. */
ALLJAILS("general"),
/** The message sent to the sender whenever they try to remove a cell but was unsuccessful due to a prisoner. */
CELLREMOVALUNSUCCESSFUL("general"),
/** The message sent whenever a cell is successfully removed. */
CELLREMOVED("general"),
/** The simple word jailing to be put in other parts. */
JAILING("general"),
/** The message sent to the sender when they try to remove a jail but there are still prisoners in there. */
JAILREMOVALUNSUCCESSFUL("general"),
/** The message sent whenever a jail is successfully removed. */
JAILREMOVED("general"),
/** The message sent whenever a player toggles using jail stick to disabled. */
JAILSTICKDISABLED("general"),
/** The message sent whenever a player toggles using jail stick to enabled. */
JAILSTICKENABLED("general"),
/** The message sent whenever a player tries to toggle using jail stick but the config has it disabled. */
JAILSTICKUSAGEDISABLED("general"),
/** Message sent when doing something that requires a cell but the given name of a cell doesn't exist. */
NOCELL("general"),
/** Message sent when needing a cell or something and there are no cells. */
NOCELLS("general"),
/** The message sent whenever the sender does something which the jail does not found. */
NOJAIL("general"),
/** The message sent whenever the sender does something and there are no jails. */
NOJAILS("general"),
/** The message sent whenever the sender/player doesn't have permission. */
NOPERMISSION("general"),
/** The message sent whenever the sender/player supplies a number format that is incorrect. */
NUMBERFORMATINCORRECT("general"),
/** The message sent whenever something is done that needs a player but doesn't have it. */
PLAYERCONTEXTREQUIRED("general"),
/** The message sent whenever an online player is required but not found. */
PLAYERNOTONLINE("general"),
/** The message sent to the sender when the plugin data has been reloaded. */
PLUGINRELOADED("general"),
/** The message sent whenever the prisoners are cleared from jail(s). */
PRISONERSCLEARED("general"),
/** The format we should use when entering a record into flatfile or showing it. */
RECORDENTRY("general"),
/** The message format sent saying how many times a user has been jailed. */
RECORDTIMESJAILED("general"),
/** The format of the time entry we should use for the record entries. */
TIMEFORMAT("general"),
/** The simple word transferring to be put in other parts. */
TRANSFERRING("general"),
/** The message sent whenever someone does a command we don't know. */
UNKNOWNCOMMAND("general"),
// Jail pay
/** The message sent when the jail pay portion is not enabled. */
PAYNOTENABLED("jailpay", "notenabled"),
/** The message sent when finding out how much it costs. */
PAYCOST("jailpay", "cost"),
/** The message sent when finding out how much it costs and they are jailed forever. */
PAYCOSTINFINITE("jailpay", "costinfinite"),
/** The message sent when someone tries to pay a negative amount. */
PAYNONEGATIVEAMOUNTS("jailpay", "nonegativeamounts"),
/** The message sent when someone is jailed and tries to pay for someone else. */
PAYCANTPAYWHILEJAILED("jailpay", "cantpayforotherswhilejailed"),
/** The message sent whenever someone tries to pay an amount they don't have. */
PAYNOTENOUGHMONEY("jailpay", "notenoughmoney"),
/** The message sent when they try to pay an amount but it isn't enough for the jailing sentence. */
PAYNOTENOUGHMONEYPROVIDED("jailpay", "notenoughmoneyprovided"),
/** The message sent when they pay and get released. */
PAYPAIDRELEASED("jailpay", "paidreleased"),
/** The message sent when they pay for someone else and release them. */
PAYPAIDRELEASEDELSE("jailpay", "paidreleasedelse"),
/** The message sent when they pay and lower their time. */
PAYPAIDLOWEREDTIME("jailpay", "paidloweredtime"),
/** The message sent when they pay and lower someone else's time. */
PAYPAIDLOWEREDTIMEELSE("jailpay", "paidloweredtimeelse"),
// Confirming action messages.
/** The message sent when the sender is already confirming something. */
ALREADY("confirm"),
/** The message sent when their confirmation has expired. */
EXPIRED("confirm"),
/** The message sent to the sender when they tried to confirm something but don't have anything to confirm. */
NOTHING("confirm"),
/** The message sent to the sender when they type something and need to confirm it. */
START("confirm");
private String section, name, path;
private static YamlConfiguration lang;
Lang(String section) {
this.section = section;
this.name = toString().toLowerCase();
this.path = "language." + this.section + "." + this.name;
}
Lang(String section, String name) {
this.section = section;
this.name = name;
this.path = "language." + this.section + "." + this.name;
}
/**
* Sets the {@link YamlConfiguration} instance to use.
*
* @param file
* of the language to use.
*/
public static void setFile(YamlConfiguration file) {
lang = file;
}
/** Gets the {@link YamlConfiguration} instance. */
public static YamlConfiguration getFile() {
return lang;
}
/** Writes any new language settings to the language file in storage. */
public static boolean writeNewLanguage(YamlConfiguration newLang) {
boolean anything = false;
for(Lang l : values()) {
if(!lang.contains(l.path)) {
lang.set(l.path, newLang.getString(l.path));
anything = true;
}
}
return anything;
}
/** Returns the message in the language, no variables are replaced. */
public String get() {
return get(new String[] {});
}
/** Returns the message in the language, no variables are replaced. */
public String get(Lang langString) {
return get(new String[] { langString.get() });
}
/**
* Returns the message in the language, with the provided variables being replaced.
*
* @param variables
* All the variables to replace, in order from 0 to however many.
* @return The message as a colorful message or an empty message if that
* isn't defined in the language file.
*/
public String get(String... variables) {
String message = lang.getString(path);
if (message == null) return "";
for (int i = 0; i < variables.length; i++) {
message = message.replaceAll("%" + i + "%", variables[i]);
}
return ChatColor.translateAlternateColorCodes('&', message);
}
}

View File

@ -1,231 +0,0 @@
package com.graywolf336.jail.enums;
public enum LangString {
//actions section
/** Section for when they break a block. */
BLOCKBREAKING ("actions"),
/** Section for when they place a block. */
BLOCKPLACING ("actions"),
/** Section for when they try to do a command that isn't whitelisted. */
COMMAND ("actions"),
/** Section for when a player tramples a crop and protection is enabled. */
CROPTRAMPLING ("actions"),
/** Section for when a player interacts with a block that is blacklisted. */
INTERACTIONBLOCKS ("actions"),
/** Section for when a player interacts with an item that is blacklisted. */
INTERACTIONITEMS ("actions"),
/** Section for when a player moves outside of the jail. */
MOVING ("actions"),
//Jailing section
/** The message displayed when players are kicked for being afk. */
AFKKICKMESSAGE ("jailing"),
/** The message sent when jailing someone that is already jailed. */
ALREADYJAILED ("jailing"),
/** The message sent when we broadcast/log the message for time below -1. */
BROADCASTMESSAGEFOREVER ("jailing"),
/** The message sent when we broadcast/log the message for any time above -1. */
BROADCASTMESSAGEFORMINUTES ("jailing"),
/** The message sent to the broadcast/log the unjailing of someone. */
BROADCASTUNJAILING ("jailing"),
/** The message sent to the sender when trying to jail someone and a plugin cancels it but doesn't leave a message why. */
CANCELLEDBYANOTHERPLUGIN ("jailing"),
/** The message sent when trying to jail someone who can't be jailed by permission. */
CANTBEJAILED ("jailing"),
/** The message sent to the sender when they are trying to jail into a cell which is not empty. */
CELLNOTEMPTY ("jailing"),
/** The message sent when someone is jailed without a reason. */
DEFAULTJAILEDREASON ("jailing"),
/** The message sent when someone is unjailed yet they never came online and so they were forcefully unjailed. */
FORCEUNJAILED ("jailing"),
/** The message sent when players are jailed without a reason. */
JAILED ("jailing"),
/** The message sent when players are jailed with a reason. */
JAILEDWITHREASON ("jailing"),
/** The message sent when players are jailed and they try to talk. */
MUTED ("jailing"),
/** The message sent when the sender tries to jail someone in a cell and there aren't any cells to suggest. */
NOEMPTYCELLS ("jailing"),
/** The message sent to the sender when they list all the prisoners in a jail which has no prisoners. */
NOPRISONERS ("jailing"),
/** The message sent when a player is not jailed and the sender is trying to see/do something about it. */
NOTJAILED ("jailing"),
/** The message sent to the sender when they mute a prisoner. */
NOWMUTED ("jailing"),
/** The message sent to the sender when they unmute a prisoner. */
NOWUNMUTED ("jailing"),
/** The message sent to the jailer when they jail someone offline. */
OFFLINEJAIL ("jailing"),
/** The message sent to the jailer when they jail someone who is online. */
ONLINEJAIL ("jailing"),
/** The message sent when finding out how much time a prisoner has. */
PRISONERSTIME ("jailing"),
/** The message sent to the prisoner when they try to do something but it is protected. */
PROTECTIONMESSAGE ("jailing"),
/** The message sent to the prisoner when they try to do something and it is protected, but no penalty. */
PROTECTIONMESSAGENOPENALTY ("jailing"),
/** The message sent to the sender when they need to provide a player. */
PROVIDEAPLAYER ("jailing"),
/** The message sent to the sender when they need to provide a jail. */
PROVIDEAJAIL ("jailing"),
/** The message sent to someone trying to jail someone else with a jail stick that requires health below a certain amount. */
RESISTEDARRESTJAILER ("jailing"),
/** The message sent to the person someone else is trying to jail that requires their health below a certain amount. */
RESISTEDARRESTPLAYER ("jailing"),
/** The message sent when to a prisoner about their status in jail. */
STATUS ("jailing"),
/** The message sent to the sender of a command when suggesting a cell. */
SUGGESTEDCELL ("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport in location. */
TELEIN ("jailing"),
/** The message sent to the sender when they teleport someone to a jail's teleport out location. */
TELEOUT ("jailing"),
/** The message sent to the sender when they transfer all a jail's prisoners to another jail. */
TRANSFERALLCOMPLETE ("jailing"),
/** The message sent when another plugin cancels the transferring but doesn't provide a reason why. */
TRANSFERCANCELLEDBYANOTHERPLUGIN ("jailing"),
/** The message sent to the sender when they transfer someone to a jail and a cell. */
TRANSFERCOMPLETECELL ("jailing"),
/** The message sent to the sender when they transfer someone to a jail. */
TRANSFERCOMPLETENOCELL ("jailing"),
/** The message sent to the player when they get transferred to a new jail. */
TRANSFERRED ("jailing"),
/** The message sent when players are released from jail. */
UNJAILED ("jailing"),
/** The message sent to the person who released a prisoner from jail. */
UNJAILSUCCESS ("jailing"),
/** The message went when an offline player is unjailed. */
WILLBEUNJAILED ("jailing"),
/** The message sent when trying to jail a player in an unloaded world. */
WORLDUNLOADED ("jailing"),
/** The message sent when a player joins and is jailed in a world that is unloaded. */
WORLDUNLOADEDKICK ("jailing"),
/** The message sent to the sender when they check their jail status and they aren't jailed. */
YOUARENOTJAILED ("jailing"),
//Handcuffing section
/** The message sent to the sender when trying to handcuff someone who can't be. */
CANTBEHANDCUFFED ("handcuffing"),
/** The message sent to the sender whenever they try to handcuff someone who is in jail. */
CURRENTLYJAILEDHANDCUFF ("handcuffing", "currentlyjailed"),
/** The message sent to the sender when the player doesn't have any handcuffs. */
NOTHANDCUFFED ("handcuffing"),
/** The message sent to the handcuff on a successful handcuffing. */
HANDCUFFSON ("handcuffing"),
/** The message sent when players are handcuffed. */
HANDCUFFED ("handcuffing"),
/** The message sent to the player who has release handcuffs. */
HANDCUFFSRELEASED ("handcuffing"),
/** The message sent when the player has his/her handcuffs removed. */
UNHANDCUFFED ("handcuffing"),
//General section, used by different parts
/** Part message of any messages which require 'all the jails' or such. */
ALLJAILS ("general"),
/** The message sent to the sender whenever they try to remove a cell but was unsuccessful due to a prisoner. */
CELLREMOVALUNSUCCESSFUL ("general"),
/** The message sent whenever a cell is successfully removed. */
CELLREMOVED ("general"),
/** The simple word jailing to be put in other parts. */
JAILING ("jailing"),
/** THe message sent to the sender when they try to remove a jail but there are still prisoners in there. */
JAILREMOVALUNSUCCESSFUL ("general"),
/** The message sent whenever a jail is successfully removed. */
JAILREMOVED ("general"),
/** The message sent whenever a player toggles using jail stick to disabled. */
JAILSTICKDISABLED ("general"),
/** The message sent whenever a player toggles using jail stick to enabled. */
JAILSTICKENABLED ("general"),
/** The message sent whenever a player tries to toggle using jail stick but the config has it disabled. */
JAILSTICKUSAGEDISABLED ("general"),
/** Message sent when doing something that requires a cell but the given name of a cell doesn't exist. */
NOCELL ("general"),
/** Message sent when needing a cell or something and there are no cells. */
NOCELLS ("general"),
/** The message sent whenever the sender does something which the jail does not found. */
NOJAIL ("general"),
/** The message sent whenever the sender does something and there are no jails. */
NOJAILS ("general"),
/** The message sent whenever the sender/player doesn't have permission. */
NOPERMISSION ("general"),
/** The message sent whenever the sender/player supplies a number format that is incorrect. */
NUMBERFORMATINCORRECT ("general"),
/** The message sent whenever something is done that needs a player but doesn't have it. */
PLAYERCONTEXTREQUIRED ("general"),
/** The message sent whenever an online player is required but not found. */
PLAYERNOTONLINE ("general"),
/** The message sent to the sender when the plugin data has been reloaded. */
PLUGINRELOADED ("general"),
/** The message sent whenever the prisoners are cleared from jail(s). */
PRISONERSCLEARED ("general"),
/** The format we should use when entering a record into flatfile or showing it. */
RECORDENTRY ("general"),
/** The message format sent saying how many times a user has been jailed.*/
RECORDTIMESJAILED ("general"),
/** The format of the time entry we should use for the record entries. */
TIMEFORMAT ("general"),
/** The simple word transferring to be put in other parts. */
TRANSFERRING ("general"),
/** The message sent whenever someone does a command we don't know. */
UNKNOWNCOMMAND ("general"),
//Jail pay
/** The message sent when the jail pay portion is not enabled. */
PAYNOTENABLED ("jailpay", "notenabled"),
/** The message sent when finding out how much it costs. */
PAYCOST ("jailpay", "cost"),
/** The message sent when finding out how much it costs and they are jailed forever. */
PAYCOSTINFINITE ("jailpay", "costinfinite"),
/** The message sent when someone tries to pay a negative amount. */
PAYNONEGATIVEAMOUNTS ("jailpay", "nonegativeamounts"),
/** The message sent when someone is jailed and tries to pay for someone else. */
PAYCANTPAYWHILEJAILED ("jailpay", "cantpayforotherswhilejailed"),
/** The message sent whenever someone tries to pay an amount they don't have. */
PAYNOTENOUGHMONEY ("jailpay", "notenoughmoney"),
/** The message sent when they try to pay an amount but it isn't enough for the jailing sentence. */
PAYNOTENOUGHMONEYPROVIDED ("jailpay", "notenoughmoneyprovided"),
/** The message sent when they pay and get released. */
PAYPAIDRELEASED ("jailpay", "paidreleased"),
/** The message sent when they pay for someone else and release them. */
PAYPAIDRELEASEDELSE ("jailpay", "PAYPAIDRELEASEDELSE"),
/** The message sent when they pay and lower their time. */
PAYPAIDLOWEREDTIME ("jailpay", "paidloweredtime"),
/** The message sent when they pay and lower someone else's time. */
PAYPAIDLOWEREDTIMEELSE ("jailpay", "paidloweredtimeelse"),
//Confirming action messages.
/** The message sent when the sender is already confirming something. */
ALREADY ("confirm"),
/** The message sent when their confirmation has expired. */
EXPIRED ("confirm"),
/** The message sent to the sender when they tried to confirm something but don't have anything to confirm. */
NOTHING ("confirm"),
/** The message sent to the sender when they type something and need to confirm it. */
START ("confirm");
private String section, name;
LangString(String section) {
this.section = section;
}
LangString(String section, String name) {
this.section = section;
this.name = name;
}
/** Gets the section in the language file this is located at. */
public String getSection() {
return this.section;
}
/** Returns the name of this enum if a custom one isn't present. */
public String getName() {
return (name == null ? this.toString().toLowerCase() : name);
}
}

View File

@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
import com.graywolf336.jail.events.PrePrisonerJailedEvent;
@ -24,7 +24,7 @@ public class JailingListener implements Listener {
public JailingListener(JailMain plugin) {
this.pl = plugin;
this.dateFormat = new SimpleDateFormat(pl.getJailIO().getLanguageString(LangString.TIMEFORMAT));
this.dateFormat = new SimpleDateFormat(Lang.TIMEFORMAT.get());
}
@EventHandler(ignoreCancelled=true)

View File

@ -12,7 +12,7 @@ import com.graywolf336.jail.Util;
import com.graywolf336.jail.beans.CachePrisoner;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
public class MoveProtectionListener implements Listener {
@ -54,13 +54,11 @@ public class MoveProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.MOVING));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.MOVING) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.MOVING.get() });
}
//Send the message

View File

@ -27,7 +27,7 @@ import com.graywolf336.jail.beans.Cell;
import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.beans.Stick;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
import com.graywolf336.jail.events.PrePrisonerJailedByJailStickEvent;
import com.graywolf336.jail.events.PrisonerDeathEvent;
@ -67,7 +67,7 @@ public class PlayerListener implements Listener {
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getUniqueId())) {
if(pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).isMuted()) {
event.setCancelled(true);
event.getPlayer().sendMessage(pl.getJailIO().getLanguageString(LangString.MUTED));
event.getPlayer().sendMessage(Lang.MUTED.get());
}
}
@ -95,7 +95,7 @@ public class PlayerListener implements Listener {
Jail j = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getUniqueId());
if(!j.isEnabled()) {
event.getPlayer().kickPlayer(pl.getJailIO().getLanguageString(LangString.WORLDUNLOADEDKICK));
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;
}
@ -226,10 +226,10 @@ public class PlayerListener implements Listener {
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(pl.getJailIO().getLanguageString(LangString.ALREADYJAILED, player.getName()));
attacker.sendMessage(Lang.ALREADYJAILED.get(player.getName()));
}else {
if(player.hasPermission("jail.cantbejailed")) {
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.CANTBEJAILED));
attacker.sendMessage(Lang.CANTBEJAILED.get());
}else {
Stick s = pl.getJailStickManager().getStick(attacker.getItemInHand().getType());
@ -245,7 +245,7 @@ public class PlayerListener implements Listener {
if(jEvent.isCancelled()) {
if(jEvent.getCancelledMessage().isEmpty())
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.CANCELLEDBYANOTHERPLUGIN, player.getName()));
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
else
attacker.sendMessage(jEvent.getCancelledMessage());
}else {
@ -257,12 +257,10 @@ public class PlayerListener implements Listener {
//Player is not online
if(player == null) {
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.OFFLINEJAIL,
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
attacker.sendMessage(Lang.OFFLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
}else {
//Player *is* online
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.ONLINEJAIL,
new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
attacker.sendMessage(Lang.ONLINEJAIL.get(new String[] { p.getLastKnownName(), String.valueOf(p.getRemainingTimeInMinutes()) }));
}
try {
@ -272,8 +270,8 @@ public class PlayerListener implements Listener {
}
}
}else {
attacker.sendMessage(pl.getJailIO().getLanguageString(LangString.RESISTEDARRESTJAILER, player.getName()));
player.sendMessage(pl.getJailIO().getLanguageString(LangString.RESISTEDARRESTPLAYER, attacker.getName()));
attacker.sendMessage(Lang.RESISTEDARRESTJAILER.get(player.getName()));
player.sendMessage(Lang.RESISTEDARRESTPLAYER.get(attacker.getName()));
}
}
}

View File

@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.Util;
import com.graywolf336.jail.enums.LangString;
import com.graywolf336.jail.enums.Lang;
import com.graywolf336.jail.enums.Settings;
public class ProtectionListener implements Listener {
@ -47,13 +47,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.BLOCKBREAKING));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.BLOCKBREAKING) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKBREAKING.get() });
}
//Send the message
@ -92,13 +90,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.BLOCKPLACING));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.BLOCKPLACING) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.BLOCKPLACING.get() });
}
//Send the message
@ -138,13 +134,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.COMMAND));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.COMMAND) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.COMMAND.get() });
}
//Send the message
@ -221,13 +215,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.CROPTRAMPLING));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.CROPTRAMPLING) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.CROPTRAMPLING.get() });
}
//Send the message
@ -264,13 +256,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.INTERACTIONBLOCKS));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.INTERACTIONBLOCKS) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONBLOCKS.get() });
}
//Send the message
@ -295,13 +285,11 @@ public class ProtectionListener implements Listener {
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.INTERACTIONITEMS));
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 = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.INTERACTIONITEMS) });
msg = Lang.PROTECTIONMESSAGE.get(new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), Lang.INTERACTIONITEMS.get() });
}
//Send the message

View File

@ -179,6 +179,18 @@ public class TestInstanceCreator {
return null;
}});
when(mockScheduler.scheduleSyncDelayedTask(any(Plugin.class), any(Runnable.class))).
thenAnswer(new Answer<Integer>() {
public Integer answer(InvocationOnMock invocation) throws Throwable {
Runnable arg;
try {
arg = (Runnable) invocation.getArguments()[1];
} catch (Exception e) {
return null;
}
arg.run();
return null;
}});
when(mockScheduler.runTaskTimerAsynchronously(any(Plugin.class), any(Runnable.class), anyLong(), anyLong())).
thenAnswer(new Answer<Integer>() {
public Integer answer(InvocationOnMock invocation) throws Throwable {
Runnable arg;