From 6044ca63c2abad116ca25602e2a063a83f2ed387 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 1 Nov 2014 09:29:08 +1100 Subject: [PATCH] fixes --- .../intellectualcrafters/plot/PlotHelper.java | 2 +- .../intellectualcrafters/plot/PlotMain.java | 129 +++++++++--------- .../intellectualcrafters/plot/Settings.java | 1 + .../plot/commands/Auto.java | 39 ++---- .../plot/commands/Claim.java | 7 +- .../plot/commands/Purge.java | 2 +- .../plot/commands/Visit.java | 2 +- .../plot/database/SQLManager.java | 2 +- .../plot/listeners/ForceFieldListener.java | 22 +-- .../plot/listeners/PlotListener.java | 2 +- 10 files changed, 100 insertions(+), 108 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotHelper.java index d67bf573a..6597585e3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotHelper.java @@ -274,7 +274,7 @@ public class PlotHelper { SetBlockFast.set(block.getWorld(), block.getX(), block.getY(), block.getZ(), plotblock.id, plotblock.data); return true; } - catch (NoSuchMethodException e) { + catch (Throwable e) { canSetFast = false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index 1af5d99be..65a7885ee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -733,10 +733,8 @@ public class PlotMain extends JavaPlugin { /** * Get MySQL Connection - * * @return connection MySQL Connection. */ - @SuppressWarnings("unused") public static Connection getConnection() { return connection; } @@ -959,7 +957,7 @@ public class PlotMain extends JavaPlugin { */ @SuppressWarnings("deprecation") public static void killAllEntities() { - Bukkit.getScheduler().scheduleAsyncRepeatingTask(getMain(), new Runnable() { + Bukkit.getScheduler().scheduleSyncRepeatingTask(getMain(), new Runnable() { Location location; long ticked = 0l; long error = 0l; @@ -986,73 +984,72 @@ public class PlotMain extends JavaPlugin { Entity[] entities = chunk.getEntities(); for (int i = entities.length - 1; i >= 0; i--) { Entity entity = entities[i]; - if ((entity instanceof Player) || PlayerEvents.isInPlot(entity.getLocation())) { continue; } - - boolean tamed = false; - if (Settings.MOB_PATHFINDING) { - if (entity instanceof Tameable) { - Tameable tameable = (Tameable) entity; - if (tameable.isTamed()) { - tamed = true; - } - } - else - if (entity instanceof LivingEntity) { - LivingEntity livingEntity = ((LivingEntity) entity); - if (livingEntity.getCustomName() != null) { - tamed = true; - } - } - if (!tamed) { - entity.remove(); - continue; - } - boolean found = false; - int radius = 1; - int dir = 0; - int x = this.location.getBlockX(); - int y = this.location.getBlockY(); - int z = this.location.getBlockZ(); - while (!found && (radius < 4)) { - Location pos; - switch (dir) { - case 0: - pos = new Location(world, x + radius, y, z); - dir++; - break; - case 1: - pos = new Location(world, x, y, z + radius); - dir++; - break; - case 2: - pos = new Location(world, x - radius, y, z); - dir++; - break; - case 3: - pos = new Location(world, x, y, z - radius); - dir = 0; - radius++; - break; - default: - pos = this.location; - break; - - } - if (PlayerEvents.isInPlot(pos)) { - entity.teleport(pos.add(0.5, 0, 0.5)); - found = true; - break; - } - } - entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2))); - } + entity.remove(); +// boolean tamed = false; +// if (Settings.MOB_PATHFINDING) { +// if (entity instanceof Tameable) { +// Tameable tameable = (Tameable) entity; +// if (tameable.isTamed()) { +// tamed = true; +// } +// } +// else +// if (entity instanceof LivingEntity) { +// LivingEntity livingEntity = ((LivingEntity) entity); +// if (livingEntity.getCustomName() != null) { +// tamed = true; +// } +// } +// if (!tamed) { +// entity.remove(); +// continue; +// } +// boolean found = false; +// int radius = 1; +// int dir = 0; +// int x = this.location.getBlockX(); +// int y = this.location.getBlockY(); +// int z = this.location.getBlockZ(); +// while (!found && (radius < 4)) { +// Location pos; +// switch (dir) { +// case 0: +// pos = new Location(world, x + radius, y, z); +// dir++; +// break; +// case 1: +// pos = new Location(world, x, y, z + radius); +// dir++; +// break; +// case 2: +// pos = new Location(world, x - radius, y, z); +// dir++; +// break; +// case 3: +// pos = new Location(world, x, y, z - radius); +// dir = 0; +// radius++; +// break; +// default: +// pos = this.location; +// break; +// +// } +// if (PlayerEvents.isInPlot(pos)) { +// entity.teleport(pos.add(0.5, 0, 0.5)); +// found = true; +// break; +// } +// } +// entity.teleport(this.location.subtract(this.location.getDirection().normalize().multiply(2))); +// } } } } - catch (Exception e) { + catch (Throwable e) { ++this.error; } finally { @@ -1060,7 +1057,7 @@ public class PlotMain extends JavaPlugin { } } } - }, 0l, 2l); + }, 2L, 2L); } /** @@ -1083,6 +1080,7 @@ public class PlotMain extends JavaPlugin { options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); options.put("api.location", Settings.API_URL); options.put("api.custom", Settings.CUSTOM_API); + options.put("titles", Settings.TITLES); for (Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { @@ -1099,6 +1097,7 @@ public class PlotMain extends JavaPlugin { Settings.METRICS = config.getBoolean("metrics"); Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days"); Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled"); + Settings.TITLES = config.getBoolean("titles"); Settings.MAX_PLOTS = config.getInt("max_plots"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/Settings.java index b2da46ba5..7c53c2e6a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/Settings.java @@ -15,6 +15,7 @@ package com.intellectualcrafters.plot; * @author Empire92 */ public class Settings { + public static boolean TITLES = true; /** * Schematic Save Path */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index be9643e16..8208c7630 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -14,6 +14,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import com.intellectualcrafters.plot.C; +import com.intellectualcrafters.plot.FlagManager; import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.PlotHelper; @@ -108,40 +109,21 @@ public class Auto extends SubCommand { } } boolean br = false; - int x = 0, z = 0, q = 100; - PlotId id; if ((size_x == 1) && (size_z == 1)) { while (!br) { Plot plot = PlotHelper.getPlot(world, Auto.lastPlot); if (plot==null || plot.owner == null) { plot = PlotHelper.getPlot(world, Auto.lastPlot); - boolean result = Claim.claimPlot(plr, plot, true); - br = !result; + Claim.claimPlot(plr, plot, true); + br = true; + PlotWorld pw = PlotMain.getWorldSettings(world); + Plot plot2 = PlotMain.getPlots(world).get(plot.id); + if (pw.DEFAULT_FLAGS != null && pw.DEFAULT_FLAGS.size() > 0) { + plot2.settings.setFlags(FlagManager.parseFlags(pw.DEFAULT_FLAGS)); + } } Auto.lastPlot = getNextPlot(Auto.lastPlot, 1); } - while (!br) { - id = new PlotId(x, z); - if (PlotHelper.getPlot(world, id).owner == null) { - Plot plot = PlotHelper.getPlot(world, id); - boolean result = Claim.claimPlot(plr, plot, true); - br = !result; - } - if ((z < q) && ((z - x) < q)) { - z++; - } - else { - if (x < q) { - x++; - z = q - 100; - } - else { - q += 100; - x = q; - z = q; - } - } - } } else { boolean claimed = true; @@ -168,6 +150,11 @@ public class Auto extends SubCommand { return false; } br = true; + PlotWorld pw = PlotMain.getWorldSettings(world); + Plot plot2 = PlotMain.getPlots(world).get(start); + if (pw.DEFAULT_FLAGS != null && pw.DEFAULT_FLAGS.size() > 0) { + plot2.settings.setFlags(FlagManager.parseFlags(pw.DEFAULT_FLAGS)); + } } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index a240b6bbe..1db3c1562 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -99,6 +99,9 @@ public class Claim extends SubCommand { PlotMain.teleportPlayer(player, player.getLocation(), plot); } PlotWorld world = PlotMain.getWorldSettings(plot.getWorld()); + + Plot plot2 = PlotMain.getPlots(player.getWorld()).get(plot.id); + if (world.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; if (schematic.equals("")) { @@ -110,10 +113,10 @@ public class Claim extends SubCommand { sch = SchematicHandler.getSchematic(world.SCHEMATIC_FILE); } } - SchematicHandler.paste(player.getLocation(), sch, plot, 0, 0); + SchematicHandler.paste(player.getLocation(), sch, plot2, 0, 0); } if (world.DEFAULT_FLAGS != null && world.DEFAULT_FLAGS.size() > 0) { - plot.settings.setFlags(FlagManager.parseFlags(PlotMain.getWorldSettings(player.getWorld()).DEFAULT_FLAGS)); + plot2.settings.setFlags(FlagManager.parseFlags(world.DEFAULT_FLAGS)); } } return event.isCancelled(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index 97bdcaa0e..3b03ae3b8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -23,7 +23,7 @@ import com.intellectualcrafters.plot.database.DBFunc; public class Purge extends SubCommand { public Purge() { - super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.ACTIONS, false); + super("purge", "plots.admin", "Purge all plots for a world", "purge", "", CommandCategory.DEBUG, false); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index 684506f41..54d1f495c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -67,7 +67,7 @@ public class Visit extends SubCommand { PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } - if ((i < 0) || (i > plots.size())) { + if ((i < 0) || (i >= plots.size())) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java index d33c678a7..4625c6e9b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java @@ -439,7 +439,7 @@ public class SQLManager extends AbstractDB { user = UUID.fromString(o); uuids.put(o, user); } - p = new Plot(plot_id, user, Biome.FOREST, new ArrayList(), new ArrayList(), new ArrayList(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[0]); + p = new Plot(plot_id, user, Biome.FOREST, new ArrayList(), new ArrayList(), new ArrayList(), "", PlotHomePosition.DEFAULT, null, worldname, new boolean[] {false, false, false, false}); plots.put(id, p); } stmt.close(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java index 04f091a40..2786a94b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/ForceFieldListener.java @@ -77,16 +77,18 @@ public class ForceFieldListener implements Listener { if(!PlayerFunctions.isInPlot(player)) return; Plot plot = PlayerFunctions.getCurrentPlot(player); - if(!PlotListener.booleanFlag(plot, "forcefield")) - if(plot.hasRights(player)) { - Set players = getNearbyPlayers(player, plot); - for(Player oPlayer : players) { - oPlayer.setVelocity(calculateVelocity(player, oPlayer)); + if (plot.settings.getFlag("forcefield") != null && plot.settings.getFlag("forcefield").getValue().equals("true")) { + if(!PlotListener.booleanFlag(plot, "forcefield")) + if(plot.hasRights(player)) { + Set players = getNearbyPlayers(player, plot); + for(Player oPlayer : players) { + oPlayer.setVelocity(calculateVelocity(player, oPlayer)); + } + } else { + Player oPlayer = hasNearbyPermitted(player, plot); + if(oPlayer == null) return; + player.setVelocity(calculateVelocity(oPlayer, player)); } - } else { - Player oPlayer = hasNearbyPermitted(player, plot); - if(oPlayer == null) return; - player.setVelocity(calculateVelocity(oPlayer, player)); - } + } } } \ No newline at end of file diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index 14a1e310c..59b9a3de4 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -176,7 +176,7 @@ public class PlotListener { if(plot.settings.getFlag("weather") != null) { player.setPlayerWeather(getWeatherType(plot.settings.getFlag("weather").getValue())); } - if (C.TITLE_ENTERED_PLOT.s().length() > 2) { + if (Settings.TITLES && C.TITLE_ENTERED_PLOT.s().length() > 2) { String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceFirst("%s", plot.getDisplayName()); String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceFirst("%s", getName(plot.owner)); ChatColor sTitleMainColor = ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s());