mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Fixes #396
This commit is contained in:
parent
9182013434
commit
1392611a06
@ -20,26 +20,21 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.InfoInventory;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
@ -50,6 +45,37 @@ public class Info extends SubCommand {
|
|||||||
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false);
|
super(Command.INFO, "Display plot info", "info", CommandCategory.INFO, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getPlayerList(final Collection<UUID> uuids) {
|
||||||
|
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 "unknown";
|
||||||
|
}
|
||||||
|
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
|
@Override
|
||||||
public boolean execute(final PlotPlayer player, String... args) {
|
public boolean execute(final PlotPlayer player, String... args) {
|
||||||
String arg = null;
|
String arg = null;
|
||||||
@ -173,15 +199,11 @@ public class Info extends SubCommand {
|
|||||||
final String members = getPlayerList(plot.members);
|
final String members = getPlayerList(plot.members);
|
||||||
final String denied = getPlayerList(plot.denied);
|
final String denied = getPlayerList(plot.denied);
|
||||||
|
|
||||||
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : C.NONE.s());
|
||||||
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
||||||
String owner = "none";
|
|
||||||
if (plot.owner == null) {
|
String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
|
||||||
owner = "unowned";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
owner = getPlayerList(plot.getOwners());
|
|
||||||
}
|
|
||||||
info = info.replaceAll("%alias%", alias);
|
info = info.replaceAll("%alias%", alias);
|
||||||
info = info.replaceAll("%id%", id.toString());
|
info = info.replaceAll("%id%", id.toString());
|
||||||
info = info.replaceAll("%id2%", id2.toString());
|
info = info.replaceAll("%id2%", id2.toString());
|
||||||
@ -227,35 +249,4 @@ public class Info extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
|
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER);
|
||||||
MainUtil.sendMessage(player, info, false);
|
MainUtil.sendMessage(player, info, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPlayerList(final Collection<UUID> uuids) {
|
|
||||||
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 "unknown";
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user