From 65c3ea442f81a574f9ec24bb90a0fea779c3a99e Mon Sep 17 00:00:00 2001 From: tastybento Date: Sun, 22 Oct 2017 16:45:53 -0700 Subject: [PATCH] Pull over from AcidIsland. Fixes level placeholder. May fix mobspawn issue when setting is off. --- .../askyblock/LevelCalcByChunk.java | 9 ++- .../askyblock/commands/IslandCmd.java | 2 +- .../askyblock/listeners/AcidEffect.java | 2 +- .../askyblock/listeners/EntityLimits.java | 56 +++++++++---------- .../askyblock/listeners/IslandGuard.java | 2 +- .../askyblock/listeners/IslandGuard1_8.java | 2 +- .../askyblock/listeners/IslandGuard1_9.java | 2 +- .../askyblock/listeners/NetherPortals.java | 2 +- .../askyblock/listeners/PlayerEvents.java | 2 +- .../askyblock/listeners/PlayerEvents2.java | 2 +- .../askyblock/listeners/PlayerEvents3.java | 2 +- .../askyblock/panels/SettingsPanel.java | 2 +- .../askyblock/panels/WarpPanel.java | 2 +- 13 files changed, 43 insertions(+), 44 deletions(-) diff --git a/src/com/wasteofplastic/askyblock/LevelCalcByChunk.java b/src/com/wasteofplastic/askyblock/LevelCalcByChunk.java index 271b239ff..5dd5e43d7 100644 --- a/src/com/wasteofplastic/askyblock/LevelCalcByChunk.java +++ b/src/com/wasteofplastic/askyblock/LevelCalcByChunk.java @@ -445,12 +445,12 @@ public void run() { if (!(sender instanceof Player)) { // Console if (!report) { - Util.sendMessage(sender, ChatColor.GREEN + plugin.myLocale().islandislandLevelis + " " + ChatColor.WHITE + plugin.getPlayers().getIslandLevel(targetPlayer)); + Util.sendMessage(sender, ChatColor.GREEN + plugin.myLocale().islandislandLevelis.replace("[level]", String.valueOf(plugin.getPlayers().getIslandLevel(targetPlayer)))); } else { for (String line: reportLines) { Util.sendMessage(sender, line); } - Util.sendMessage(sender, ChatColor.GREEN + plugin.myLocale().islandislandLevelis + " " + ChatColor.WHITE + plugin.getPlayers().getIslandLevel(targetPlayer)); + Util.sendMessage(sender, ChatColor.GREEN + plugin.myLocale().islandislandLevelis.replace("[level]", String.valueOf(plugin.getPlayers().getIslandLevel(targetPlayer)))); if (event.getLongPointsToNextLevel() >= 0) { String toNextLevel = ChatColor.GREEN + plugin.myLocale().islandrequiredPointsToNextLevel.replace("[points]", String.valueOf(event.getLongPointsToNextLevel())); toNextLevel = toNextLevel.replace("[next]", String.valueOf(plugin.getPlayers().getIslandLevel(targetPlayer) + 1)); @@ -463,11 +463,10 @@ public void run() { // Tell offline team members the island level changed if (plugin.getPlayers().getIslandLevel(targetPlayer) != oldLevel) { //plugin.getLogger().info("DEBUG: telling offline players"); - plugin.getMessages().tellOfflineTeam(targetPlayer, ChatColor.GREEN + plugin.myLocale(targetPlayer).islandislandLevelis + " " + ChatColor.WHITE - + plugin.getPlayers().getIslandLevel(targetPlayer)); + plugin.getMessages().tellOfflineTeam(targetPlayer, ChatColor.GREEN + plugin.myLocale().islandislandLevelis.replace("[level]", String.valueOf(plugin.getPlayers().getIslandLevel(targetPlayer)))); } if (sender instanceof Player && ((Player)sender).isOnline()) { - String message = ChatColor.GREEN + plugin.myLocale(((Player)sender).getUniqueId()).islandislandLevelis + " " + ChatColor.WHITE + plugin.getPlayers().getIslandLevel(targetPlayer); + String message = ChatColor.GREEN + plugin.myLocale().islandislandLevelis.replace("[level]", String.valueOf(plugin.getPlayers().getIslandLevel(targetPlayer))); if (Settings.deathpenalty != 0) { message += " " + plugin.myLocale(((Player)sender).getUniqueId()).levelDeaths.replace("[number]", String.valueOf(deathHandicap)); } diff --git a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java index a1a35f674..e6d0bddda 100644 --- a/src/com/wasteofplastic/askyblock/commands/IslandCmd.java +++ b/src/com/wasteofplastic/askyblock/commands/IslandCmd.java @@ -936,7 +936,7 @@ public boolean calculateIslandLevel(final CommandSender sender, final UUID targe if (asker.getUniqueId().equals(targetPlayer) || asker.isOp() || VaultHelper.checkPerm(asker, Settings.PERMPREFIX + "mod.info")) { // Newer better system - uses chunks if (!onLevelWaitTime(asker) || Settings.levelWait <= 0 || asker.isOp() || VaultHelper.checkPerm(asker, Settings.PERMPREFIX + "mod.info")) { - Util.sendMessage(asker, ChatColor.GREEN + plugin.myLocale(asker.getUniqueId()).levelCalculating); + //Util.sendMessage(asker, ChatColor.GREEN + plugin.myLocale(asker.getUniqueId()).levelCalculating); setLevelWaitTime(asker); new LevelCalcByChunk(plugin, targetPlayer, asker, report); } else { diff --git a/src/com/wasteofplastic/askyblock/listeners/AcidEffect.java b/src/com/wasteofplastic/askyblock/listeners/AcidEffect.java index 0147a26ca..3db79ee75 100644 --- a/src/com/wasteofplastic/askyblock/listeners/AcidEffect.java +++ b/src/com/wasteofplastic/askyblock/listeners/AcidEffect.java @@ -48,8 +48,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings.GameType; import com.wasteofplastic.askyblock.util.Util; import com.wasteofplastic.askyblock.util.VaultHelper; diff --git a/src/com/wasteofplastic/askyblock/listeners/EntityLimits.java b/src/com/wasteofplastic/askyblock/listeners/EntityLimits.java index 9ab7ad050..2f527cfb4 100644 --- a/src/com/wasteofplastic/askyblock/listeners/EntityLimits.java +++ b/src/com/wasteofplastic/askyblock/listeners/EntityLimits.java @@ -32,8 +32,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.Util; import com.wasteofplastic.askyblock.util.VaultHelper; @@ -95,17 +95,19 @@ private boolean actionAllowed(Player player, Location location, SettingsFlag fla @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onAnimalSpawn(final CreatureSpawnEvent e) { - if (DEBUG2) { - plugin.getLogger().info("Animal spawn event! " + e.getEventName()); - plugin.getLogger().info(e.getSpawnReason().toString()); - plugin.getLogger().info(e.getEntityType().toString()); + // If not in the right world, return + if (!IslandGuard.inWorld(e.getEntity())) { + return; } // If not an animal if (!(e.getEntity() instanceof Animals) && !e.getEntityType().equals(EntityType.SQUID)) { - if (DEBUG2) - plugin.getLogger().info("Not an animal"); return; } + if (DEBUG2) { + plugin.getLogger().info("Animal spawn event! " + e.getEventName()); + plugin.getLogger().info(e.getSpawnReason().toString()); + plugin.getLogger().info(e.getEntityType().toString()); + } // If there's no limit - leave it if (Settings.breedingLimit <= 0) { if (DEBUG2) @@ -120,15 +122,6 @@ public void onAnimalSpawn(final CreatureSpawnEvent e) { return; } LivingEntity animal = e.getEntity(); - // If not in the right world, return - if (!animal.getWorld().equals(ASkyBlock.getIslandWorld())) { - // Check nether - if (!(Settings.createNether && Settings.newNether && ASkyBlock.getNetherWorld() != null)) { - return; - } - } - if (DEBUG2) - plugin.getLogger().info("Correct world"); Island island = plugin.getGrid().getProtectedIslandAt(animal.getLocation()); if (island == null) { // Animal is spawning outside of an island so ignore @@ -223,15 +216,12 @@ public void onAnimalSpawn(final CreatureSpawnEvent e) { } /** - * Prevents mobs spawning natually at spawn or in an island + * Prevents mobs spawning naturally at spawn or in an island * * @param e */ @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) - public void onMobSpawn(final CreatureSpawnEvent e) { - if (DEBUG2) { - plugin.getLogger().info("on Mob spawn" + e.getEventName()); - } + public void onNaturalMobSpawn(final CreatureSpawnEvent e) { // if grid is not loaded yet, return. if (plugin.getGrid() == null) { return; @@ -241,10 +231,15 @@ public void onMobSpawn(final CreatureSpawnEvent e) { return; } // Deal with natural spawning - if (e.getSpawnReason().equals(SpawnReason.NATURAL)) { + if (e.getSpawnReason().equals(SpawnReason.NATURAL) || e.getSpawnReason().equals(SpawnReason.JOCKEY) + || e.getSpawnReason().equals(SpawnReason.CHUNK_GEN) + || e.getSpawnReason().equals(SpawnReason.DEFAULT) + || e.getSpawnReason().equals(SpawnReason.MOUNT) + || e.getSpawnReason().equals(SpawnReason.JOCKEY) + || e.getSpawnReason().equals(SpawnReason.NETHER_PORTAL)) { if (e.getEntity() instanceof Monster || e.getEntity() instanceof Slime) { if (!actionAllowed(e.getLocation(), SettingsFlag.MONSTER_SPAWN)) { - if (DEBUG2) + if (DEBUG3) plugin.getLogger().info("Natural monster spawn cancelled."); // Mobs not allowed to spawn e.setCancelled(true); @@ -260,6 +255,11 @@ public void onMobSpawn(final CreatureSpawnEvent e) { } } } + if (DEBUG2) { + plugin.getLogger().info("Mob spawn allowed " + e.getEventName()); + plugin.getLogger().info(e.getSpawnReason().toString()); + plugin.getLogger().info(e.getEntityType().toString()); + } } @@ -275,7 +275,7 @@ public void onPlayerBlockPlace(final BlockMultiPlaceEvent e) { plugin.getLogger().info("DEBUG: Block is " + e.getBlock().toString()); } if (Settings.allowedFakePlayers.contains(e.getPlayer().getName())) return; - + // plugin.getLogger().info(e.getEventName()); if (IslandGuard.inWorld(e.getPlayer())) { // This permission bypasses protection @@ -338,9 +338,9 @@ public void onPlayerBlockPlace(final BlockPlaceEvent e) { } plugin.getLogger().info("DEBUG: Block is " + e.getBlock().toString()); } - + if (Settings.allowedFakePlayers.contains(e.getPlayer().getName())) return; - + // plugin.getLogger().info(e.getEventName()); if (IslandGuard.inWorld(e.getPlayer())) { // This permission bypasses protection @@ -396,9 +396,9 @@ public void onPlayerBlockPlace(final HangingPlaceEvent e) { plugin.getLogger().info("DEBUG: block placed " + e.getBlock().getType()); plugin.getLogger().info("DEBUG: entity " + e.getEntity().getType()); } - + if (Settings.allowedFakePlayers.contains(e.getPlayer().getName())) return; - + // plugin.getLogger().info(e.getEventName()); if (IslandGuard.inWorld(e.getPlayer())) { // This permission bypasses protection diff --git a/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java b/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java index 797dffd54..75311153f 100644 --- a/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java +++ b/src/com/wasteofplastic/askyblock/listeners/IslandGuard.java @@ -94,8 +94,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.events.IslandEnterEvent; import com.wasteofplastic.askyblock.events.IslandExitEvent; import com.wasteofplastic.askyblock.util.Util; diff --git a/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_8.java b/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_8.java index 327d14035..c10801a3f 100644 --- a/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_8.java +++ b/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_8.java @@ -34,8 +34,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.Util; import com.wasteofplastic.askyblock.util.VaultHelper; diff --git a/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_9.java b/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_9.java index cf5ba69b4..1d1b31eb7 100644 --- a/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_9.java +++ b/src/com/wasteofplastic/askyblock/listeners/IslandGuard1_9.java @@ -58,8 +58,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.Util; import com.wasteofplastic.askyblock.util.VaultHelper; diff --git a/src/com/wasteofplastic/askyblock/listeners/NetherPortals.java b/src/com/wasteofplastic/askyblock/listeners/NetherPortals.java index 4d86aad9e..936b0f4ed 100644 --- a/src/com/wasteofplastic/askyblock/listeners/NetherPortals.java +++ b/src/com/wasteofplastic/askyblock/listeners/NetherPortals.java @@ -42,9 +42,9 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.GridManager; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.SafeSpotTeleport; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.commands.IslandCmd; import com.wasteofplastic.askyblock.events.IslandEnterEvent; import com.wasteofplastic.askyblock.schematics.Schematic; diff --git a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents.java b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents.java index 8db65c0a8..07a911d58 100644 --- a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents.java +++ b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents.java @@ -52,8 +52,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.InventorySave; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.events.IslandEnterEvent; import com.wasteofplastic.askyblock.events.IslandExitEvent; import com.wasteofplastic.askyblock.util.Util; diff --git a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents2.java b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents2.java index 9ee8f6a14..b250fb16e 100644 --- a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents2.java +++ b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents2.java @@ -23,8 +23,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.VaultHelper; /** diff --git a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents3.java b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents3.java index c94877296..c60425670 100644 --- a/src/com/wasteofplastic/askyblock/listeners/PlayerEvents3.java +++ b/src/com/wasteofplastic/askyblock/listeners/PlayerEvents3.java @@ -24,8 +24,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.VaultHelper; /** diff --git a/src/com/wasteofplastic/askyblock/panels/SettingsPanel.java b/src/com/wasteofplastic/askyblock/panels/SettingsPanel.java index 8a466eae7..ef002e1f1 100644 --- a/src/com/wasteofplastic/askyblock/panels/SettingsPanel.java +++ b/src/com/wasteofplastic/askyblock/panels/SettingsPanel.java @@ -39,8 +39,8 @@ import com.google.common.collect.HashBiMap; import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.Util; public class SettingsPanel implements Listener { diff --git a/src/com/wasteofplastic/askyblock/panels/WarpPanel.java b/src/com/wasteofplastic/askyblock/panels/WarpPanel.java index 98cb72aba..84164cdaa 100644 --- a/src/com/wasteofplastic/askyblock/panels/WarpPanel.java +++ b/src/com/wasteofplastic/askyblock/panels/WarpPanel.java @@ -43,8 +43,8 @@ import com.wasteofplastic.askyblock.ASkyBlock; import com.wasteofplastic.askyblock.Island; -import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.Settings; +import com.wasteofplastic.askyblock.Island.SettingsFlag; import com.wasteofplastic.askyblock.util.Util; public class WarpPanel implements Listener {