Allow protecting and penalizing trampling of crops.
This commit is contained in:
parent
4e06336c99
commit
863793543f
@ -9,6 +9,8 @@ public enum LangString {
|
||||
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"),
|
||||
|
||||
//Jailing section
|
||||
|
||||
|
@ -15,6 +15,8 @@ public enum Settings {
|
||||
COMMANDPROTECTION("jailing.during.commandProtection"),
|
||||
COMMANDWHITELIST("jailing.during.commandWhitelist"),
|
||||
COUNTDOWNTIMEOFFLINE("jailing.during.countDownTimeWhileOffline"),
|
||||
CROPTRAMPLINGPENALTY("jailing.during.cropTramplingPenalty"),
|
||||
CROPTRAMPLINGPROTECTION("jailing.during.cropTramplingProtection"),
|
||||
DEBUG("system.debug"),
|
||||
DEFAULTJAIL("jailing.jail.defaultJail"),
|
||||
DELETEINVENTORY("jailing.jail.deleteInventory"),
|
||||
|
@ -206,4 +206,42 @@ public class ProtectionListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled=true)
|
||||
public void cropTramplingProtection(PlayerInteractEvent event) {
|
||||
//First thing is first, let's be sure the player we're dealing with is in jail
|
||||
if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) {
|
||||
//Next, check if crap trampling protection is enabled
|
||||
if(pl.getConfig().getBoolean(Settings.CROPTRAMPLINGPROTECTION.getPath())) {
|
||||
if(event.getAction() == Action.PHYSICAL && event.getClickedBlock().getType() == Material.SOIL) {
|
||||
if(pl.getJailManager().getJailFromLocation(event.getClickedBlock().getLocation()) != null) {
|
||||
try {
|
||||
long add = Util.getTime(pl.getConfig().getString(Settings.CROPTRAMPLINGPENALTY.getPath()));
|
||||
pl.getJailManager().getPrisoner(event.getPlayer().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.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) });
|
||||
}
|
||||
|
||||
//Send the message
|
||||
event.getPlayer().sendMessage(msg);
|
||||
}catch (Exception e) {
|
||||
pl.getLogger().severe("Crop Trampling penalty's time is in the wrong format, please fix.");
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,8 @@ jailing:
|
||||
commandProtection: true
|
||||
commandWhitelist: ['/ping', '/list']
|
||||
countDownTimeWhileOffline: false
|
||||
cropTramplingPenalty: 5m
|
||||
cropTramplingProtection: true
|
||||
foodControl: true
|
||||
foodControlMax: 20
|
||||
foodControlMin: 10
|
||||
|
@ -3,6 +3,7 @@ language:
|
||||
blockbreaking: 'breaking a block'
|
||||
blockplacing: 'placing a block'
|
||||
command: 'trying to use a command'
|
||||
croptrampling: 'trampling crops'
|
||||
general:
|
||||
alljails: 'all the jails'
|
||||
cellremoved: '&9Cell %0% has been successfully removed from the jail %1%.'
|
||||
|
Loading…
Reference in New Issue
Block a user