Fix for sponge

This commit is contained in:
Jesse Boyd
2015-10-07 17:33:33 +11:00
parent 74a967b535
commit 0c4b703510
66 changed files with 1266 additions and 1198 deletions

View File

@ -80,7 +80,7 @@ public class Buy extends SubCommand {
if (currentPlots > MainUtil.getAllowedPlots(plr)) {
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
}
final Flag flag = FlagManager.getPlotFlag(plot, "price");
final Flag flag = FlagManager.getPlotFlagRaw(plot, "price");
if (flag == null) {
return sendMessage(plr, C.NOT_FOR_SALE);
}

View File

@ -79,7 +79,7 @@ public class Clear extends SubCommand {
MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false;
}
if ((FlagManager.getPlotFlag(plot, "done") != null)
if ((FlagManager.getPlotFlagRaw(plot, "done") != null)
&& (!Permissions.hasPermission(plr, "plots.continue") || (Settings.DONE_COUNTS_TOWARDS_LIMIT && (MainUtil.getAllowedPlots(plr) >= MainUtil.getPlayerPlotCount(plr))))) {
MainUtil.sendMessage(plr, C.DONE_ALREADY_DONE);
return false;
@ -97,10 +97,10 @@ public class Clear extends SubCommand {
public void run() {
plot.removeRunning();
// If the state changes, then mark it as no longer done
if (FlagManager.getPlotFlag(plot, "done") != null) {
if (FlagManager.getPlotFlagRaw(plot, "done") != null) {
FlagManager.removePlotFlag(plot, "done");
}
if (FlagManager.getPlotFlag(plot, "analysis") != null) {
if (FlagManager.getPlotFlagRaw(plot, "analysis") != null) {
FlagManager.removePlotFlag(plot, "analysis");
}
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));

View File

@ -219,7 +219,7 @@ public class DebugExec extends SubCommand {
}
final String flag = args[1];
for (final Plot plot : PS.get().getPlots()) {
if (FlagManager.getPlotFlag(plot, flag) != null) {
if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
FlagManager.removePlotFlag(plot, flag);
}
}

View File

@ -38,7 +38,7 @@ public class Download extends SubCommand {
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
return false;
}
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlag(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
if ((!plot.isOwner(plr.getUUID()) || (Settings.DOWNLOAD_REQUIRES_DONE && (FlagManager.getPlotFlagRaw(plot, "done") != null))) && !Permissions.hasPermission(plr, "plots.admin.command.download")) {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}

View File

@ -20,65 +20,21 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import java.util.Collection;
import java.util.UUID;
import java.util.regex.Matcher;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotInventory;
import com.intellectualcrafters.plot.object.PlotItemStack;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "info", aliases = { "i" }, description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
public class Info extends SubCommand {
public static String getPlayerList(final Collection<UUID> uuids) {
final ArrayList<UUID> l = new ArrayList<>(uuids);
if ((l == null) || (l.size() < 1)) {
return C.NONE.s();
}
final String c = C.PLOT_USER_LIST.s();
final StringBuilder list = new StringBuilder();
for (int x = 0; x < l.size(); x++) {
if ((x + 1) == l.size()) {
list.append(c.replace("%user%", getPlayerName(l.get(x))).replace(",", ""));
} else {
list.append(c.replace("%user%", getPlayerName(l.get(x))));
}
}
return list.toString();
}
public static String getPlayerName(final UUID uuid) {
if (uuid == null) {
return C.UNKNOWN.s();
}
if (uuid.equals(DBFunc.everyone) || uuid.toString().equalsIgnoreCase(DBFunc.everyone.toString())) {
return "everyone";
}
final String name = UUIDHandler.getName(uuid);
if (name == null) {
return "unknown";
}
return name;
}
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
String arg = null;
@ -166,16 +122,26 @@ public class Info extends SubCommand {
return true;
}
String info = C.PLOT_INFO.s();
boolean full;
if (arg != null) {
info = getCaption(arg);
if (info == null) {
MainUtil.sendMessage(player, "&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating");
return false;
}
formatAndSend(info, plot.world, plot, player, true);
full = true;
} else {
formatAndSend(info, plot.world, plot, player, false);
full = false;
}
MainUtil.format(info, plot, player, full, new RunnableVal<String>() {
@Override
public void run() {
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
MainUtil.sendMessage(player, value, false);
MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
}
});
return true;
}
@ -205,71 +171,4 @@ public class Info extends SubCommand {
return null;
}
}
private void formatAndSend(String info, final String world, final Plot plot, final PlotPlayer player, final boolean full) {
final int num = MainUtil.getConnectedPlots(plot).size();
final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s();
final Location top = MainUtil.getPlotTopLocAbs(world, plot.id);
final Location bot = MainUtil.getPlotBottomLocAbs(world, plot.id);
final String biome = BlockManager.manager.getBiome(plot.world, bot.getX() + ((top.getX() - bot.getX()) / 2), bot.getZ() + ((top.getZ() - bot.getZ()) / 2));
final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.getMembers());
final String denied = getPlayerList(plot.getDenied());
final Flag descriptionFlag = FlagManager.getPlotFlag(plot, "description");
final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
final String flags = StringMan.replaceFromMap(
"$2"
+ (StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true).values(), "").length() > 0 ? StringMan.join(FlagManager.getPlotFlags(plot.world, plot.getSettings(), true)
.values(), "$1, $2") : C.NONE.s()), C.replacements);
final boolean build = plot.isAdded(player.getUUID());
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
info = info.replaceAll("%id%", plot.id.toString());
info = info.replaceAll("%alias%", alias);
info = info.replaceAll("%num%", num + "");
info = info.replaceAll("%desc%", description);
info = info.replaceAll("%biome%", biome);
info = info.replaceAll("%owner%", owner);
info = info.replaceAll("%members%", members);
info = info.replaceAll("%trusted%", trusted);
info = info.replaceAll("%helpers%", members);
info = info.replaceAll("%denied%", denied);
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
info = info.replaceAll("%build%", build + "");
info = info.replaceAll("%desc%", "No description set.");
if (info.contains("%rating%")) {
final String newInfo = info;
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
int max = 10;
if ((Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 0)) {
max = 8;
}
String info;
if (full && (Settings.RATING_CATEGORIES != null) && (Settings.RATING_CATEGORIES.size() > 1)) {
String rating = "";
String prefix = "";
final double[] ratings = MainUtil.getAverageRatings(plot);
for (int i = 0; i < ratings.length; i++) {
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
prefix = ",";
}
info = newInfo.replaceAll("%rating%", rating);
} else {
info = newInfo.replaceAll("%rating%", String.format("%.1f", MainUtil.getAverageRating(plot)) + "/" + max);
}
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
MainUtil.sendMessage(player, info, false);
MainUtil.sendMessage(player, C.PLOT_INFO_FOOTER);
}
});
return;
}
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
MainUtil.sendMessage(player, info, false);
}
}

