Adjusted event priorities to stop console spam for island lock or ban

Changed enter-exit messages to notify
This commit is contained in:
tastybento 2018-08-15 21:01:00 -07:00
parent 22121ad4f9
commit 382b47abbf
2 changed files with 9 additions and 9 deletions

View File

@ -25,7 +25,7 @@ public class EnterExitListener extends AbstractFlagListener {
private static final Vector XZ = new Vector(1,0,1); private static final Vector XZ = new Vector(1,0,1);
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onMove(PlayerMoveEvent e) { public void onMove(PlayerMoveEvent e) {
// Only process if Enter Exit flags are active, we are in the right world and there is a change in X or Z coords // Only process if Enter Exit flags are active, we are in the right world and there is a change in X or Z coords
if (!getIWM().inWorld(e.getFrom()) if (!getIWM().inWorld(e.getFrom())
@ -52,13 +52,13 @@ public class EnterExitListener extends AbstractFlagListener {
User user = User.getInstance(e.getPlayer()); User user = User.getInstance(e.getPlayer());
// Send message if island is owned by someone // Send message if island is owned by someone
from.filter(i -> i.getOwner() != null).ifPresent(i -> user.sendMessage("protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (i.getName() != null) ? i.getName() : from.filter(i -> i.getOwner() != null).ifPresent(i -> user.notify("protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, (i.getName() != null) ? i.getName() :
user.getTranslation("protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(i.getOwner())))); user.getTranslation("protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(i.getOwner()))));
to.filter(i -> i.getOwner() != null).ifPresent(i -> user.sendMessage("protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (i.getName() != null) ? i.getName() : to.filter(i -> i.getOwner() != null).ifPresent(i -> user.notify("protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, (i.getName() != null) ? i.getName() :
user.getTranslation("protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(i.getOwner())))); user.getTranslation("protection.flags.ENTER_EXIT_MESSAGES.island", TextVariables.NAME, getPlugin().getPlayers().getName(i.getOwner()))));
// Send message if island is unowned, but has a name // Send message if island is unowned, but has a name
from.filter(i -> i.getOwner() == null && (i.getName() != null)).ifPresent(i -> user.sendMessage("protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, i.getName())); from.filter(i -> i.getOwner() == null && (i.getName() != null)).ifPresent(i -> user.notify("protection.flags.ENTER_EXIT_MESSAGES.now-leaving", TextVariables.NAME, i.getName()));
to.filter(i -> i.getOwner() == null && (i.getName() != null)).ifPresent(i -> user.sendMessage("protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, i.getName())); to.filter(i -> i.getOwner() == null && (i.getName() != null)).ifPresent(i -> user.notify("protection.flags.ENTER_EXIT_MESSAGES.now-entering", TextVariables.NAME, i.getName()));
} }
} }

View File

@ -35,13 +35,13 @@ public class LockAndBanListener implements Listener {
// Teleport check // Teleport check
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerTeleport(PlayerTeleportEvent e) { public void onPlayerTeleport(PlayerTeleportEvent e) {
e.setCancelled(!checkAndNotify(e.getPlayer(), e.getTo()).equals(CheckResult.OPEN)); e.setCancelled(!checkAndNotify(e.getPlayer(), e.getTo()).equals(CheckResult.OPEN));
} }
// Movement check // Movement check
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent e) { public void onPlayerMove(PlayerMoveEvent e) {
// Ignore only vertical movement // Ignore only vertical movement
if (e.getFrom().getBlockX() - e.getTo().getBlockX() == 0 && e.getFrom().getBlockZ() - e.getTo().getBlockZ() == 0) { if (e.getFrom().getBlockX() - e.getTo().getBlockX() == 0 && e.getFrom().getBlockZ() - e.getTo().getBlockZ() == 0) {
@ -61,7 +61,7 @@ public class LockAndBanListener implements Listener {
} }
// Vehicle move check // Vehicle move check
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onVehicleMove(VehicleMoveEvent e) { public void onVehicleMove(VehicleMoveEvent e) {
// Ignore only vertical movement // Ignore only vertical movement
if (e.getFrom().getBlockX() - e.getTo().getBlockX() == 0 && e.getFrom().getBlockZ() - e.getTo().getBlockZ() == 0) { if (e.getFrom().getBlockX() - e.getTo().getBlockX() == 0 && e.getFrom().getBlockZ() - e.getTo().getBlockZ() == 0) {
@ -79,7 +79,7 @@ public class LockAndBanListener implements Listener {
} }
// Login check // Login check
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerLogin(PlayerJoinEvent e) { public void onPlayerLogin(PlayerJoinEvent e) {
if (!checkAndNotify(e.getPlayer(), e.getPlayer().getLocation()).equals(CheckResult.OPEN)) { if (!checkAndNotify(e.getPlayer(), e.getPlayer().getLocation()).equals(CheckResult.OPEN)) {
eject(e.getPlayer()); eject(e.getPlayer());