Skip to content

Commit

Permalink
Pull over from AcidIsland.
Browse files Browse the repository at this point in the history
Fixes level placeholder. May fix mobspawn issue when setting is off.
  • Loading branch information
tastybento committed Oct 22, 2017
1 parent f721402 commit 65c3ea4
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 44 deletions.
9 changes: 4 additions & 5 deletions src/com/wasteofplastic/askyblock/LevelCalcByChunk.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/wasteofplastic/askyblock/commands/IslandCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/com/wasteofplastic/askyblock/listeners/AcidEffect.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
56 changes: 28 additions & 28 deletions src/com/wasteofplastic/askyblock/listeners/EntityLimits.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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());
}
}


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/com/wasteofplastic/askyblock/panels/SettingsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/com/wasteofplastic/askyblock/panels/WarpPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 65c3ea4

Please sign in to comment.