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 //Get the max and min food level in the config
int maxFood = pl.getConfig().getInt(Settings.MAXFOODLEVEL.getPath(), 20); int maxFood = pl.getConfig().getInt(Settings.FOODCONTROLMAX.getPath(), 20);
int minFood = pl.getConfig().getInt(Settings.MINFOODLEVEL.getPath(), 10); 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 //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 //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"), DEFAULTJAIL("jailing.jail.defaultJail"),
DELETEINVENTORY("jailing.jail.deleteInventory"), DELETEINVENTORY("jailing.jail.deleteInventory"),
EXPLOSIONPROTECTION("jailing.during.explosionProtection"), EXPLOSIONPROTECTION("jailing.during.explosionProtection"),
FOODCONTROL("jailing.during.foodControl"),
FOODCONTROLMAX("jailing.during.foodControlMax"),
FOODCONTROLMIN("jailing.during.foodControlMin"),
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"), IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
JAILDEFAULTTIME("jailing.jail.defaultTime"), JAILDEFAULTTIME("jailing.jail.defaultTime"),
JAILEDGAMEMODE("jailing.jail.gameMode"), JAILEDGAMEMODE("jailing.jail.gameMode"),
JAILEDSTOREINVENTORY("jailing.jail.storeInventory"), JAILEDSTOREINVENTORY("jailing.jail.storeInventory"),
LOGJAILING("jailing.jail.logToConsole"), LOGJAILING("jailing.jail.logToConsole"),
MAXAFKTIME("jailing.during.maxAFKTime"), MAXAFKTIME("jailing.during.maxAFKTime"),
MAXFOODLEVEL("jailing.during.maxFoodLevel"),
MINFOODLEVEL("jailing.during.minFoodLevel"),
RECIEVEMESSAGES("jailing.during.recieveMessages"), RECIEVEMESSAGES("jailing.during.recieveMessages"),
RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"), RELEASETOPREVIOUSPOSITION("jailing.release.backToPreviousPosition"),
RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"), RESTOREPREVIOUSGAMEMODE("jailing.release.restorePreviousGameMode"),

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent; 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'] commandWhitelist: ['/ping', '/list']
countDownTimeWhileOffline: false countDownTimeWhileOffline: false
explosionProtection: true explosionProtection: true
foodControl: true
foodControlMax: 20
foodControlMin: 10
ignoreSleeping: true ignoreSleeping: true
maxAFKTime: 10m #in minutes maxAFKTime: 10m #in minutes
maxFoodLevel: 20
minFoodLevel: 10
openChest: true openChest: true
recieveMessages: true recieveMessages: true
jail: jail: