Skip to content

Commit

Permalink
Fix for #553 - enter and exit messages are still shown for Spawn island
Browse files Browse the repository at this point in the history
even if they are switched off in settings.
  • Loading branch information
tastybento committed Mar 19, 2017
1 parent 5daaa84 commit 225e4f5
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 22 deletions.
32 changes: 24 additions & 8 deletions src/com/wasteofplastic/askyblock/listeners/IslandGuard.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ public void onVehicleMove(final VehicleMoveEvent e) {
// Entering
if (islandTo.isSpawn()) {
if (!plugin.myLocale(player.getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockEnteringSpawn);
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockEnteringSpawn);
}
}
} else {
if (!plugin.myLocale(player.getUniqueId()).lockNowEntering.isEmpty()) {
Expand All @@ -325,7 +327,9 @@ public void onVehicleMove(final VehicleMoveEvent e) {
if (islandFrom.isSpawn()) {
// Leaving
if (!plugin.myLocale(player.getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockLeavingSpawn);
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockLeavingSpawn);
}
}
} else {
if (!plugin.myLocale(player.getUniqueId()).lockNowLeaving.isEmpty()) {
Expand All @@ -339,7 +343,9 @@ public void onVehicleMove(final VehicleMoveEvent e) {
if (islandFrom.isSpawn()) {
// Leaving
if (!plugin.myLocale(player.getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockLeavingSpawn);
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockLeavingSpawn);
}
}
} else if (islandFrom.getOwner() != null){
if (!plugin.myLocale(player.getUniqueId()).lockNowLeaving.isEmpty()) {
Expand All @@ -350,7 +356,9 @@ public void onVehicleMove(final VehicleMoveEvent e) {
}
if (islandTo.isSpawn()) {
if (!plugin.myLocale(player.getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockEnteringSpawn);
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(player, plugin.myLocale(player.getUniqueId()).lockEnteringSpawn);
}
}
} else if (islandTo.getOwner() != null) {
if (!plugin.myLocale(player.getUniqueId()).lockNowEntering.isEmpty()) {
Expand Down Expand Up @@ -431,7 +439,9 @@ public void onPlayerMove(final PlayerMoveEvent e) {
}
if (islandTo.isSpawn()) {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
}
}
} else {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.isEmpty()) {
Expand All @@ -448,7 +458,9 @@ public void onPlayerMove(final PlayerMoveEvent e) {
if (islandFrom.isSpawn()) {
// Leaving
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
}
}
} else {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.isEmpty()) {
Expand All @@ -463,14 +475,18 @@ public void onPlayerMove(final PlayerMoveEvent e) {
// Adjacent islands or overlapping protections
if (islandFrom.isSpawn()) {
// Leaving
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
}
} else if (islandFrom.getOwner() != null) {
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
sendEnterExit(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn.replace("[name]", plugin.getGrid().getIslandName(islandFrom.getOwner())));
}
}
if (islandTo.isSpawn()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
}
} else if (islandTo.getOwner() != null) {
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
sendEnterExit(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn.replace("[name]", plugin.getGrid().getIslandName(islandTo.getOwner())));
Expand Down
44 changes: 30 additions & 14 deletions src/com/wasteofplastic/askyblock/listeners/PlayerEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,18 @@ public void onPlayerTeleport(final PlayerTeleportEvent e) {
if (islandTo.isSpawn()) {
if (DEBUG )
plugin.getLogger().info("DEBUG: islandTo is locked spawn");
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
}
}
} else {
if (DEBUG )
plugin.getLogger().info("DEBUG: islandTo is locked regular");
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.replace("[name]", plugin.getGrid().getIslandName(islandTo.getOwner())));
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.replace("[name]", plugin.getGrid().getIslandName(islandTo.getOwner())));
}
}
}
// Fire entry event
Expand All @@ -706,14 +710,18 @@ public void onPlayerTeleport(final PlayerTeleportEvent e) {
if (DEBUG )
plugin.getLogger().info("DEBUG: leaving spawn");
// Leaving
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
}
}
} else {
if (DEBUG )
plugin.getLogger().info("DEBUG: leaving locked");
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.replace("[name]", plugin.getGrid().getIslandName(islandFrom.getOwner())));
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
if (!plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.replace("[name]", plugin.getGrid().getIslandName(islandFrom.getOwner())));
}
}
}
// Remove temp perms
Expand All @@ -739,14 +747,22 @@ public void onPlayerTeleport(final PlayerTeleportEvent e) {
}
if (islandFrom.isSpawn()) {
// Leaving
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
} else if (islandFrom.getOwner() != null) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.replace("[name]", plugin.getGrid().getIslandName(islandFrom.getOwner())));
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES) && !plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockLeavingSpawn);
}
} else if (islandFrom.getOwner() != null && !plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.isEmpty()) {
if(islandFrom.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowLeaving.replace("[name]", plugin.getGrid().getIslandName(islandFrom.getOwner())));
}
}
if (islandTo.isSpawn()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
} else if (islandTo.getOwner() != null) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.replace("[name]", plugin.getGrid().getIslandName(islandTo.getOwner())));
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES) && !plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn.isEmpty()) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockEnteringSpawn);
}
} else if (islandTo.getOwner() != null && !plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.isEmpty()) {
if(islandTo.getIgsFlag(SettingsFlag.ENTER_EXIT_MESSAGES)) {
Util.sendMessage(e.getPlayer(), plugin.myLocale(e.getPlayer().getUniqueId()).lockNowEntering.replace("[name]", plugin.getGrid().getIslandName(islandTo.getOwner())));
}
}
// Remove temp perms
if (!islandTo.getMembers().contains(e.getPlayer().getUniqueId())) {
Expand Down

0 comments on commit 225e4f5

Please sign in to comment.