Sponge stuff + done flag

This commit is contained in:
boy0001 2015-08-14 08:52:31 +10:00
parent 393a85c1bc
commit ccbd2ab30f
19 changed files with 211 additions and 40 deletions

View File

@ -1792,6 +1792,10 @@ public class PS {
} }
config.set("clear.keep-if-modified", null); config.set("clear.keep-if-modified", null);
config.set("clear.ignore-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 // Schematics
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH); 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.permissions", Settings.PERMISSION_CACHING);
options.put("cache.ratings", Settings.CACHE_RATINGS); options.put("cache.ratings", Settings.CACHE_RATINGS);
options.put("cache.ratings", Settings.CACHE_RATINGS);
// Titles // Titles
options.put("titles", Settings.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.air_sd = config.getInt("clear.auto.calibration.air_sd");
PlotAnalysis.MODIFIERS.variety_sd = config.getInt("clear.auto.calibration.variety_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 // Schematics
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path"); Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");

View File

@ -88,6 +88,10 @@ public class Clear extends SubCommand {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER); MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false; 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() { Runnable runnable = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -96,7 +100,7 @@ public class Clear extends SubCommand {
@Override @Override
public void run() { public void run() {
// If the state changes, then mark it as no longer done // 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"); FlagManager.removePlotFlag(plot, "done");
} }
if (FlagManager.getPlotFlag(plot, "analysis") != null) { if (FlagManager.getPlotFlag(plot, "analysis") != null) {

View File

@ -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;
}
}

View File

@ -103,6 +103,14 @@ public class DebugExec extends SubCommand {
} }
} }
public ScriptEngine getEngine() {
return engine;
}
public Bindings getScope() {
return scope;
}
public void init() { public void init() {
if (engine != null) { if (engine != null) {
return; return;

View File

@ -100,11 +100,12 @@ public class DebugUUID extends SubCommand {
if (args.length != 2 || !args[1].equals("-o")) { if (args.length != 2 || !args[1].equals("-o")) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o"); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o");
MainUtil.sendMessage(player, "&cBe aware of the following!"); 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 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 - &cIf an error occurs, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion"); MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion");
MainUtil.sendMessage(player, "&cBACK UP YOUR DATABASE BEFORE USING THIS!!!"); MainUtil.sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!");
MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready"); MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready :)");
return false; return false;
} }
@ -114,10 +115,8 @@ public class DebugUUID extends SubCommand {
} }
MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion"); MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion");
MainUtil.sendConsoleMessage("&7 - Disconnecting players"); MainUtil.sendConsoleMessage("&7 - Disconnecting players");
for (PlotPlayer user : UUIDHandler.getPlayers().values()) { for (PlotPlayer pp : UUIDHandler.getPlayers().values()) {
for (PlotPlayer pp : UUIDHandler.getPlayers().values()) { pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
} }
MainUtil.sendConsoleMessage("&7 - Initializing map"); MainUtil.sendConsoleMessage("&7 - Initializing map");
@ -240,7 +239,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendConsoleMessage("&7 - Creating tables"); MainUtil.sendConsoleMessage("&7 - Creating tables");
try { try {
database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite"); database.createTables();
if (!result) { if (!result) {
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery"); MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
for (Plot plot : PS.get().getPlots()) { for (Plot plot : PS.get().getPlots()) {

View File

@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;

View File

@ -25,6 +25,7 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -41,6 +42,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.Rating; import com.intellectualcrafters.plot.object.Rating;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
@ -101,6 +103,9 @@ public class list extends SubCommand {
if (Permissions.hasPermission(player, "plots.list.world")) { if (Permissions.hasPermission(player, "plots.list.world")) {
args.add("<world>"); args.add("<world>");
} }
if (Permissions.hasPermission(player, "plots.list.done")) {
args.add("<world>");
}
return args.toArray(new String[args.size()]); return args.toArray(new String[args.size()]);
} }
@ -175,6 +180,50 @@ public class list extends SubCommand {
plots = new ArrayList<>(PS.get().getPlots()); plots = new ArrayList<>(PS.get().getPlots());
break; 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<Plot>() {
@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": { case "top": {
if (!Permissions.hasPermission(plr, "plots.list.top")) { if (!Permissions.hasPermission(plr, "plots.list.top")) {
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top"); MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.top");

View File

@ -174,8 +174,10 @@ public enum C {
* Done * Done
*/ */
DONE_ALREADY_DONE("$2This plot is already marked as done.","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_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_SUCCESS("$1Successfully marked this plot as done.","Done"),
DONE_REMOVED("$1You may now continue building in this plot.","Done"),
/* /*
* Ratings * Ratings
*/ */

View File

@ -52,6 +52,7 @@ public class Settings {
*/ */
public static List<String> RATING_CATEGORIES = null; public static List<String> RATING_CATEGORIES = null;
public static boolean REQUIRE_DONE = false; public static boolean REQUIRE_DONE = false;
public static boolean DONE_COUNTS_TOWARDS_LIMIT = false;
/** /**
* PlotMe settings * PlotMe settings
*/ */

View File

@ -140,7 +140,7 @@ public class DBFunc {
* @throws Exception * @throws Exception
*/ */
public static void createTables(final String database) throws Exception { public static void createTables(final String database) throws Exception {
dbManager.createTables(database); dbManager.createTables();
} }
/** /**

View File

@ -21,6 +21,7 @@ public class ConsolePlayer extends PlotPlayer {
public static ConsolePlayer getConsole() { public static ConsolePlayer getConsole() {
if (instance == null) { if (instance == null) {
instance = new ConsolePlayer(); instance = new ConsolePlayer();
instance.teleport(instance.getLocation());
} }
return instance; return instance;
} }
@ -79,6 +80,8 @@ public class ConsolePlayer extends PlotPlayer {
@Override @Override
public void teleport(Location loc) { public void teleport(Location loc) {
Plot plot = MainUtil.getPlot(loc);
setMeta("lastplot", plot);
this.loc = loc; this.loc = loc;
} }

View File

@ -40,17 +40,17 @@ public class PlotAnalysis {
if (flag != null) { if (flag != null) {
PlotAnalysis analysis = new PlotAnalysis(); PlotAnalysis analysis = new PlotAnalysis();
List<Integer> values = (List<Integer>) flag.getValue(); List<Integer> values = (List<Integer>) flag.getValue();
analysis.changes = values.get(0); analysis.changes = values.get(0); // 2126
analysis.faces = values.get(1); analysis.faces = values.get(1); // 90
analysis.data = values.get(2); analysis.data = values.get(2); // 0
analysis.air = values.get(3); analysis.air = values.get(3); // 19100
analysis.variety = values.get(4); analysis.variety = values.get(4); // 266
analysis.changes_sd = values.get(5); analysis.changes_sd = values.get(5); // 2104
analysis.faces_sd = values.get(6); analysis.faces_sd = values.get(6); // 89
analysis.data_sd = values.get(7); analysis.data_sd = values.get(7); // 0
analysis.air_sd = values.get(8); analysis.air_sd = values.get(8); // 18909
analysis.variety_sd = values.get(9); analysis.variety_sd = values.get(9); // 263
analysis.complexity = analysis.getComplexity(); analysis.complexity = analysis.getComplexity();
return analysis; return analysis;

View File

@ -440,7 +440,7 @@ public class MainUtil {
final UUID uuid = plr.getUUID(); final UUID uuid = plr.getUUID();
int count = 0; int count = 0;
for (final Plot plot : PS.get().getPlotsInWorld(world)) { 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++; count++;
} }
} }

View File

@ -678,7 +678,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} }
else if (FlagManager.isPlotFlagTrue(plot, "done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
@ -2077,7 +2077,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
return; return;
} }
} }
else if (FlagManager.isPlotFlagTrue(plot, "done")) { else if (plot.getSettings().flags.containsKey("done")) {
if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);

View File

@ -507,8 +507,8 @@ public class MainListener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) { if (Permissions.hasPermission(pp, PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return; return;
} }
@ -516,8 +516,7 @@ public class MainListener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); else if (!plot.isAdded(pp.getUUID())) {
if (!plot.isAdded(pp.getUUID())) {
final Flag destroy = FlagManager.getPlotFlag(plot, "break"); final Flag destroy = FlagManager.getPlotFlag(plot, "break");
BlockState state = blockLoc.getBlock(); BlockState state = blockLoc.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { if ((destroy != null) && ((HashSet<PlotBlock>) 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); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); 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; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);
@ -554,8 +560,8 @@ public class MainListener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
final PlotPlayer pp = SpongeUtil.getPlayer(player);
if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) { if (Permissions.hasPermission(pp, PERMISSION_ADMIN_BUILD_UNOWNED)) {
return; return;
} }
@ -563,8 +569,7 @@ public class MainListener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); else if (!plot.isAdded(pp.getUUID())) {
if (!plot.isAdded(pp.getUUID())) {
final Flag destroy = FlagManager.getPlotFlag(plot, "place"); final Flag destroy = FlagManager.getPlotFlag(plot, "place");
BlockState state = blockLoc.getBlock(); BlockState state = blockLoc.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(SpongeMain.THIS.getPlotBlock(state))) { if ((destroy != null) && ((HashSet<PlotBlock>) 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); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); 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; return;
} }
final PlotPlayer pp = SpongeUtil.getPlayer(player); final PlotPlayer pp = SpongeUtil.getPlayer(player);

View File

@ -2,9 +2,11 @@ package com.plotsquared.sponge.object;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.spongepowered.api.data.key.Keys; 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.manipulator.mutable.entity.GameModeData;
import org.spongepowered.api.data.value.mutable.Value; import org.spongepowered.api.data.value.mutable.Value;
import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.Player;
@ -130,8 +132,8 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public void setCompassTarget(Location loc) { public void setCompassTarget(Location loc) {
// TODO set compass target TargetedLocationData target = player.getOrCreate(TargetedLocationData.class).get();
throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); target.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(loc));
} }
@Override @Override
@ -175,7 +177,6 @@ public class SpongePlayer extends PlotPlayer {
@Override @Override
public PlotGamemode getGamemode() { public PlotGamemode getGamemode() {
// TODO Auto-generated method stub
GameMode gamemode = player.getGameModeData().type().get(); GameMode gamemode = player.getGameModeData().type().get();
if (gamemode == GameModes.ADVENTURE) { if (gamemode == GameModes.ADVENTURE) {
return PlotGamemode.ADVENTURE; return PlotGamemode.ADVENTURE;

View File

@ -10,13 +10,11 @@ import org.spongepowered.api.block.tileentity.Sign;
import org.spongepowered.api.block.tileentity.TileEntity; import org.spongepowered.api.block.tileentity.TileEntity;
import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.data.manipulator.mutable.tileentity.SignData; 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.data.value.mutable.ListValue;
import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Text;
import org.spongepowered.api.world.World; import org.spongepowered.api.world.World;
import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeType;
import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.biome.BiomeTypes;
import org.spongepowered.common.data.value.mutable.SpongeListValue;
import com.google.common.base.Optional; import com.google.common.base.Optional;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
@ -153,12 +151,12 @@ public class SpongeBlockManager extends BlockManager {
return null; return null;
} }
Sign sign = (Sign) tile; Sign sign = (Sign) tile;
Optional<List<Text>> optional = tile.get(Keys.SIGN_LINES); Optional<SignData> optional = sign.getOrCreate(SignData.class);
if (!optional.isPresent()) { if (!optional.isPresent()) {
return null; return null;
} }
String[] result = new String[4]; String[] result = new String[4];
List<Text> lines = optional.get(); ListValue<Text> lines = optional.get().lines();
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
result[i] = lines.get(i).toString(); result[i] = lines.get(i).toString();
} }
@ -195,8 +193,15 @@ public class SpongeBlockManager extends BlockManager {
text.add(SpongeMain.THIS.getText(lines[i])); text.add(SpongeMain.THIS.getText(lines[i]));
} }
try { try {
SpongeListValue<Text> offering = new SpongeListValue<Text>(Keys.SIGN_LINES, text); Optional<SignData> optional = sign.getOrCreate(SignData.class);
sign.offer(offering); 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) { catch (NullPointerException e) {
e.printStackTrace(); e.printStackTrace();

View File

@ -102,4 +102,12 @@ public class SpongeUtil {
} }
return null; return null;
} }
public static org.spongepowered.api.world.Location getLocation(Location loc) {
Optional<World> 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());
}
} }

View File

@ -16,7 +16,6 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
public SpongeUUIDHandler(UUIDWrapper wrapper) { public SpongeUUIDHandler(UUIDWrapper wrapper) {
super(wrapper); super(wrapper);
// TODO Auto-generated constructor stub
} }
@Override @Override
@ -28,8 +27,6 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation {
} }
public boolean cache(Runnable whenDone) { public boolean cache(Runnable whenDone) {
// TODO cache UUIDS
// SpongeMain.THIS.getRegistry().get
add(new StringWrapper("*"), DBFunc.everyone); add(new StringWrapper("*"), DBFunc.everyone);
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) { for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
add(new StringWrapper(profile.getName()), profile.getUniqueId()); add(new StringWrapper(profile.getName()), profile.getUniqueId());