Changed existing "deny-enderpearl" config setting to only deny ender pearls which are thrown past the border, and switched it to be enabled by default. Added new command /wb denypearl <on/off> to toggle the option on or off, which requires the new permission worldborder.denypearl to use.

This commit is contained in:
Brettflan 2014-02-17 05:51:40 -06:00
parent cfaf955e9a
commit fd161533d0
5 changed files with 50 additions and 16 deletions

View File

@ -27,7 +27,8 @@ public class BorderCheckTask implements Runnable
Player[] players = Bukkit.getServer().getOnlinePlayers(); Player[] players = Bukkit.getServer().getOnlinePlayers();
for (int i = 0; i < players.length; i++){ for (int i = 0; i < players.length; i++)
{
checkPlayer(players[i], null, false, true); checkPlayer(players[i], null, false, true);
} }
} }

View File

@ -238,13 +238,7 @@ public class Config
{ {
return whooshEffect; return whooshEffect;
} }
public static boolean getIfPlayerKill(){
return killPlayer;
}
public static boolean getDenyEnderpearl()
{
return denyEnderpearl;
}
public static void showWhooshEffect(Location loc) public static void showWhooshEffect(Location loc)
{ {
if (!whooshEffect()) if (!whooshEffect())
@ -259,6 +253,23 @@ public class Config
world.playEffect(loc, Effect.GHAST_SHOOT, 0); world.playEffect(loc, Effect.GHAST_SHOOT, 0);
} }
public static boolean getIfPlayerKill()
{
return killPlayer;
}
public static boolean getDenyEnderpearl()
{
return denyEnderpearl;
}
public static void setDenyEnderpearl(boolean enable)
{
denyEnderpearl = enable;
Log("Direct cancellation of ender pearls thrown past the border " + (enable ? "enabled" : "disabled") + ".");
save(true);
}
public static void setPortalRedirection(boolean enable) public static void setPortalRedirection(boolean enable)
{ {
portalRedirection = enable; portalRedirection = enable;
@ -532,7 +543,7 @@ public class Config
dynmapMessage = cfg.getString("dynmap-border-message", "The border of the world."); dynmapMessage = cfg.getString("dynmap-border-message", "The border of the world.");
LogConfig("Using " + (ShapeName()) + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + "."); LogConfig("Using " + (ShapeName()) + " border, knockback of " + knockBack + " blocks, and timer delay of " + timerTicks + ".");
killPlayer = cfg.getBoolean("player-killed-bad-spawn", false); killPlayer = cfg.getBoolean("player-killed-bad-spawn", false);
denyEnderpearl = cfg.getBoolean("deny-enderpearl", false); denyEnderpearl = cfg.getBoolean("deny-enderpearl", true);
fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30); fillAutosaveFrequency = cfg.getInt("fill-autosave-frequency", 30);
bypassPlayers = Collections.synchronizedSet(new LinkedHashSet<String>(cfg.getStringList("bypass-list"))); bypassPlayers = Collections.synchronizedSet(new LinkedHashSet<String>(cfg.getStringList("bypass-list")));
fillMemoryTolerance = cfg.getInt("fill-memory-tolerance", 500); fillMemoryTolerance = cfg.getInt("fill-memory-tolerance", 500);

View File

@ -405,6 +405,20 @@ public class WBCommand implements CommandExecutor
} }
} }
// "denypearl" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("denypearl"))
{
if (!Config.HasPermission(player, "denypearl")) return true;
Config.setDenyEnderpearl(strAsBool(split[1]));
if (player != null)
{
Config.Log((Config.whooshEffect() ? "Enabling" : "Disabling") + " direct cancellation of ender pearls thrown past the border at the command of player \"" + player.getName() + "\".");
sender.sendMessage("Direct cancellation of ender pearls thrown past the border " + enabledColored(Config.whooshEffect()) + ".");
}
}
// "knockback" command from player or console // "knockback" command from player or console
else if (split.length == 2 && split[0].equalsIgnoreCase("knockback")) else if (split.length == 2 && split[0].equalsIgnoreCase("knockback"))
{ {
@ -889,6 +903,7 @@ public class WBCommand implements CommandExecutor
sender.sendMessage(cmd+" bypasslist " + clrDesc + " - list players with border bypass enabled."); sender.sendMessage(cmd+" bypasslist " + clrDesc + " - list players with border bypass enabled.");
sender.sendMessage(cmd+" fillautosave " + clrReq + "<seconds>" + clrDesc + " - world save interval for Fill."); sender.sendMessage(cmd+" fillautosave " + clrReq + "<seconds>" + clrDesc + " - world save interval for Fill.");
sender.sendMessage(cmd+" portal " + clrReq + "<on|off>" + clrDesc + " - turn portal redirection on or off."); sender.sendMessage(cmd+" portal " + clrReq + "<on|off>" + clrDesc + " - turn portal redirection on or off.");
sender.sendMessage(cmd+" denypearl " + clrReq + "<on|off>" + clrDesc + " - stop ender pearls thrown past the border.");
sender.sendMessage(cmd+" reload" + clrDesc + " - re-load data from config.yml."); sender.sendMessage(cmd+" reload" + clrDesc + " - re-load data from config.yml.");
sender.sendMessage(cmd+" debug " + clrReq + "<on|off>" + clrDesc + " - turn console debug output on or off."); sender.sendMessage(cmd+" debug " + clrReq + "<on|off>" + clrDesc + " - turn console debug output on or off.");
if (page == 4) if (page == 4)

View File

@ -22,16 +22,18 @@ public class WBListener implements Listener
if (Config.Debug()) if (Config.Debug())
Config.Log("Teleport cause: "+event.getCause().toString()); Config.Log("Teleport cause: "+event.getCause().toString());
if(event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && Config.getDenyEnderpearl())
{
event.getPlayer().sendMessage(Config.Message());
event.setCancelled(true);
return;
}
Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true, true); Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true, true);
if (newLoc != null) if (newLoc != null)
{
if(event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && Config.getDenyEnderpearl())
{
event.getPlayer().sendMessage(Config.Message());
event.setCancelled(true);
return;
}
event.setTo(newLoc); event.setTo(newLoc);
}
} }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)