View File

@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import com.intellectualcrafters.plot.PS;
@ -311,15 +310,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
if (help_index != -1) {
displayHelp(player, category, help_index, cmd);
return true;
}
final StringBuilder builder = new StringBuilder(cmd).append(" ");
final Iterator<String> iterator = Arrays.asList(args).iterator();
while (iterator.hasNext()) {
builder.append(iterator.next());
if (iterator.hasNext()) {
builder.append(" ");
}
if (args[0].contains(":")) {
args[0] = args[0].replaceFirst(":", " ");
}
}
String fullCmd = StringMan.join(args, " ");
getInstance().handle(player, cmd + " " + fullCmd);
return true;
}

View File

@ -36,6 +36,7 @@ public class Reload extends SubCommand {
try {
// The following won't affect world generation, as that has to be
// loaded during startup unfortunately.
PS.get().style.load(PS.get().styleFile);
PS.get().config.load(PS.get().configFile);
PS.get().setupConfig();
C.load(PS.get().translationFile);

View File

@ -252,7 +252,7 @@ public class list extends SubCommand {
}
plots = new ArrayList<>();
for (final Plot plot : PS.get().getPlots()) {
final Flag price = FlagManager.getPlotFlag(plot, "price");
final Flag price = FlagManager.getPlotFlagRaw(plot, "price");
if (price != null) {
plots.add(plot);
}
@ -378,9 +378,9 @@ public class list extends SubCommand {
} else {
color = "$1";
}
final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.getTrusted())))).color("$1");
final PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted())))).color("$1");
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.getMembers())))).color("$1");
final PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers())))).color("$1");
String strFlags = StringMan.join(plot.getFlags().values(), ",");
if (strFlags.length() == 0) {