closes #679
closes #676
This commit is contained in:
Jesse Boyd
2015-10-19 17:27:51 +11:00
parent f509252646
commit fa442f5903
23 changed files with 127 additions and 83 deletions

View File

@ -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<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
if (pp.getAttribute("chatspy")) {
MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " "));
}

View File

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

View File

@ -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) {

View File

@ -42,11 +42,11 @@ public class DebugSaveTest extends SubCommand {
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final ArrayList<Plot> plots = new ArrayList<Plot>();
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;

View File

@ -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<String, PlotPlayer> 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<UUID, UUID> uCMap = new HashMap<UUID, UUID>();
final HashMap<UUID, UUID> uCReverse = new HashMap<UUID, UUID>();
MainUtil.sendConsoleMessage("&7 - Collecting playerdata");
MainUtil.sendMessage(player, "&7 - Collecting playerdata");
final HashSet<String> 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;

View File

@ -104,7 +104,7 @@ public class Purge extends SubCommand {
final Set<PlotId> 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);

View File

@ -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 <world>");
MainUtil.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall <world>");
return false;
}
final Collection<Plot> plots = PS.get().getPlotsInWorld(args[1]);

View File

@ -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<ChunkLoc> 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!");
}
});
}

View File

@ -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 {