Enable food control

This commit is contained in:
graywolf336 2014-01-20 15:24:27 -06:00
parent 392b1d94cc
commit 4eae8778ea
4 changed files with 25 additions and 6 deletions

View File

@ -178,8 +178,8 @@ public class PrisonerManager {
}
//Get the max and min food level in the config
int maxFood = pl.getConfig().getInt(Settings.MAXFOODLEVEL.getPath(), 20);
int minFood = pl.getConfig().getInt(Settings.MINFOODLEVEL.getPath(), 10);
int maxFood = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath(), 20);
int minFood = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath(), 10);
//If their food level is less than the min food level, set it to the min
//but if it is higher than the max, set it to the max

View File

@ -18,14 +18,15 @@ public enum Settings {
DEFAULTJAIL("jailing.jail.defaultJail"),
DELETEINVENTORY("jailing.jail.deleteInventory"),
EXPLOSIONPROTECTION("jailing.during.explosionProtection"),
FOODCONTROL("jailing.during.foodControl"),
FOODCONTROLMAX("jailing.during.foodControlMax"),
FOODCONTROLMIN("jailing.during.foodControlMin"),
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
JAILDEFAULTTIME("jailing.jail.defaultTime"),
JAILEDGAMEMODE("jailing.jail.gameMode"),
JAILEDSTOREINVENTORY("jailing.jail.storeInventory"),
LOGJAILING("jailing.jail.logToConsole"),
MAXAFKTIME("jailing.during.maxAFKTime"),
MAXFOODLEVEL("jailing.during.maxFoodLevel"),
MINFOODLEVEL("jailing.during.minFoodLevel"),
RECIEVEMESSAGES("jailing.during.recieveMessages"),
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
@ -83,4 +84,20 @@ public class PlayerListener implements Listener {
}
}
}
@EventHandler
public void foodControl(FoodLevelChangeEvent event) {
if(pl.getConfig().getBoolean(Settings.FOODCONTROL.getPath())) {
if(pl.getJailManager().isPlayerJailed(event.getEntity().getName())) {
int min = pl.getConfig().getInt(Settings.FOODCONTROLMIN.getPath());
int max = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath());
if (event.getFoodLevel() < min) {
event.setFoodLevel(min);
}else {
event.setFoodLevel(max);
}
}
}
}
}

View File

@ -24,10 +24,11 @@ jailing:
commandWhitelist: ['/ping', '/list']
countDownTimeWhileOffline: false
explosionProtection: true
foodControl: true
foodControlMax: 20
foodControlMin: 10
ignoreSleeping: true
maxAFKTime: 10m #in minutes
maxFoodLevel: 20
minFoodLevel: 10
openChest: true
recieveMessages: true
jail: