From ccbd2ab30fee358073b3b38968767e53b6c3a805 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 14 Aug 2015 08:52:31 +1000 Subject: [PATCH] Sponge stuff + done flag --- .../com/intellectualcrafters/plot/PS.java | 10 +++ .../plot/commands/Clear.java | 6 +- .../plot/commands/Continue.java | 71 +++++++++++++++++++ .../plot/commands/DebugExec.java | 8 +++ .../plot/commands/DebugUUID.java | 13 ++-- .../plot/commands/MainCommand.java | 1 + .../plot/commands/list.java | 49 +++++++++++++ .../intellectualcrafters/plot/config/C.java | 2 + .../plot/config/Settings.java | 1 + .../plot/database/DBFunc.java | 2 +- .../plot/object/ConsolePlayer.java | 3 + .../plot/object/PlotAnalysis.java | 20 +++--- .../plot/util/MainUtil.java | 2 +- .../bukkit/listeners/PlayerEvents.java | 4 +- .../sponge/listener/MainListener.java | 24 +++++-- .../sponge/object/SpongePlayer.java | 7 +- .../sponge/util/SpongeBlockManager.java | 17 +++-- .../plotsquared/sponge/util/SpongeUtil.java | 8 +++ .../sponge/uuid/SpongeUUIDHandler.java | 3 - 19 files changed, 211 insertions(+), 40 deletions(-) create mode 100644 src/main/java/com/intellectualcrafters/plot/commands/Continue.java diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java index 0c75a0a16..45a149e2d 100644 --- a/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1792,6 +1792,10 @@ public class PS { } config.set("clear.keep-if-modified", null); config.set("clear.ignore-if-modified", null); + + // Done + config.set("approval.ratings.require-done", Settings.REQUIRE_DONE); + config.set("approval.done.counts-towards-limit", Settings.DONE_COUNTS_TOWARDS_LIMIT); // Schematics options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); @@ -1804,6 +1808,8 @@ public class PS { options.put("cache.permissions", Settings.PERMISSION_CACHING); options.put("cache.ratings", Settings.CACHE_RATINGS); + options.put("cache.ratings", Settings.CACHE_RATINGS); + // Titles options.put("titles", Settings.TITLES); @@ -1894,6 +1900,10 @@ public class PS { PlotAnalysis.MODIFIERS.air_sd = config.getInt("clear.auto.calibration.air_sd"); PlotAnalysis.MODIFIERS.variety_sd = config.getInt("clear.auto.calibration.variety_sd"); + // Done + Settings.REQUIRE_DONE = config.getBoolean("approval.ratings.require-done"); + Settings.DONE_COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit"); + // Schematics Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index f92661fa8..7834414e3 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -88,6 +88,10 @@ public class Clear extends SubCommand { MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); return false; } + if (Settings.DONE_COUNTS_TOWARDS_LIMIT && FlagManager.isPlotFlagTrue(plot, "done" ) && MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr)) { + MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE); + return false; + } Runnable runnable = new Runnable() { @Override public void run() { @@ -96,7 +100,7 @@ public class Clear extends SubCommand { @Override public void run() { // If the state changes, then mark it as no longer done - if (FlagManager.isPlotFlagTrue(plot, "done" )) { + if (FlagManager.getPlotFlag(plot, "done" ) != null) { FlagManager.removePlotFlag(plot, "done"); } if (FlagManager.getPlotFlag(plot, "analysis") != null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Continue.java b/src/main/java/com/intellectualcrafters/plot/commands/Continue.java new file mode 100644 index 000000000..3aa2bd76c --- /dev/null +++ b/src/main/java/com/intellectualcrafters/plot/commands/Continue.java @@ -0,0 +1,71 @@ +//////////////////////////////////////////////////////////////////////////////////////////////////// +// PlotSquared - A plot manager and world generator for the Bukkit API / +// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / +// / +// This program is free software; you can redistribute it and/or modify / +// it under the terms of the GNU General Public License as published by / +// the Free Software Foundation; either version 3 of the License, or / +// (at your option) any later version. / +// / +// This program is distributed in the hope that it will be useful, / +// but WITHOUT ANY WARRANTY; without even the implied warranty of / +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / +// GNU General Public License for more details. / +// / +// You should have received a copy of the GNU General Public License / +// along with this program; if not, write to the Free Software Foundation, / +// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / +// / +// You can contact us via: support@intellectualsites.com / +//////////////////////////////////////////////////////////////////////////////////////////////////// +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.flag.Flag; +import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.generator.HybridUtils; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotAnalysis; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.general.commands.CommandDeclaration; + +@CommandDeclaration( + command = "continue", + description = "Continue a plot that was previously marked as done", + permission = "plots.done", + category = CommandCategory.ACTIONS, + requiredType = RequiredType.NONE +) +public class Continue extends SubCommand { + + @Override + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocation(); + final Plot plot = MainUtil.getPlot(loc); + if (plot == null || !plot.hasOwner()) { + return !sendMessage(plr, C.NOT_IN_PLOT); + } + if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) { + MainUtil.sendMessage(plr, C.NO_PLOT_PERMS); + return false; + } + if (!plot.getSettings().flags.containsKey("done")) { + MainUtil.sendMessage(plr, C.DONE_NOT_DONE); + return false; + } + if (MainUtil.runners.containsKey(plot)) { + MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); + return false; + } + FlagManager.removePlotFlag(plot, "done"); + MainUtil.sendMessage(plr, C.DONE_REMOVED); + return true; + } +} diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 871f0d9dd..a98a0151f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -103,6 +103,14 @@ public class DebugExec extends SubCommand { } } + public ScriptEngine getEngine() { + return engine; + } + + public Bindings getScope() { + return scope; + } + public void init() { if (engine != null) { return; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index f9120701b..f400b5077 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -100,11 +100,12 @@ public class DebugUUID extends SubCommand { if (args.length != 2 || !args[1].equals("-o")) { MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o"); MainUtil.sendMessage(player, "&cBe aware of the following!"); + MainUtil.sendMessage(player, "&8 - &cUse the database command or another method to backup your plots beforehand"); MainUtil.sendMessage(player, "&8 - &cIf the process is interrupted, all plots could be deleted"); MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted"); MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion"); - MainUtil.sendMessage(player, "&cBACK UP YOUR DATABASE BEFORE USING THIS!!!"); - MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready"); + MainUtil.sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!"); + MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready :)"); return false; } @@ -114,10 +115,8 @@ public class DebugUUID extends SubCommand { } MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion"); MainUtil.sendConsoleMessage("&7 - Disconnecting players"); - for (PlotPlayer user : UUIDHandler.getPlayers().values()) { - for (PlotPlayer pp : UUIDHandler.getPlayers().values()) { - pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished."); - } + for (PlotPlayer pp : UUIDHandler.getPlayers().values()) { + pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished."); } MainUtil.sendConsoleMessage("&7 - Initializing map"); @@ -240,7 +239,7 @@ public class DebugUUID extends SubCommand { MainUtil.sendConsoleMessage("&7 - Creating tables"); try { - database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite"); + database.createTables(); if (!result) { MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); for (Plot plot : PS.get().getPlots()) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index b93581b10..d57217c54 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.Permissions; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java index c33b46cac..1878f411b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -25,6 +25,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map.Entry; +import java.util.Set; import java.util.UUID; import org.bukkit.ChatColor; @@ -41,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.Rating; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; @@ -101,6 +103,9 @@ public class list extends SubCommand { if (Permissions.hasPermission(player, "plots.list.world")) { args.add(""); } + if (Permissions.hasPermission(player, "plots.list.done")) { + args.add(""); + } return args.toArray(new String[args.size()]); } @@ -175,6 +180,50 @@ public class list extends SubCommand { plots = new ArrayList<>(PS.get().getPlots()); break; } + case "done": { + if (!Permissions.hasPermission(plr, "plots.list.done")) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.done"); + return false; + } + plots = new ArrayList<>(); + String match; + if (args.length == 2) { + match = args[2]; + } + else { + match = null; + } + for (Plot plot : PS.get().getPlots()) { + Flag flag = plot.getSettings().flags.get("done"); + if (flag == null) { + return false; + } + if (match != null) { + flag.getValueString().matches(match); + } + else { + plots.add(plot); + } + } + if (match != null) { + Collections.sort(plots, new Comparator() { + @Override + public int compare(Plot a, Plot b) { + String va = a.getSettings().flags.get("done").getValueString(); + String vb = b.getSettings().flags.get("done").getValueString(); + if (MathMan.isInteger(va)) { + if (MathMan.isInteger(vb)) { + return Integer.parseInt(va) - Integer.parseInt(vb); + } + return -1; + } + return 1; + } + }); + sort = false; + } + break; + } case "top": { if (!Permissions.hasPermission(plr, "plots.list.top")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top"); diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java index 3c4bc9a6e..fed4758a4 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -174,8 +174,10 @@ public enum C { * Done */ DONE_ALREADY_DONE("$2This plot is already marked as done.","Done"), + DONE_NOT_DONE("$2This plot is not marked as done.","Done"), DONE_INSUFFICIENT_COMPLEXITY("$2This plot is too simple. Please add more detail before using this command.","Done"), DONE_SUCCESS("$1Successfully marked this plot as done.","Done"), + DONE_REMOVED("$1You may now continue building in this plot.","Done"), /* * Ratings */ diff --git a/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 86c6e836f..78ef765f5 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -52,6 +52,7 @@ public class Settings { */ public static List RATING_CATEGORIES = null; public static boolean REQUIRE_DONE = false; + public static boolean DONE_COUNTS_TOWARDS_LIMIT = false; /** * PlotMe settings */ diff --git a/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java b/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java index c10ddf72e..fb0605f7e 100644 --- a/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java +++ b/src/main/java/com/intellectualcrafters/plot/database/DBFunc.java @@ -140,7 +140,7 @@ public class DBFunc { * @throws Exception */ public static void createTables(final String database) throws Exception { - dbManager.createTables(database); + dbManager.createTables(); } /** diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java index 422ec4428..bad9f9f5a 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java +++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java @@ -21,6 +21,7 @@ public class ConsolePlayer extends PlotPlayer { public static ConsolePlayer getConsole() { if (instance == null) { instance = new ConsolePlayer(); + instance.teleport(instance.getLocation()); } return instance; } @@ -79,6 +80,8 @@ public class ConsolePlayer extends PlotPlayer { @Override public void teleport(Location loc) { + Plot plot = MainUtil.getPlot(loc); + setMeta("lastplot", plot); this.loc = loc; } diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java index d11d7800e..db70b9664 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java @@ -40,17 +40,17 @@ public class PlotAnalysis { if (flag != null) { PlotAnalysis analysis = new PlotAnalysis(); List values = (List) flag.getValue(); - analysis.changes = values.get(0); - analysis.faces = values.get(1); - analysis.data = values.get(2); - analysis.air = values.get(3); - analysis.variety = values.get(4); + analysis.changes = values.get(0); // 2126 + analysis.faces = values.get(1); // 90 + analysis.data = values.get(2); // 0 + analysis.air = values.get(3); // 19100 + analysis.variety = values.get(4); // 266 - analysis.changes_sd = values.get(5); - analysis.faces_sd = values.get(6); - analysis.data_sd = values.get(7); - analysis.air_sd = values.get(8); - analysis.variety_sd = values.get(9); + analysis.changes_sd = values.get(5); // 2104 + analysis.faces_sd = values.get(6); // 89 + analysis.data_sd = values.get(7); // 0 + analysis.air_sd = values.get(8); // 18909 + analysis.variety_sd = values.get(9); // 263 analysis.complexity = analysis.getComplexity(); return analysis; diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 0e0e7ad08..3715d4af2 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -440,7 +440,7 @@ public class MainUtil { final UUID uuid = plr.getUUID(); int count = 0; for (final Plot plot : PS.get().getPlotsInWorld(world)) { - if (plot.hasOwner() && plot.owner.equals(uuid) && plot.countsTowardsMax) { + if (plot.hasOwner() && plot.owner.equals(uuid) && (!Settings.DONE_COUNTS_TOWARDS_LIMIT || !plot.getSettings().flags.containsKey("done"))) { count++; } } diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index f550c2848..50687a08d 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -678,7 +678,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); event.setCancelled(true); } - else if (FlagManager.isPlotFlagTrue(plot, "done")) { + else if (plot.getSettings().flags.containsKey("done")) { if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); event.setCancelled(true); @@ -2077,7 +2077,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen return; } } - else if (FlagManager.isPlotFlagTrue(plot, "done")) { + else if (plot.getSettings().flags.containsKey("done")) { if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); event.setCancelled(true); diff --git a/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/src/main/java/com/plotsquared/sponge/listener/MainListener.java index a042b744b..a65f1c479 100644 --- a/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -507,8 +507,8 @@ public class MainListener { event.setCancelled(true); return; } + final PlotPlayer pp = SpongeUtil.getPlayer(player); if (!plot.hasOwner()) { - final PlotPlayer pp = SpongeUtil.getPlayer(player); if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { return; } @@ -516,8 +516,7 @@ public class MainListener { event.setCancelled(true); return; } - final PlotPlayer pp = SpongeUtil.getPlayer(player); - if (!plot.isAdded(pp.getUUID())) { + else if (!plot.isAdded(pp.getUUID())) { final Flag destroy = FlagManager.getPlotFlag(plot, "break"); BlockState state = blockLoc.getBlock(); if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { @@ -529,6 +528,13 @@ public class MainListener { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); event.setCancelled(true); } + else if (plot.getSettings().flags.containsKey("done")) { + if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { + MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); + event.setCancelled(true); + return; + } + } return; } final PlotPlayer pp = SpongeUtil.getPlayer(player); @@ -554,8 +560,8 @@ public class MainListener { event.setCancelled(true); return; } + final PlotPlayer pp = SpongeUtil.getPlayer(player); if (!plot.hasOwner()) { - final PlotPlayer pp = SpongeUtil.getPlayer(player); if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { return; } @@ -563,8 +569,7 @@ public class MainListener { event.setCancelled(true); return; } - final PlotPlayer pp = SpongeUtil.getPlayer(player); - if (!plot.isAdded(pp.getUUID())) { + else if (!plot.isAdded(pp.getUUID())) { final Flag destroy = FlagManager.getPlotFlag(plot, "place"); BlockState state = blockLoc.getBlock(); if ((destroy != null) && ((HashSet) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { @@ -576,6 +581,13 @@ public class MainListener { MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); event.setCancelled(true); } + else if (plot.getSettings().flags.containsKey("done")) { + if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { + MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); + event.setCancelled(true); + return; + } + } return; } final PlotPlayer pp = SpongeUtil.getPlayer(player); diff --git a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index 04ed348ec..f061d9d90 100644 --- a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -2,9 +2,11 @@ package com.plotsquared.sponge.object; import java.util.Date; import java.util.HashSet; +import java.util.Set; import java.util.UUID; import org.spongepowered.api.data.key.Keys; +import org.spongepowered.api.data.manipulator.mutable.TargetedLocationData; import org.spongepowered.api.data.manipulator.mutable.entity.GameModeData; import org.spongepowered.api.data.value.mutable.Value; import org.spongepowered.api.entity.player.Player; @@ -130,8 +132,8 @@ public class SpongePlayer extends PlotPlayer { @Override public void setCompassTarget(Location loc) { - // TODO set compass target - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); + TargetedLocationData target = player.getOrCreate(TargetedLocationData.class).get(); + target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(loc)); } @Override @@ -175,7 +177,6 @@ public class SpongePlayer extends PlotPlayer { @Override public PlotGamemode getGamemode() { - // TODO Auto-generated method stub GameMode gamemode = player.getGameModeData().type().get(); if (gamemode == GameModes.ADVENTURE) { return PlotGamemode.ADVENTURE; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java index 9513d2f9c..4309c8431 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java @@ -10,13 +10,11 @@ import org.spongepowered.api.block.tileentity.Sign; import org.spongepowered.api.block.tileentity.TileEntity; import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; -import org.spongepowered.api.data.value.immutable.ImmutableListValue; import org.spongepowered.api.data.value.mutable.ListValue; import org.spongepowered.api.text.Text; import org.spongepowered.api.world.World; import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; -import org.spongepowered.common.data.value.mutable.SpongeListValue; import com.google.common.base.Optional; import com.intellectualcrafters.plot.object.Location; @@ -153,12 +151,12 @@ public class SpongeBlockManager extends BlockManager { return null; } Sign sign = (Sign) tile; - Optional> optional = tile.get(Keys.SIGN_LINES); + Optional optional = sign.getOrCreate(SignData.class); if (!optional.isPresent()) { return null; } String[] result = new String[4]; - List lines = optional.get(); + ListValue lines = optional.get().lines(); for (int i = 0; i < 4; i++) { result[i] = lines.get(i).toString(); } @@ -195,8 +193,15 @@ public class SpongeBlockManager extends BlockManager { text.add(SpongeMain.THIS.getText(lines[i])); } try { - SpongeListValue offering = new SpongeListValue(Keys.SIGN_LINES, text); - sign.offer(offering); + Optional optional = sign.getOrCreate(SignData.class); + if(optional.isPresent()) { + SignData offering = optional.get(); + offering.lines().set(0, SpongeMain.THIS.getText(lines[0])); + offering.lines().set(1, SpongeMain.THIS.getText(lines[1])); + offering.lines().set(2, SpongeMain.THIS.getText(lines[2])); + offering.lines().set(3, SpongeMain.THIS.getText(lines[3])); + sign.offer(offering); + } } catch (NullPointerException e) { e.printStackTrace(); diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index 701101025..a13c06a8d 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -102,4 +102,12 @@ public class SpongeUtil { } return null; } + + public static org.spongepowered.api.world.Location getLocation(Location loc) { + Optional world = SpongeMain.THIS.getServer().getWorld(loc.getWorld()); + if (!world.isPresent()) { + return null; + } + return new org.spongepowered.api.world.Location(world.get(), loc.getX(), loc.getY(), loc.getZ()); + } } diff --git a/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java b/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java index 1d511d8c0..5e9736459 100644 --- a/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java +++ b/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java @@ -16,7 +16,6 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation { public SpongeUUIDHandler(UUIDWrapper wrapper) { super(wrapper); - // TODO Auto-generated constructor stub } @Override @@ -28,8 +27,6 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation { } public boolean cache(Runnable whenDone) { - // TODO cache UUIDS -// SpongeMain.THIS.getRegistry().get add(new StringWrapper("*"), DBFunc.everyone); for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) { add(new StringWrapper(profile.getName()), profile.getUniqueId());