If the time is 0, then send a different message.

This commit is contained in:
graywolf336 2014-01-21 12:10:43 -06:00
parent 4c13948549
commit b005248deb
3 changed files with 39 additions and 15 deletions

View File

@ -30,6 +30,8 @@ public enum LangString {
MUTED ("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 when players are released from jail. */
UNJAILED ("jailing"),

View File

@ -43,11 +43,18 @@ public class ProtectionListener implements Listener {
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKBREAKPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
String msg = "";
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.BLOCKBREAKING));
}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
String msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.BLOCKBREAKING) });
}
//Send the message
event.getPlayer().sendMessage(msg);
@ -82,11 +89,18 @@ public class ProtectionListener implements Listener {
long add = Util.getTime(pl.getConfig().getString(Settings.BLOCKPLACEPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
String msg = "";
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.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
String msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.BLOCKPLACING) });
}
//Send the message
event.getPlayer().sendMessage(msg);
@ -121,11 +135,18 @@ public class ProtectionListener implements Listener {
long add = Util.getTime(pl.getConfig().getString(Settings.COMMANDPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getName()).addTime(add);
String msg = "";
if(add == 0L) {
//Generate the protection message, provide the method with one argument
//which is the thing we are protecting against
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGENOPENALTY, pl.getJailIO().getLanguageString(LangString.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
String msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
msg = pl.getJailIO().getLanguageString(LangString.PROTECTIONMESSAGE,
new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)),
pl.getJailIO().getLanguageString(LangString.COMMAND) });
}
//Send the message
event.getPlayer().sendMessage(msg);

View File

@ -18,6 +18,7 @@ language:
jailedwithreason: '&cYou have been jailed for: %0%'
muted: '&cStop talking, you are in jail.'
protectionmessage: '&c%0% minutes has been added to your time for %1%.'
protectionmessagenopenalty: '&cProtection enabled for %0%, do not do it again.'
unjailed: '&2You have been released! Please respect the server rules.'
handcuffing:
cantbehandcuffed: '&9%0% &ccan not be handcuffed.'