Protect the jails against explosions, if it is enabled

This commit is contained in:
graywolf336 2014-01-08 15:27:38 -06:00
parent d734d99e88
commit cf7c9fc4c2
4 changed files with 32 additions and 2 deletions

View File

@ -44,7 +44,7 @@ public class JailMain extends JavaPlugin {
PluginManager plm = this.getServer().getPluginManager(); PluginManager plm = this.getServer().getPluginManager();
plm.registerEvents(new BlockListener(this), this); plm.registerEvents(new BlockListener(this), this);
plm.registerEvents(new EntityListener(), this); plm.registerEvents(new EntityListener(this), this);
plm.registerEvents(new HandCuffListener(this), this); plm.registerEvents(new HandCuffListener(this), this);
plm.registerEvents(new PlayerListener(this), this); plm.registerEvents(new PlayerListener(this), this);

View File

@ -10,6 +10,7 @@ public enum Settings {
DEBUG("system.debug"), DEBUG("system.debug"),
DEFAULTJAIL("jailing.jail.defaultJail"), DEFAULTJAIL("jailing.jail.defaultJail"),
DELETEINVENTORY("jailing.jail.deleteInventory"), DELETEINVENTORY("jailing.jail.deleteInventory"),
EXPLOSIONPROTECTION("jailing.during.explosionProtection"),
IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"), IGNORESLEEPINGSTATE("jailing.during.ignoreSleeping"),
JAILDEFAULTTIME("jailing.jail.defaultTime"), JAILDEFAULTTIME("jailing.jail.defaultTime"),
JAILEDGAMEMODE("jailing.jail.gameMode"), JAILEDGAMEMODE("jailing.jail.gameMode"),

View File

@ -1,7 +1,35 @@
package com.graywolf336.jail.listeners; package com.graywolf336.jail.listeners;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.enums.Settings;
public class EntityListener implements Listener { public class EntityListener implements Listener {
private JailMain pl;
public EntityListener(JailMain plugin) {
this.pl = plugin;
}
@EventHandler(ignoreCancelled=true)
public void onEntityExplode(EntityExplodeEvent event) {
//Only do the checking if plugin has it enabled
//otherwise let's not go through all the blocks
if(pl.getConfig().getBoolean(Settings.EXPLOSIONPROTECTION.getPath())) {
//Loop through the blocklist and do stuff
for(Block b : event.blockList()) {
//Check the current block and if it is inside a jail,
//then let's do something else
if(pl.getJailManager().getJailFromLocation(b.getLocation()) != null) {
//Clear the blocklist, this way the explosion effect still happens
event.blockList().clear();
return;
}
}
}
}
} }

View File

@ -16,6 +16,7 @@ jailing:
blockBreakProtection: true blockBreakProtection: true
blockPlaceProtection: true blockPlaceProtection: true
countDownTimeWhileOffline: false countDownTimeWhileOffline: false
explosionProtection: true
ignoreSleeping: true ignoreSleeping: true
maxAFKTime: 10m #in minutes maxAFKTime: 10m #in minutes
maxFoodLevel: 20 maxFoodLevel: 20