diff --git a/src/main/java/com/graywolf336/jail/enums/LangString.java b/src/main/java/com/graywolf336/jail/enums/LangString.java index 46da107..04f2931 100644 --- a/src/main/java/com/graywolf336/jail/enums/LangString.java +++ b/src/main/java/com/graywolf336/jail/enums/LangString.java @@ -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"), diff --git a/src/main/java/com/graywolf336/jail/listeners/ProtectionListener.java b/src/main/java/com/graywolf336/jail/listeners/ProtectionListener.java index 614705b..b54bacc 100644 --- a/src/main/java/com/graywolf336/jail/listeners/ProtectionListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/ProtectionListener.java @@ -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); - //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, - new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), - pl.getJailIO().getLanguageString(LangString.BLOCKBREAKING) }); + 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 + 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); - //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, - new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), - pl.getJailIO().getLanguageString(LangString.BLOCKPLACING) }); + 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 + 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); - //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, - new String[] { String.valueOf(TimeUnit.MINUTES.convert(add, TimeUnit.MILLISECONDS)), - pl.getJailIO().getLanguageString(LangString.COMMAND) }); + 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 + 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); diff --git a/src/main/resources/en.yml b/src/main/resources/en.yml index 44760f4..86442df 100644 --- a/src/main/resources/en.yml +++ b/src/main/resources/en.yml @@ -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.'