diff --git a/acidIsland/src/com/wasteofplastic/askyblock/ASkyBlock.java b/acidIsland/src/com/wasteofplastic/askyblock/ASkyBlock.java index 31cc8b875..36dbb1f7f 100644 --- a/acidIsland/src/com/wasteofplastic/askyblock/ASkyBlock.java +++ b/acidIsland/src/com/wasteofplastic/askyblock/ASkyBlock.java @@ -322,8 +322,16 @@ public Location getSafeHomeLocation(final UUID p) { // Try the default location Location dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 2.5D, 0F, 30F); if (isSafeLocation(dl)) { + players.setHomeLocation(p, dl); return dl; } + // Try just above the bedrock + dl = new Location(l.getWorld(), l.getX(), l.getY() + 5D, l.getZ(), 0F, 30F); + if (isSafeLocation(dl)) { + players.setHomeLocation(p, dl); + return dl; + } + // Try higher up - 25 blocks high and then move down for (int y = l.getBlockY() + 25; y > 0; y--) { final Location n = new Location(l.getWorld(), l.getBlockX(), y, l.getBlockZ()); @@ -338,6 +346,21 @@ public Location getSafeHomeLocation(final UUID p) { return n; } } + // Try anywhere in the island area + // Start from up above and work down + for (int y = l.getWorld().getMaxHeight(); y>0; y--) { + for (int x = l.getBlockX() - Settings.islandDistance/2; x < l.getBlockX() + Settings.islandDistance/2; x++) { + for (int z = l.getBlockZ() - Settings.islandDistance/2; z < l.getBlockZ() + Settings.islandDistance/2; z++) { + Location ultimate = new Location(l.getWorld(),x,y,z); + if (!ultimate.getBlock().equals(Material.AIR)) { + if (isSafeLocation(ultimate)) { + players.setHomeLocation(p, ultimate); + return ultimate; + } + } + } + } + } // Nothing worked return null; } diff --git a/acidIsland/src/com/wasteofplastic/askyblock/DeleteIsland.java b/acidIsland/src/com/wasteofplastic/askyblock/DeleteIsland.java index 4fcba2cfd..9dc78e147 100644 --- a/acidIsland/src/com/wasteofplastic/askyblock/DeleteIsland.java +++ b/acidIsland/src/com/wasteofplastic/askyblock/DeleteIsland.java @@ -75,7 +75,11 @@ public DeleteIsland(ASkyBlock plugin, Location loc) { private int checkVersion() throws ClassNotFoundException, IllegalArgumentException, SecurityException, InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { - int slice = 255; + // Calculate how many slices we should take without killing the server + int slice = (int)Math.floor(255D * ((double)10000/(Settings.islandDistance*Settings.islandDistance))); + if (slice < 10) { + slice = 10; + } String serverPackageName = plugin.getServer().getClass().getPackage().getName(); String pluginPackageName = plugin.getClass().getPackage().getName(); String version = serverPackageName.substring(serverPackageName.lastIndexOf('.') + 1); @@ -86,10 +90,14 @@ private int checkVersion() throws ClassNotFoundException, IllegalArgumentExcepti } catch (Exception e) { plugin.getLogger().info("No NMS Handler found, falling back to slow island delete."); clazz = Class.forName(pluginPackageName + ".fallback.NMSHandler"); - slice = 51; + slice = (int)Math.floor(51D * ((double)10000/(Settings.islandDistance*Settings.islandDistance))); + if (slice < 10) { + slice = 10; + } } - //plugin.getLogger().info(serverPackageName); - //plugin.getLogger().info(pluginPackageName); + //plugin.getLogger().info("Slice is = " + slice); + plugin.getLogger().info(serverPackageName); + plugin.getLogger().info(pluginPackageName); // Check if we have a NMSAbstraction implementing class at that location. if (NMSAbstraction.class.isAssignableFrom(clazz)) { nms = (NMSAbstraction) clazz.getConstructor().newInstance(); @@ -142,6 +150,11 @@ void removeSlice(int top, int bottom) { chunks.add(chunkCoords); } final Material bt = b.getType(); + Material setTo = Material.AIR; + // Split depending on below or above water line + if (y < Settings.sea_level) { + setTo = Material.STATIONARY_WATER; + } // Grab anything out of containers (do that it is // destroyed) switch (bt) { @@ -152,46 +165,44 @@ void removeSlice(int top, int bottom) { final Chest c = (Chest) b.getState(); final ItemStack[] items = new ItemStack[c.getInventory().getContents().length]; c.getInventory().setContents(items); - b.setType(Material.AIR); + b.setType(setTo); break; case FURNACE: final Furnace f = (Furnace) b.getState(); final ItemStack[] i2 = new ItemStack[f.getInventory().getContents().length]; f.getInventory().setContents(i2); - b.setType(Material.AIR); + b.setType(setTo); break; case DISPENSER: final Dispenser d = (Dispenser) b.getState(); final ItemStack[] i3 = new ItemStack[d.getInventory().getContents().length]; d.getInventory().setContents(i3); - b.setType(Material.AIR); + b.setType(setTo); break; case HOPPER: final Hopper h = (Hopper) b.getState(); final ItemStack[] i4 = new ItemStack[h.getInventory().getContents().length]; h.getInventory().setContents(i4); - b.setType(Material.AIR); + b.setType(setTo); break; case SIGN_POST: case WALL_SIGN: case SIGN: //getLogger().info("DEBUG: Sign"); - b.setType(Material.AIR); + b.setType(setTo); break; + case AIR: + if (setTo.equals(Material.STATIONARY_WATER)) { + nms.setBlockSuperFast(b, setTo); + } + case STATIONARY_WATER: + if (setTo.equals(Material.AIR)) { + nms.setBlockSuperFast(b, setTo); + } default: + nms.setBlockSuperFast(b, setTo); break; } - // Split depending on below or above water line - if (y < Settings.sea_level) { - if (!bt.equals(Material.STATIONARY_WATER)) - nms.setBlockSuperFast(b, Material.STATIONARY_WATER); - //b.setType(Material.STATIONARY_WATER); - } else { - if (!bt.equals(Material.AIR)) - nms.setBlockSuperFast(b, Material.AIR); - //b.setType(Material.AIR); - } - } } } diff --git a/acidIsland/src/com/wasteofplastic/askyblock/IslandCmd.java b/acidIsland/src/com/wasteofplastic/askyblock/IslandCmd.java index f24ff869d..b6b56d188 100644 --- a/acidIsland/src/com/wasteofplastic/askyblock/IslandCmd.java +++ b/acidIsland/src/com/wasteofplastic/askyblock/IslandCmd.java @@ -18,7 +18,6 @@ import java.io.File; import java.io.IOException; -import java.io.InputStream; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Calendar; @@ -45,7 +44,6 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; -import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; @@ -755,6 +753,7 @@ public void run() { plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable () { @Override public void run() { + //plugin.homeTeleport(player); player.getWorld().spawnEntity(cowSpot, EntityType.COW); } @@ -765,7 +764,7 @@ public void run() { if (oldIsland != null) { plugin.removeIsland(oldIsland); DeleteIsland deleteIsland = new DeleteIsland(plugin,oldIsland); - deleteIsland.runTaskTimer(plugin, 40L, 40L); + deleteIsland.runTaskTimer(plugin, 80L, 40L); } plugin.restartEvents(); } else { diff --git a/plugin.yml b/plugin.yml index a0e5b341c..df9c4330f 100644 --- a/plugin.yml +++ b/plugin.yml @@ -14,7 +14,7 @@ commands: asadmin: description: Admin commands usage: | - /acid + /asadmin asc: description: Game challenges aliases: [c, challenge, aschallenge]