mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java # Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java # Core/src/main/java/com/intellectualcrafters/plot/database/SQLManager.java # Core/src/main/java/com/intellectualcrafters/plot/generator/HybridUtils.java # Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java # Core/src/main/java/com/intellectualcrafters/plot/object/PlotAnalysis.java
This commit is contained in:
@ -76,7 +76,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
final List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
return toDouble(val.get(0), def);
|
||||
}
|
||||
@ -94,7 +94,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
final List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
return toInt(val.get(0), def);
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
final List<?> val = ((List<?>) obj);
|
||||
final List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
return toLong(val.get(0), def);
|
||||
}
|
||||
@ -166,7 +166,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
builder.insert(0, parent.getName());
|
||||
}
|
||||
|
||||
if ((key != null) && (!key.isEmpty())) {
|
||||
if ((key != null) && !key.isEmpty()) {
|
||||
if (builder.length() > 0) {
|
||||
builder.append(separator);
|
||||
}
|
||||
@ -528,7 +528,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
final List<String> result = new ArrayList<>();
|
||||
|
||||
for (final Object object : list) {
|
||||
if ((object instanceof String) || (isPrimitiveWrapper(object))) {
|
||||
if ((object instanceof String) || isPrimitiveWrapper(object)) {
|
||||
result.add(String.valueOf(object));
|
||||
}
|
||||
}
|
||||
@ -819,7 +819,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
for (final Map.Entry<String, Object> entry : sec.map.entrySet()) {
|
||||
output.add(createPath(section, entry.getKey(), this));
|
||||
|
||||
if ((deep) && (entry.getValue() instanceof ConfigurationSection)) {
|
||||
if (deep && (entry.getValue() instanceof ConfigurationSection)) {
|
||||
final ConfigurationSection subsection = (ConfigurationSection) entry.getValue();
|
||||
mapChildrenKeys(output, subsection, deep);
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
boolean readingHeader = true;
|
||||
boolean foundHeader = false;
|
||||
|
||||
for (int i = 0; (i < lines.length) && (readingHeader); i++) {
|
||||
for (int i = 0; (i < lines.length) && readingHeader; i++) {
|
||||
final String line = lines[i];
|
||||
|
||||
if (line.startsWith(COMMENT_PREFIX)) {
|
||||
@ -172,7 +172,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
}
|
||||
|
||||
foundHeader = true;
|
||||
} else if ((foundHeader) && (line.isEmpty())) {
|
||||
} else if (foundHeader && line.isEmpty()) {
|
||||
result.append("\n");
|
||||
} else if (foundHeader) {
|
||||
readingHeader = false;
|
||||
@ -189,11 +189,11 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
if (options().copyHeader()) {
|
||||
final Configuration def = getDefaults();
|
||||
|
||||
if ((def != null) && (def instanceof FileConfiguration)) {
|
||||
if (def != null && def instanceof FileConfiguration) {
|
||||
final FileConfiguration filedefaults = (FileConfiguration) def;
|
||||
final String defaultsHeader = filedefaults.buildHeader();
|
||||
|
||||
if ((defaultsHeader != null) && (!defaultsHeader.isEmpty())) {
|
||||
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
||||
return defaultsHeader;
|
||||
}
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
for (int i = lines.length - 1; i >= 0; i--) {
|
||||
builder.insert(0, "\n");
|
||||
|
||||
if ((startedHeader) || (!lines[i].isEmpty())) {
|
||||
if (startedHeader || !lines[i].isEmpty()) {
|
||||
builder.insert(0, lines[i]);
|
||||
builder.insert(0, COMMENT_PREFIX);
|
||||
startedHeader = true;
|
||||
|
@ -363,7 +363,7 @@ public class JSONObject {
|
||||
}
|
||||
|
||||
public static Writer quote(final String string, final Writer w) throws IOException {
|
||||
if ((string == null) || (string.isEmpty())) {
|
||||
if ((string == null) || string.isEmpty()) {
|
||||
w.write("\"\"");
|
||||
return w;
|
||||
}
|
||||
@ -427,7 +427,7 @@ public class JSONObject {
|
||||
*/
|
||||
public static Object stringToValue(final String string) {
|
||||
Double d;
|
||||
if (string.equals("")) {
|
||||
if (string.isEmpty()) {
|
||||
return string;
|
||||
}
|
||||
if (string.equalsIgnoreCase("true")) {
|
||||
@ -1115,7 +1115,7 @@ public class JSONObject {
|
||||
} else if (name.startsWith("is")) {
|
||||
key = name.substring(2);
|
||||
}
|
||||
if ((!key.isEmpty()) && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) {
|
||||
if (!key.isEmpty() && Character.isUpperCase(key.charAt(0)) && (method.getParameterTypes().length == 0)) {
|
||||
if (key.length() == 1) {
|
||||
key = key.toLowerCase();
|
||||
} else if (!Character.isUpperCase(key.charAt(1))) {
|
||||
|
@ -342,7 +342,7 @@ public class JSONTokener {
|
||||
}
|
||||
back();
|
||||
string = sb.toString().trim();
|
||||
if ("".equals(string)) {
|
||||
if (string != null && string.isEmpty()) {
|
||||
throw syntaxError("Missing value");
|
||||
}
|
||||
return JSONObject.stringToValue(string);
|
||||
|
@ -54,7 +54,6 @@ import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||
import com.plotsquared.listener.WESubscriber;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
@ -165,7 +164,7 @@ public class PS {
|
||||
}
|
||||
TASK = IMP.getTaskManager();
|
||||
if (!C.ENABLED.s().isEmpty()) {
|
||||
log(C.ENABLED.s());
|
||||
log(C.ENABLED);
|
||||
}
|
||||
setupConfigs();
|
||||
translationFile = new File(IMP.getDirectory() + File.separator + "translations" + File.separator + "PlotSquared.use_THIS.yml");
|
||||
@ -1370,10 +1369,10 @@ public class PS {
|
||||
// Conventional plot generator
|
||||
PlotArea plotArea = pg.getNewPlotArea(world, null, null, null);
|
||||
PlotManager plotManager = pg.getNewPlotManager();
|
||||
log(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
|
||||
log(C.PREFIX.s() + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||
log(C.PREFIX.s() + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
log(C.PREFIX.s() + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + pg);
|
||||
log(C.PREFIX + "&3 - plotworld: &7" + plotArea.getClass().getName());
|
||||
log(C.PREFIX + "&3 - manager: &7" + plotManager.getClass().getName());
|
||||
if (!config.contains(path)) {
|
||||
config.createSection(path);
|
||||
worldSection = config.getConfigurationSection(path);
|
||||
@ -1399,7 +1398,7 @@ public class PS {
|
||||
PS.debug("World possibly already loaded: " + world);
|
||||
return;
|
||||
}
|
||||
log(C.PREFIX.s() + "&aDetected world load for '" + world + "'");
|
||||
log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
|
||||
if (type == 2) {
|
||||
Set<PlotCluster> clusters = clusters_tmp != null ? clusters_tmp.get(world) : new HashSet<PlotCluster>();
|
||||
@ -1415,7 +1414,7 @@ public class PS {
|
||||
worldSection.createSection("areas." + fullId);
|
||||
DBFunc.replaceWorld(world, world + ";" + name, pos1, pos2); // NPE
|
||||
|
||||
log(C.PREFIX.s() + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||
log(C.PREFIX + "&3 - " + name + "-" + pos1 + "-" + pos2);
|
||||
GeneratorWrapper<?> areaGen = IMP.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
@ -1428,10 +1427,10 @@ public class PS {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX.s() + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX.s() + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX.s() + "&c | &9manager: &7" + pa);
|
||||
log(C.PREFIX.s() + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&c | &9manager: &7" + pa);
|
||||
log(C.PREFIX + "&cNote: &7Area created for cluster:" + name + " (invalid or old configuration?)");
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
toLoad.add(pa);
|
||||
@ -1453,9 +1452,9 @@ public class PS {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX.s() + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX.s() + "&3 - plotworld: &7" + pa);
|
||||
log(C.PREFIX.s() + "&3 - manager: &7" + pa.getPlotManager());
|
||||
log(C.PREFIX + "&3 - generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&3 - plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&3 - manager: &7" + pa.getPlotManager());
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
addPlotArea(pa);
|
||||
@ -1465,7 +1464,7 @@ public class PS {
|
||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
log(C.PREFIX.s() + "&3 - " + areaId);
|
||||
log(C.PREFIX + "&3 - " + areaId);
|
||||
String[] split = areaId.split("([^\\-]+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)(?:-{1})(-{0,1}\\d+\\;-{0,1}\\d+)");
|
||||
if (split.length != 3) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||
@ -1524,10 +1523,10 @@ public class PS {
|
||||
} catch (final IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(C.PREFIX.s() + "&aDetected area load for '" + world + "'");
|
||||
log(C.PREFIX.s() + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX.s() + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX.s() + "&c | &9manager: &7" + pa.getPlotManager());
|
||||
log(C.PREFIX + "&aDetected area load for '" + world + "'");
|
||||
log(C.PREFIX + "&c | &9generator: &7" + baseGenerator + ">" + areaGen);
|
||||
log(C.PREFIX + "&c | &9plotworld: &7" + pa);
|
||||
log(C.PREFIX + "&c | &9manager: &7" + pa.getPlotManager());
|
||||
areaGen.getPlotGenerator().initialize(pa);
|
||||
areaGen.augment(pa);
|
||||
addPlotArea(pa);
|
||||
@ -1764,7 +1763,7 @@ public class PS {
|
||||
public void setupDatabase() {
|
||||
try {
|
||||
if (Settings.DB.USE_MONGO) {
|
||||
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||
log(C.PREFIX + "MongoDB is not yet implemented");
|
||||
log(C.PREFIX + "&cNo storage type is set!");
|
||||
IMP.disable();
|
||||
return;
|
||||
@ -1786,7 +1785,7 @@ public class PS {
|
||||
this.clusters_tmp = DBFunc.getClusters();
|
||||
}
|
||||
} catch (ClassNotFoundException | SQLException e) {
|
||||
log(C.PREFIX.s() + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
|
||||
if (Settings.DB.USE_MONGO) {
|
||||
log("$4MONGO");
|
||||
} else if (Settings.DB.USE_MYSQL) {
|
||||
@ -2195,7 +2194,7 @@ public class PS {
|
||||
// Misc
|
||||
Settings.DEBUG = config.getBoolean("debug");
|
||||
if (Settings.DEBUG) {
|
||||
log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
log(C.PREFIX + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||
}
|
||||
Settings.CONSOLE_COLOR = config.getBoolean("console.color");
|
||||
if (!config.getBoolean("chat.fancy") || !checkVersion(IMP.getServerVersion(), 1, 8, 0)) {
|
||||
@ -2216,7 +2215,7 @@ public class PS {
|
||||
public void setupConfigs() {
|
||||
final File folder = new File(IMP.getDirectory() + File.separator + "config");
|
||||
if (!folder.exists() && !folder.mkdirs()) {
|
||||
log(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||
}
|
||||
try {
|
||||
styleFile = new File(IMP.getDirectory() + File.separator + "translations" + File.separator + "style.yml");
|
||||
@ -2315,7 +2314,7 @@ public class PS {
|
||||
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
||||
settings.put("API Location", "" + Settings.API_URL);
|
||||
for (final Entry<String, String> setting : settings.entrySet()) {
|
||||
log(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||
log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ aliases = { "biome", "sb", "setb", "b" },
|
||||
category = CommandCategory.APPEARANCE,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Biome extends SetCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean set(final PlotPlayer plr, final Plot plot, final String value) {
|
||||
final int biome = WorldUtil.IMP.getBiomeFromString(value);
|
||||
|
@ -14,6 +14,6 @@ public class Chat extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, final String... args) {
|
||||
return MainCommand.onCommand(player, "plot", new String[] { "toggle", "chat" });
|
||||
return MainCommand.onCommand(player, "plot", "toggle", "chat");
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class Database extends SubCommand {
|
||||
MainUtil.sendMessage(player, "/plot database import [sqlite file] [prefix]");
|
||||
return false;
|
||||
}
|
||||
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), (args[1].endsWith(".db")) ? args[1] : args[1] + ".db");
|
||||
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), args[1].endsWith(".db") ? args[1] : args[1] + ".db");
|
||||
if (!file.exists()) {
|
||||
MainUtil.sendMessage(player, "&6Database does not exist: " + file);
|
||||
return false;
|
||||
|
@ -90,7 +90,7 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_DELETE && !(Permissions.hasPermission(plr, "plots.confirm.bypass"))) {
|
||||
if (Settings.CONFIRM_DELETE && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
|
@ -17,7 +17,8 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class GenerateDocs {
|
||||
public static void main(final String[] args) {
|
||||
|
||||
public static void main(String[] args) {
|
||||
MainCommand.getInstance().addCommand(new WE_Anywhere());
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
final ArrayList<Command<PlotPlayer>> commands = MainCommand.getInstance().getCommands();
|
||||
@ -39,8 +40,8 @@ public class GenerateDocs {
|
||||
printCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public static void printCommand(final Command<PlotPlayer> command) {
|
||||
|
||||
public static void printCommand(Command<PlotPlayer> command) {
|
||||
try {
|
||||
final String clazz = command.getClass().getSimpleName();
|
||||
final String name = command.getCommand();
|
||||
@ -129,8 +130,8 @@ public class GenerateDocs {
|
||||
return new ArrayList<>(usages);
|
||||
}
|
||||
|
||||
public static List<String> getPerms(final String cmd, final List<String> lines) {
|
||||
final HashSet<String> perms = new HashSet<String>();
|
||||
public static List<String> getPerms(String cmd, List<String> lines) {
|
||||
final HashSet<String> perms = new HashSet<>();
|
||||
final Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
|
||||
String last = null;
|
||||
@ -202,13 +203,13 @@ public class GenerateDocs {
|
||||
}
|
||||
return new ArrayList<>(perms);
|
||||
}
|
||||
|
||||
public static String getComments(final List<String> lines) {
|
||||
|
||||
public static String getComments(List<String> lines) {
|
||||
final StringBuilder result = new StringBuilder();
|
||||
for (String line : lines) {
|
||||
line = line.trim();
|
||||
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
||||
line = (line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "")).trim();
|
||||
line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim();
|
||||
result.append(line + "\n");
|
||||
}
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ requiredType = RequiredType.NONE)
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
public void displayComments(final PlotPlayer player, final List<PlotComment> oldComments, int page) {
|
||||
if ((oldComments == null) || (oldComments.isEmpty())) {
|
||||
if ((oldComments == null) || oldComments.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
||||
return;
|
||||
}
|
||||
@ -65,10 +65,10 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append(StringMan.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + "\n");
|
||||
PlotComment c;
|
||||
|
||||
// This might work xD
|
||||
for (int x = (page * 12); x < max; x++) {
|
||||
c = comments[x];
|
||||
for (int x = page * 12; x < max; x++) {
|
||||
PlotComment c = comments[x];
|
||||
String color;
|
||||
if (player.getName().equals(c.senderName)) {
|
||||
color = "&a";
|
||||
@ -152,12 +152,11 @@ public class Inbox extends SubCommand {
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
final List<PlotComment> comments = value;
|
||||
if (index > comments.size()) {
|
||||
if (index > value.size()) {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return;
|
||||
}
|
||||
final PlotComment comment = comments.get(index - 1);
|
||||
final PlotComment comment = value.get(index - 1);
|
||||
inbox.removeComment(plot, comment);
|
||||
plot.getSettings().removeComment(comment);
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
|
||||
@ -199,8 +198,7 @@ public class Inbox extends SubCommand {
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
@Override
|
||||
public void run(List<PlotComment> value) {
|
||||
final List<PlotComment> comments = value;
|
||||
displayComments(player, comments, page);
|
||||
displayComments(player, value, page);
|
||||
}
|
||||
})) {
|
||||
if (plot == null) {
|
||||
|
@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -43,7 +42,7 @@ import java.util.UUID;
|
||||
public class Merge extends SubCommand {
|
||||
public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
|
||||
public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" };
|
||||
|
||||
|
||||
public static String direction(float yaw) {
|
||||
yaw = yaw / 90;
|
||||
final int i = Math.round(yaw);
|
||||
@ -65,7 +64,7 @@ public class Merge extends SubCommand {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocationFull();
|
||||
@ -131,7 +130,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
|
||||
|
||||
}
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
if (args[0].equalsIgnoreCase(values[i]) || args[0].equalsIgnoreCase(aliases[i])) {
|
||||
@ -165,7 +164,7 @@ public class Merge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||
return false;
|
||||
}
|
||||
HashSet<UUID> uuids = adjacent.getOwners();
|
||||
|
@ -1,9 +1,5 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -19,6 +15,10 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "save", aliases = { "backup" }, description = "Save your plot", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, permission = "plots.save")
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@ -73,7 +73,7 @@ public class Save extends SubCommand {
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SAVE_SUCCESS);
|
||||
final List<String> schematics = (List<String>) plr.getMeta("plot_schematics");
|
||||
final List<String> schematics = plr.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public class SetHome extends SetCommand {
|
||||
Plot base = plot.getBasePlot(false);
|
||||
Location bot = base.getBottomAbs();
|
||||
Location loc = plr.getLocationFull();
|
||||
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());;
|
||||
BlockLoc rel = new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(), loc.getYaw(), loc.getPitch());
|
||||
base.setHome(rel);
|
||||
return MainUtil.sendMessage(plr, C.POSITION_SET);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Setup extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
// going through setup
|
||||
SetupObject object = (SetupObject) plr.getMeta("setup");
|
||||
SetupObject object = plr.getMeta("setup");
|
||||
if (object == null) {
|
||||
object = new SetupObject();
|
||||
plr.setMeta("setup", object);
|
||||
|
@ -23,22 +23,32 @@ package com.intellectualcrafters.plot.flag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Flag Manager Utility
|
||||
*
|
||||
*/
|
||||
public class FlagManager {
|
||||
|
||||
|
||||
private final static HashSet<String> reserved = new HashSet<>();
|
||||
|
||||
|
||||
private final static HashSet<AbstractFlag> flags = new HashSet<>();
|
||||
|
||||
|
||||
/**
|
||||
* Reserve a flag so that it cannot be set by players
|
||||
* @param flag
|
||||
@ -46,7 +56,7 @@ public class FlagManager {
|
||||
public static void reserveFlag(final String flag) {
|
||||
reserved.add(flag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get if a flag is reserved
|
||||
* @param flag
|
||||
@ -55,7 +65,7 @@ public class FlagManager {
|
||||
public static boolean isReserved(final String flag) {
|
||||
return reserved.contains(flag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the reserved flags
|
||||
* @return
|
||||
@ -63,7 +73,7 @@ public class FlagManager {
|
||||
public static HashSet<String> getReservedFlags() {
|
||||
return (HashSet<String>) reserved.clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Unreserve a flag
|
||||
* @param flag
|
||||
@ -71,7 +81,7 @@ public class FlagManager {
|
||||
public static void unreserveFlag(final String flag) {
|
||||
reserved.remove(flag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register an AbstractFlag with PlotSquared
|
||||
*
|
||||
@ -82,9 +92,9 @@ public class FlagManager {
|
||||
public static boolean addFlag(final AbstractFlag af) {
|
||||
return addFlag(af, false);
|
||||
}
|
||||
|
||||
|
||||
public static boolean addFlag(final AbstractFlag af, final boolean reserved) {
|
||||
PS.debug(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
||||
PS.debug(C.PREFIX + "&8 - Adding flag: &7" + af);
|
||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override
|
||||
public void run(PlotArea value) {
|
||||
@ -125,7 +135,7 @@ public class FlagManager {
|
||||
}
|
||||
return flag_string.toString();
|
||||
}
|
||||
|
||||
|
||||
public static Flag getSettingFlag(final PlotArea area, final PlotSettings settings, final String id) {
|
||||
Flag flag;
|
||||
if (settings.flags.isEmpty() || (flag = settings.flags.get(id)) == null) {
|
||||
@ -139,7 +149,7 @@ public class FlagManager {
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
||||
final Flag flag = FlagManager.getPlotFlagRaw(plot, key);
|
||||
if (flag == null) {
|
||||
@ -151,7 +161,7 @@ public class FlagManager {
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a flag for a plot (respects flag defaults)
|
||||
* @param plot
|
||||
@ -177,7 +187,7 @@ public class FlagManager {
|
||||
}
|
||||
return getSettingFlag(plot.getArea(), plot.getSettings(), flag);
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPlotFlagTrue(final Plot plot, final String strFlag) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
@ -185,7 +195,7 @@ public class FlagManager {
|
||||
final Flag flag = getPlotFlagRaw(plot, strFlag);
|
||||
return !(flag == null || !((Boolean) flag.getValue()));
|
||||
}
|
||||
|
||||
|
||||
public static boolean isPlotFlagFalse(final Plot plot, final String strFlag) {
|
||||
if (plot.owner == null) {
|
||||
return false;
|
||||
@ -196,7 +206,7 @@ public class FlagManager {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the value of a flag for a plot (ignores flag defaults)
|
||||
* @param plot
|
||||
@ -206,14 +216,14 @@ public class FlagManager {
|
||||
public static Flag getPlotFlagAbs(final Plot plot, final String flag) {
|
||||
return getSettingFlagAbs(plot.getSettings(), flag);
|
||||
}
|
||||
|
||||
|
||||
public static Flag getSettingFlagAbs(final PlotSettings settings, final String flag) {
|
||||
if (settings.flags.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return settings.flags.get(flag);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a flag to a plot
|
||||
* @param origin
|
||||
@ -231,7 +241,7 @@ public class FlagManager {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean addPlotFlagAbs(final Plot plot, final Flag flag) {
|
||||
final boolean result = EventUtil.manager.callFlagAdd(flag, plot);
|
||||
if (!result) {
|
||||
@ -240,14 +250,14 @@ public class FlagManager {
|
||||
plot.getFlags().put(flag.getKey(), flag);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean addClusterFlag(final PlotCluster cluster, final Flag flag) {
|
||||
getSettingFlag(cluster.area, cluster.settings, flag.getKey());
|
||||
cluster.settings.flags.put(flag.getKey(), flag);
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags.values());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plot
|
||||
@ -259,7 +269,7 @@ public class FlagManager {
|
||||
}
|
||||
return getSettingFlags(plot.getArea(), plot.getSettings());
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Flag> getPlotFlags(PlotArea area, final PlotSettings settings, final boolean ignorePluginflags) {
|
||||
final HashMap<String, Flag> flags = new HashMap<>();
|
||||
if (area != null && !area.DEFAULT_FLAGS.isEmpty()) {
|
||||
@ -275,14 +285,14 @@ public class FlagManager {
|
||||
} else {
|
||||
flags.putAll(settings.flags);
|
||||
}
|
||||
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Flag> getSettingFlags(PlotArea area, final PlotSettings settings) {
|
||||
return getPlotFlags(area, settings, false);
|
||||
}
|
||||
|
||||
|
||||
public static boolean removePlotFlag(final Plot plot, final String id) {
|
||||
final Flag flag = plot.getFlags().remove(id);
|
||||
if (flag == null) {
|
||||
@ -297,7 +307,7 @@ public class FlagManager {
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean removeClusterFlag(final PlotCluster cluster, final String id) {
|
||||
final Flag flag = cluster.settings.flags.remove(id);
|
||||
if (flag == null) {
|
||||
@ -311,7 +321,7 @@ public class FlagManager {
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags.values());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static void setPlotFlags(final Plot origin, final Set<Flag> flags) {
|
||||
for (Plot plot : origin.getConnectedPlots()) {
|
||||
if (flags != null && !flags.isEmpty()) {
|
||||
@ -328,7 +338,7 @@ public class FlagManager {
|
||||
DBFunc.setFlags(plot, plot.getFlags().values());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void setClusterFlags(final PlotCluster cluster, final Set<Flag> flags) {
|
||||
if (flags != null && !flags.isEmpty()) {
|
||||
cluster.settings.flags.clear();
|
||||
@ -342,7 +352,7 @@ public class FlagManager {
|
||||
}
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags.values());
|
||||
}
|
||||
|
||||
|
||||
public static Flag[] removeFlag(final Flag[] flags, final String r) {
|
||||
final Flag[] f = new Flag[flags.length - 1];
|
||||
int index = 0;
|
||||
@ -353,7 +363,7 @@ public class FlagManager {
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
public static Set<Flag> removeFlag(final Set<Flag> flags, final String r) {
|
||||
final HashSet<Flag> newflags = new HashSet<>();
|
||||
for (final Flag flag : flags) {
|
||||
@ -363,7 +373,7 @@ public class FlagManager {
|
||||
}
|
||||
return newflags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of registered AbstractFlag objects
|
||||
*
|
||||
@ -372,7 +382,7 @@ public class FlagManager {
|
||||
public static HashSet<AbstractFlag> getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of registered AbstractFlag objects based on player permissions
|
||||
*
|
||||
@ -389,7 +399,7 @@ public class FlagManager {
|
||||
}
|
||||
return returnFlags;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an AbstractFlag by a string Returns null if flag does not exist
|
||||
*
|
||||
@ -405,7 +415,7 @@ public class FlagManager {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an AbstractFlag by a string
|
||||
*
|
||||
@ -420,7 +430,7 @@ public class FlagManager {
|
||||
}
|
||||
return getFlag(string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove a registered AbstractFlag
|
||||
*
|
||||
@ -431,7 +441,7 @@ public class FlagManager {
|
||||
public static boolean removeFlag(final AbstractFlag flag) {
|
||||
return flags.remove(flag);
|
||||
}
|
||||
|
||||
|
||||
public static HashMap<String, Flag> parseFlags(final List<String> flagstrings) {
|
||||
final HashMap<String, Flag> map = new HashMap<>();
|
||||
for (final String key : flagstrings) {
|
||||
|
@ -23,17 +23,16 @@ package com.intellectualcrafters.plot.generator;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
|
||||
public interface GeneratorWrapper<T> {
|
||||
public IndependentPlotGenerator getPlotGenerator();
|
||||
|
||||
public T getPlatformGenerator();
|
||||
|
||||
public void augment(PlotArea area);
|
||||
|
||||
public boolean isFull();
|
||||
|
||||
@Override
|
||||
public String toString();
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj);
|
||||
IndependentPlotGenerator getPlotGenerator();
|
||||
|
||||
T getPlatformGenerator();
|
||||
|
||||
void augment(PlotArea area);
|
||||
|
||||
boolean isFull();
|
||||
|
||||
@Override String toString();
|
||||
|
||||
@Override boolean equals(Object obj);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -177,7 +176,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
PS.debug("&c - road schematics are disabled for this world.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isCompatible(PlotArea plotworld) {
|
||||
if (!(plotworld instanceof SquarePlotWorld)) {
|
||||
@ -250,7 +249,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
if (schem1 == null || schem2 == null || ROAD_WIDTH == 0) {
|
||||
PS.debug(C.PREFIX.s() + "&3 - schematic: &7false");
|
||||
PS.debug(C.PREFIX + "&3 - schematic: &7false");
|
||||
return;
|
||||
}
|
||||
ROAD_SCHEMATIC_ENABLED = true;
|
||||
@ -298,7 +297,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addOverlayBlock(short x, final short y, short z, final short id, byte data, final boolean rotate) {
|
||||
if (z < 0) {
|
||||
z += SIZE;
|
||||
|
@ -41,17 +41,17 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
|
||||
@Override
|
||||
public Location getPlotTopLocAbs(final PlotArea plotworld, final PlotId plotid) {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - ((int) Math.floor(dpw.ROAD_WIDTH / 2)) - 1;
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - (int) Math.floor(dpw.ROAD_WIDTH / 2) - 1;
|
||||
return new Location(plotworld.worldname, x, Math.min(plotworld.MAX_BUILD_HEIGHT, 255), z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotId getPlotIdAbs(final PlotArea plotworld, int x, final int y, int z) {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
if (dpw.ROAD_OFFSET_X != 0) {
|
||||
x -= dpw.ROAD_OFFSET_X;
|
||||
}
|
||||
@ -73,20 +73,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
}
|
||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||
int idx;
|
||||
int idz;
|
||||
if (x < 0) {
|
||||
idx = (x / size);
|
||||
idx = x / size;
|
||||
x = size + (x % size);
|
||||
} else {
|
||||
idx = (x / size) + 1;
|
||||
x = (x % size);
|
||||
x = x % size;
|
||||
}
|
||||
int idz;
|
||||
if (z < 0) {
|
||||
idz = (z / size);
|
||||
idz = z / size;
|
||||
z = size + (z % size);
|
||||
} else {
|
||||
idz = (z / size) + 1;
|
||||
z = (z % size);
|
||||
z = z % size;
|
||||
}
|
||||
return ((z <= pathWidthLower) || (z > end) || (x <= pathWidthLower) || (x > end)) ? null : new PlotId(idx, idz);
|
||||
}
|
||||
@ -94,7 +94,7 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
@Override
|
||||
public PlotId getPlotId(final PlotArea plotworld, int x, final int y, int z) {
|
||||
try {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
if (plotworld == null) {
|
||||
return null;
|
||||
}
|
||||
@ -117,23 +117,23 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
int dx;
|
||||
int rx;
|
||||
if (x < 0) {
|
||||
dx = (x / size);
|
||||
dx = x / size;
|
||||
rx = size + (x % size);
|
||||
} else {
|
||||
dx = (x / size) + 1;
|
||||
rx = (x % size);
|
||||
rx = x % size;
|
||||
}
|
||||
int dz;
|
||||
int rz;
|
||||
if (z < 0) {
|
||||
dz = (z / size);
|
||||
dz = z / size;
|
||||
rz = size + (z % size);
|
||||
} else {
|
||||
dz = (z / size) + 1;
|
||||
rz = (z % size);
|
||||
rz = z % size;
|
||||
}
|
||||
PlotId id = new PlotId(dx, dz);
|
||||
boolean[] merged = new boolean[] { (rz <= pathWidthLower), (rx > end), (rz > end), (rx <= pathWidthLower) };
|
||||
boolean[] merged = new boolean[]{rz <= pathWidthLower, rx > end, rz > end, rx <= pathWidthLower};
|
||||
int hash = MainUtil.hash(merged);
|
||||
// Not merged, and no need to check if it is
|
||||
if (hash == 0) {
|
||||
@ -182,11 +182,11 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
||||
*/
|
||||
@Override
|
||||
public Location getPlotBottomLocAbs(final PlotArea plotworld, final PlotId plotid) {
|
||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||
final SquarePlotWorld dpw = (SquarePlotWorld) plotworld;
|
||||
final int px = plotid.x;
|
||||
final int pz = plotid.y;
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - ((int) Math.floor(dpw.ROAD_WIDTH / 2));
|
||||
final int x = (dpw.ROAD_OFFSET_X + (px * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
final int z = (dpw.ROAD_OFFSET_Z + (pz * (dpw.ROAD_WIDTH + dpw.PLOT_WIDTH))) - dpw.PLOT_WIDTH - (int) Math.floor(dpw.ROAD_WIDTH / 2);
|
||||
return new Location(plotworld.worldname, x, plotworld.MIN_BUILD_HEIGHT, z);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.intellectualcrafters.plot.object.comment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InboxOwner extends CommentInbox {
|
||||
|
||||
@Override
|
||||
@ -17,10 +17,10 @@ public class InboxOwner extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,9 +28,10 @@ public class InboxOwner extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write."
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.write."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,9 +39,10 @@ public class InboxOwner extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify."
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +61,7 @@ public class InboxOwner extends CommentInbox {
|
||||
public void run(List<PlotComment> value) {
|
||||
whenDone.value = value;
|
||||
if (value != null) {
|
||||
for (final PlotComment comment : (ArrayList<PlotComment>) value) {
|
||||
for (final PlotComment comment : value) {
|
||||
plot.getSettings().addComment(comment);
|
||||
}
|
||||
} else {
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.intellectualcrafters.plot.object.comment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -10,6 +7,9 @@ import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InboxPublic extends CommentInbox {
|
||||
|
||||
@Override
|
||||
@ -17,10 +17,10 @@ public class InboxPublic extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
return Permissions.hasPermission(player, "plots.inbox.read." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.read."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -28,9 +28,10 @@ public class InboxPublic extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.write."
|
||||
return Permissions.hasPermission(player, "plots.inbox.write." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.write."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -38,9 +39,10 @@ public class InboxPublic extends CommentInbox {
|
||||
if (plot == null) {
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString());
|
||||
}
|
||||
return (Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.inbox.modify."
|
||||
return Permissions.hasPermission(player, "plots.inbox.modify." + toString()) && (plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, "plots.inbox.modify."
|
||||
+ toString()
|
||||
+ ".other")));
|
||||
+ ".other"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -59,7 +61,7 @@ public class InboxPublic extends CommentInbox {
|
||||
public void run(List<PlotComment> value) {
|
||||
whenDone.value = value;
|
||||
if (value != null) {
|
||||
for (final PlotComment comment : (ArrayList<PlotComment>) value) {
|
||||
for (final PlotComment comment : value) {
|
||||
plot.getSettings().addComment(comment);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
public class CmdConfirm {
|
||||
public static CmdInstance getPending(final PlotPlayer player) {
|
||||
return player.<CmdInstance>getMeta("cmdConfirm");
|
||||
return player.getMeta("cmdConfirm");
|
||||
}
|
||||
|
||||
public static void removePending(final PlotPlayer player) {
|
||||
|
@ -54,20 +54,22 @@ public class ExpireManager {
|
||||
public void confirmExpiry(final PlotPlayer pp) {
|
||||
if (Settings.AUTO_CLEAR_CONFIRMATION && plotsToDelete != null && !plotsToDelete.isEmpty() && pp.hasPermission("plots.admin.command.autoclear")) {
|
||||
final int num = plotsToDelete.size();
|
||||
Iterator<Plot> iter = plotsToDelete.iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Plot current = iter.next();
|
||||
for (final Plot current : plotsToDelete) {
|
||||
if (isExpired(current)) {
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pp.teleport(current.getCenter());
|
||||
PlotMessage msg = new PlotMessage()
|
||||
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired").tooltip("/plot list expired")
|
||||
.text(num + " " + (num > 1 ? "plots are" : "plot is") + " expired:").color("$1").command("/plot list expired")
|
||||
.tooltip("/plot list expired")
|
||||
//.text("\n - ").color("$3").text("Delete all (/plot delete expired)").color("$2").command("/plot delete expired")
|
||||
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete").tooltip("/plot delete")
|
||||
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d").tooltip("/plot set keep 1d")
|
||||
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true").tooltip("/plot set keep true");
|
||||
.text("\n - ").color("$3").text("Delete this (/plot delete)").color("$2").command("/plot delete")
|
||||
.tooltip("/plot delete")
|
||||
.text("\n - ").color("$3").text("Remind later (/plot set keep 1d)").color("$2").command("/plot set keep 1d")
|
||||
.tooltip("/plot set keep 1d")
|
||||
.text("\n - ").color("$3").text("Keep this (/plot set keep true)").color("$2").command("/plot set keep true")
|
||||
.tooltip("/plot set keep true");
|
||||
msg.send(pp);
|
||||
}
|
||||
});
|
||||
@ -75,7 +77,6 @@ public class ExpireManager {
|
||||
}
|
||||
}
|
||||
plotsToDelete.clear();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +248,7 @@ public class ExpireManager {
|
||||
return false;
|
||||
}
|
||||
final long compared = System.currentTimeMillis() - last;
|
||||
if (compared >= (TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS))) {
|
||||
if (compared >= TimeUnit.DAYS.toMillis(Settings.AUTO_CLEAR_DAYS)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -266,7 +267,7 @@ public class ExpireManager {
|
||||
return false;
|
||||
}
|
||||
} else if (value instanceof Long) {
|
||||
if (((Long) value) > System.currentTimeMillis()) {
|
||||
if ((Long) value > System.currentTimeMillis()) {
|
||||
return false;
|
||||
}
|
||||
} else { // Invalid?
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* The Permissions class handles checking user permissions.<br>
|
||||
* - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)<br>
|
||||
@ -34,7 +34,7 @@ public class Permissions {
|
||||
if (!Settings.PERMISSION_CACHING) {
|
||||
return hasPermission((CommandCaller) player, perm);
|
||||
}
|
||||
HashMap<String, Boolean> map = (HashMap<String, Boolean>) player.getMeta("perm");
|
||||
HashMap<String, Boolean> map = player.getMeta("perm");
|
||||
if (map != null) {
|
||||
Boolean result = map.get(perm);
|
||||
if (result != null) {
|
||||
@ -63,7 +63,7 @@ public class Permissions {
|
||||
final String[] nodes = perm.split("\\.");
|
||||
final StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i <= (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ("."));
|
||||
n.append(nodes[i] + ".");
|
||||
if (!perm.equals(n + C.PERMISSION_STAR.s())) {
|
||||
if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
|
||||
return true;
|
||||
@ -106,7 +106,7 @@ public class Permissions {
|
||||
final String[] nodes = stub.split("\\.");
|
||||
final StringBuilder n = new StringBuilder();
|
||||
for (int i = 0; i < (nodes.length - 1); i++) {
|
||||
n.append(nodes[i] + ("."));
|
||||
n.append(nodes[i] + ".");
|
||||
if (!stub.equals(n + C.PERMISSION_STAR.s())) {
|
||||
if (player.hasPermission(n + C.PERMISSION_STAR.s())) {
|
||||
return Integer.MAX_VALUE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
public enum PlotGamemode {
|
||||
ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR;
|
||||
ADVENTURE, SURVIVAL, CREATIVE, SPECTATOR
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
package com.intellectualcrafters.plot.util;
|
||||
|
||||
public enum PlotWeather {
|
||||
RAIN, CLEAR, RESET;
|
||||
RAIN, CLEAR, RESET
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@ -166,7 +167,8 @@ public abstract class SchematicHandler {
|
||||
final int HEIGHT = demensions.getY();
|
||||
// Validate dimensions
|
||||
RegionWrapper region = plot.getLargestRegion();
|
||||
if ((((region.maxX - region.minX + x_offset) + 1) < WIDTH) || (((region.maxZ - region.minZ + z_offset) + 1) < LENGTH) || (HEIGHT > 256)) {
|
||||
if (((region.maxX - region.minX + x_offset + 1) < WIDTH) || ((region.maxZ - region.minZ + z_offset + 1) < LENGTH) || (HEIGHT
|
||||
> 256)) {
|
||||
PS.debug("Schematic is too large");
|
||||
PS.debug("(" + WIDTH + "," + LENGTH + "," + HEIGHT + ") is bigger than (" + (region.maxX - region.minX) + "," + (region.maxZ - region.minZ) + ",256)");
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -451,7 +453,7 @@ public abstract class SchematicHandler {
|
||||
final List<Tag> blockStates = ListTag.class.cast(tagMap.get("TileEntities")).getValue();
|
||||
for (final Tag stateTag : blockStates) {
|
||||
try {
|
||||
final CompoundTag ct = ((CompoundTag) stateTag);
|
||||
final CompoundTag ct = (CompoundTag) stateTag;
|
||||
final Map<String, Tag> state = ct.getValue();
|
||||
final short x = IntTag.class.cast(state.get("x")).getValue().shortValue();
|
||||
final short y = IntTag.class.cast(state.get("y")).getValue().shortValue();
|
||||
@ -782,15 +784,15 @@ public abstract class SchematicHandler {
|
||||
int dz = schematicDimension.getZ();
|
||||
|
||||
for (int y = y1; y <= y2; y++) {
|
||||
int yy = y >= 0 ? (y < dy ? y : y - dy) : y + dy;
|
||||
int yy = y >= 0 ? y < dy ? y : y - dy : y + dy;
|
||||
int i1 = yy * dx * dz;
|
||||
int j1 = (y - y1) * width * length;
|
||||
for (int z = z1; z <= z2; z++) {
|
||||
int zz = z >= 0 ? (z < dz ? z : z - dz) : z + dz;
|
||||
int zz = z >= 0 ? z < dz ? z : z - dz : z + dz;
|
||||
int i2 = i1 + zz * dx;
|
||||
int j2 = j1 + (z - z1) * width;
|
||||
for (int x = x1; x <= x2; x++) {
|
||||
int xx = x >= 0 ? (x < dx ? x : x - dx) : x + dx;
|
||||
int xx = x >= 0 ? x < dx ? x : x - dx : x + dx;
|
||||
int i3 = i2 + xx;
|
||||
int j3 = j2 + (x - x1);
|
||||
ids2[j3] = ids[i3];
|
||||
|
@ -179,7 +179,7 @@ public class SetQueue {
|
||||
return false;
|
||||
}
|
||||
final ChunkWrapper other = (ChunkWrapper) obj;
|
||||
return ((x == other.x) && (z == other.z) && (StringMan.isEqual(world, other.world)));
|
||||
return (x == other.x) && (z == other.z) && StringMan.isEqual(world, other.world);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -29,19 +28,19 @@ public abstract class UUIDHandlerImplementation {
|
||||
public UUIDWrapper uuidWrapper = null;
|
||||
public HashSet<UUID> unknown = new HashSet<>();
|
||||
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
|
||||
|
||||
public UUIDHandlerImplementation(final UUIDWrapper wrapper) {
|
||||
uuidWrapper = wrapper;
|
||||
players = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* If the UUID is not found, some commands can request to fetch the UUID when possible
|
||||
* @param name
|
||||
* @param ifFetch
|
||||
*/
|
||||
public abstract void fetchUUID(final String name, final RunnableVal<UUID> ifFetch);
|
||||
|
||||
|
||||
/**
|
||||
* Start UUID caching (this should be an async task)
|
||||
* Recommended to override this is you want to cache offline players
|
||||
@ -52,20 +51,20 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return CACHED = true;
|
||||
}
|
||||
|
||||
|
||||
public UUIDWrapper getUUIDWrapper() {
|
||||
return uuidWrapper;
|
||||
}
|
||||
|
||||
|
||||
public void setUUIDWrapper(final UUIDWrapper wrapper) {
|
||||
uuidWrapper = wrapper;
|
||||
}
|
||||
|
||||
|
||||
public void rename(final UUID uuid, final StringWrapper name) {
|
||||
uuidMap.inverse().remove(uuid);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
|
||||
|
||||
public void add(final BiMap<StringWrapper, UUID> toAdd) {
|
||||
if (uuidMap.isEmpty()) {
|
||||
uuidMap = toAdd;
|
||||
@ -86,9 +85,9 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
PS.debug(C.PREFIX.s() + "&6Cached a total of: " + uuidMap.size() + " UUIDs");
|
||||
PS.debug(C.PREFIX + "&6Cached a total of: " + uuidMap.size() + " UUIDs");
|
||||
}
|
||||
|
||||
|
||||
public boolean add(final StringWrapper name, final UUID uuid) {
|
||||
if ((uuid == null)) {
|
||||
return false;
|
||||
@ -102,7 +101,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lazy UUID conversion:
|
||||
* - Useful if the person misconfigured the database, or settings before PlotMe conversion
|
||||
@ -165,25 +164,25 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean uuidExists(final UUID uuid) {
|
||||
return uuidMap.containsValue(uuid);
|
||||
}
|
||||
|
||||
|
||||
public BiMap<StringWrapper, UUID> getUUIDMap() {
|
||||
return uuidMap;
|
||||
}
|
||||
|
||||
|
||||
public boolean nameExists(final StringWrapper wrapper) {
|
||||
return uuidMap.containsKey(wrapper);
|
||||
}
|
||||
|
||||
|
||||
public void handleShutdown() {
|
||||
players.clear();
|
||||
uuidMap.clear();
|
||||
uuidWrapper = null;
|
||||
}
|
||||
|
||||
|
||||
public String getName(final UUID uuid) {
|
||||
if (uuid == null) {
|
||||
return null;
|
||||
@ -200,7 +199,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public UUID getUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||
if ((name == null) || (name.isEmpty())) {
|
||||
return null;
|
||||
@ -228,15 +227,15 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public UUID getUUID(final PlotPlayer player) {
|
||||
return uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
|
||||
public UUID getUUID(final OfflinePlotPlayer player) {
|
||||
return uuidWrapper.getUUID(player);
|
||||
}
|
||||
|
||||
|
||||
public PlotPlayer getPlayer(final UUID uuid) {
|
||||
String name = getName(uuid);
|
||||
if (name != null) {
|
||||
@ -244,13 +243,13 @@ public abstract class UUIDHandlerImplementation {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public PlotPlayer getPlayer(final String name) {
|
||||
return players.get(name);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, PlotPlayer> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,36 +1,35 @@
|
||||
package com.intellectualcrafters.plot.util.helpmenu;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class HelpPage {
|
||||
|
||||
|
||||
private final List<HelpObject> helpObjects;
|
||||
private final String _header;
|
||||
|
||||
|
||||
public HelpPage(final CommandCategory category, final int currentPage, final int maxPages) {
|
||||
helpObjects = new ArrayList<>();
|
||||
_header = C.HELP_PAGE_HEADER.s().replace("%category%", category == null ? "ALL" : category.toString()).replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + "");
|
||||
}
|
||||
|
||||
|
||||
public void render(final PlotPlayer player) {
|
||||
if (helpObjects.size() < 1) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0)");
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.HELP_HEADER.s(), false);
|
||||
MainUtil.sendMessage(player, C.HELP_HEADER, false);
|
||||
MainUtil.sendMessage(player, _header, false);
|
||||
for (final HelpObject object : helpObjects) {
|
||||
MainUtil.sendMessage(player, object.toString(), false);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.HELP_FOOTER.s(), false);
|
||||
MainUtil.sendMessage(player, C.HELP_FOOTER, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void addHelpItem(final HelpObject object) {
|
||||
helpObjects.add(object);
|
||||
}
|
||||
|
@ -85,10 +85,14 @@ public class CommandManager<T extends CommandCaller> {
|
||||
}
|
||||
|
||||
public int handle(final T plr, String input) {
|
||||
if ((initialCharacter != null) && !input.startsWith(initialCharacter + "")) {
|
||||
if (initialCharacter != null && !input.startsWith(initialCharacter + "")) {
|
||||
return CommandHandlingOutput.NOT_COMMAND;
|
||||
}
|
||||
input = initialCharacter == null ? input : input.substring(1);
|
||||
if (initialCharacter == null) {
|
||||
input = input;
|
||||
} else {
|
||||
input = input.substring(1);
|
||||
}
|
||||
final String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
final String command = parts[0].toLowerCase();
|
||||
|
@ -29,8 +29,17 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.CommentManager;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -40,7 +49,7 @@ import java.util.UUID;
|
||||
|
||||
*/
|
||||
public class PlotListener {
|
||||
|
||||
|
||||
public static boolean plotEntry(final PlotPlayer pp, final Plot plot) {
|
||||
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||
return false;
|
||||
@ -59,7 +68,7 @@ public class PlotListener {
|
||||
final int size = flags.size();
|
||||
boolean titles = Settings.TITLES;
|
||||
final String greeting;
|
||||
|
||||
|
||||
if (size != 0) {
|
||||
final Flag titleFlag = flags.get("titles");
|
||||
if (titleFlag != null) {
|
||||
@ -115,7 +124,7 @@ public class PlotListener {
|
||||
if (weatherFlag != null) {
|
||||
pp.setWeather((PlotWeather) weatherFlag.getValue());
|
||||
}
|
||||
|
||||
|
||||
final Flag musicFlag = flags.get("music");
|
||||
if (musicFlag != null) {
|
||||
final Integer id = (Integer) musicFlag.getValue();
|
||||
@ -174,7 +183,7 @@ public class PlotListener {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public static boolean plotExit(final PlotPlayer pp, final Plot plot) {
|
||||
pp.deleteMeta("lastplot");
|
||||
EventUtil.manager.callLeave(pp, plot);
|
||||
|
Reference in New Issue
Block a user