View File

@ -37,6 +37,7 @@ commands:
/<command> bypasslist - list players with border bypass enabled. /<command> bypasslist - list players with border bypass enabled.
/<command> remount <amount> - delay before remounting after knockback. /<command> remount <amount> - delay before remounting after knockback.
/<command> fillautosave <seconds> - world save interval for Fill process. /<command> fillautosave <seconds> - world save interval for Fill process.
/<command> denypearl <on/off> - stop ender pearls thrown past the border.
/<command> dynmap <on/off> - turn DynMap border display on or off. /<command> dynmap <on/off> - turn DynMap border display on or off.
/<command> dynmapmsg <text> - DynMap border labels will show this. /<command> dynmapmsg <text> - DynMap border labels will show this.
/<command> debug <on/off> - turn debug mode on or off. /<command> debug <on/off> - turn debug mode on or off.
@ -68,6 +69,7 @@ permissions:
worldborder.portal: true worldborder.portal: true
worldborder.remount: true worldborder.remount: true
worldborder.fillautosave: true worldborder.fillautosave: true
worldborder.denypearl: true
worldborder.set: worldborder.set:
description: Can set borders for any world description: Can set borders for any world
default: op default: op
@ -140,3 +142,6 @@ permissions:
worldborder.bypasslist: worldborder.bypasslist:
description: Can get list of players with border bypass enabled description: Can get list of players with border bypass enabled
default: op default: op
worldborder.denypearl:
description: Can enable/disable direct cancellation of ender pearls thrown past border
default: op