diff --git a/pom.xml b/pom.xml
index 02813205c..4a4b28618 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@
UTF-8
PlotSquared
- 3.2.12
+ 3.2.13
PlotSquared
jar
diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java
index 487d172f1..2ee43fe0e 100644
--- a/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -1371,7 +1371,9 @@ public class PS {
}
}
try {
- plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world));
+ ConfigurationSection section = config.getConfigurationSection("worlds." + world);
+ plotworld.saveConfiguration(section);
+ plotworld.loadConfiguration(section);
config.save(configFile);
} catch (final Exception e) {
e.printStackTrace();
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
index 564fa2521..0864e87e0 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java
@@ -21,6 +21,7 @@
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
+import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
@@ -76,7 +77,8 @@ public class Comment extends SubCommand {
sendMessage(player, C.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|"));
return false;
}
- for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ PlotPlayer pp = entry.getValue();
if (pp.getAttribute("chatspy")) {
MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " "));
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
index 0d319ac64..4759841d0 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java
@@ -77,7 +77,7 @@ public class DebugClaimTest extends SubCommand {
}
final String world = args[0];
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
- return !MainUtil.sendMessage(null, "&cInvalid plot world!");
+ return !MainUtil.sendMessage(plr, "&cInvalid plot world!");
}
PlotId min, max;
try {
@@ -86,18 +86,18 @@ public class DebugClaimTest extends SubCommand {
min = PlotId.fromString(args[1]);
max = PlotId.fromString(args[2]);
} catch (final Exception e) {
- return !MainUtil.sendMessage(null,
+ return !MainUtil.sendMessage(plr,
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion will only check the plots in the selected area.");
}
- MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
- MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
+ MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
+ MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
final PlotManager manager = PS.get().getPlotManager(world);
final PlotWorld plotworld = PS.get().getPlotWorld(world);
final ArrayList plots = new ArrayList<>();
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
final Plot plot = MainUtil.getPlotAbs(world, id);
if (PS.get().getPlot(world, plot.id) != null) {
- MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
+ MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.id);
continue;
}
final Location loc = manager.getSignLoc(plotworld, plot);
@@ -125,29 +125,29 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null);
}
if (uuid != null) {
- MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
+ MainUtil.sendMessage(plr, " - &aFound plot: " + plot.id + " : " + line);
plot.owner = uuid;
plots.add(plot);
} else {
- MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
+ MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.id + " : " + line);
}
}
}
}
if (plots.size() > 0) {
- MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
+ MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
- MainUtil.sendMessage(null, "&6Database update finished!");
+ MainUtil.sendMessage(plr, "&6Database update finished!");
}
});
for (final Plot plot : plots) {
PS.get().updatePlot(plot);
}
- MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
+ MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
} else {
- MainUtil.sendMessage(null, "No plots were found for the given search.");
+ MainUtil.sendMessage(plr, "No plots were found for the given search.");
}
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 c7e919af1..9c650ad2d 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
@@ -433,13 +433,13 @@ public class DebugExec extends SubCommand {
} catch (final ScriptException e) {
e.printStackTrace();
}
- PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
+ ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
});
} else {
final long start = System.currentTimeMillis();
Object result = engine.eval(script, scope);
- PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
+ ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
return true;
} catch (final ScriptException e) {
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
index f5aff3b28..67148e362 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java
@@ -42,11 +42,11 @@ public class DebugSaveTest extends SubCommand {
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final ArrayList plots = new ArrayList();
plots.addAll(PS.get().getPlots());
- MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
+ MainUtil.sendMessage(plr, "&6Starting `DEBUGSAVETEST`");
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
- MainUtil.sendMessage(null, "&6Database sync finished!");
+ MainUtil.sendMessage(plr, "&6Database sync finished!");
}
});
return true;
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java
index 9ef6d921b..edc2ebcd2 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java
@@ -67,9 +67,7 @@ public class DebugUUID extends SubCommand {
}
@Override
- public boolean onCommand(final PlotPlayer plr, final String[] args) {
- final PlotPlayer player = null;
-
+ public boolean onCommand(final PlotPlayer player, final String[] args) {
final UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
final UUIDWrapper newWrapper;
@@ -113,18 +111,18 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
}
- MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion");
- MainUtil.sendConsoleMessage("&7 - Disconnecting players");
- for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
- pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
+ MainUtil.sendMessage(player, "&6Beginning UUID mode conversion");
+ MainUtil.sendMessage(player, "&7 - Disconnecting players");
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ entry.getValue().kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
- MainUtil.sendConsoleMessage("&7 - Initializing map");
+ MainUtil.sendMessage(player, "&7 - Initializing map");
final HashMap uCMap = new HashMap();
final HashMap uCReverse = new HashMap();
- MainUtil.sendConsoleMessage("&7 - Collecting playerdata");
+ MainUtil.sendMessage(player, "&7 - Collecting playerdata");
final HashSet worlds = new HashSet<>();
worlds.add(Bukkit.getWorlds().get(0).getName());
@@ -146,7 +144,7 @@ public class DebugUUID extends SubCommand {
final UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (final Exception e) {
- MainUtil.sendMessage(plr, C.PREFIX.s() + "Invalid playerdata: " + current);
+ MainUtil.sendMessage(player, C.PREFIX.s() + "Invalid playerdata: " + current);
}
}
}
@@ -164,7 +162,7 @@ public class DebugUUID extends SubCommand {
}
}
- MainUtil.sendConsoleMessage("&7 - Populating map");
+ MainUtil.sendMessage(player, "&7 - Populating map");
UUID uuid2;
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
for (UUID uuid : uuids) {
@@ -177,7 +175,7 @@ public class DebugUUID extends SubCommand {
uCReverse.put(uuid2, uuid);
}
} catch (final Throwable e) {
- MainUtil.sendMessage(plr, C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
+ MainUtil.sendMessage(player, C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (final String name : names) {
@@ -189,7 +187,7 @@ public class DebugUUID extends SubCommand {
}
}
if (uCMap.size() == 0) {
- MainUtil.sendConsoleMessage("&c - Error! Attempting to repopulate");
+ MainUtil.sendMessage(player, "&c - Error! Attempting to repopulate");
for (final OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) {
if (op.getLastPlayed() != 0) {
// String name = op.getName();
@@ -203,14 +201,14 @@ public class DebugUUID extends SubCommand {
}
}
if (uCMap.size() == 0) {
- MainUtil.sendConsoleMessage("&cError. Failed to collect UUIDs!");
+ MainUtil.sendMessage(player, "&cError. Failed to collect UUIDs!");
return false;
} else {
- MainUtil.sendConsoleMessage("&a - Successfully repopulated");
+ MainUtil.sendMessage(player, "&a - Successfully repopulated");
}
}
- MainUtil.sendConsoleMessage("&7 - Replacing cache");
+ MainUtil.sendMessage(player, "&7 - Replacing cache");
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@@ -221,7 +219,7 @@ public class DebugUUID extends SubCommand {
}
}
- MainUtil.sendConsoleMessage("&7 - Scanning for applicable files (uuids.txt)");
+ MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
final File file = new File(PS.get().IMP.getDirectory(), "uuids.txt");
if (file.exists()) {
@@ -256,10 +254,10 @@ public class DebugUUID extends SubCommand {
}
}
- MainUtil.sendConsoleMessage("&7 - Replacing wrapper");
+ MainUtil.sendMessage(player, "&7 - Replacing wrapper");
UUIDHandler.setUUIDWrapper(newWrapper);
- MainUtil.sendConsoleMessage("&7 - Updating plot objects");
+ MainUtil.sendMessage(player, "&7 - Updating plot objects");
for (final Plot plot : PS.get().getPlotsRaw()) {
final UUID value = uCMap.get(plot.owner);
@@ -271,16 +269,16 @@ public class DebugUUID extends SubCommand {
plot.getDenied().clear();
}
- MainUtil.sendConsoleMessage("&7 - Deleting database");
+ MainUtil.sendMessage(player, "&7 - Deleting database");
final AbstractDB database = DBFunc.dbManager;
final boolean result = database.deleteTables();
- MainUtil.sendConsoleMessage("&7 - Creating tables");
+ MainUtil.sendMessage(player, "&7 - Creating tables");
try {
database.createTables();
if (!result) {
- MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
+ MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
for (final Plot plot : PS.get().getPlots()) {
final UUID value = uCReverse.get(plot.owner);
if (value != null) {
@@ -290,7 +288,7 @@ public class DebugUUID extends SubCommand {
database.createPlotsAndData(new ArrayList<>(PS.get().getPlots()), new Runnable() {
@Override
public void run() {
- MainUtil.sendMessage(null, "&6Recovery was successful!");
+ MainUtil.sendMessage(player, "&6Recovery was successful!");
}
});
return;
@@ -313,10 +311,10 @@ public class DebugUUID extends SubCommand {
try {
PS.get().config.save(PS.get().configFile);
} catch (final Exception e) {
- MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!");
+ MainUtil.sendMessage(player, "Could not save configuration. It will need to be manuall set!");
}
- MainUtil.sendConsoleMessage("&7 - Populating tables");
+ MainUtil.sendMessage(player, "&7 - Populating tables");
TaskManager.runTaskAsync(new Runnable() {
@Override
@@ -325,14 +323,14 @@ public class DebugUUID extends SubCommand {
database.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
- MainUtil.sendConsoleMessage("&aConversion complete!");
+ MainUtil.sendMessage(player, "&aConversion complete!");
}
});
}
});
- MainUtil.sendConsoleMessage("&aIt is now safe for players to join");
- MainUtil.sendConsoleMessage("&cConversion is still in progress, you will be notified when it is complete");
+ MainUtil.sendMessage(player, "&aIt is now safe for players to join");
+ MainUtil.sendMessage(player, "&cConversion is still in progress, you will be notified when it is complete");
}
});
return true;
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
index a5bf5f8d8..44e89a3b6 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java
@@ -104,7 +104,7 @@ public class Purge extends SubCommand {
final Set ids = PS.get().getPlots(worldname).keySet();
final int length = ids.size();
if (length == 0) {
- return MainUtil.sendMessage(null, "&cNo plots found");
+ return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);
@@ -122,7 +122,7 @@ public class Purge extends SubCommand {
}
final int length = ids.size();
if (length == 0) {
- return MainUtil.sendMessage(null, "&cNo plots found");
+ return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);
@@ -137,7 +137,7 @@ public class Purge extends SubCommand {
}
final int length = ids.size();
if (length == 0) {
- return MainUtil.sendMessage(null, "&cNo plots found");
+ return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java
index ff60d1fc8..69bc68650 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java
@@ -167,7 +167,7 @@ public class SchematicCmd extends SubCommand {
return false;
}
if (args.length != 2) {
- MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall ");
+ MainUtil.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall ");
return false;
}
final Collection plots = PS.get().getPlotsInWorld(args[1]);
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
index 21fd15867..df3a3ddcc 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Trim.java
@@ -31,6 +31,7 @@ import java.util.HashSet;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.ChunkLoc;
+import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
@@ -158,7 +159,7 @@ public class Trim extends SubCommand {
}
public static void sendMessage(final String message) {
- PS.log("&3PlotSquared -> World trim&8: &7" + message);
+ ConsolePlayer.getConsole().sendMessage("&3PlotSquared -> World trim&8: &7" + message);
}
public PlotId getId(final String id) {
@@ -207,11 +208,12 @@ public class Trim extends SubCommand {
sendMessage(C.TASK_START.s());
final ArrayList empty = new ArrayList<>();
getTrimRegions(empty, world, new Runnable() {
+ @Override
public void run() {
deleteChunks(world, empty, new Runnable() {
@Override
public void run() {
- PS.log("$1Trim task complete!");
+ ConsolePlayer.getConsole().sendMessage("$1Trim task complete!");
}
});
}
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Update.java b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
index 4241e2947..f52f26f52 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/Update.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/Update.java
@@ -50,8 +50,8 @@ public class Update extends SubCommand {
try {
url = new URL(args[0]);
} catch (final MalformedURLException e) {
- MainUtil.sendConsoleMessage("&cInvalid url: " + args[0]);
- MainUtil.sendConsoleMessage(C.COMMAND_SYNTAX, "/plot update [url]");
+ MainUtil.sendMessage(plr, "&cInvalid url: " + args[0]);
+ MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
return false;
}
} else {
diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
index e9be75aa4..b24515c78 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java
@@ -25,8 +25,12 @@ public class ConsolePlayer extends PlotPlayer {
}
return instance;
}
-
- private ConsolePlayer() {
+
+ /**
+ * Direct access is deprecated
+ */
+ @Deprecated
+ public ConsolePlayer() {
String world;
final Set plotworlds = PS.get().getPlotWorlds();
if (plotworlds.size() > 0) {
@@ -39,7 +43,7 @@ public class ConsolePlayer extends PlotPlayer {
}
public static boolean isConsole(final PlotPlayer plr) {
- return instance == plr;
+ return plr instanceof ConsolePlayer;
}
@Override
diff --git a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
index accf49424..d90e429be 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/ChunkManager.java
@@ -9,6 +9,7 @@ import java.util.Set;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
+import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
@@ -141,7 +142,7 @@ public abstract class ChunkManager {
for (final ChunkLoc loc : chunks) {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(PS.get().IMP.getWorldContainer(), directory);
- PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
+ ConsolePlayer.getConsole().sendMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
if (file.exists()) {
file.delete();
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
index f6238140c..0118776ef 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
@@ -44,6 +44,7 @@ import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
+import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
@@ -283,7 +284,8 @@ public class MainUtil {
public static List getPlayersInPlot(final Plot plot) {
final ArrayList players = new ArrayList<>();
- for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ PlotPlayer pp = entry.getValue();
if (plot.equals(pp.getCurrentPlot())) {
players.add(pp);
}
@@ -2013,7 +2015,7 @@ public class MainUtil {
public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) {
if ((msg.length() > 0) && !msg.equals("")) {
if (plr == null) {
- PS.log((prefix ? C.PREFIX.s() : "") + msg);
+ ConsolePlayer.getConsole().sendMessage((prefix ? C.PREFIX.s() : "") + msg);
} else {
plr.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
}
@@ -2103,7 +2105,7 @@ public class MainUtil {
msg = C.format(c, args);
}
if (plr == null) {
- PS.log(msg);
+ ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}
@@ -2126,7 +2128,7 @@ public class MainUtil {
msg = C.format(c, args);
}
if (plr == null) {
- PS.log(msg);
+ ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java b/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
index 3e4b776f6..4eeeabb9e 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java
@@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
@@ -13,6 +14,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
+import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@@ -25,11 +27,11 @@ public abstract class UUIDHandlerImplementation {
private BiMap uuidMap = HashBiMap.create(new HashMap());
public boolean CACHED = false;
public UUIDWrapper uuidWrapper = null;
- public final HashMap players;
+ public final ConcurrentHashMap players;
public UUIDHandlerImplementation(final UUIDWrapper wrapper) {
uuidWrapper = wrapper;
- players = new HashMap<>();
+ players = new ConcurrentHashMap<>();
}
/**
@@ -96,7 +98,7 @@ public abstract class UUIDHandlerImplementation {
try {
unknown.add(uuid);
} catch (final Exception e) {
- PS.log("&c(minor) Invalid UUID mapping: " + uuid);
+ ConsolePlayer.getConsole().sendMessage("&c(minor) Invalid UUID mapping: " + uuid);
e.printStackTrace();
}
return false;
@@ -178,11 +180,11 @@ public abstract class UUIDHandlerImplementation {
if (uuid == null) {
return null;
}
- // check online
- final PlotPlayer player = getPlayer(uuid);
- if (player != null) {
- return player.getName();
- }
+ // // check online
+ // final PlotPlayer player = getPlayer(uuid);
+ // if (player != null) {
+ // return player.getName();
+ // }
// check cache
final StringWrapper name = uuidMap.inverse().get(uuid);
if (name != null) {
@@ -228,10 +230,9 @@ public abstract class UUIDHandlerImplementation {
}
public PlotPlayer getPlayer(final UUID uuid) {
- for (final PlotPlayer player : players.values()) {
- if (player.getUUID().equals(uuid)) {
- return player;
- }
+ String name = getName(uuid);
+ if (name != null) {
+ return getPlayer(name);
}
return null;
}
diff --git a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java
index 8dd52e568..71f041af8 100644
--- a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java
+++ b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java
@@ -41,7 +41,6 @@ public class AugmentedPopulator extends BlockPopulator {
public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
MainUtil.initCache();
- PS.log("== NEW AUGMENTED POPULATOR FOR: " + world);
this.cluster = cluster;
this.generator = generator;
plotworld = PS.get().getPlotWorld(world);
diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
index 3354d3882..8cfa13391 100644
--- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
+++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
@@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@@ -140,7 +141,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final int x = bloc.getBlockX();
final int z = bloc.getBlockZ();
final int distance = Bukkit.getViewDistance() * 16;
- for (final PlotPlayer player : UUIDHandler.getPlayers().values()) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ PlotPlayer player = entry.getValue();
final Location loc = player.getLocation();
if (loc.getWorld().equals(world)) {
if ((16 * (Math.abs(loc.getX() - x) / 16)) > distance) {
@@ -223,8 +225,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
if (Settings.REDSTONE_DISABLER_UNOCCUPIED) {
- for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
- if (plot.equals(pp.getCurrentPlot())) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ if (plot.equals(entry.getValue().getCurrentPlot())) {
return;
}
}
diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
index eddd41016..3140d3ecd 100644
--- a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
+++ b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
@@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@@ -34,7 +35,33 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
}
- return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
+ if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
+ return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
+ }
+ @SuppressWarnings("deprecation")
+ ConsolePlayer sender = new ConsolePlayer() {
+ @Override
+ public void sendMessage(String message) {
+ commandSender.sendMessage(commandLabel);
+ }
+
+ @Override
+ public boolean hasPermission(String perm) {
+ return commandSender.hasPermission(commandLabel);
+ }
+
+ @Override
+ public String getName() {
+ if (commandSender.getName().equals("CONSOLE")) {
+ return "*";
+ }
+ return commandSender.getName();
+ }
+ };
+ sender.teleport(ConsolePlayer.getConsole().getLocationFull());
+ boolean result = MainCommand.onCommand(sender, commandLabel, args);
+ ConsolePlayer.getConsole().teleport(sender.getLocationFull());
+ return result;
}
@Override
diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
index 62168d56f..fdaacb8b9 100644
--- a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
+++ b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
@@ -125,7 +125,7 @@ public class BukkitUtil extends BlockManager {
return lastPlotPlayer;
}
final String name = player.getName();
- final PlotPlayer pp = UUIDHandler.getPlayers().get(name);
+ final PlotPlayer pp = UUIDHandler.getPlayer(name);
if (pp != null) {
return pp;
}
diff --git a/src/main/java/com/plotsquared/bukkit/util/SendChunk.java b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java
index 120c4d68b..989a0c1d3 100644
--- a/src/main/java/com/plotsquared/bukkit/util/SendChunk.java
+++ b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java
@@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@@ -76,7 +77,8 @@ public class SendChunk {
final Object c = methodGetHandleChunk.of(chunk).call();
methodInitLighting.of(c).call();
}
- for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ PlotPlayer pp = entry.getValue();
final Plot plot = pp.getCurrentPlot();
Location loc = null;
String world;
diff --git a/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/src/main/java/com/plotsquared/sponge/listener/MainListener.java
index 35c882b2e..41b347100 100644
--- a/src/main/java/com/plotsquared/sponge/listener/MainListener.java
+++ b/src/main/java/com/plotsquared/sponge/listener/MainListener.java
@@ -3,6 +3,7 @@ package com.plotsquared.sponge.listener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
@@ -408,7 +409,8 @@ public class MainListener {
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
final Text forcedMessage = event.getMessage();
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
- for (final PlotPlayer user : UUIDHandler.getPlayers().values()) {
+ for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
+ PlotPlayer user = entry.getValue();
String toSend;
if (plot.equals(MainUtil.getPlot(user.getLocation()))) {
toSend = newMessage;
diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
index a95b9a74c..e40e7712d 100644
--- a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
+++ b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java
@@ -46,7 +46,7 @@ public class SpongeUtil {
return lastPlotPlayer;
}
final String name = player.getName();
- final PlotPlayer pp = UUIDHandler.getPlayers().get(name);
+ final PlotPlayer pp = UUIDHandler.getPlayer(name);
if (pp != null) {
return pp;
}
diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar
index 9d1116e16..97d647d4d 100644
Binary files a/target/PlotSquared-Bukkit.jar and b/target/PlotSquared-Bukkit.jar differ