From 5f3fab5e4273bcdac305d25ef02fdfdb8b27fd3e Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 10 Jun 2015 04:54:00 +1000 Subject: [PATCH] Fixed player time / music / expire keep / Economy / remove unused messages --- PlotSquared/pom.xml | 2 +- .../plot/PlotSquared.java | 6 ++++- .../intellectualcrafters/plot/config/C.java | 4 --- .../plot/listeners/PlotListener.java | 25 +++++++++++++++---- .../plot/util/EconHandler.java | 6 ++--- .../plot/util/ExpireManager.java | 2 +- .../plot/util/MainUtil.java | 6 +++++ .../plot/util/SetBlockQueue.java | 11 ++++++++ .../plot/util/bukkit/BukkitEconHandler.java | 12 +++------ .../plot/util/bukkit/BukkitSetupUtils.java | 7 +++++- 10 files changed, 57 insertions(+), 24 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index b976f864b..c5daac02e 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.11.15 + 2.11.17 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 1ea38bd17..1aa501ea0 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -374,7 +374,11 @@ public class PlotSquared { config.createSection(path); } - plotWorld.TYPE = 2; + System.out.print("GENERATOR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + System.out.print(generator != null); + System.out.print(generator instanceof PlotGenerator); + + plotWorld.TYPE = generator instanceof PlotGenerator ? 0 : 2; plotWorld.TERRAIN = 0; plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index dd186da17..fd32a9479 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -194,10 +194,6 @@ public enum C { TITLE_ENTERED_PLOT_COLOR("GOLD", "Titles"), TITLE_ENTERED_PLOT_SUB("Owned by %s", "Titles"), TITLE_ENTERED_PLOT_SUB_COLOR("RED", "Titles"), - TITLE_LEFT_PLOT("You left plot %s", "Titles"), - TITLE_LEFT_PLOT_COLOR("GOLD", "Titles"), - TITLE_LEFT_PLOT_SUB("Owned by %s", "Titles"), - TITLE_LEFT_PLOT_SUB_COLOR("RED", "Titles"), PREFIX_GREETING("$1%id%$2> ", "Titles"), PREFIX_FAREWELL("$1%id%$2> ", "Titles"), /* 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 16711f2b0..4bd1b65fd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -39,10 +39,13 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.BukkitPlayer; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.titles.AbstractTitle; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -108,7 +111,7 @@ public class PlotListener extends APlotListener { if (timeFlag != null) { try { final long time = (long) timeFlag.getValue(); - player.setPlayerTime(time, true); + player.setPlayerTime(time, false); } catch (final Exception e) { FlagManager.removePlotFlag(plot, "time"); } @@ -126,8 +129,12 @@ public class PlotListener extends APlotListener { else { greeting = ""; } - final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceFirst("%s", getName(plot.owner)); - final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceFirst("%s", getName(plot.owner)); + String alias = plot.settings.getAlias(); + if (alias.length() == 0) { + alias = plot.toString(); + } + final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias); + final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias); AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); } { @@ -139,7 +146,10 @@ public class PlotListener extends APlotListener { player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); Integer id = (Integer) musicFlag.getValue(); if (id != 0) { - player.playEffect(player.getLocation(), Effect.RECORD_PLAY, Material.getMaterial(id)); + Location center = MainUtil.getPlotCenter(plot); + org.bukkit.Location newLoc = BukkitUtil.getLocation(center); + newLoc.setY(Math.min((((int) player.getLocation().getBlockY())/16) * 16, 240)); + player.playEffect(newLoc, Effect.RECORD_PLAY, Material.getMaterial(id)); } } CommentManager.sendTitle(pp, plot); @@ -163,7 +173,12 @@ public class PlotListener extends APlotListener { player.resetPlayerWeather(); } if (FlagManager.getPlotFlag(plot, "music") != null) { - player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); + Location center = MainUtil.getPlotCenter(plot); + for (int i = 0; i < 256; i+= 16) { + org.bukkit.Location newLoc = BukkitUtil.getLocation(center); + newLoc.setY(i); + player.playEffect(newLoc, Effect.RECORD_PLAY, 0); + } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index 8c42f8ea4..4b9cadc63 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -7,9 +7,9 @@ public abstract class EconHandler { public static EconHandler manager; public abstract double getMoney(PlotPlayer player); - public abstract double withdrawMoney(PlotPlayer player, double amount); - public abstract double depositMoney(PlotPlayer player, double amount); - public abstract double depositMoney(OfflinePlotPlayer player, double amount); + public abstract void withdrawMoney(PlotPlayer player, double amount); + public abstract void depositMoney(PlotPlayer player, double amount); + public abstract void depositMoney(OfflinePlotPlayer player, double amount); public abstract void setPermission(PlotPlayer player, String perm, boolean value); public abstract boolean getPermission(PlotPlayer player, String perm); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 813cf199e..fd5728c54 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -126,7 +126,7 @@ public class ExpireManager { @Override public void run() { int changed = (int) this.value; - if (changed >= Settings.MIN_BLOCKS_CHANGED) { + if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) { PlotSquared.log("&aKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : "")); FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("keep"), true)); expiredPlots.get(world).remove(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 257a2ce40..a4709ffb1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -67,6 +67,12 @@ public class MainUtil { return true; } + public static Location getPlotCenter(Plot plot) { + Location bot = getPlotBottomLoc(plot.world, plot.id); + Location top = getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1); + return new Location(plot.world, bot.getX() + (top.getX() - bot.getX()) / 2, 0, bot.getZ() + (top.getZ() - bot.getZ()) / 2); + } + /** * Merges all plots in the arraylist (with cost) * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java index 2f303f0e7..14f111665 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SetBlockQueue.java @@ -6,6 +6,7 @@ import java.util.Map.Entry; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.generator.AugmentedPopulator; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; public class SetBlockQueue { @@ -130,6 +131,16 @@ public class SetBlockQueue { running = true; } } + + public static void setChunk(final String world, ChunkLoc loc, PlotBlock[][] result) { + locked = true; + if (!running) { + init(); + } + ChunkWrapper wrap = new ChunkWrapper(world, loc.x, loc.z); + blocks.put(wrap, result); + locked = false; + } public static void setBlock(final String world, int x, final int y, int z, final PlotBlock block) { locked = true; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEconHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEconHandler.java index a8fc27dfb..5c75e4592 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEconHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitEconHandler.java @@ -46,26 +46,22 @@ public class BukkitEconHandler extends EconHandler { @Override public double getMoney(PlotPlayer player) { - econ.getBalance(player.getName()); - return 0; + return econ.getBalance(player.getName()); } @Override - public double withdrawMoney(PlotPlayer player, double amount) { + public void withdrawMoney(PlotPlayer player, double amount) { econ.withdrawPlayer(player.getName(), amount); - return 0; } @Override - public double depositMoney(PlotPlayer player, double amount) { + public void depositMoney(PlotPlayer player, double amount) { econ.depositPlayer(player.getName(), amount); - return 0; } @Override - public double depositMoney(OfflinePlotPlayer player, double amount) { + public void depositMoney(OfflinePlotPlayer player, double amount) { econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount); - return 0; } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index c2ae5c586..941dbe72b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -26,12 +26,17 @@ public class BukkitSetupUtils extends SetupUtils { } final String testWorld = "CheckingPlotSquaredGenerator"; for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { + System.out.print(plugin.getName()); if (plugin.isEnabled()) { + System.out.print(" - enabled"); final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); if (generator != null) { + System.out.print(" - non null"); PlotSquared.removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); -// if (generator instanceof PlotGenerator) { + if (generator instanceof PlotGenerator) { + System.out.print(" - ps gen"); + } // final PlotGenerator pgen = (PlotGenerator) generator; // if (pgen.getPlotManager() instanceof SquarePlotManager) { SetupUtils.generators.put(name, generator);