mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Merge branch 'breaking' into paperstuff
# Conflicts: # Bukkit/build.gradle # Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java # Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java # Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/object/BukkitPlayer.java # Core/src/main/java/com/github/intellectualsites/plotsquared/commands/Command.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Add.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Buy.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Clear.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/DebugExec.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Grant.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Help.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/MainCommand.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Near.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Relight.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/SubCommand.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Trust.java # Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Visit.java
This commit is contained in:
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.api;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -37,7 +37,7 @@ import java.util.UUID;
|
||||
@SuppressWarnings({"unused", "WeakerAccess"}) @NoArgsConstructor public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Get all plots.
|
||||
* Gets all plots.
|
||||
*
|
||||
* @return all plots
|
||||
* @see PlotSquared#getPlots()
|
||||
@ -47,7 +47,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all plots for a player.
|
||||
* Gets all plots for a player.
|
||||
*
|
||||
* @param player Player, whose plots to search for
|
||||
* @return all plots that a player owns
|
||||
@ -57,7 +57,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plot world.
|
||||
* Adds a plot world.
|
||||
*
|
||||
* @param plotArea Plot World Object
|
||||
* @see PlotSquared#addPlotArea(PlotArea)
|
||||
@ -67,17 +67,17 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the PlotSquared configurations file.
|
||||
* Gets the configuration file for this plugin.
|
||||
*
|
||||
* @return main configuration
|
||||
* @see PlotSquared#config
|
||||
* @return the configuration file for PlotSquared
|
||||
* =
|
||||
*/
|
||||
public YamlConfiguration getConfig() {
|
||||
return PlotSquared.get().config;
|
||||
return PlotSquared.get().getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared storage file.
|
||||
* Gets the PlotSquared storage file.
|
||||
*
|
||||
* @return storage configuration
|
||||
* @see PlotSquared#storage
|
||||
@ -86,16 +86,6 @@ import java.util.UUID;
|
||||
return PlotSquared.get().storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main class for this plugin. Only use this if you really need it.
|
||||
*
|
||||
* @return PlotSquared PlotSquared Main Class
|
||||
* @see PlotSquared
|
||||
*/
|
||||
public PlotSquared getMain() {
|
||||
return PlotSquared.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChunkManager class contains several useful methods.
|
||||
* <ul>
|
||||
@ -114,7 +104,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the block/biome set queue
|
||||
* Gets the block/biome set queue
|
||||
*
|
||||
* @return GlobalBlockQueue.IMP
|
||||
*/
|
||||
@ -145,7 +135,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of PlotAreas in the world.
|
||||
* Gets a list of PlotAreas in the world.
|
||||
*
|
||||
* @param world The world to check for plot areas
|
||||
* @return A set of PlotAreas
|
||||
@ -161,20 +151,20 @@ import java.util.UUID;
|
||||
* Send a message to the console. The message supports color codes.
|
||||
*
|
||||
* @param message the message
|
||||
* @see MainUtil#sendConsoleMessage(C, String...)
|
||||
* @see MainUtil#sendConsoleMessage(Captions, String...)
|
||||
*/
|
||||
public void sendConsoleMessage(String message) {
|
||||
PlotSquared.log(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the console.
|
||||
* Sends a message to the console.
|
||||
*
|
||||
* @param caption the message
|
||||
* @see #sendConsoleMessage(String)
|
||||
* @see C
|
||||
* @see Captions
|
||||
*/
|
||||
public void sendConsoleMessage(C caption) {
|
||||
public void sendConsoleMessage(Captions caption) {
|
||||
sendConsoleMessage(caption.s());
|
||||
}
|
||||
|
||||
@ -198,7 +188,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a UUID.
|
||||
* Gets the PlotPlayer for a UUID.
|
||||
*
|
||||
* <p><i>Please note that PlotSquared can be configured to provide
|
||||
* different UUIDs than bukkit</i>
|
||||
@ -212,7 +202,7 @@ import java.util.UUID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a username.
|
||||
* Gets the PlotPlayer for a username.
|
||||
*
|
||||
* @param player the player to wrap
|
||||
* @return a {@code PlotPlayer}
|
||||
|
@ -5,12 +5,16 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@ -102,7 +106,7 @@ public abstract class Command {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<Command> getCommands(PlotPlayer player) {
|
||||
public List<Command> getCommands(CommandCaller player) {
|
||||
List<Command> commands = new ArrayList<>();
|
||||
for (Command cmd : this.allCommands) {
|
||||
if (cmd.canExecute(player, false)) {
|
||||
@ -112,15 +116,10 @@ public abstract class Command {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
||||
public List<Command> getCommands(CommandCategory category, CommandCaller player) {
|
||||
List<Command> commands = getCommands(player);
|
||||
if (cat != null) {
|
||||
Iterator<Command> iterator = commands.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
if (iterator.next().category != cat) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if (category != null) {
|
||||
commands.removeIf(command -> command.category != category);
|
||||
}
|
||||
return commands;
|
||||
}
|
||||
@ -129,7 +128,7 @@ public abstract class Command {
|
||||
return this.allCommands;
|
||||
}
|
||||
|
||||
public boolean hasConfirmation(PlotPlayer player) {
|
||||
public boolean hasConfirmation(CommandCaller player) {
|
||||
return this.confirmation && !player.hasPermission(getPermission() + ".confirm.bypass");
|
||||
}
|
||||
|
||||
@ -158,10 +157,10 @@ public abstract class Command {
|
||||
this.perm = declaration.permission();
|
||||
this.required = declaration.requiredType();
|
||||
this.category = declaration.category();
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
List<String> aliasOptions = new ArrayList<>();
|
||||
aliasOptions.add(this.id);
|
||||
aliasOptions.addAll(Arrays.asList(declaration.aliases()));
|
||||
HashMap<String, Object> options = new HashMap<>();
|
||||
options.put("aliases", aliasOptions);
|
||||
options.put("description", declaration.description());
|
||||
options.put("usage", declaration.usage());
|
||||
@ -245,18 +244,19 @@ public abstract class Command {
|
||||
if (page < totalPages && page > 0) { // Back | Next
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ")
|
||||
.color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
.text(Captions.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1")
|
||||
.command(baseCommand + " " + (0 + 2)).text(C.CLICKABLE.s()).color("$2")
|
||||
.command(baseCommand + " " + (0 + 2)).text(Captions.CLICKABLE.s()).color("$2")
|
||||
.send(player);
|
||||
return;
|
||||
}
|
||||
if (page == totalPages && totalPages != 0) { // Back
|
||||
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ")
|
||||
.color("$3").text("->").color("$3").text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
.color("$3").text("->").color("$3").text(Captions.CLICKABLE.s()).color("$2")
|
||||
.send(player);
|
||||
}
|
||||
}
|
||||
|
||||
@ -274,7 +274,7 @@ public abstract class Command {
|
||||
if (this.parent == null) {
|
||||
MainCommand.getInstance().help.displayHelp(player, null, 0);
|
||||
} else {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
@ -286,7 +286,7 @@ public abstract class Command {
|
||||
Command cmd = getCommand(args[0]);
|
||||
if (cmd == null) {
|
||||
if (this.parent != null) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
// Help command
|
||||
@ -301,11 +301,11 @@ public abstract class Command {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
// Command recommendation
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_SUBCOMMAND);
|
||||
List<Command> commands = getCommands(player);
|
||||
if (commands.isEmpty()) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.DID_YOU_MEAN, MainCommand.getInstance().help.getUsage());
|
||||
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN,
|
||||
MainCommand.getInstance().help.getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
HashSet<String> setArgs = new HashSet<>(args.length);
|
||||
@ -323,7 +323,7 @@ public abstract class Command {
|
||||
if (cmd == null) {
|
||||
cmd = new StringComparison<>(args[0], this.allCommands).getMatchObject();
|
||||
}
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN, cmd.getUsage());
|
||||
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN, cmd.getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
String[] newArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
@ -338,7 +338,7 @@ public abstract class Command {
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
|
||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
||||
public boolean checkArgs(CommandCaller player, String[] args) {
|
||||
Argument<?>[] reqArgs = getRequiredArguments();
|
||||
if (reqArgs != null && reqArgs.length > 0) {
|
||||
boolean failed = args.length < reqArgs.length;
|
||||
@ -355,7 +355,7 @@ public abstract class Command {
|
||||
failed = failed || reqArgs[i].parse(args[i]) == null;
|
||||
}
|
||||
if (failed) {
|
||||
C.COMMAND_SYNTAX.send(player, StringMan.join(fullSplit, " "));
|
||||
Captions.COMMAND_SYNTAX.send(player, StringMan.join(fullSplit, " "));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -363,14 +363,10 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public int getMatch(String[] args, Command cmd) {
|
||||
int count = 0;
|
||||
String perm = cmd.getPermission();
|
||||
HashSet<String> desc = new HashSet<>();
|
||||
for (String alias : cmd.getAliases()) {
|
||||
if (alias.startsWith(args[0])) {
|
||||
count += 5;
|
||||
}
|
||||
}
|
||||
int count = cmd.getAliases().stream().filter(alias -> alias.startsWith(args[0]))
|
||||
.mapToInt(alias -> 5).sum();
|
||||
Collections.addAll(desc, cmd.getDescription().split(" "));
|
||||
for (String arg : args) {
|
||||
if (perm.startsWith(arg)) {
|
||||
@ -435,18 +431,19 @@ public abstract class Command {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean canExecute(PlotPlayer player, boolean message) {
|
||||
public boolean canExecute(CommandCaller player, boolean message) {
|
||||
if (player == null) {
|
||||
return true;
|
||||
}
|
||||
if (!this.required.allows(player)) {
|
||||
if (message) {
|
||||
MainUtil.sendMessage(player,
|
||||
this.required == RequiredType.PLAYER ? C.IS_CONSOLE : C.NOT_CONSOLE);
|
||||
MainUtil.sendMessage(player, this.required == RequiredType.PLAYER ?
|
||||
Captions.IS_CONSOLE :
|
||||
Captions.NOT_CONSOLE);
|
||||
}
|
||||
} else if (!Permissions.hasPermission(player, getPermission())) {
|
||||
if (message) {
|
||||
C.NO_PERMISSION.send(player, getPermission());
|
||||
Captions.NO_PERMISSION.send(player, getPermission());
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
@ -460,7 +457,6 @@ public abstract class Command {
|
||||
}
|
||||
|
||||
public String getCommandString() {
|
||||
String base;
|
||||
if (this.parent == null) {
|
||||
return "/" + toString();
|
||||
} else {
|
||||
@ -563,13 +559,13 @@ public abstract class Command {
|
||||
return this.getFullId().hashCode();
|
||||
}
|
||||
|
||||
public void checkTrue(boolean mustBeTrue, C message, Object... args) {
|
||||
public void checkTrue(boolean mustBeTrue, Captions message, Object... args) {
|
||||
if (!mustBeTrue) {
|
||||
throw new CommandException(message, args);
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Object> T check(T object, C message, Object... args) {
|
||||
public <T extends Object> T check(T object, Captions message, Object... args) {
|
||||
if (object == null) {
|
||||
throw new CommandException(message, args);
|
||||
}
|
||||
@ -583,14 +579,14 @@ public abstract class Command {
|
||||
|
||||
public static class CommandException extends RuntimeException {
|
||||
private final Object[] args;
|
||||
private final C message;
|
||||
private final Captions message;
|
||||
|
||||
public CommandException(C message, Object... args) {
|
||||
public CommandException(Captions message, Object... args) {
|
||||
this.message = message;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public void perform(PlotPlayer player) {
|
||||
public void perform(CommandCaller player) {
|
||||
if (player != null && message != null) {
|
||||
message.send(player, args);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.configuration.MemoryConfiguratio
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* This is a base class for all File based implementations of {@link
|
||||
@ -14,13 +15,13 @@ import java.nio.charset.StandardCharsets;
|
||||
public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
/**
|
||||
* Creates an empty {@link FileConfiguration} with no default values.
|
||||
* Creates an empty FileConfiguration with no default values.
|
||||
*/
|
||||
FileConfiguration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an empty {@link FileConfiguration} using the specified {@link
|
||||
* Creates an empty FileConfiguration using the specified {@link
|
||||
* Configuration} as a source for all default values.
|
||||
*
|
||||
* @param defaults Default value provider
|
||||
@ -30,7 +31,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this {@link FileConfiguration} to the specified location.
|
||||
* Saves this FileConfiguration to the specified location.
|
||||
*
|
||||
* <p>If the file does not exist, it will be created. If already exists, it
|
||||
* will be overwritten. If it cannot be overwritten or created, an
|
||||
@ -58,14 +59,14 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this {@link FileConfiguration} to a string, and returns it.
|
||||
* Saves this FileConfiguration to a string, and returns it.
|
||||
*
|
||||
* @return String containing this configuration.
|
||||
*/
|
||||
public abstract String saveToString();
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified location.
|
||||
* Loads this FileConfiguration from the specified location.
|
||||
*
|
||||
* <p>All the values contained within this configuration will be removed,
|
||||
* leaving only settings and defaults, and the new values will be loaded
|
||||
@ -84,13 +85,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
*/
|
||||
public void load(File file) throws IOException, InvalidConfigurationException {
|
||||
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
try (FileInputStream stream = new FileInputStream(file)) {
|
||||
load(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified reader.
|
||||
* Loads this FileConfiguration from the specified reader.
|
||||
*
|
||||
* <p>All the values contained within this configuration will be removed,
|
||||
* leaving only settings and defaults, and the new values will be loaded
|
||||
@ -103,24 +104,20 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
*/
|
||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String builder;
|
||||
|
||||
try (BufferedReader input = reader instanceof BufferedReader ?
|
||||
(BufferedReader) reader :
|
||||
new BufferedReader(reader)) {
|
||||
String line;
|
||||
|
||||
while ((line = input.readLine()) != null) {
|
||||
builder.append(line);
|
||||
builder.append('\n');
|
||||
}
|
||||
builder = input.lines().map(line -> line + '\n').collect(Collectors.joining());
|
||||
}
|
||||
|
||||
loadFromString(builder.toString());
|
||||
loadFromString(builder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified string, as
|
||||
* Loads this FileConfiguration from the specified string, as
|
||||
* opposed to from file.
|
||||
*
|
||||
* <p>All the values contained within this configuration will be removed,
|
||||
@ -136,7 +133,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
||||
* Compiles the header for this FileConfiguration and returns the
|
||||
* result.
|
||||
*
|
||||
* <p>This will use the header from {@link #options()} -> {@link
|
||||
|
@ -212,10 +212,15 @@ public class ConfigurationSerialization {
|
||||
return result;
|
||||
}
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
ex instanceof InvocationTargetException ? ex.getCause() : ex);
|
||||
if (ex instanceof InvocationTargetException) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex.getCause());
|
||||
} else {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -226,10 +231,15 @@ public class ConfigurationSerialization {
|
||||
try {
|
||||
return ctor.newInstance(args);
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
ex instanceof InvocationTargetException ? ex.getCause() : ex);
|
||||
if (ex instanceof InvocationTargetException) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex.getCause());
|
||||
} else {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName()).log(Level.SEVERE,
|
||||
"Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization", ex);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -9,6 +9,7 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
/**
|
||||
* A JSONObject is an unordered collection of name/value pairs. Its external form is a string wrapped in curly braces
|
||||
@ -296,11 +297,7 @@ public class JSONObject {
|
||||
if (length == 0) {
|
||||
return null;
|
||||
}
|
||||
String[] names = new String[length];
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
names[i] = fields[i].getName();
|
||||
}
|
||||
return names;
|
||||
return IntStream.range(0, length).mapToObj(i -> fields[i].getName()).toArray(String[]::new);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -8,6 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.BlockRegistry;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
@ -15,28 +16,28 @@ import java.util.List;
|
||||
public interface IPlotMain extends ILogger {
|
||||
|
||||
/**
|
||||
* Log a message to console.
|
||||
* Logs a message to console.
|
||||
*
|
||||
* @param message The message to log
|
||||
* @param message the message to log
|
||||
*/
|
||||
void log(String message);
|
||||
|
||||
/**
|
||||
* Get the `PlotSquared` directory.
|
||||
* Gets the directory which contains PlotSquared files. The directory may not exist.
|
||||
*
|
||||
* @return The plugin directory
|
||||
* @return the PlotSquared directory
|
||||
*/
|
||||
File getDirectory();
|
||||
|
||||
/**
|
||||
* Get the directory containing all the worlds.
|
||||
* Gets the folder where all world data is stored.
|
||||
*
|
||||
* @return The directory containing the worlds
|
||||
* @return the world folder
|
||||
*/
|
||||
File getWorldContainer();
|
||||
|
||||
/**
|
||||
* Wrap a player into a PlotPlayer object.
|
||||
* Wraps a player into a PlotPlayer object.
|
||||
*
|
||||
* @param player The player to convert to a PlotPlayer
|
||||
* @return A PlotPlayer
|
||||
@ -44,70 +45,56 @@ public interface IPlotMain extends ILogger {
|
||||
PlotPlayer wrapPlayer(Object player);
|
||||
|
||||
/**
|
||||
* Disable the implementation.
|
||||
*
|
||||
* <ul>
|
||||
* <li>If a full disable isn't feasibly, just disable what it can.
|
||||
* </ul>
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Completely shut down the plugin
|
||||
* Completely shuts down the plugin.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
/**
|
||||
* Get the version of the PlotSquared being used.
|
||||
* Gets the version of the PlotSquared being used.
|
||||
*
|
||||
* @return the plugin version
|
||||
*/
|
||||
int[] getPluginVersion();
|
||||
|
||||
/**
|
||||
* Get the version of the PlotSquared being used as a string.
|
||||
* Gets the version of the PlotSquared being used as a string.
|
||||
*
|
||||
* @return the plugin version as a string
|
||||
*/
|
||||
String getPluginVersionString();
|
||||
|
||||
/**
|
||||
* Usually PlotSquared
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getPluginName();
|
||||
|
||||
/**
|
||||
* Get the version of Minecraft that is running.
|
||||
* Gets the version of Minecraft that is running.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int[] getServerVersion();
|
||||
|
||||
/**
|
||||
* Get the server implementation name and version
|
||||
* Gets the server implementation name and version
|
||||
*/
|
||||
String getServerImplementation();
|
||||
|
||||
/**
|
||||
* Get the NMS package prefix.
|
||||
* Gets the NMS package prefix.
|
||||
*
|
||||
* @return The NMS package prefix
|
||||
*/
|
||||
String getNMSPackage();
|
||||
|
||||
/**
|
||||
* Get the schematic handler.
|
||||
* Gets the schematic handler.
|
||||
*
|
||||
* @return The {@link SchematicHandler}
|
||||
*/
|
||||
SchematicHandler initSchematicHandler();
|
||||
|
||||
/**
|
||||
* Get the Chat Manager.
|
||||
* Starts the {@link ChatManager}.
|
||||
*
|
||||
* @return The {@link ChatManager}
|
||||
* @return the ChatManager
|
||||
*/
|
||||
ChatManager initChatManager();
|
||||
|
||||
@ -124,7 +111,7 @@ public interface IPlotMain extends ILogger {
|
||||
void runEntityTask();
|
||||
|
||||
/**
|
||||
* Register the implementation specific commands.
|
||||
* Registerss the implementation specific commands.
|
||||
*/
|
||||
void registerCommands();
|
||||
|
||||
@ -133,11 +120,6 @@ public interface IPlotMain extends ILogger {
|
||||
*/
|
||||
void registerPlayerEvents();
|
||||
|
||||
/**
|
||||
* Register inventory related events.
|
||||
*/
|
||||
void registerInventoryEvents();
|
||||
|
||||
/**
|
||||
* Register plot plus related events.
|
||||
*/
|
||||
@ -149,54 +131,54 @@ public interface IPlotMain extends ILogger {
|
||||
void registerForceFieldEvents();
|
||||
|
||||
/**
|
||||
* Register the WorldEdit hook.
|
||||
* Registers the WorldEdit hook.
|
||||
*/
|
||||
boolean initWorldEdit();
|
||||
|
||||
/**
|
||||
* Get the economy provider.
|
||||
* Gets the economy provider.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
EconHandler getEconomyHandler();
|
||||
|
||||
/**
|
||||
* Get the {@link QueueProvider} class.
|
||||
* Gets the {@link QueueProvider} class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
QueueProvider initBlockQueue();
|
||||
|
||||
/**
|
||||
* Get the {@link WorldUtil} class.
|
||||
* Gets the {@link WorldUtil} class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
WorldUtil initWorldUtil();
|
||||
|
||||
/**
|
||||
* Get the EventUtil class.
|
||||
* Gets the EventUtil class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
EventUtil initEventUtil();
|
||||
|
||||
/**
|
||||
* Get the chunk manager.
|
||||
* Gets the chunk manager.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ChunkManager initChunkManager();
|
||||
|
||||
/**
|
||||
* Get the {@link SetupUtils} class.
|
||||
* Gets the {@link SetupUtils} class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
SetupUtils initSetupUtils();
|
||||
|
||||
/**
|
||||
* Get {@link HybridUtils} class.
|
||||
* Gets {@link HybridUtils} class.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@ -215,7 +197,7 @@ public interface IPlotMain extends ILogger {
|
||||
void setGenerator(String world);
|
||||
|
||||
/**
|
||||
* Get the {@link UUIDHandlerImplementation} which will cache and
|
||||
* Gets the {@link UUIDHandlerImplementation} which will cache and
|
||||
* provide UUIDs.
|
||||
*
|
||||
* @return
|
||||
@ -223,7 +205,7 @@ public interface IPlotMain extends ILogger {
|
||||
UUIDHandlerImplementation initUUIDHandler();
|
||||
|
||||
/**
|
||||
* Get the {@link InventoryUtil} class (used for implementation specific
|
||||
* Gets the {@link InventoryUtil} class (used for implementation specific
|
||||
* inventory guis).
|
||||
*
|
||||
* @return
|
||||
@ -231,14 +213,14 @@ public interface IPlotMain extends ILogger {
|
||||
InventoryUtil initInventoryUtil();
|
||||
|
||||
/**
|
||||
* Unregister a PlotPlayer from cache e.g. if they have logged off.
|
||||
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
void unregister(PlotPlayer player);
|
||||
|
||||
/**
|
||||
* Get the generator wrapper for a world (world) and generator (name).
|
||||
* Gets the generator wrapper for a world (world) and generator (name).
|
||||
*
|
||||
* @param world
|
||||
* @param name
|
||||
@ -265,14 +247,7 @@ public interface IPlotMain extends ILogger {
|
||||
*
|
||||
* @return Default implementation generator
|
||||
*/
|
||||
IndependentPlotGenerator getDefaultGenerator();
|
||||
|
||||
/**
|
||||
* Get the class that will manage player titles.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
AbstractTitle initTitleManager();
|
||||
@NotNull IndependentPlotGenerator getDefaultGenerator();
|
||||
|
||||
List<String> getPluginIds();
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot;
|
||||
|
||||
public enum Platform {
|
||||
Bukkit, Sponge, Spigot, Cauldron
|
||||
Bukkit, Sponge, Spigot, Paper
|
||||
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -32,10 +32,9 @@ public class PlotVersion {
|
||||
|
||||
@Override public String toString() {
|
||||
if (hash == 0 && build == 0) {
|
||||
return "PlotSquared-" + year + "." + month + "." + day + "-SNAPSHOT";
|
||||
return "PlotSquared-NoVer-SNAPSHOT";
|
||||
} else {
|
||||
return "PlotSquared-" + year + "." + month + "." + day + "-" + Integer.toHexString(hash)
|
||||
+ "-" + build;
|
||||
return "PlotSquared-4." + build;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
@CommandDeclaration(command = "add",
|
||||
description = "Allow a user to build in a plot while you are online",
|
||||
usage = "/plot add <player>", category = CommandCategory.SETTINGS, permission = "plots.add",
|
||||
requiredType = RequiredType.NONE) public class Add extends Command {
|
||||
requiredType = RequiredType.PLAYER) public class Add extends Command {
|
||||
|
||||
public Add() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
@ -29,39 +29,41 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), Captions.PLOT_UNOWNED);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||
Captions.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
||||
Iterator<UUID> iterator = uuids.iterator();
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
while (iterator.hasNext()) {
|
||||
UUID uuid = iterator.next();
|
||||
if (uuid == DBFunc.EVERYONE && !(
|
||||
Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
Permissions.hasPermission(player, Captions.PERMISSION_TRUST_EVERYONE) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (plot.getMembers().contains(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
size += plot.getTrusted().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||
Captions.PLOT_MAX_MEMBERS);
|
||||
// Success
|
||||
confirm.run(this, () -> {
|
||||
for (UUID uuid : uuids) {
|
||||
@ -74,7 +76,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
}
|
||||
plot.addMember(uuid);
|
||||
EventUtil.manager.callMember(player, plot, uuid, true);
|
||||
MainUtil.sendMessage(player, C.MEMBER_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.MEMBER_ADDED);
|
||||
}
|
||||
}, null);
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -15,29 +15,29 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
@CommandDeclaration(command = "setalias", permission = "plots.alias",
|
||||
description = "Set the plot name", usage = "/plot alias <set|remove> <alias>",
|
||||
aliases = {"alias", "sa", "name", "rename", "setname", "seta", "nameplot"},
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Alias
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Alias
|
||||
extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot alias <set|remove> <value>");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot alias <set|remove> <value>");
|
||||
return false;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!plot.isOwner(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -46,25 +46,25 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "set":
|
||||
if (args.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot alias <set> <value>");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot alias <set> <value>");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (canExecuteCommand(player, C.PERMISSION_ALIAS_SET, false) || canExecuteCommand(
|
||||
player, C.PERMISSION_ALIAS_SET_OBSOLETE, false)) {
|
||||
if (canExecuteCommand(player, Captions.PERMISSION_ALIAS_SET, false)
|
||||
|| canExecuteCommand(player, Captions.PERMISSION_ALIAS_SET_OBSOLETE, false)) {
|
||||
result = setAlias(player, plot, args[1]);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION);
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION);
|
||||
}
|
||||
|
||||
break;
|
||||
case "remove":
|
||||
if (canExecuteCommand(player, C.PERMISSION_ALIAS_REMOVE, true)) {
|
||||
if (canExecuteCommand(player, Captions.PERMISSION_ALIAS_REMOVE, true)) {
|
||||
result = removeAlias(player, plot);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, "/plot alias <set|remove> <alias>");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot alias <set|remove> <alias>");
|
||||
result = false;
|
||||
}
|
||||
|
||||
@ -74,47 +74,47 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
|
||||
private boolean setAlias(PlotPlayer player, Plot plot, String alias) {
|
||||
if (alias.isEmpty()) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot alias <set> <value>");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot alias <set> <value>");
|
||||
return false;
|
||||
}
|
||||
if (alias.length() >= 50) {
|
||||
MainUtil.sendMessage(player, C.ALIAS_TOO_LONG);
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_TOO_LONG);
|
||||
return false;
|
||||
}
|
||||
if (alias.contains(" ")) {
|
||||
C.NOT_VALID_VALUE.send(player);
|
||||
Captions.NOT_VALID_VALUE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (MathMan.isInteger(alias)) {
|
||||
C.NOT_VALID_VALUE.send(player);
|
||||
Captions.NOT_VALID_VALUE.send(player);
|
||||
return false;
|
||||
}
|
||||
for (Plot p : PlotSquared.get().getPlots(plot.getArea())) {
|
||||
if (p.getAlias().equalsIgnoreCase(alias)) {
|
||||
MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (UUIDHandler.nameExists(new StringWrapper(alias)) || PlotSquared.get()
|
||||
.hasPlotArea(alias)) {
|
||||
MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
plot.setAlias(alias);
|
||||
MainUtil.sendMessage(player, C.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_SET_TO.s().replaceAll("%alias%", alias));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean removeAlias(PlotPlayer player, Plot plot) {
|
||||
plot.setAlias(null);
|
||||
MainUtil.sendMessage(player, C.ALIAS_REMOVED.s());
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_REMOVED.s());
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean canExecuteCommand(PlotPlayer player, C caption, boolean sendMessage) {
|
||||
private boolean canExecuteCommand(PlotPlayer player, Captions caption, boolean sendMessage) {
|
||||
if (!Permissions.hasPermission(player, caption)) {
|
||||
if (sendMessage) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION);
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.AugmentedUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
||||
@ -23,20 +23,20 @@ import java.util.Set;
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "c":
|
||||
case "setup":
|
||||
case "create":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_CREATE)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_CREATE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_CREATE)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_CREATE);
|
||||
return false;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 1:
|
||||
C.COMMAND_SYNTAX
|
||||
Captions.COMMAND_SYNTAX
|
||||
.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
case 2:
|
||||
@ -44,13 +44,13 @@ import java.util.Set;
|
||||
case "pos1": { // Set position 1
|
||||
HybridPlotWorld area = player.getMeta("area_create_area");
|
||||
if (area == null) {
|
||||
C.COMMAND_SYNTAX.send(player,
|
||||
Captions.COMMAND_SYNTAX.send(player,
|
||||
"/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
Location location = player.getLocation();
|
||||
player.setMeta("area_pos1", location);
|
||||
C.SET_ATTRIBUTE.send(player, "area_pos1",
|
||||
Captions.SET_ATTRIBUTE.send(player, "area_pos1",
|
||||
location.getX() + "," + location.getZ());
|
||||
MainUtil.sendMessage(player,
|
||||
"You will now set pos2: /plot area create pos2"
|
||||
@ -60,7 +60,7 @@ import java.util.Set;
|
||||
case "pos2": // Set position 2 and finish creation for type=2 (partial)
|
||||
final HybridPlotWorld area = player.getMeta("area_create_area");
|
||||
if (area == null) {
|
||||
C.COMMAND_SYNTAX.send(player,
|
||||
Captions.COMMAND_SYNTAX.send(player,
|
||||
"/plot area create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
@ -87,7 +87,7 @@ import java.util.Set;
|
||||
Set<PlotArea> areas =
|
||||
PlotSquared.get().getPlotAreas(area.worldname, region);
|
||||
if (!areas.isEmpty()) {
|
||||
C.CLUSTER_INTERSECTION
|
||||
Captions.CLUSTER_INTERSECTION
|
||||
.send(player, areas.iterator().next().toString());
|
||||
return false;
|
||||
}
|
||||
@ -104,36 +104,34 @@ import java.util.Set;
|
||||
final String path =
|
||||
"worlds." + area.worldname + ".areas." + area.id + '-'
|
||||
+ object.min + '-' + object.max;
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (offsetX != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.x", offsetX);
|
||||
}
|
||||
if (offsetZ != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.z", offsetZ);
|
||||
}
|
||||
final String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
PlotSquared.get().loadWorld(world, null);
|
||||
C.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
if (area.TERRAIN != 3) {
|
||||
ChunkManager.largeRegionTask(world, region,
|
||||
new RunnableVal<ChunkLoc>() {
|
||||
@Override public void run(ChunkLoc value) {
|
||||
AugmentedUtils
|
||||
.generate(world, value.x, value.z,
|
||||
null);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(player,
|
||||
"An error occurred while creating the world: "
|
||||
+ area.worldname);
|
||||
Runnable run = () -> {
|
||||
if (offsetX != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.x", offsetX);
|
||||
}
|
||||
if (offsetZ != 0) {
|
||||
PlotSquared.get().worlds
|
||||
.set(path + ".road.offset.z", offsetZ);
|
||||
}
|
||||
final String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
PlotSquared.get().loadWorld(world, null);
|
||||
Captions.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
if (area.TERRAIN != 3) {
|
||||
ChunkManager.largeRegionTask(world, region,
|
||||
new RunnableVal<ChunkLoc>() {
|
||||
@Override public void run(ChunkLoc value) {
|
||||
AugmentedUtils
|
||||
.generate(world, value.x, value.z,
|
||||
null);
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(player,
|
||||
"An error occurred while creating the world: "
|
||||
+ area.worldname);
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
@ -145,7 +143,6 @@ import java.util.Set;
|
||||
return true;
|
||||
}
|
||||
default: // Start creation
|
||||
final SetupObject object = new SetupObject();
|
||||
String[] split = args[1].split(":");
|
||||
String id;
|
||||
if (split.length == 2) {
|
||||
@ -153,12 +150,13 @@ import java.util.Set;
|
||||
} else {
|
||||
id = null;
|
||||
}
|
||||
final SetupObject object = new SetupObject();
|
||||
object.world = split[0];
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id,
|
||||
PlotSquared.get().IMP.getDefaultGenerator(), null, null);
|
||||
PlotArea other = PlotSquared.get().getPlotArea(pa.worldname, id);
|
||||
if (other != null && Objects.equals(pa.id, other.id)) {
|
||||
C.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
return false;
|
||||
}
|
||||
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(pa.worldname);
|
||||
@ -170,7 +168,7 @@ import java.util.Set;
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
String[] pair = args[i].split("=");
|
||||
if (pair.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
+ " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
@ -218,42 +216,40 @@ import java.util.Set;
|
||||
object.type = pa.TYPE;
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
+ " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (pa.TYPE != 2) {
|
||||
if (WorldUtil.IMP.isWorld(pa.worldname)) {
|
||||
C.SETUP_WORLD_TAKEN.send(player, pa.worldname);
|
||||
Captions.SETUP_WORLD_TAKEN.send(player, pa.worldname);
|
||||
return false;
|
||||
}
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
String path = "worlds." + pa.worldname;
|
||||
if (!PlotSquared.get().worlds.contains(path)) {
|
||||
PlotSquared.get().worlds.createSection(path);
|
||||
}
|
||||
ConfigurationSection section =
|
||||
PlotSquared.get().worlds.getConfigurationSection(path);
|
||||
pa.saveConfiguration(section);
|
||||
pa.loadConfiguration(section);
|
||||
object.plotManager = PlotSquared.imp().getPluginName();
|
||||
object.setupGenerator = PlotSquared.imp().getPluginName();
|
||||
String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
C.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
} else {
|
||||
MainUtil.sendMessage(player,
|
||||
"An error occurred while creating the world: "
|
||||
+ pa.worldname);
|
||||
}
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Runnable run = () -> {
|
||||
String path = "worlds." + pa.worldname;
|
||||
if (!PlotSquared.get().worlds.contains(path)) {
|
||||
PlotSquared.get().worlds.createSection(path);
|
||||
}
|
||||
ConfigurationSection section =
|
||||
PlotSquared.get().worlds.getConfigurationSection(path);
|
||||
pa.saveConfiguration(section);
|
||||
pa.loadConfiguration(section);
|
||||
object.plotManager = PlotSquared.imp().getPluginName();
|
||||
object.setupGenerator = PlotSquared.imp().getPluginName();
|
||||
String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
Captions.SETUP_FINISHED.send(player);
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
} else {
|
||||
MainUtil.sendMessage(player,
|
||||
"An error occurred while creating the world: "
|
||||
+ pa.worldname);
|
||||
}
|
||||
try {
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
@ -265,7 +261,7 @@ import java.util.Set;
|
||||
return true;
|
||||
}
|
||||
if (pa.id == null) {
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString()
|
||||
+ " create [world[:id]] [<modifier>=<value>]...");
|
||||
return false;
|
||||
}
|
||||
@ -288,8 +284,8 @@ import java.util.Set;
|
||||
return true;
|
||||
case "i":
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_INFO)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_INFO);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_INFO)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_INFO);
|
||||
return false;
|
||||
}
|
||||
PlotArea area;
|
||||
@ -301,14 +297,14 @@ import java.util.Set;
|
||||
area = PlotSquared.get().getPlotAreaByString(args[1]);
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]");
|
||||
return false;
|
||||
}
|
||||
if (area == null) {
|
||||
if (args.length == 2) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
} else {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -335,13 +331,14 @@ import java.util.Set;
|
||||
+ "\n$1Claimed: $2" + claimed + "\n$1Clusters: $2" + clusters + "\n$1Region: $2"
|
||||
+ region + "\n$1Generator: $2" + generator;
|
||||
MainUtil.sendMessage(player,
|
||||
C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
||||
Captions.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + Captions.PLOT_INFO_FOOTER
|
||||
.s(), false);
|
||||
return true;
|
||||
}
|
||||
case "l":
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_LIST)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_LIST);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_LIST)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_LIST);
|
||||
return false;
|
||||
}
|
||||
int page;
|
||||
@ -355,7 +352,7 @@ import java.util.Set;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||
Captions.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]");
|
||||
return false;
|
||||
}
|
||||
ArrayList<PlotArea> areas = new ArrayList<>(PlotSquared.get().getPlotAreas());
|
||||
@ -397,19 +394,19 @@ import java.util.Set;
|
||||
.color("$1").text(" - ").color("$2")
|
||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||
}
|
||||
}, "/plot area list", C.AREA_LIST_HEADER_PAGED.s());
|
||||
}, "/plot area list", Captions.AREA_LIST_HEADER_PAGED.s());
|
||||
return true;
|
||||
case "regen":
|
||||
case "clear":
|
||||
case "reset":
|
||||
case "regenerate": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_REGEN)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_REGEN);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_REGEN)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_REGEN);
|
||||
return false;
|
||||
}
|
||||
final PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
if (area.TYPE != 2) {
|
||||
@ -422,11 +419,7 @@ import java.util.Set;
|
||||
@Override public void run(ChunkLoc value) {
|
||||
AugmentedUtils.generate(area.worldname, value.x, value.z, null);
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override public void run() {
|
||||
player.sendMessage("Regen complete");
|
||||
}
|
||||
});
|
||||
}, () -> player.sendMessage("Regen complete"));
|
||||
return true;
|
||||
}
|
||||
case "goto":
|
||||
@ -434,17 +427,17 @@ import java.util.Set;
|
||||
case "teleport":
|
||||
case "visit":
|
||||
case "tp":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_TP)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_TP);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_AREA_TP)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_TP);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot visit [area]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
}
|
||||
Location center;
|
||||
@ -470,7 +463,7 @@ import java.util.Set;
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
return true;
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2,11 +2,20 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ByteArrayUtilities;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
@ -21,36 +30,41 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
private static boolean checkAllowedPlots(PlotPlayer player, PlotArea plotarea,
|
||||
@Nullable Integer allowed_plots, int size_x, int size_z) {
|
||||
if (allowed_plots == null)
|
||||
allowed_plots = player.getAllowedPlots();
|
||||
int currentPlots =
|
||||
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
|
||||
int diff = currentPlots - allowed_plots;
|
||||
if (diff + size_x * size_z > 0) {
|
||||
@Nullable Integer allowedPlots, int sizeX, int sizeZ) {
|
||||
if (allowedPlots == null) {
|
||||
allowedPlots = player.getAllowedPlots();
|
||||
}
|
||||
int currentPlots;
|
||||
if (Settings.Limit.GLOBAL) {
|
||||
currentPlots = player.getPlotCount();
|
||||
} else {
|
||||
currentPlots = player.getPlotCount(plotarea.worldname);
|
||||
}
|
||||
int diff = currentPlots - allowedPlots;
|
||||
if (diff + sizeX * sizeZ > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
return false;
|
||||
} else if (player.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots =
|
||||
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
if (grantedPlots - diff < size_x * size_z) {
|
||||
if (grantedPlots - diff < sizeX * sizeZ) {
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||
return false;
|
||||
} else {
|
||||
int left = grantedPlots - diff - size_x * size_z;
|
||||
int left = grantedPlots - diff - sizeX * sizeZ;
|
||||
if (left == 0) {
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
} else {
|
||||
player.setPersistentMeta("grantedPlots",
|
||||
ByteArrayUtilities.integerToBytes(left));
|
||||
}
|
||||
MainUtil.sendMessage(player, C.REMOVED_GRANTED_PLOT, "" + left,
|
||||
MainUtil.sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "" + left,
|
||||
"" + (grantedPlots - left));
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -63,15 +77,15 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void homeOrAuto(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem) {
|
||||
final String schematic) {
|
||||
Set<Plot> plots = player.getPlots();
|
||||
if (!plots.isEmpty()) {
|
||||
plots.iterator().next().teleportPlayer(player);
|
||||
} else {
|
||||
autoClaimSafe(player, area, start, schem);
|
||||
autoClaimSafe(player, area, start, schematic);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,11 +95,11 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem) {
|
||||
autoClaimSafe(player, area, start, schem, null);
|
||||
final String schematic) {
|
||||
autoClaimSafe(player, area, start, schematic, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +108,10 @@ public class Auto extends SubCommand {
|
||||
* @param player
|
||||
* @param area
|
||||
* @param start
|
||||
* @param schem
|
||||
* @param schematic
|
||||
*/
|
||||
public static void autoClaimSafe(final PlotPlayer player, final PlotArea area, PlotId start,
|
||||
final String schem, @Nullable final Integer allowed_plots) {
|
||||
final String schematic, @Nullable final Integer allowedPlots) {
|
||||
player.setMeta(Auto.class.getName(), true);
|
||||
autoClaimFromDatabase(player, area, start, new RunnableVal<Plot>() {
|
||||
@Override public void run(final Plot plot) {
|
||||
@ -105,9 +119,9 @@ public class Auto extends SubCommand {
|
||||
@Override public void run(Object ignore) {
|
||||
player.deleteMeta(Auto.class.getName());
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
} else if (checkAllowedPlots(player, area, allowed_plots, 1, 1)) {
|
||||
plot.claim(player, true, schem, false);
|
||||
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
||||
} else if (checkAllowedPlots(player, area, allowedPlots, 1, 1)) {
|
||||
plot.claim(player, true, schematic, false);
|
||||
if (area.AUTO_MERGE) {
|
||||
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
||||
}
|
||||
@ -129,11 +143,8 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
whenDone.value = plot;
|
||||
plot.owner = player.getUUID();
|
||||
DBFunc.createPlotSafe(plot, whenDone, new Runnable() {
|
||||
@Override public void run() {
|
||||
autoClaimFromDatabase(player, area, plot.getId(), whenDone);
|
||||
}
|
||||
});
|
||||
DBFunc.createPlotSafe(plot, whenDone,
|
||||
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
@ -152,7 +163,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (plotarea == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -160,7 +171,7 @@ public class Auto extends SubCommand {
|
||||
int size_z = 1;
|
||||
String schematic = null;
|
||||
if (args.length > 0) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_AUTO_MEGA)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_AUTO_MEGA)) {
|
||||
try {
|
||||
String[] split = args[0].split(",|;");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
@ -181,29 +192,31 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
} else {
|
||||
schematic = args[0];
|
||||
// PlayerFunctions.sendMessage(plr, C.NO_PERMISSION);
|
||||
// PlayerFunctions.sendMessage(plr, Captions.NO_PERMISSION);
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
if (size_x * size_z > Settings.Claim.MAX_AUTO_AREA) {
|
||||
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM,
|
||||
MainUtil.sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS_NUM,
|
||||
Settings.Claim.MAX_AUTO_AREA + "");
|
||||
return false;
|
||||
}
|
||||
final int allowed_plots = player.getAllowedPlots();
|
||||
if (player.getMeta(Auto.class.getName(), false) || !checkAllowedPlots(player, plotarea,
|
||||
allowed_plots, size_x, size_z))
|
||||
allowed_plots, size_x, size_z)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (schematic != null && !schematic.isEmpty()) {
|
||||
if (!plotarea.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic))
|
||||
&& !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLAIM_SCHEMATIC.f(schematic));
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLAIM_SCHEMATIC.f(schematic))
|
||||
&& !Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLAIM_SCHEMATIC.f(schematic));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -215,11 +228,11 @@ public class Auto extends SubCommand {
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return true;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(player, cost);
|
||||
sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
// TODO handle type 2 the same as normal worlds!
|
||||
@ -228,7 +241,7 @@ public class Auto extends SubCommand {
|
||||
return true;
|
||||
} else {
|
||||
if (plotarea.TYPE == 2) {
|
||||
MainUtil.sendMessage(player, C.NO_FREE_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.NO_FREE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
while (true) {
|
||||
@ -243,8 +256,7 @@ public class Auto extends SubCommand {
|
||||
plot.claim(player, teleport, null);
|
||||
}
|
||||
}
|
||||
if (!plotarea
|
||||
.mergePlots(MainUtil.getPlotSelectionIds(start, end), true)) {
|
||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), true)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
@ -17,21 +17,19 @@ import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
int biome = WorldUtil.IMP.getBiomeFromString(value);
|
||||
if (biome == -1) {
|
||||
String biomes =
|
||||
StringMan.join(WorldUtil.IMP.getBiomeList(), C.BLOCK_LIST_SEPARATER.s());
|
||||
C.NEED_BIOME.send(player);
|
||||
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
|
||||
StringMan.join(WorldUtil.IMP.getBiomeList(), Captions.BLOCK_LIST_SEPARATER.s());
|
||||
Captions.NEED_BIOME.send(player);
|
||||
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.s() + biomes);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
plot.setBiome(value.toUpperCase(), new Runnable() {
|
||||
@Override public void run() {
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(player, C.BIOME_SET_TO.s() + value.toLowerCase());
|
||||
}
|
||||
plot.setBiome(value.toUpperCase(), () -> {
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(player, Captions.BIOME_SET_TO.s() + value.toLowerCase());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -27,39 +27,40 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||
check(EconHandler.manager, C.ECON_DISABLED);
|
||||
|
||||
check(EconHandler.manager, Captions.ECON_DISABLED);
|
||||
final Plot plot;
|
||||
if (args.length != 0) {
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
plot = check(MainUtil.getPlotFromString(player, args[0], true), null);
|
||||
} else {
|
||||
plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
}
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(!plot.isOwner(player.getUUID()), C.CANNOT_BUY_OWN);
|
||||
checkTrue(plot.hasOwner(), Captions.PLOT_UNOWNED);
|
||||
checkTrue(!plot.isOwner(player.getUUID()), Captions.CANNOT_BUY_OWN);
|
||||
Set<Plot> plots = plot.getConnectedPlots();
|
||||
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(),
|
||||
C.CANT_CLAIM_MORE_PLOTS);
|
||||
Captions.CANT_CLAIM_MORE_PLOTS);
|
||||
Optional<Double> flag = plot.getFlag(Flags.PRICE);
|
||||
if (!flag.isPresent()) {
|
||||
throw new CommandException(C.NOT_FOR_SALE);
|
||||
throw new CommandException(Captions.NOT_FOR_SALE);
|
||||
}
|
||||
final double price = flag.get();
|
||||
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
||||
checkTrue(player.getMoney() >= price, Captions.CANNOT_AFFORD_PLOT);
|
||||
player.withdraw(price);
|
||||
// Failure
|
||||
// Success
|
||||
confirm.run(this, () -> {
|
||||
C.REMOVED_BALANCE.send(player, price);
|
||||
Captions.REMOVED_BALANCE.send(player, price);
|
||||
EconHandler.manager
|
||||
.depositMoney(UUIDHandler.getUUIDWrapper().getOfflinePlayer(plot.owner), price);
|
||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
C.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||
Captions.PLOT_SOLD.send(owner, plot.getId(), player.getName(), price);
|
||||
}
|
||||
plot.removeFlag(Flags.PRICE);
|
||||
plot.setOwner(player.getUUID());
|
||||
C.CLAIMED.send(player);
|
||||
Captions.CLAIMED.send(player);
|
||||
whenDone.run(Buy.this, CommandResult.SUCCESS);
|
||||
}, () -> {
|
||||
player.deposit(price);
|
||||
|
@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off",
|
||||
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT,
|
||||
requiredType = RequiredType.NONE) public class Chat extends SubCommand {
|
||||
requiredType = RequiredType.PLAYER) public class Chat extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
@ -23,7 +23,7 @@ public class Claim extends SubCommand {
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
int currentPlots =
|
||||
Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(loc.getWorld());
|
||||
@ -34,40 +34,43 @@ public class Claim extends SubCommand {
|
||||
ByteArrayUtilities.bytesToInteger(player.getPersistentMeta("grantedPlots"));
|
||||
if (grants <= 0) {
|
||||
player.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
} else {
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_PLOTS);
|
||||
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
}
|
||||
if (!plot.canClaim(player)) {
|
||||
return sendMessage(player, C.PLOT_IS_CLAIMED);
|
||||
return sendMessage(player, Captions.PLOT_IS_CLAIMED);
|
||||
}
|
||||
final PlotArea area = plot.getArea();
|
||||
if (!schematic.isEmpty()) {
|
||||
if (area.SCHEMATIC_CLAIM_SPECIFY) {
|
||||
if (!area.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||
"non-existent: " + schematic);
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic))
|
||||
&& !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
return sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLAIM_SCHEMATIC.f(schematic))
|
||||
&& !Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
return sendMessage(player, Captions.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}
|
||||
}
|
||||
}
|
||||
int border = area.getBorder();
|
||||
if (border != Integer.MAX_VALUE && plot.getDistanceFromOrigin() > border) {
|
||||
return !sendMessage(player, C.BORDER);
|
||||
return !sendMessage(player, Captions.BORDER);
|
||||
}
|
||||
if ((EconHandler.manager != null) && area.USE_ECONOMY) {
|
||||
Expression<Double> costExr = area.PRICES.get("claim");
|
||||
double cost = costExr.evaluate((double) currentPlots);
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
return sendMessage(player, Captions.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(player, cost);
|
||||
sendMessage(player, C.REMOVED_BALANCE, cost + "");
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, cost + "");
|
||||
}
|
||||
}
|
||||
if (grants > 0) {
|
||||
@ -77,30 +80,22 @@ public class Claim extends SubCommand {
|
||||
player.setPersistentMeta("grantedPlots",
|
||||
ByteArrayUtilities.integerToBytes(grants - 1));
|
||||
}
|
||||
sendMessage(player, C.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
||||
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
|
||||
}
|
||||
if (plot.canClaim(player)) {
|
||||
plot.owner = player.getUUID();
|
||||
final String finalSchematic = schematic;
|
||||
DBFunc.createPlotSafe(plot, new Runnable() {
|
||||
@Override public void run() {
|
||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
plot.claim(player, true, finalSchematic, false);
|
||||
if (area.AUTO_MERGE) {
|
||||
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
||||
}
|
||||
}
|
||||
});
|
||||
DBFunc.createPlotSafe(plot, () -> TaskManager.IMP.sync(new RunnableVal<Object>() {
|
||||
@Override public void run(Object value) {
|
||||
plot.claim(player, true, finalSchematic, false);
|
||||
if (area.AUTO_MERGE) {
|
||||
plot.autoMerge(-1, Integer.MAX_VALUE, player.getUUID(), true);
|
||||
}
|
||||
}
|
||||
}, new Runnable() {
|
||||
@Override public void run() {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
});
|
||||
}), () -> sendMessage(player, Captions.PLOT_NOT_CLAIMED));
|
||||
return true;
|
||||
} else {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
@ -30,13 +30,14 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_CLEAR), C.NO_PLOT_PERMS);
|
||||
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CLEAR),
|
||||
Captions.NO_PLOT_PERMS);
|
||||
checkTrue(plot.getRunning() == 0, Captions.WAIT_FOR_TIMER);
|
||||
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_CONTINUE), C.DONE_ALREADY_DONE);
|
||||
.hasPermission(player, Captions.PERMISSION_CONTINUE), Captions.DONE_ALREADY_DONE);
|
||||
confirm.run(this, () -> {
|
||||
final long start = System.currentTimeMillis();
|
||||
boolean result = plot.clear(true, false, () -> {
|
||||
@ -50,12 +51,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
if (plot.getFlag(Flags.ANALYSIS).isPresent()) {
|
||||
FlagManager.removePlotFlag(plot, Flags.ANALYSIS);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.CLEARING_DONE,
|
||||
MainUtil.sendMessage(player, Captions.CLEARING_DONE,
|
||||
"" + (System.currentTimeMillis() - start));
|
||||
});
|
||||
});
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
} else {
|
||||
plot.addRunning();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
@ -25,56 +25,59 @@ import java.util.UUID;
|
||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||
if (args.length == 0) {
|
||||
// return arguments
|
||||
MainUtil.sendMessage(player, C.CLUSTER_AVAILABLE_ARGS);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_AVAILABLE_ARGS);
|
||||
return false;
|
||||
}
|
||||
String sub = args[0].toLowerCase();
|
||||
switch (sub) {
|
||||
case "l":
|
||||
case "list": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_LIST)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_LIST);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_LIST)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_LIST);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster list");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster list");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
Set<PlotCluster> clusters = area.getClusters();
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_HEADING, clusters.size() + "");
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_HEADING, clusters.size() + "");
|
||||
for (PlotCluster cluster : clusters) {
|
||||
// Ignore unmanaged clusters
|
||||
String name = "'" + cluster.getName() + "' : " + cluster.toString();
|
||||
if (player.getUUID().equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&a" + name);
|
||||
} else if (cluster.helpers.contains(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&3" + name);
|
||||
} else if (cluster.invited.contains(player.getUUID())) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, "&9" + name);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.CLUSTER_LIST_ELEMENT, cluster.toString());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "c":
|
||||
case "create": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_CREATE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_CREATE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_CREATE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_CREATE);
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 4) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster create <name> <id-bot> <id-top>");
|
||||
return false;
|
||||
}
|
||||
@ -82,19 +85,22 @@ import java.util.UUID;
|
||||
player.getClusterCount() :
|
||||
player.getPlotCount(player.getLocation().getWorld());
|
||||
if (currentClusters >= player.getAllowedPlots()) {
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_CLUSTERS);
|
||||
return sendMessage(player, Captions.CANT_CLAIM_MORE_CLUSTERS);
|
||||
}
|
||||
PlotId pos1;
|
||||
PlotId pos2;
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[2]);
|
||||
PlotId pos2 = PlotId.fromString(args[3]);
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
try {
|
||||
pos1 = PlotId.fromString(args[2]);
|
||||
pos2 = PlotId.fromString(args[3]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
// check if name is taken
|
||||
String name = args[1];
|
||||
if (area.getCluster(name) != null) {
|
||||
MainUtil.sendMessage(player, C.ALIAS_IS_TAKEN);
|
||||
MainUtil.sendMessage(player, Captions.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
||||
@ -105,22 +111,23 @@ import java.util.UUID;
|
||||
//check if overlap
|
||||
PlotCluster cluster = area.getFirstIntersectingCluster(pos1, pos2);
|
||||
if (cluster != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, cluster.getName());
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_INTERSECTION, cluster.getName());
|
||||
return false;
|
||||
}
|
||||
// Check if it occupies existing plots
|
||||
if (!area.contains(pos1) || !area.contains(pos2)) {
|
||||
C.CLUSTER_OUTSIDE.send(player, area);
|
||||
Captions.CLUSTER_OUTSIDE.send(player, area);
|
||||
return false;
|
||||
}
|
||||
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
if (!plots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_CREATE_OTHER)) {
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_CREATE_OTHER)) {
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot plot : plots) {
|
||||
if (!plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_CREATE_OTHER);
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_CREATE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -134,11 +141,12 @@ import java.util.UUID;
|
||||
} else {
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||
}
|
||||
int allowed = Permissions.hasPermissionRange(player, C.PERMISSION_CLUSTER_SIZE,
|
||||
Settings.Limit.MAX_PLOTS);
|
||||
int allowed = Permissions
|
||||
.hasPermissionRange(player, Captions.PERMISSION_CLUSTER_SIZE,
|
||||
Settings.Limit.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// create cluster
|
||||
@ -148,72 +156,79 @@ import java.util.UUID;
|
||||
// Add any existing plots to the current cluster
|
||||
for (Plot plot : plots) {
|
||||
if (plot.hasOwner()) {
|
||||
if (!cluster.isAdded(plot.owner)) {
|
||||
cluster.invited.add(plot.owner);
|
||||
DBFunc.setInvited(cluster, plot.owner);
|
||||
if (!cluster.isAdded(plot.getOwner())) {
|
||||
cluster.invited.add(plot.getOwner());
|
||||
DBFunc.setInvited(cluster, plot.getOwner());
|
||||
}
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.CLUSTER_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_ADDED);
|
||||
return true;
|
||||
}
|
||||
case "disband":
|
||||
case "del":
|
||||
case "delete": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_DELETE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_DELETE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_DELETE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster delete [name]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!cluster.owner.equals(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_DELETE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_DELETE_OTHER);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_DELETE_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_DELETE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
DBFunc.delete(cluster);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_DELETED);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_DELETED);
|
||||
return true;
|
||||
}
|
||||
case "res":
|
||||
case "resize": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_RESIZE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_RESIZE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster resize <pos1> <pos2>");
|
||||
return false;
|
||||
}
|
||||
PlotId pos1;
|
||||
PlotId pos2;
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[1]);
|
||||
PlotId pos2 = PlotId.fromString(args[2]);
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
try {
|
||||
pos1 = PlotId.fromString(args[2]);
|
||||
pos2 = PlotId.fromString(args[3]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
||||
@ -223,29 +238,30 @@ import java.util.UUID;
|
||||
// check if in cluster
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_RESIZE_OTHER);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_RESIZE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
//check if overlap
|
||||
PlotCluster intersect = area.getFirstIntersectingCluster(pos1, pos2);
|
||||
if (intersect != null) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_INTERSECTION, intersect.getName());
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.CLUSTER_INTERSECTION, intersect.getName());
|
||||
return false;
|
||||
}
|
||||
Set<Plot> existing =
|
||||
area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
Set<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
Set<Plot> newPlots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
// Set<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||
Set<Plot> removed = new HashSet<>(existing);
|
||||
@ -253,17 +269,19 @@ import java.util.UUID;
|
||||
removed.removeAll(newPlots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_RESIZE_SHRINK);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_RESIZE_SHRINK);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
newPlots.removeAll(existing);
|
||||
if (!newPlots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_RESIZE_EXPAND);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_RESIZE_EXPAND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -275,50 +293,53 @@ import java.util.UUID;
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||
}
|
||||
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||
int allowed = Permissions
|
||||
.hasPermissionRange(player, C.PERMISSION_CLUSTER, Settings.Limit.MAX_PLOTS);
|
||||
int allowed = Permissions.hasPermissionRange(player, Captions.PERMISSION_CLUSTER,
|
||||
Settings.Limit.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER.s() + "." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER.s() + "." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// resize cluster
|
||||
DBFunc.resizeCluster(cluster, pos1, pos2);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_RESIZED);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_RESIZED);
|
||||
return true;
|
||||
}
|
||||
case "add":
|
||||
case "inv":
|
||||
case "invite": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INVITE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_INVITE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_INVITE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_INVITE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster invite <player>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster invite <player>");
|
||||
return false;
|
||||
}
|
||||
// check if in cluster
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INVITE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_INVITE_OTHER);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_INVITE_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_INVITE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
@ -327,49 +348,52 @@ import java.util.UUID;
|
||||
DBFunc.setInvited(cluster, uuid);
|
||||
PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
|
||||
if (player2 != null) {
|
||||
MainUtil.sendMessage(player2, C.CLUSTER_INVITED, cluster.getName());
|
||||
MainUtil.sendMessage(player2, Captions.CLUSTER_INVITED, cluster.getName());
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.CLUSTER_ADDED_USER);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_ADDED_USER);
|
||||
return true;
|
||||
}
|
||||
case "k":
|
||||
case "remove":
|
||||
case "kick": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_KICK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_KICK);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_KICK)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_KICK);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster kick <player>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster kick <player>");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_KICK_OTHER)) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_KICK_OTHER);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_KICK_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_KICK_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// check uuid
|
||||
UUID uuid = UUIDHandler.getUUID(args[1], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[1]);
|
||||
return false;
|
||||
}
|
||||
// Can't kick if the player is yourself, the owner, or not added to the cluster
|
||||
if (uuid.equals(player.getUUID()) || uuid.equals(cluster.owner) || !cluster
|
||||
.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(player, C.CANNOT_KICK_PLAYER, cluster.getName());
|
||||
MainUtil.sendMessage(player, Captions.CANNOT_KICK_PLAYER, cluster.getName());
|
||||
return false;
|
||||
}
|
||||
if (cluster.helpers.contains(uuid)) {
|
||||
@ -380,7 +404,7 @@ import java.util.UUID;
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
PlotPlayer player2 = UUIDHandler.getPlayer(uuid);
|
||||
if (player2 != null) {
|
||||
MainUtil.sendMessage(player2, C.CLUSTER_REMOVED, cluster.getName());
|
||||
MainUtil.sendMessage(player2, Captions.CLUSTER_REMOVED, cluster.getName());
|
||||
}
|
||||
for (Plot plot : new ArrayList<>(
|
||||
PlotSquared.get().getPlots(player2.getLocation().getWorld(), uuid))) {
|
||||
@ -389,44 +413,46 @@ import java.util.UUID;
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player2, C.CLUSTER_KICKED_USER);
|
||||
MainUtil.sendMessage(player2, Captions.CLUSTER_KICKED_USER);
|
||||
return true;
|
||||
}
|
||||
case "quit":
|
||||
case "leave": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_LEAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_LEAVE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_LEAVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_LEAVE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
UUID uuid = player.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
if (uuid.equals(cluster.owner)) {
|
||||
MainUtil.sendMessage(player, C.CLUSTER_CANNOT_LEAVE);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_CANNOT_LEAVE);
|
||||
return false;
|
||||
}
|
||||
if (cluster.helpers.contains(uuid)) {
|
||||
@ -435,12 +461,11 @@ import java.util.UUID;
|
||||
}
|
||||
cluster.invited.remove(uuid);
|
||||
DBFunc.removeInvited(cluster, uuid);
|
||||
MainUtil.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName());
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED, cluster.getName());
|
||||
for (Plot plot : new ArrayList<>(
|
||||
PlotSquared.get().getPlots(player.getLocation().getWorld(), uuid))) {
|
||||
PlotCluster current = plot.getCluster();
|
||||
if (current != null && current.equals(cluster)) {
|
||||
player.getLocation().getWorld();
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
@ -450,102 +475,107 @@ import java.util.UUID;
|
||||
case "admin":
|
||||
case "helper":
|
||||
case "helpers": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_HELPERS)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_HELPERS);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_HELPERS)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_HELPERS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster helpers <add|remove> <player>");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = UUIDHandler.getUUID(args[2], null);
|
||||
if (uuid == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[2]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[2]);
|
||||
return false;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("add")) {
|
||||
cluster.helpers.add(uuid);
|
||||
DBFunc.setHelper(cluster, uuid);
|
||||
return MainUtil.sendMessage(player, C.CLUSTER_ADDED_HELPER);
|
||||
return MainUtil.sendMessage(player, Captions.CLUSTER_ADDED_HELPER);
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("remove")) {
|
||||
cluster.helpers.remove(uuid);
|
||||
DBFunc.removeHelper(cluster, uuid);
|
||||
return MainUtil.sendMessage(player, C.CLUSTER_REMOVED_HELPER);
|
||||
return MainUtil.sendMessage(player, Captions.CLUSTER_REMOVED_HELPER);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot cluster helpers <add|remove> <player>");
|
||||
return false;
|
||||
}
|
||||
case "spawn":
|
||||
case "home":
|
||||
case "tp": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_TP)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_TP);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_TP)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_TP);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster tp <name>");
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster tp <name>");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
return false;
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = player.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_TP_OTHER)) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_TP_OTHER);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_TP_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_TP_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
player.teleport(cluster.getHome());
|
||||
return MainUtil.sendMessage(player, C.CLUSTER_TELEPORTING);
|
||||
return MainUtil.sendMessage(player, Captions.CLUSTER_TELEPORTING);
|
||||
}
|
||||
case "i":
|
||||
case "info":
|
||||
case "show":
|
||||
case "information": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INFO)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_INFO);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_INFO)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_INFO);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster info [name]");
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster info [name]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster;
|
||||
if (args.length == 2) {
|
||||
cluster = area.getCluster(args[1]);
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.INVALID_CLUSTER, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_CLUSTER, args[1]);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -558,7 +588,7 @@ import java.util.UUID;
|
||||
String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (
|
||||
cluster.getP2().y - cluster.getP1().y + 1);
|
||||
String rights = cluster.isAdded(player.getUUID()) + "";
|
||||
String message = C.CLUSTER_INFO.s();
|
||||
String message = Captions.CLUSTER_INFO.s();
|
||||
message = message.replaceAll("%id%", id);
|
||||
message = message.replaceAll("%owner%", owner);
|
||||
message = message.replaceAll("%name%", name);
|
||||
@ -570,27 +600,29 @@ import java.util.UUID;
|
||||
case "sh":
|
||||
case "setspawn":
|
||||
case "sethome":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_SETHOME)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_SETHOME);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_CLUSTER_SETHOME)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_SETHOME);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster sethome");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot cluster sethome");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area == null) {
|
||||
C.NOT_IN_PLOT_WORLD.send(player);
|
||||
Captions.NOT_IN_PLOT_WORLD.send(player);
|
||||
}
|
||||
PlotCluster cluster = area.getCluster(player.getLocation());
|
||||
if (cluster == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_CLUSTER);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_CLUSTER);
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_SETHOME_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_CLUSTER_SETHOME_OTHER);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_CLUSTER_SETHOME_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_CLUSTER_SETHOME_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -600,9 +632,9 @@ import java.util.UUID;
|
||||
cluster.settings.setPosition(blockloc);
|
||||
DBFunc.setPosition(cluster,
|
||||
relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
||||
return MainUtil.sendMessage(player, C.POSITION_SET);
|
||||
return MainUtil.sendMessage(player, Captions.POSITION_SET);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.CLUSTER_AVAILABLE_ARGS);
|
||||
MainUtil.sendMessage(player, Captions.CLUSTER_AVAILABLE_ARGS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,56 +1,58 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* CommandCategory.
|
||||
*/
|
||||
public enum CommandCategory {
|
||||
@RequiredArgsConstructor public enum CommandCategory {
|
||||
/**
|
||||
* Claiming CommandConfig.
|
||||
* Such as: /plot claim
|
||||
*/
|
||||
CLAIMING("Claiming"), /**
|
||||
CLAIMING(Captions.COMMAND_CATEGORY_CLAIMING),
|
||||
/**
|
||||
* Teleportation CommandConfig.
|
||||
* Such as: /plot visit
|
||||
*/
|
||||
TELEPORT("Teleport"), /**
|
||||
TELEPORT(Captions.COMMAND_CATEGORY_TELEPPORT),
|
||||
/**
|
||||
* Protection.
|
||||
*/
|
||||
SETTINGS("Protection"), /**
|
||||
SETTINGS(Captions.COMMAND_CATEGORY_SETTINGS),
|
||||
/**
|
||||
* Chat.
|
||||
*/
|
||||
CHAT("Chat"), /**
|
||||
CHAT(Captions.COMMAND_CATEGORY_CHAT),
|
||||
/**
|
||||
* Web.
|
||||
*/
|
||||
SCHEMATIC("Web"), /**
|
||||
SCHEMATIC(Captions.COMMAND_CATEGORY_SCHEMATIC),
|
||||
/**
|
||||
* Cosmetic.
|
||||
*/
|
||||
APPEARANCE("Cosmetic"), /**
|
||||
APPEARANCE(Captions.COMMAND_CATEGORY_APPEARANCE),
|
||||
/**
|
||||
* Information CommandConfig.
|
||||
* Such as: /plot info
|
||||
*/
|
||||
INFO("Info"), /**
|
||||
INFO(Captions.COMMAND_CATEGORY_INFO),
|
||||
/**
|
||||
* Debug CommandConfig.
|
||||
* Such as: /plot debug
|
||||
*/
|
||||
DEBUG("Debug"), /**
|
||||
DEBUG(Captions.COMMAND_CATEGORY_DEBUG),
|
||||
/**
|
||||
* Administration commands.
|
||||
*/
|
||||
ADMINISTRATION("Admin");
|
||||
ADMINISTRATION(Captions.COMMAND_CATEGORY_ADMINISTRATION);
|
||||
/**
|
||||
* The category name (Readable).
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param name readable name
|
||||
*/
|
||||
CommandCategory(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
private final Captions caption;
|
||||
|
||||
@Override public String toString() {
|
||||
return this.name;
|
||||
return this.caption.s();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
@ -17,23 +17,29 @@ import java.util.Arrays;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
@CommandDeclaration(command = "comment", aliases = {"msg"}, description = "Comment on a plot",
|
||||
category = CommandCategory.CHAT, requiredType = RequiredType.NONE, permission = "plots.comment")
|
||||
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER, permission = "plots.comment")
|
||||
public class Comment extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX,
|
||||
sendMessage(player, Captions.COMMENT_SYNTAX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||
if (inbox == null) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX,
|
||||
sendMessage(player, Captions.COMMENT_SYNTAX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
PlotId id = PlotId.fromString(args[1]);
|
||||
PlotId id;
|
||||
try {
|
||||
id = PlotId.fromString(args[1]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
Plot plot = MainUtil.getPlotFromString(player, args[1], false);
|
||||
int index;
|
||||
if (plot == null) {
|
||||
@ -41,14 +47,14 @@ public class Comment extends SubCommand {
|
||||
plot = loc.getPlotAbs();
|
||||
} else {
|
||||
if (args.length < 4) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX,
|
||||
sendMessage(player, Captions.COMMENT_SYNTAX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
index = 2;
|
||||
}
|
||||
if (!inbox.canWrite(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX, "");
|
||||
sendMessage(player, Captions.NO_PERM_INBOX, "");
|
||||
return false;
|
||||
}
|
||||
String message = StringMan.join(Arrays.copyOfRange(args, index, args.length), " ");
|
||||
@ -57,8 +63,8 @@ public class Comment extends SubCommand {
|
||||
System.currentTimeMillis());
|
||||
boolean result = inbox.addComment(plot, comment);
|
||||
if (!result) {
|
||||
sendMessage(player, C.NO_PLOT_INBOX, "");
|
||||
sendMessage(player, C.COMMENT_SYNTAX,
|
||||
sendMessage(player, Captions.NO_PLOT_INBOX, "");
|
||||
sendMessage(player, Captions.COMMENT_SYNTAX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), "|"));
|
||||
return false;
|
||||
}
|
||||
@ -68,7 +74,7 @@ public class Comment extends SubCommand {
|
||||
MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " "));
|
||||
}
|
||||
}
|
||||
sendMessage(player, C.COMMENT_ADDED);
|
||||
sendMessage(player, Captions.COMMENT_ADDED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,11 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
@ -104,6 +108,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, "TASK STARTED...");
|
||||
Condense.TASK = true;
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (!Condense.TASK) {
|
||||
@ -126,13 +131,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
}
|
||||
i++;
|
||||
final AtomicBoolean result = new AtomicBoolean(false);
|
||||
result.set(origin.move(possible, new Runnable() {
|
||||
@Override public void run() {
|
||||
if (result.get()) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Moving: " + origin + " -> " + possible);
|
||||
TaskManager.runTaskLater(task, 1);
|
||||
}
|
||||
result.set(origin.move(possible, () -> {
|
||||
if (result.get()) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Moving: " + origin + " -> " + possible);
|
||||
TaskManager.runTaskLater(task, 1);
|
||||
}
|
||||
}, false));
|
||||
if (result.get()) {
|
||||
@ -149,7 +152,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
}
|
||||
}
|
||||
};
|
||||
Condense.TASK = true;
|
||||
TaskManager.runTaskAsync(run);
|
||||
return true;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.CmdInstance;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -16,13 +16,13 @@ import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
CmdInstance command = CmdConfirm.getPending(player);
|
||||
if (command == null) {
|
||||
MainUtil.sendMessage(player, C.FAILED_CONFIRM);
|
||||
MainUtil.sendMessage(player, Captions.FAILED_CONFIRM);
|
||||
return false;
|
||||
}
|
||||
CmdConfirm.removePending(player);
|
||||
if ((System.currentTimeMillis() - command.timestamp)
|
||||
> Settings.Confirmation.CONFIRMATION_TIMEOUT_SECONDS * 1000) {
|
||||
MainUtil.sendMessage(player, C.EXPIRED_CONFIRM);
|
||||
MainUtil.sendMessage(player, Captions.EXPIRED_CONFIRM);
|
||||
return false;
|
||||
}
|
||||
TaskManager.runTask(command.command);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -17,29 +17,30 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasFlag(Flags.DONE)) {
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
int size = plot.getConnectedPlots().size();
|
||||
if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots()
|
||||
< player.getPlotCount() + size)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_ADMIN_COMMAND_CONTINUE);
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_ADMIN_COMMAND_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.removeFlag(Flags.DONE);
|
||||
MainUtil.sendMessage(player, C.DONE_REMOVED);
|
||||
MainUtil.sendMessage(player, Captions.DONE_REMOVED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -16,15 +16,15 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
@ -32,22 +32,18 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
Captions.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.copy(plot2, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, C.COPY_SUCCESS);
|
||||
}
|
||||
})) {
|
||||
if (plot1.copy(plot2, () -> MainUtil.sendMessage(player, Captions.COPY_SUCCESS))) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
@ -19,10 +19,10 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!(loc.getPlotArea() instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
HybridUtils.manager.setupRoadSchematic(plot);
|
||||
MainUtil.sendMessage(player,
|
||||
|
@ -30,25 +30,18 @@ import java.util.Map.Entry;
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots,
|
||||
final PlotPlayer player) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
try {
|
||||
ArrayList<Plot> ps = new ArrayList<>();
|
||||
for (Plot p : plots) {
|
||||
ps.add(p);
|
||||
}
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
manager.createPlotsAndData(ps, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
||||
manager.close();
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
MainUtil.sendMessage(player,
|
||||
"Failed to insert plot objects, see stacktrace for info");
|
||||
e.printStackTrace();
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
ArrayList<Plot> ps = new ArrayList<>(plots);
|
||||
MainUtil.sendMessage(player, "&6Starting...");
|
||||
manager.createPlotsAndData(ps, () -> {
|
||||
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
||||
manager.close();
|
||||
});
|
||||
} catch (Exception e) {
|
||||
MainUtil
|
||||
.sendMessage(player, "Failed to insert plot objects, see stacktrace for info");
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -94,8 +87,8 @@ import java.util.Map.Entry;
|
||||
HashMap<String, HashMap<PlotId, Plot>> map = manager.getPlots();
|
||||
plots = new ArrayList<>();
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : map.entrySet()) {
|
||||
String areaname = entry.getKey();
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaByString(areaname);
|
||||
String areaName = entry.getKey();
|
||||
PlotArea pa = PlotSquared.get().getPlotAreaByString(areaName);
|
||||
if (pa != null) {
|
||||
for (Entry<PlotId, Plot> entry2 : entry.getValue().entrySet()) {
|
||||
Plot plot = entry2.getValue();
|
||||
@ -130,20 +123,13 @@ import java.util.Map.Entry;
|
||||
plots.add(plot);
|
||||
}
|
||||
} else {
|
||||
HashMap<PlotId, Plot> plotmap =
|
||||
PlotSquared.get().plots_tmp.get(areaname);
|
||||
if (plotmap == null) {
|
||||
plotmap = new HashMap<>();
|
||||
PlotSquared.get().plots_tmp.put(areaname, plotmap);
|
||||
}
|
||||
plotmap.putAll(entry.getValue());
|
||||
HashMap<PlotId, Plot> plotMap = PlotSquared.get().plots_tmp
|
||||
.computeIfAbsent(areaName, k -> new HashMap<>());
|
||||
plotMap.putAll(entry.getValue());
|
||||
}
|
||||
}
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "&6Database conversion finished!");
|
||||
}
|
||||
});
|
||||
DBFunc.createPlotsAndData(plots,
|
||||
() -> MainUtil.sendMessage(player, "&6Database conversion finished!"));
|
||||
return true;
|
||||
case "mysql":
|
||||
if (args.length < 6) {
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -14,23 +14,23 @@ public class Debug extends SubCommand {
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
for (C caption : C.values()) {
|
||||
for (Captions caption : Captions.values()) {
|
||||
msg.append(caption.s()).append("\n");
|
||||
}
|
||||
MainUtil.sendMessage(player, msg.toString());
|
||||
return true;
|
||||
}
|
||||
StringBuilder information = new StringBuilder();
|
||||
String header = C.DEBUG_HEADER.s();
|
||||
String line = C.DEBUG_LINE.s();
|
||||
String section = C.DEBUG_SECTION.s();
|
||||
String header = Captions.DEBUG_HEADER.s();
|
||||
String line = Captions.DEBUG_LINE.s();
|
||||
String section = Captions.DEBUG_SECTION.s();
|
||||
information.append(header);
|
||||
information.append(getSection(section, "PlotArea"));
|
||||
information.append(
|
||||
getLine(line, "Plot Worlds", StringMan.join(PlotSquared.get().getPlotAreas(), ", ")));
|
||||
information.append(getLine(line, "Owned Plots", PlotSquared.get().getPlots().size()));
|
||||
information.append(getSection(section, "Messages"));
|
||||
information.append(getLine(line, "Total Messages", C.values().length));
|
||||
information.append(getLine(line, "Total Messages", Captions.values().length));
|
||||
information.append(getLine(line, "View all captions", "/plot debug msg"));
|
||||
MainUtil.sendMessage(player, information.toString());
|
||||
return true;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -19,10 +19,10 @@ import java.util.UUID;
|
||||
|
||||
if (unsafeAllowed.contains(player.getUUID())) {
|
||||
unsafeAllowed.remove(player.getUUID());
|
||||
sendMessage(player, C.DEBUGALLOWUNSAFE_OFF);
|
||||
sendMessage(player, Captions.DEBUGALLOWUNSAFE_OFF);
|
||||
} else {
|
||||
unsafeAllowed.add(player.getUUID());
|
||||
sendMessage(player, C.DEBUGALLOWUNSAFE_ON);
|
||||
sendMessage(player, Captions.DEBUGALLOWUNSAFE_ON);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
@ -29,7 +29,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||
return false;
|
||||
}
|
||||
PlotId min, max;
|
||||
@ -55,7 +55,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
MainUtil.sendMessage(player, " - &cDB Already contains: " + plot.getId());
|
||||
continue;
|
||||
}
|
||||
Location loc = manager.getSignLoc(area, plot);
|
||||
Location loc = manager.getSignLoc(plot);
|
||||
ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||
boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
if (!result) {
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
@ -17,12 +17,21 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import javax.script.*;
|
||||
import javax.script.Bindings;
|
||||
import javax.script.ScriptContext;
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import javax.script.SimpleScriptContext;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(command = "debugexec", permission = "plots.admin",
|
||||
@ -32,6 +41,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
private Bindings scope;
|
||||
|
||||
public DebugExec() {
|
||||
init();
|
||||
/*
|
||||
try {
|
||||
if (PlotSquared.get() != null) {
|
||||
File file = new File(PlotSquared.get().IMP.getDirectory(),
|
||||
@ -50,6 +61,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
} catch (IOException | ScriptException ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
@ -67,7 +79,15 @@ import java.util.concurrent.CompletableFuture;
|
||||
if (this.engine != null) {
|
||||
return;
|
||||
}
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("nashorn");
|
||||
//create script engine manager
|
||||
ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
|
||||
//create nashorn engine
|
||||
this.engine = scriptEngineManager.getEngineByName("nashorn");
|
||||
try {
|
||||
engine.eval("print('PlotSquared Scripting Test');");
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (this.engine == null) {
|
||||
this.engine = new ScriptEngineManager(null).getEngineByName("JavaScript");
|
||||
}
|
||||
@ -97,7 +117,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
this.scope.put("WEManager", new WEManager());
|
||||
}
|
||||
this.scope.put("TaskManager", TaskManager.IMP);
|
||||
this.scope.put("TitleManager", AbstractTitle.TITLE_CLASS);
|
||||
this.scope.put("ConsolePlayer", ConsolePlayer.getConsole());
|
||||
this.scope.put("SchematicHandler", SchematicHandler.manager);
|
||||
this.scope.put("ChunkManager", ChunkManager.manager);
|
||||
@ -112,7 +131,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
this.scope.put("MainCommand", MainCommand.getInstance());
|
||||
|
||||
// enums
|
||||
for (Enum<?> value : C.values()) {
|
||||
for (Enum<?> value : Captions.values()) {
|
||||
this.scope.put("C_" + value.name(), value);
|
||||
}
|
||||
}
|
||||
@ -130,7 +149,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
case "analyze": {
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
PlotAnalysis analysis = plot.getComplexity(null);
|
||||
@ -149,7 +168,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
}
|
||||
case "calibrate-analysis":
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot debugexec analyze <threshold>");
|
||||
MainUtil.sendMessage(player,
|
||||
"$1<threshold> $2= $1The percentage of plots you want to clear (100 clears 100% of plots so no point calibrating "
|
||||
@ -165,8 +184,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
"$1<threshold> $2= $1The percentage of plots you want to clear as a number between 0 - 100");
|
||||
return false;
|
||||
}
|
||||
PlotAnalysis.calcOptimalModifiers(
|
||||
() -> MainUtil.sendMessage(player, "$1Thank you for calibrating plot expiry"), threshold);
|
||||
PlotAnalysis.calcOptimalModifiers(() -> MainUtil
|
||||
.sendMessage(player, "$1Thank you for calibrating plot expiry"), threshold);
|
||||
return true;
|
||||
case "stop-expire":
|
||||
if (ExpireManager.IMP == null || !ExpireManager.IMP.cancelTask()) {
|
||||
@ -175,7 +194,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
return MainUtil.sendMessage(player, "Cancelled task.");
|
||||
case "remove-flag":
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot debugexec remove-flag <flag>");
|
||||
return false;
|
||||
}
|
||||
@ -195,7 +214,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[1]);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[1]);
|
||||
return false;
|
||||
}
|
||||
boolean result;
|
||||
@ -275,7 +294,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
DebugExec.this.engine.eval(cmd, DebugExec.this.scope);
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, C.COMMAND_WENT_WRONG);
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_WENT_WRONG);
|
||||
}
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
@ -283,8 +302,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil
|
||||
.sendMessage(player, C.COMMAND_SYNTAX, "/plot debugexec addcmd <file>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot debugexec addcmd <file>");
|
||||
return false;
|
||||
}
|
||||
case "runasync":
|
||||
@ -324,7 +343,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, "/plot debugexec list-scripts [#]");
|
||||
Captions.COMMAND_SYNTAX
|
||||
.send(player, "/plot debugexec list-scripts [#]");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -341,7 +361,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
return true;
|
||||
case "allcmd":
|
||||
if (args.length < 3) {
|
||||
C.COMMAND_SYNTAX
|
||||
Captions.COMMAND_SYNTAX
|
||||
.send(player, "/plot debugexec allcmd <condition> <command>");
|
||||
return false;
|
||||
}
|
||||
@ -381,7 +401,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
break;
|
||||
case "all":
|
||||
if (args.length < 3) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot debugexec all <condition> <code>");
|
||||
Captions.COMMAND_SYNTAX
|
||||
.send(player, "/plot debugexec all <condition> <code>");
|
||||
return false;
|
||||
}
|
||||
script =
|
||||
@ -394,7 +415,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
script = StringMan.join(args, " ");
|
||||
}
|
||||
if (!(player instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||
MainUtil.sendMessage(player, Captions.NOT_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
init();
|
||||
@ -411,8 +432,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PlotSquared.log(
|
||||
"> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
PlotSquared
|
||||
.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
|
||||
});
|
||||
} else {
|
||||
long start = System.currentTimeMillis();
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -28,7 +28,7 @@ public class DebugFixFlags extends SubCommand {
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
|
||||
if (area == null || !WorldUtil.IMP.isWorld(area.worldname)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD, args[0]);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, "&8--- &6Starting task &8 ---");
|
||||
|
@ -37,10 +37,20 @@ import java.util.concurrent.CompletableFuture;
|
||||
SinglePlotArea area = ((SinglePlotAreaManager) pam).getArea();
|
||||
PlotId id = new PlotId(0, 0);
|
||||
File container = PlotSquared.imp().getWorldContainer();
|
||||
if (container.equals(new File("."))) {
|
||||
player.sendMessage(
|
||||
"World container must be configured to be a separate directory to your base files!");
|
||||
return;
|
||||
}
|
||||
for (File folder : container.listFiles()) {
|
||||
String name = folder.getName();
|
||||
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromString(name) == null) {
|
||||
UUID uuid = UUIDHandler.getUUID(name, null);
|
||||
if (!WorldUtil.IMP.isWorld(name) && PlotId.fromStringOrNull(name) == null) {
|
||||
UUID uuid;
|
||||
if (name.length() > 16) {
|
||||
uuid = UUID.fromString(name);
|
||||
} else {
|
||||
uuid = UUIDHandler.getUUID(name, null);
|
||||
}
|
||||
if (uuid == null) {
|
||||
uuid =
|
||||
UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8));
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.IncendoPaster;
|
||||
@ -18,25 +18,37 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste",
|
||||
description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml and your latest.log to https://incendo.org",
|
||||
description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml and your latest.log to https://athion.net/ISPaster/paste",
|
||||
permission = "plots.debugpaste", category = CommandCategory.DEBUG) public class DebugPaste
|
||||
extends SubCommand {
|
||||
|
||||
private static String readFile(@NonNull final File file) throws IOException {
|
||||
final List<String> lines;
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
lines = reader.lines().collect(Collectors.toList());
|
||||
}
|
||||
final StringBuilder content = new StringBuilder();
|
||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||
content.append(lines.get(i)).append("\n");
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
final IncendoPaster incendoPaster = new IncendoPaster("plotsquared");
|
||||
|
||||
StringBuilder b = new StringBuilder();
|
||||
b.append(
|
||||
"# Welcome to this paste\n# It is meant to provide us at IntellectualSites with better information about your "
|
||||
+ "problem\n\n");
|
||||
b.append("# Server Information\n");
|
||||
b.append("server.version: ").append(PlotSquared.get().IMP.getServerImplementation()).append("\n");
|
||||
b.append("server.version: ").append(PlotSquared.get().IMP.getServerImplementation())
|
||||
.append("\n");
|
||||
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';')
|
||||
.append(!Settings.UUID.OFFLINE).append('\n');
|
||||
b.append("plugins:");
|
||||
@ -55,40 +67,42 @@ import java.util.List;
|
||||
b.append("memory.max: ").append(runtime.maxMemory()).append('\n');
|
||||
b.append("java.specification.version: '")
|
||||
.append(System.getProperty("java.specification.version")).append("'\n");
|
||||
b.append("java.vendor: '").append(System.getProperty("java.vendor"))
|
||||
.append("'\n");
|
||||
b.append("java.vendor: '").append(System.getProperty("java.vendor")).append("'\n");
|
||||
b.append("java.version: '").append(System.getProperty("java.version"))
|
||||
.append("'\n");
|
||||
b.append("os.arch: '").append(System.getProperty("os.arch")).append("'\n");
|
||||
b.append("os.name: '").append(System.getProperty("os.name")).append("'\n");
|
||||
b.append("os.version: '").append(System.getProperty("os.version"))
|
||||
.append("'\n\n");
|
||||
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
|
||||
b.append("# Okay :D Great. You are now ready to create your bug report!");
|
||||
b.append(
|
||||
"\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
|
||||
b.append("\n# or via our Discord at https://discord.gg/ngZCzbU");
|
||||
|
||||
final IncendoPaster incendoPaster = new IncendoPaster("plotsquared");
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("information", b.toString()));
|
||||
|
||||
try {
|
||||
final File logFile = new File(PlotSquared.get().IMP.getDirectory(),
|
||||
"../../logs/latest.log");
|
||||
final File logFile =
|
||||
new File(PlotSquared.get().IMP.getDirectory(), "../../logs/latest.log");
|
||||
if (Files.size(logFile.toPath()) > 14_000_000) {
|
||||
throw new IOException("Too big...");
|
||||
}
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("latest.log", readFile(logFile)));
|
||||
incendoPaster
|
||||
.addFile(new IncendoPaster.PasteFile("latest.log", readFile(logFile)));
|
||||
} catch (IOException ignored) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&clatest.log is too big to be pasted, will ignore");
|
||||
MainUtil
|
||||
.sendMessage(player, "&clatest.log is too big to be pasted, will ignore");
|
||||
}
|
||||
|
||||
try {
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("settings.yml", readFile(PlotSquared.get().configFile)));
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("settings.yml",
|
||||
readFile(PlotSquared.get().configFile)));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cSkipping settings.yml because it's empty");
|
||||
}
|
||||
try {
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("worlds.yml", readFile(PlotSquared.get().worldsFile)));
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("worlds.yml",
|
||||
readFile(PlotSquared.get().worldsFile)));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cSkipping worlds.yml because it's empty");
|
||||
}
|
||||
@ -96,25 +110,30 @@ import java.util.List;
|
||||
incendoPaster.addFile(new IncendoPaster.PasteFile("PlotSquared.use_THIS.yml",
|
||||
readFile(PlotSquared.get().translationFile)));
|
||||
} catch (final IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cSkipping PlotSquared.use_THIS.yml because it's empty");
|
||||
MainUtil.sendMessage(player,
|
||||
"&cSkipping PlotSquared.use_THIS.yml because it's empty");
|
||||
}
|
||||
|
||||
try {
|
||||
final String rawResponse = incendoPaster.upload();
|
||||
final JsonObject jsonObject = new JsonParser().parse(rawResponse).getAsJsonObject();
|
||||
final JsonObject jsonObject =
|
||||
new JsonParser().parse(rawResponse).getAsJsonObject();
|
||||
|
||||
if (jsonObject.has("created")) {
|
||||
final String pasteId = jsonObject.get("paste_id").getAsString();
|
||||
final String link = String.format("https://incendo.org/paste/view/%s", pasteId);
|
||||
player.sendMessage(
|
||||
C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
|
||||
final String link =
|
||||
String.format("https://athion.net/ISPaster/paste/view/%s", pasteId);
|
||||
player
|
||||
.sendMessage(Captions.DEBUG_REPORT_CREATED.s().replace("%url%", link));
|
||||
} else {
|
||||
final String responseMessage = jsonObject.get("response").getAsString();
|
||||
MainUtil.sendMessage(player, String.format("&cFailed to create the debug paste: %s", responseMessage));
|
||||
MainUtil.sendMessage(player, String
|
||||
.format("&cFailed to create the debug paste: %s", responseMessage));
|
||||
}
|
||||
} catch (final Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
MainUtil.sendMessage(player, "&cFailed to create the debug paste: " + throwable.getMessage());
|
||||
MainUtil.sendMessage(player,
|
||||
"&cFailed to create the debug paste: " + throwable.getMessage());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@ -122,19 +141,4 @@ import java.util.List;
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String readFile(@NonNull final File file) throws IOException {
|
||||
final StringBuilder content = new StringBuilder();
|
||||
final List<String> lines = new ArrayList<>();
|
||||
try (final BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
for (int i = Math.max(0, lines.size() - 1000); i < lines.size(); i++) {
|
||||
content.append(lines.get(i)).append("\n");
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
}
|
||||
|
@ -1,41 +1,109 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotWorld;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
|
||||
@CommandDeclaration(command = "debugroadregen", usage = "/plot debugroadregen",
|
||||
import java.util.Arrays;
|
||||
|
||||
@CommandDeclaration(command = "debugroadregen", usage = DebugRoadRegen.USAGE,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Regenerate all roads based on the road schematic",
|
||||
description = "Regenerate roads in the plot or region the user is, based on the road schematic",
|
||||
category = CommandCategory.DEBUG, permission = "plots.debugroadregen")
|
||||
public class DebugRoadRegen extends SubCommand {
|
||||
public static final String USAGE = "/plot debugroadregen <plot|region [height]>";
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
DebugRoadRegen.USAGE);
|
||||
return false;
|
||||
}
|
||||
String kind = args[0].toLowerCase();
|
||||
switch (kind) {
|
||||
case "plot":
|
||||
return regenPlot(player);
|
||||
|
||||
case "region":
|
||||
return regenRegion(player, Arrays.copyOfRange(args, 1, args.length));
|
||||
|
||||
default:
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
DebugRoadRegen.USAGE);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean regenPlot(PlotPlayer player) {
|
||||
Location loc = player.getLocation();
|
||||
PlotArea plotArea = loc.getPlotArea();
|
||||
if (!(plotArea instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
C.NOT_IN_PLOT.send(player);
|
||||
Captions.NOT_IN_PLOT.send(player);
|
||||
} else if (plot.isMerged()) {
|
||||
C.REQUIRES_UNMERGED.send(player);
|
||||
Captions.REQUIRES_UNMERGED.send(player);
|
||||
} else {
|
||||
HybridPlotManager manager = (HybridPlotManager) plotArea.getPlotManager();
|
||||
manager.createRoadEast(plotArea, plot);
|
||||
manager.createRoadSouth(plotArea, plot);
|
||||
manager.createRoadSouthEast(plotArea, plot);
|
||||
PlotManager manager = area.getPlotManager();
|
||||
manager.createRoadEast(plot);
|
||||
manager.createRoadSouth(plot);
|
||||
manager.createRoadSouthEast(plot);
|
||||
MainUtil.sendMessage(player, "&6Regenerating plot south/east roads: " + plot.getId()
|
||||
+ "\n&6 - Result: &aSuccess");
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean regenRegion(PlotPlayer player, String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
height = Integer.parseInt(args[0]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
DebugRoadRegen.USAGE);
|
||||
return false;
|
||||
}
|
||||
} else if (args.length != 0) {
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
DebugRoadRegen.USAGE);
|
||||
return false;
|
||||
}
|
||||
|
||||
Location loc = player.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
Plot plot = player.getCurrentPlot();
|
||||
PlotManager manager = area.getPlotManager();
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
||||
return true;
|
||||
}
|
||||
MainUtil
|
||||
.sendMessage(player, "&cIf no schematic is set, the following will not do anything");
|
||||
MainUtil.sendMessage(player,
|
||||
"&7 - To set a schematic, stand in a plot and use &c/plot createroadschematic");
|
||||
MainUtil.sendMessage(player, "&cTo regenerate all roads: /plot regenallroads");
|
||||
boolean result = HybridUtils.manager.scheduleSingleRegionRoadUpdate(plot, height);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&cCannot schedule mass schematic update! (Is one already in progress?)");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,10 @@ import java.util.ArrayList;
|
||||
public class DebugSaveTest extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
plots.addAll(PlotSquared.get().getPlots());
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
MainUtil.sendMessage(player, "&6Starting `DEBUGSAVETEST`");
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "&6Database sync finished!");
|
||||
}
|
||||
});
|
||||
DBFunc.createPlotsAndData(plots,
|
||||
() -> MainUtil.sendMessage(player, "&6Database sync finished!"));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
@ -16,18 +16,17 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
// The syntax also works with any command: /plot <plot> <command>
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(player, C.PLOT_UNOWNED);
|
||||
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DELETE)) {
|
||||
return !sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DELETE)) {
|
||||
return !sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
}
|
||||
final PlotArea plotArea = plot.getArea();
|
||||
final java.util.Set<Plot> plots = plot.getConnectedPlots();
|
||||
@ -36,7 +35,7 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return;
|
||||
}
|
||||
final long start = System.currentTimeMillis();
|
||||
@ -48,17 +47,17 @@ import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
double value = plots.size() * valueExr.evaluate((double) currentPlots);
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(player, value);
|
||||
sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));
|
||||
sendMessage(player, Captions.ADDED_BALANCE, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.DELETING_DONE,
|
||||
MainUtil.sendMessage(player, Captions.DELETING_DONE,
|
||||
System.currentTimeMillis() - start);
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
plot.addRunning();
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -3,20 +3,24 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "deny", aliases = {"d", "ban"},
|
||||
description = "Deny a user from a plot", usage = "/plot deny <player>",
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) public class Deny
|
||||
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny
|
||||
extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
@ -28,38 +32,36 @@ import java.util.UUID;
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DENY)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DENY)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid == DBFunc.EVERYONE && !(
|
||||
Permissions.hasPermission(player, C.PERMISSION_DENY_EVERYONE) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DENY))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
Permissions.hasPermission(player, Captions.PERMISSION_DENY_EVERYONE) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DENY))) {
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
continue;
|
||||
}
|
||||
if (plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
if (uuid != DBFunc.EVERYONE) {
|
||||
@ -77,7 +79,7 @@ import java.util.UUID;
|
||||
}
|
||||
}
|
||||
if (!uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.DENIED_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.DENIED_ADDED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -97,13 +99,13 @@ import java.util.UUID;
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
|
||||
MainUtil.sendMessage(player, C.YOU_GOT_DENIED);
|
||||
MainUtil.sendMessage(player, Captions.YOU_GOT_DENIED);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn =
|
||||
WorldUtil.IMP.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player.kick(C.YOU_GOT_DENIED.s());
|
||||
player.kick(Captions.YOU_GOT_DENIED.s());
|
||||
} else {
|
||||
player.teleport(newSpawn);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -11,20 +11,20 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
@CommandDeclaration(command = "setdescription", permission = "plots.set.desc",
|
||||
description = "Set the plot description", usage = "/plot desc <description>",
|
||||
aliases = {"desc", "setdesc", "setd", "description"}, category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE) public class Desc extends SetCommand {
|
||||
requiredType = RequiredType.PLAYER) public class Desc extends SetCommand {
|
||||
|
||||
@Override public boolean set(PlotPlayer player, Plot plot, String desc) {
|
||||
if (desc.isEmpty()) {
|
||||
plot.removeFlag(Flags.DESCRIPTION);
|
||||
MainUtil.sendMessage(player, C.DESC_UNSET);
|
||||
MainUtil.sendMessage(player, Captions.DESC_UNSET);
|
||||
return true;
|
||||
}
|
||||
boolean result = FlagManager.addPlotFlag(plot, Flags.DESCRIPTION, desc);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.DESC_SET);
|
||||
MainUtil.sendMessage(player, Captions.DESC_SET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(command = "dislike", permission = "plots.dislike",
|
||||
description = "Dislike the plot", usage = "/plot dislike [next|purge]",
|
||||
category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Dislike
|
||||
extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
return Like.handleLike(player, args, false);
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||
@ -22,23 +22,23 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DONE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DONE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.hasFlag(Flags.DONE)) {
|
||||
MainUtil.sendMessage(player, C.DONE_ALREADY_DONE);
|
||||
MainUtil.sendMessage(player, Captions.DONE_ALREADY_DONE);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK);
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_LINK);
|
||||
final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
|
||||
if (ExpireManager.IMP == null || doneRequirements == null) {
|
||||
finish(plot, player, true);
|
||||
@ -60,9 +60,9 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
|
||||
if (success) {
|
||||
long flagValue = System.currentTimeMillis() / 1000;
|
||||
plot.setFlag(Flags.DONE, flagValue);
|
||||
MainUtil.sendMessage(pp, C.DONE_SUCCESS);
|
||||
MainUtil.sendMessage(pp, Captions.DONE_SUCCESS);
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, C.DONE_INSUFFICIENT_COMPLEXITY);
|
||||
MainUtil.sendMessage(pp, Captions.DONE_INSUFFICIENT_COMPLEXITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -21,34 +21,34 @@ import java.net.URL;
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent()))
|
||||
&& !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
&& !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
|
||||
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if ((!plot.isOwner(player.getUUID())) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0 || (args.length == 1 && StringMan
|
||||
.isEqualIgnoreCaseToAny(args[0], "sch", "schem", "schematic"))) {
|
||||
if (plot.getVolume() > Integer.MAX_VALUE) {
|
||||
C.SCHEMATIC_TOO_LARGE.send(player);
|
||||
Captions.SCHEMATIC_TOO_LARGE.send(player);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
@ -58,7 +58,7 @@ import java.net.URL;
|
||||
SchematicHandler.manager.upload(value, null, null, new RunnableVal<URL>() {
|
||||
@Override public void run(URL url) {
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, url.toString());
|
||||
@ -68,8 +68,8 @@ import java.net.URL;
|
||||
});
|
||||
} else if (args.length == 1 && StringMan
|
||||
.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_WORLD)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_DOWNLOAD_WORLD);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_DOWNLOAD_WORLD)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_DOWNLOAD_WORLD);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, "&cNote: The `.mca` files are 512x512");
|
||||
@ -79,17 +79,17 @@ import java.net.URL;
|
||||
@Override public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_LINK_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, url.toString());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.GENERATING_LINK);
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_LINK);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,25 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.IntegerFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.ListFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.PlotBlockListFlag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -21,7 +32,8 @@ import java.util.*;
|
||||
private boolean checkPermValue(PlotPlayer player, Flag flag, String key, String value) {
|
||||
key = key.toLowerCase();
|
||||
value = value.toLowerCase();
|
||||
String perm = C.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(), value.toLowerCase());
|
||||
String perm =
|
||||
Captions.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(), value.toLowerCase());
|
||||
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
|
||||
try {
|
||||
int numeric = Integer.parseInt(value);
|
||||
@ -30,13 +42,39 @@ import java.util.*;
|
||||
int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
|
||||
numeric :
|
||||
Settings.Limit.MAX_PLOTS;
|
||||
return player.hasPermissionRange(perm, checkRange) >= numeric;
|
||||
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SET_FLAG_KEY_VALUE
|
||||
.f(key.toLowerCase(), value.toLowerCase()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
} else if (flag instanceof PlotBlockListFlag) {
|
||||
final PlotBlockListFlag blockListFlag = (PlotBlockListFlag) flag;
|
||||
final HashSet<PlotBlock> parsedBlocks = blockListFlag.parseValue(value);
|
||||
for (final PlotBlock block : parsedBlocks) {
|
||||
final String permission = Captions.PERMISSION_SET_FLAG_KEY_VALUE
|
||||
.f(key.toLowerCase(), block.getRawId().toString().toLowerCase());
|
||||
final boolean result = Permissions.hasPermission(player, permission);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SET_FLAG_KEY_VALUE
|
||||
.f(key.toLowerCase(), value.toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return Permissions.hasPermission(player, perm);
|
||||
final boolean result = Permissions.hasPermission(player, perm);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SET_FLAG_KEY_VALUE.f(key.toLowerCase(), value.toLowerCase()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@ -49,22 +87,24 @@ import java.util.*;
|
||||
* plot flag list
|
||||
*/
|
||||
if (args.length == 0) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot flag <set|remove|add|list|info>");
|
||||
return false;
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_SET_FLAG_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_OTHER);
|
||||
.hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER);
|
||||
return false;
|
||||
}
|
||||
Flag<?> flag = null;
|
||||
@ -77,47 +117,47 @@ import java.util.*;
|
||||
new StringComparison<>(args[1], Flags.getFlags());
|
||||
String best = stringComparison.getBestMatch();
|
||||
if (best != null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG_SUGGESTED, best);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best);
|
||||
suggested = true;
|
||||
}
|
||||
} catch (final Exception ignored) { /* Happens sometimes because of mean code */ }
|
||||
if (!suggested) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_FLAG);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.info");
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.flag.info");
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag info <flag>");
|
||||
return false;
|
||||
}
|
||||
// flag key
|
||||
MainUtil.sendMessage(player, C.FLAG_KEY, flag.getName());
|
||||
MainUtil.sendMessage(player, Captions.FLAG_KEY, flag.getName());
|
||||
// flag type
|
||||
MainUtil.sendMessage(player, C.FLAG_TYPE, flag.getClass().getSimpleName());
|
||||
MainUtil.sendMessage(player, Captions.FLAG_TYPE, flag.getClass().getSimpleName());
|
||||
// Flag type description
|
||||
MainUtil.sendMessage(player, C.FLAG_DESC, flag.getValueDescription());
|
||||
MainUtil.sendMessage(player, Captions.FLAG_DESC, flag.getValueDescription());
|
||||
return true;
|
||||
}
|
||||
case "set": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot flag set <flag> <value>");
|
||||
return false;
|
||||
}
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
if (!checkPermValue(player, flag, args[1], value)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE
|
||||
.f(args[1].toLowerCase(), value.toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
Object parsed = flag.parseValue(value);
|
||||
@ -127,33 +167,32 @@ import java.util.*;
|
||||
}
|
||||
boolean result = plot.setFlag(flag, parsed);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
|
||||
return true;
|
||||
}
|
||||
case "remove": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_REMOVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_REMOVE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_REMOVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_FLAG_REMOVE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot flag remove <flag> [values]");
|
||||
return false;
|
||||
}
|
||||
if (!Permissions
|
||||
.hasPermission(player, C.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()))) {
|
||||
if (!Permissions.hasPermission(player,
|
||||
Captions.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()))) {
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()));
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!checkPermValue(player, flag, args[1], entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -165,9 +204,19 @@ import java.util.*;
|
||||
if (flag1.isPresent()) {
|
||||
boolean o = flag1.get().removeAll((Collection) flag.parseValue(value));
|
||||
if (o) {
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
if (flag1.get().isEmpty()) {
|
||||
final boolean result = plot.removeFlag(flag);
|
||||
if (result) {
|
||||
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||
}
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -176,7 +225,7 @@ import java.util.*;
|
||||
} else {
|
||||
boolean result = plot.removeFlag(flag);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_REMOVED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_REMOVED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -185,23 +234,22 @@ import java.util.*;
|
||||
} else if (flag == Flags.WEATHER) {
|
||||
player.setWeather(PlotWeather.RESET);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_REMOVED);
|
||||
return true;
|
||||
}
|
||||
case "add":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_ADD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_ADD);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_ADD)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_ADD);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot flag add <flag> <values>");
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!checkPermValue(player, flag, args[1], entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -218,51 +266,52 @@ import java.util.*;
|
||||
if (flag1.isPresent()) {
|
||||
boolean o = flag1.get().addAll((Collection) parsed);
|
||||
if (o) {
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
|
||||
val = flag1.get();
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean result = plot.setFlag(flag, val);
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(player, C.FLAG_NOT_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
MainUtil.sendMessage(player, Captions.FLAG_ADDED);
|
||||
return true;
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_LIST)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_LIST);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_LIST)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_LIST);
|
||||
return false;
|
||||
}
|
||||
if (args.length > 1) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag list");
|
||||
return false;
|
||||
}
|
||||
HashMap<String, ArrayList<String>> flags = new HashMap<>();
|
||||
for (Flag<?> flag1 : Flags.getFlags()) {
|
||||
String type = flag1.getClass().getSimpleName();
|
||||
if (!flags.containsKey(type)) {
|
||||
flags.put(type, new ArrayList<String>());
|
||||
}
|
||||
flags.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
flags.get(type).add(flag1.getName());
|
||||
}
|
||||
String message = "";
|
||||
StringBuilder message = new StringBuilder();
|
||||
String prefix = "";
|
||||
for (Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
|
||||
String category = entry.getKey();
|
||||
List<String> flagNames = entry.getValue();
|
||||
Collections.sort(flagNames);
|
||||
message += prefix + "&6" + category + ": &7" + StringMan.join(flagNames, ", ");
|
||||
message.append(prefix).append("&6").append(category).append(": &7")
|
||||
.append(StringMan.join(flagNames, ", "));
|
||||
prefix = "\n";
|
||||
}
|
||||
MainUtil.sendMessage(player, message);
|
||||
MainUtil.sendMessage(player, message.toString());
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.io.File;
|
||||
@ -142,7 +142,7 @@ public class GenerateDocs {
|
||||
|
||||
Matcher m2 = p2.matcher(line);
|
||||
while (m2.find()) {
|
||||
perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s());
|
||||
perms.add(Captions.valueOf("PERMISSION_" + m2.group(1)).s());
|
||||
}
|
||||
if (line.contains("Permissions.hasPermission(")) {
|
||||
String[] split = line.split("Permissions.hasPermission");
|
||||
@ -151,7 +151,7 @@ public class GenerateDocs {
|
||||
String perm = method.split("[,|)]")[1].trim();
|
||||
if (!perm.equalsIgnoreCase(perm)) {
|
||||
if (perm.startsWith("C.")) {
|
||||
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||
perm = Captions.valueOf(perm.split("\\.")[1]).s();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
@ -181,7 +181,7 @@ public class GenerateDocs {
|
||||
String perm = method.split("[,|)]")[1].trim();
|
||||
if (!perm.equalsIgnoreCase(perm)) {
|
||||
if (perm.startsWith("C.")) {
|
||||
perm = C.valueOf(perm.split("\\.")[1]).s();
|
||||
perm = Captions.valueOf(perm.split("\\.")[1]).s();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
@ -27,33 +27,45 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length >= 1 && args.length <= 2, C.COMMAND_SYNTAX, getUsage());
|
||||
checkTrue(args.length >= 1 && args.length <= 2, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final String arg0 = args[0].toLowerCase();
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
case "check":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_GRANT.f(arg0))) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_GRANT.f(arg0));
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_GRANT.f(arg0))) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_GRANT.f(arg0));
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
if (args.length > 2) {
|
||||
break;
|
||||
}
|
||||
final UUID uuid =
|
||||
args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
|
||||
final UUID uuid;
|
||||
if (args.length == 2) {
|
||||
uuid = UUIDHandler.getUUIDFromString(args[1]);
|
||||
} else {
|
||||
uuid = player.getUUID();
|
||||
}
|
||||
if (uuid == null) {
|
||||
C.INVALID_PLAYER.send(player, args[1]);
|
||||
Captions.INVALID_PLAYER.send(player, args[1]);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
||||
@Override public void run(byte[] array) {
|
||||
if (arg0.equals("check")) { // check
|
||||
int granted =
|
||||
array == null ? 0 : ByteArrayUtilities.bytesToInteger(array);
|
||||
C.GRANTED_PLOTS.send(player, granted);
|
||||
int granted;
|
||||
if (array == null) {
|
||||
granted = 0;
|
||||
} else {
|
||||
granted = ByteArrayUtilities.bytesToInteger(array);
|
||||
}
|
||||
Captions.GRANTED_PLOTS.send(player, granted);
|
||||
} else { // add
|
||||
int amount =
|
||||
1 + (array == null ? 0 : ByteArrayUtilities.bytesToInteger(array));
|
||||
int amount;
|
||||
if (array == null) {
|
||||
amount = 1;
|
||||
} else {
|
||||
amount = 1 + ByteArrayUtilities.bytesToInteger(array);
|
||||
}
|
||||
boolean replace = array != null;
|
||||
String key = "grantedPlots";
|
||||
byte[] rawData = ByteArrayUtilities.integerToBytes(amount);
|
||||
@ -68,7 +80,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
});
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
@ -20,7 +21,7 @@ public class Help extends Command {
|
||||
super(parent, true);
|
||||
}
|
||||
|
||||
@Override public boolean canExecute(PlotPlayer player, boolean message) {
|
||||
@Override public boolean canExecute(CommandCaller player, boolean message) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -50,7 +51,7 @@ public class Help extends Command {
|
||||
}
|
||||
return CompletableFuture.completedFuture(false);
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
@ -76,10 +77,10 @@ public class Help extends Command {
|
||||
}
|
||||
if (cat == null && page == 0) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_HEADER.s());
|
||||
builder.append(Captions.HELP_HEADER.s());
|
||||
for (CommandCategory c : CommandCategory.values()) {
|
||||
builder.append("\n").append(StringMan
|
||||
.replaceAll(C.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(),
|
||||
.replaceAll(Captions.HELP_INFO_ITEM.s(), "%category%", c.toString().toLowerCase(),
|
||||
"%category_desc%", c.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all")
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
@ -11,21 +11,19 @@ import com.github.intellectualsites.plotsquared.plot.util.CommentManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot",
|
||||
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox",
|
||||
category = CommandCategory.CHAT, requiredType = RequiredType.NONE) public class Inbox
|
||||
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER) public class Inbox
|
||||
extends SubCommand {
|
||||
|
||||
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||
if (oldComments == null || oldComments.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INBOX_EMPTY);
|
||||
MainUtil.sendMessage(player, Captions.INBOX_EMPTY);
|
||||
return;
|
||||
}
|
||||
PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]);
|
||||
PlotComment[] comments = oldComments.toArray(new PlotComment[0]);
|
||||
if (page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
@ -42,7 +40,7 @@ import java.util.Optional;
|
||||
}
|
||||
StringBuilder string = new StringBuilder();
|
||||
string.append(StringMan
|
||||
.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur",
|
||||
.replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur",
|
||||
page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
|
||||
|
||||
// This might work xD
|
||||
@ -64,15 +62,15 @@ import java.util.Optional;
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
sendMessage(player, C.NOT_IN_PLOT);
|
||||
sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, C.PLOT_UNOWNED);
|
||||
sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX,
|
||||
sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||
if (inbox.canRead(plot, player)) {
|
||||
@ -95,16 +93,16 @@ import java.util.Optional;
|
||||
} else {
|
||||
color = "";
|
||||
}
|
||||
sendMessage(player, C.INBOX_ITEM,
|
||||
sendMessage(player, Captions.INBOX_ITEM,
|
||||
color + inbox.toString() + " (" + total + '/' + unread
|
||||
+ ')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
sendMessage(player, C.INBOX_ITEM, inbox.toString());
|
||||
sendMessage(player, Captions.INBOX_ITEM, inbox.toString());
|
||||
}
|
||||
})) {
|
||||
sendMessage(player, C.INBOX_ITEM, inbox.toString());
|
||||
sendMessage(player, Captions.INBOX_ITEM, inbox.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,7 +110,7 @@ import java.util.Optional;
|
||||
}
|
||||
final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||
if (inbox == null) {
|
||||
sendMessage(player, C.INVALID_INBOX,
|
||||
sendMessage(player, Captions.INVALID_INBOX,
|
||||
StringMan.join(CommentManager.inboxes.keySet(), ", "));
|
||||
return false;
|
||||
}
|
||||
@ -122,22 +120,22 @@ import java.util.Optional;
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "delete":
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
sendMessage(player, Captions.NO_PERM_INBOX_MODIFY);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX,
|
||||
sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot inbox " + inbox.toString() + " delete <index>");
|
||||
}
|
||||
final int index;
|
||||
try {
|
||||
index = Integer.parseInt(args[2]);
|
||||
if (index < 1) {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
sendMessage(player, Captions.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX,
|
||||
sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot inbox " + inbox.toString() + " delete <index>");
|
||||
return false;
|
||||
}
|
||||
@ -145,36 +143,35 @@ import java.util.Optional;
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
@Override public void run(List<PlotComment> value) {
|
||||
if (index > value.size()) {
|
||||
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||
sendMessage(player, Captions.NOT_VALID_INBOX_INDEX, index + "");
|
||||
return;
|
||||
}
|
||||
PlotComment comment = value.get(index - 1);
|
||||
inbox.removeComment(plot, comment);
|
||||
plot.getSettings().removeComment(comment);
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
|
||||
plot.removeComment(comment);
|
||||
MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, comment.comment);
|
||||
}
|
||||
})) {
|
||||
sendMessage(player, C.NOT_IN_PLOT);
|
||||
sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
case "clear":
|
||||
if (!inbox.canModify(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||
sendMessage(player, Captions.NO_PERM_INBOX_MODIFY);
|
||||
}
|
||||
inbox.clearInbox(plot);
|
||||
Optional<ArrayList<PlotComment>> comments =
|
||||
plot.getSettings().getComments(inbox.toString());
|
||||
if (comments.isPresent()) {
|
||||
plot.getSettings().removeComments(comments.get());
|
||||
List<PlotComment> comments = plot.getComments(inbox.toString());
|
||||
if (!comments.isEmpty()) {
|
||||
plot.removeComments(comments);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||
MainUtil.sendMessage(player, Captions.COMMENT_REMOVED, "*");
|
||||
return true;
|
||||
default:
|
||||
try {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
sendMessage(player, C.COMMAND_SYNTAX,
|
||||
sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot inbox [inbox] [delete <index>|clear|page]");
|
||||
return false;
|
||||
}
|
||||
@ -183,7 +180,7 @@ import java.util.Optional;
|
||||
page = 1;
|
||||
}
|
||||
if (!inbox.canRead(plot, player)) {
|
||||
sendMessage(player, C.NO_PERM_INBOX);
|
||||
sendMessage(player, Captions.NO_PERM_INBOX);
|
||||
return false;
|
||||
}
|
||||
if (!inbox.getComments(plot, new RunnableVal<List<PlotComment>>() {
|
||||
@ -191,7 +188,7 @@ import java.util.Optional;
|
||||
displayComments(player, value, page);
|
||||
}
|
||||
})) {
|
||||
sendMessage(player, C.PLOT_UNOWNED);
|
||||
sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1,8 +1,10 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
@ -10,8 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info",
|
||||
usage = "/plot info <id>", category = CommandCategory.INFO) public class Info
|
||||
extends SubCommand {
|
||||
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO)
|
||||
public class Info extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Plot plot;
|
||||
@ -31,6 +33,7 @@ import java.util.UUID;
|
||||
case "seen":
|
||||
case "owner":
|
||||
case "rating":
|
||||
case "likes":
|
||||
plot = MainUtil.getPlotFromString(player, null, false);
|
||||
break;
|
||||
default:
|
||||
@ -50,9 +53,10 @@ import java.util.UUID;
|
||||
plot = player.getCurrentPlot();
|
||||
}
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT.s());
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT.s());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (arg != null) {
|
||||
if (args.length == 1) {
|
||||
args = new String[0];
|
||||
@ -60,6 +64,26 @@ import java.util.UUID;
|
||||
args = new String[] {args[1]};
|
||||
}
|
||||
}
|
||||
|
||||
// hide-info flag
|
||||
if (plot.getFlag(Flags.HIDE_INFO).orElse(false)) {
|
||||
boolean allowed = false;
|
||||
for (final String argument : args) {
|
||||
if (argument.equalsIgnoreCase("-f")) {
|
||||
if (!player.hasPermission(Captions.PERMISSION_AREA_INFO_FORCE.s())) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_AREA_INFO_FORCE);
|
||||
return true;
|
||||
}
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed) {
|
||||
Captions.PLOT_INFO_HIDDEN.send(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("inv")) {
|
||||
PlotInventory inv = new PlotInventory(player) {
|
||||
@Override public boolean onClick(int index) {
|
||||
@ -69,7 +93,7 @@ import java.util.UUID;
|
||||
}
|
||||
};
|
||||
UUID uuid = player.getUUID();
|
||||
String name = MainUtil.getName(plot.owner);
|
||||
String name = MainUtil.getName(plot.getOwner());
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info",
|
||||
"&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name,
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
@ -97,18 +121,24 @@ import java.util.UUID;
|
||||
boolean trustedEveryone = plot.getMembers().contains(DBFunc.EVERYONE);
|
||||
// Unclaimed?
|
||||
if (!hasOwner && !containsEveryone && !trustedEveryone) {
|
||||
MainUtil
|
||||
.sendMessage(player, C.PLOT_INFO_UNCLAIMED, plot.getId().x + ";" + plot.getId().y);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_INFO_UNCLAIMED,
|
||||
plot.getId().x + ";" + plot.getId().y);
|
||||
return true;
|
||||
}
|
||||
String info = C.PLOT_INFO.s();
|
||||
String info = Captions.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, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, &arating");
|
||||
if (Settings.Ratings.USE_LIKES) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, " + " &alikes");
|
||||
} else {
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, " + " &arating");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
full = true;
|
||||
@ -118,7 +148,8 @@ import java.util.UUID;
|
||||
MainUtil.format(info, plot, player, full, new RunnableVal<String>() {
|
||||
@Override public void run(String value) {
|
||||
MainUtil.sendMessage(player,
|
||||
C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
|
||||
Captions.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + Captions.PLOT_INFO_FOOTER
|
||||
.s(), false);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
@ -127,27 +158,29 @@ import java.util.UUID;
|
||||
private String getCaption(String string) {
|
||||
switch (string) {
|
||||
case "trusted":
|
||||
return C.PLOT_INFO_TRUSTED.s();
|
||||
return Captions.PLOT_INFO_TRUSTED.s();
|
||||
case "alias":
|
||||
return C.PLOT_INFO_ALIAS.s();
|
||||
return Captions.PLOT_INFO_ALIAS.s();
|
||||
case "biome":
|
||||
return C.PLOT_INFO_BIOME.s();
|
||||
return Captions.PLOT_INFO_BIOME.s();
|
||||
case "denied":
|
||||
return C.PLOT_INFO_DENIED.s();
|
||||
return Captions.PLOT_INFO_DENIED.s();
|
||||
case "flags":
|
||||
return C.PLOT_INFO_FLAGS.s();
|
||||
return Captions.PLOT_INFO_FLAGS.s();
|
||||
case "id":
|
||||
return C.PLOT_INFO_ID.s();
|
||||
return Captions.PLOT_INFO_ID.s();
|
||||
case "size":
|
||||
return C.PLOT_INFO_SIZE.s();
|
||||
return Captions.PLOT_INFO_SIZE.s();
|
||||
case "members":
|
||||
return C.PLOT_INFO_MEMBERS.s();
|
||||
return Captions.PLOT_INFO_MEMBERS.s();
|
||||
case "owner":
|
||||
return C.PLOT_INFO_OWNER.s();
|
||||
return Captions.PLOT_INFO_OWNER.s();
|
||||
case "rating":
|
||||
return C.PLOT_INFO_RATING.s();
|
||||
return Captions.PLOT_INFO_RATING.s();
|
||||
case "likes":
|
||||
return Captions.PLOT_INFO_LIKES.s();
|
||||
case "seen":
|
||||
return C.PLOT_INFO_SEEN.s();
|
||||
return Captions.PLOT_INFO_SEEN.s();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -19,7 +19,7 @@ import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "kick", aliases = {"k"}, description = "Kick a player from your plot",
|
||||
permission = "plots.kick", usage = "/plot kick <player>", category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.NONE) public class Kick extends SubCommand {
|
||||
requiredType = RequiredType.PLAYER) public class Kick extends SubCommand {
|
||||
|
||||
public Kick() {
|
||||
super(Argument.PlayerName);
|
||||
@ -29,16 +29,16 @@ import java.util.UUID;
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_KICK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_KICK)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (uuids.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
@ -46,7 +46,7 @@ import java.util.UUID;
|
||||
if (uuid == DBFunc.EVERYONE) {
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
if (pp == player || Permissions
|
||||
.hasPermission(pp, C.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
.hasPermission(pp, Captions.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
continue;
|
||||
}
|
||||
players.add(pp);
|
||||
@ -60,26 +60,26 @@ import java.util.UUID;
|
||||
}
|
||||
players.remove(player); // Don't ever kick the calling player
|
||||
if (players.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
for (PlotPlayer player2 : players) {
|
||||
if (!plot.equals(player2.getCurrentPlot())) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
if (Permissions.hasPermission(player2, C.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
C.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
||||
if (Permissions.hasPermission(player2, Captions.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
Captions.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
||||
return false;
|
||||
}
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
C.YOU_GOT_KICKED.send(player2);
|
||||
Captions.YOU_GOT_KICKED.send(player2);
|
||||
if (plot.equals(spawn.getPlot())) {
|
||||
Location newSpawn = WorldUtil.IMP
|
||||
.getSpawn(PlotSquared.get().getPlotAreaManager().getAllWorlds()[0]);
|
||||
if (plot.equals(newSpawn.getPlot())) {
|
||||
// Kick from server if you can't be teleported to spawn
|
||||
player2.kick(C.YOU_GOT_KICKED.s());
|
||||
player2.kick(Captions.YOU_GOT_KICKED.s());
|
||||
} else {
|
||||
player2.plotkick(newSpawn);
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
@ -24,12 +24,12 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(plot.isAdded(player.getUUID()), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), Captions.PLOT_UNOWNED);
|
||||
checkTrue(plot.isAdded(player.getUUID()), Captions.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 0, Captions.COMMAND_SYNTAX, getUsage());
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
checkTrue(plot.hasOwner(), C.ALREADY_OWNER);
|
||||
checkTrue(plot.hasOwner(), Captions.ALREADY_OWNER);
|
||||
// TODO setowner, other
|
||||
} else {
|
||||
UUID uuid = player.getUUID();
|
||||
@ -40,9 +40,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
if (plot.removeMember(uuid)) {
|
||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, 1);
|
||||
MainUtil.sendMessage(player, Captions.REMOVED_PLAYERS, 1);
|
||||
}
|
||||
}
|
||||
return CompletableFuture.completedFuture(true);
|
||||
|
@ -0,0 +1,147 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot",
|
||||
usage = "/plot like [next|purge]", category = CommandCategory.INFO,
|
||||
requiredType = RequiredType.PLAYER) public class Like extends SubCommand {
|
||||
|
||||
protected static boolean handleLike(final PlotPlayer player, String[] args,
|
||||
final boolean like) {
|
||||
final UUID uuid = player.getUUID();
|
||||
if (args.length == 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "next": {
|
||||
final List<Plot> plots = new ArrayList<>(PlotSquared.get().getBasePlots());
|
||||
plots.sort((p1, p2) -> {
|
||||
double v1 = getLikesPercentage(p1);
|
||||
double v2 = getLikesPercentage(p2);
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
});
|
||||
for (final Plot plot : plots) {
|
||||
if ((!Settings.Done.REQUIRED_FOR_RATINGS || plot.hasFlag(Flags.DONE))
|
||||
&& plot.isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
|
||||
plot.teleportPlayer(player);
|
||||
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
||||
return true;
|
||||
}
|
||||
case "purge": {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_RATE, true)) {
|
||||
return false;
|
||||
}
|
||||
plot.clearRatings();
|
||||
Captions.RATINGS_PURGED.send(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, Captions.RATING_NOT_OWNED);
|
||||
return false;
|
||||
}
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
|
||||
return false;
|
||||
}
|
||||
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) {
|
||||
sendMessage(player, Captions.RATING_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
final Runnable run = () -> {
|
||||
final Boolean oldRating = plot.getLikes().get(uuid);
|
||||
if (oldRating != null) {
|
||||
sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
final int rating;
|
||||
if (like) {
|
||||
rating = 10;
|
||||
} else {
|
||||
rating = 1;
|
||||
}
|
||||
plot.addRating(uuid, new Rating(rating));
|
||||
final Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
if (result != null) {
|
||||
plot.addRating(uuid, result);
|
||||
if (like) {
|
||||
sendMessage(player, Captions.RATING_LIKED, plot.getId().toString());
|
||||
} else {
|
||||
sendMessage(player, Captions.RATING_DISLIKED, plot.getId().toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
plot.getSettings().ratings = new HashMap<>();
|
||||
}
|
||||
run.run();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the likes to dislike ratio of a plot as a percentage (in decimal form)
|
||||
*
|
||||
* @return likes to dislike ratio, returns zero if the plot has no likes
|
||||
*/
|
||||
public static double getLikesPercentage(final Plot plot) {
|
||||
if (!plot.hasRatings()) {
|
||||
return 0;
|
||||
}
|
||||
final Collection<Boolean> reactions = plot.getLikes().values();
|
||||
double numLikes = 0, numDislikes = 0;
|
||||
for (final boolean reaction : reactions) {
|
||||
if (reaction) {
|
||||
numLikes += 1;
|
||||
} else {
|
||||
numDislikes += 1;
|
||||
}
|
||||
}
|
||||
if (numLikes == 0 && numDislikes == 0) {
|
||||
return 0D;
|
||||
} else if (numDislikes == 0) {
|
||||
return 1.0D;
|
||||
}
|
||||
return numLikes / (numLikes + numDislikes);
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
return handleLike(player, args, true);
|
||||
}
|
||||
|
||||
}
|
@ -3,14 +3,24 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared.SortType;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Rating;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "list", aliases = {"l", "find", "search"}, description = "List plots",
|
||||
permission = "plots.list", category = CommandCategory.INFO,
|
||||
@ -20,43 +30,43 @@ public class ListCmd extends SubCommand {
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
List<String> args = new ArrayList<>();
|
||||
if (EconHandler.manager != null && Permissions
|
||||
.hasPermission(player, C.PERMISSION_LIST_FORSALE)) {
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
||||
args.add("forsale");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_MINE)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_MINE)) {
|
||||
args.add("mine");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_SHARED)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_SHARED)) {
|
||||
args.add("shared");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
args.add("world");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_TOP)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) {
|
||||
args.add("top");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_ALL)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_ALL)) {
|
||||
args.add("all");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_UNOWNED)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_UNOWNED)) {
|
||||
args.add("unowned");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_UNKNOWN)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_UNKNOWN)) {
|
||||
args.add("unknown");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_PLAYER)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_PLAYER)) {
|
||||
args.add("<player>");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
args.add("<world>");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_DONE)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_DONE)) {
|
||||
args.add("done");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_EXPIRED)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_EXPIRED)) {
|
||||
args.add("expired");
|
||||
}
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_FUZZY)) {
|
||||
if (Permissions.hasPermission(player, Captions.PERMISSION_LIST_FUZZY)) {
|
||||
args.add("fuzzy <search...>");
|
||||
}
|
||||
return args.toArray(new String[args.size()]);
|
||||
@ -64,7 +74,7 @@ public class ListCmd extends SubCommand {
|
||||
|
||||
public void noArgs(PlotPlayer player) {
|
||||
MainUtil.sendMessage(player,
|
||||
C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(player)));
|
||||
Captions.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(player)));
|
||||
}
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
@ -93,16 +103,18 @@ public class ListCmd extends SubCommand {
|
||||
boolean sort = true;
|
||||
switch (arg) {
|
||||
case "mine":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_MINE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_MINE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_MINE)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_MINE);
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
plots = PlotSquared.get().sortPlotsByTemp(PlotSquared.get().getBasePlots(player));
|
||||
break;
|
||||
case "shared":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_SHARED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_SHARED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_SHARED)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_SHARED);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -114,20 +126,23 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "world":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.get().getPlots(world));
|
||||
break;
|
||||
case "expired":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_EXPIRED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_EXPIRED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_EXPIRED)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_EXPIRED);
|
||||
return false;
|
||||
}
|
||||
plots = ExpireManager.IMP == null ?
|
||||
@ -135,27 +150,31 @@ public class ListCmd extends SubCommand {
|
||||
new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
||||
break;
|
||||
case "area":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_AREA)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_AREA);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_AREA)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_AREA);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
return false;
|
||||
}
|
||||
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
||||
break;
|
||||
case "all":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_ALL)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_ALL);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_ALL)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_ALL);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
break;
|
||||
case "done":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_DONE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_DONE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_DONE)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_DONE);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -165,60 +184,56 @@ public class ListCmd extends SubCommand {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override public int compare(Plot a, Plot b) {
|
||||
String va = "" + a.getFlags().get(Flags.DONE);
|
||||
String vb = "" + b.getFlags().get(Flags.DONE);
|
||||
if (MathMan.isInteger(va)) {
|
||||
if (MathMan.isInteger(vb)) {
|
||||
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||
}
|
||||
return -1;
|
||||
plots.sort((a, b) -> {
|
||||
String va = "" + a.getFlags().get(Flags.DONE);
|
||||
String vb = "" + b.getFlags().get(Flags.DONE);
|
||||
if (MathMan.isInteger(va)) {
|
||||
if (MathMan.isInteger(vb)) {
|
||||
return Integer.parseInt(vb) - Integer.parseInt(va);
|
||||
}
|
||||
return 1;
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
});
|
||||
sort = false;
|
||||
break;
|
||||
case "top":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_TOP)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_TOP);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_TOP)) {
|
||||
MainUtil
|
||||
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_TOP);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.get().getPlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
int p1s = p1.getSettings().getRatings().size();
|
||||
int p2s = p2.getRatings().size();
|
||||
if (!p1.getSettings().getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
double av = entry.getValue().getAverageRating();
|
||||
v1 += av * av;
|
||||
}
|
||||
v1 /= p1s;
|
||||
v1 += p1s;
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getSettings().getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
double av = entry.getValue().getAverageRating();
|
||||
v2 += av * av;
|
||||
}
|
||||
v2 /= p2s;
|
||||
v2 += p2s;
|
||||
}
|
||||
if (v2 == v1 && v2 != 0) {
|
||||
return p2s - p1s;
|
||||
}
|
||||
return (int) Math.signum(v2 - v1);
|
||||
plots.sort((p1, p2) -> {
|
||||
double v1 = 0;
|
||||
int p1s = p1.getSettings().getRatings().size();
|
||||
int p2s = p2.getRatings().size();
|
||||
if (!p1.getSettings().getRatings().isEmpty()) {
|
||||
v1 = p1.getRatings().values().stream().mapToDouble(Rating::getAverageRating)
|
||||
.map(av -> av * av).sum();
|
||||
v1 /= p1s;
|
||||
v1 += p1s;
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getSettings().getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
double av = entry.getValue().getAverageRating();
|
||||
v2 += av * av;
|
||||
}
|
||||
v2 /= p2s;
|
||||
v2 += p2s;
|
||||
}
|
||||
if (v2 == v1 && v2 != 0) {
|
||||
return p2s - p1s;
|
||||
}
|
||||
return (int) Math.signum(v2 - v1);
|
||||
});
|
||||
sort = false;
|
||||
break;
|
||||
case "forsale":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_FORSALE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_FORSALE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FOR_SALE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_FOR_SALE);
|
||||
return false;
|
||||
}
|
||||
if (EconHandler.manager == null) {
|
||||
@ -233,39 +248,42 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "unowned":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_UNOWNED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_UNOWNED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_UNOWNED)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "unknown":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_UNKNOWN)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_UNKNOWN);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_UNKNOWN)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PlotSquared.get().getPlots()) {
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
continue;
|
||||
}
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
if (UUIDHandler.getName(plot.getOwner()) == null) {
|
||||
plots.add(plot);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "fuzzy":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_FUZZY)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_FUZZY);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_FUZZY)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_FUZZY);
|
||||
return false;
|
||||
}
|
||||
if (args.length < (page == -1 ? 2 : 3)) {
|
||||
C.COMMAND_SYNTAX.send(player, "/plot list fuzzy <search...> [#]");
|
||||
Captions.COMMAND_SYNTAX.send(player, "/plot list fuzzy <search...> [#]");
|
||||
return false;
|
||||
}
|
||||
String term;
|
||||
@ -279,14 +297,15 @@ public class ListCmd extends SubCommand {
|
||||
break;
|
||||
default:
|
||||
if (PlotSquared.get().hasPlotArea(args[0])) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions
|
||||
.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(args[0]))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_LIST_WORLD_NAME.f(args[0]));
|
||||
.hasPermission(player, Captions.PERMISSION_LIST_WORLD_NAME.f(args[0]))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_WORLD_NAME.f(args[0]));
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PlotSquared.get().getPlots(args[0]));
|
||||
@ -300,8 +319,9 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (uuid != null) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_PLAYER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_PLAYER);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_LIST_PLAYER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_LIST_PLAYER);
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
@ -311,14 +331,14 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
|
||||
if (plots == null) {
|
||||
sendMessage(player, C.DID_YOU_MEAN,
|
||||
sendMessage(player, Captions.DID_YOU_MEAN,
|
||||
new StringComparison<>(args[0], new String[] {"mine", "shared", "world", "all"})
|
||||
.getBestMatch());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plots.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
displayPlots(player, plots, 12, page, area, args, sort);
|
||||
@ -341,7 +361,7 @@ public class ListCmd extends SubCommand {
|
||||
new RunnableVal3<Integer, Plot, PlotMessage>() {
|
||||
@Override public void run(Integer i, Plot plot, PlotMessage message) {
|
||||
String color;
|
||||
if (plot.owner == null) {
|
||||
if (plot.getOwner() == null) {
|
||||
color = "$3";
|
||||
} else if (plot.isOwner(player.getUUID())) {
|
||||
color = "$1";
|
||||
@ -352,18 +372,20 @@ public class ListCmd extends SubCommand {
|
||||
} else {
|
||||
color = "$1";
|
||||
}
|
||||
PlotMessage trusted = new PlotMessage().text(C.color(C.PLOT_INFO_TRUSTED.s()
|
||||
.replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted()))))
|
||||
PlotMessage trusted = new PlotMessage().text(Captions.color(
|
||||
Captions.PLOT_INFO_TRUSTED.s()
|
||||
.replaceAll("%trusted%", MainUtil.getPlayerList(plot.getTrusted()))))
|
||||
.color("$1");
|
||||
PlotMessage members = new PlotMessage().text(C.color(C.PLOT_INFO_MEMBERS.s()
|
||||
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
|
||||
PlotMessage members = new PlotMessage().text(Captions.color(
|
||||
Captions.PLOT_INFO_MEMBERS.s()
|
||||
.replaceAll("%members%", MainUtil.getPlayerList(plot.getMembers()))))
|
||||
.color("$1");
|
||||
String strFlags = StringMan.join(plot.getFlags().values(), ",");
|
||||
if (strFlags.isEmpty()) {
|
||||
strFlags = C.NONE.s();
|
||||
strFlags = Captions.NONE.s();
|
||||
}
|
||||
PlotMessage flags = new PlotMessage()
|
||||
.text(C.color(C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags)))
|
||||
PlotMessage flags = new PlotMessage().text(Captions
|
||||
.color(Captions.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags)))
|
||||
.color("$1");
|
||||
message.text("[").color("$3").text(i + "")
|
||||
.command("/plot visit " + plot.getArea() + ";" + plot.getId())
|
||||
@ -391,7 +413,7 @@ public class ListCmd extends SubCommand {
|
||||
prefix = ", ";
|
||||
}
|
||||
}
|
||||
}, "/plot list " + args[0], C.PLOT_LIST_HEADER_PAGED.s());
|
||||
}, "/plot list " + args[0], Captions.PLOT_LIST_HEADER_PAGED.s());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
@ -22,23 +26,23 @@ import java.util.List;
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_LOAD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_LOAD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -47,46 +51,46 @@ import java.util.List;
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
if (schematics == null) {
|
||||
// No schematics found:
|
||||
MainUtil.sendMessage(player, C.LOAD_NULL);
|
||||
MainUtil.sendMessage(player, Captions.LOAD_NULL);
|
||||
return false;
|
||||
}
|
||||
String schem;
|
||||
String schematic;
|
||||
try {
|
||||
schem = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
schematic = schematics.get(Integer.parseInt(args[0]) - 1);
|
||||
} catch (Exception ignored) {
|
||||
// use /plot load <index>
|
||||
MainUtil
|
||||
.sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + schematics.size() + ')');
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER,
|
||||
"(1, " + schematics.size() + ')');
|
||||
return false;
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schem);
|
||||
url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic);
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, C.LOAD_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.LOAD_FAILED);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
Schematic schematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (schematic == null) {
|
||||
Schematic taskSchematic = SchematicHandler.manager.getSchematic(url);
|
||||
if (taskSchematic == null) {
|
||||
plot.removeRunning();
|
||||
sendMessage(player, C.SCHEMATIC_INVALID,
|
||||
sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||
"non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
PlotArea area = plot.getArea();
|
||||
SchematicHandler.manager
|
||||
.paste(schematic, plot, 0, area.MIN_BUILD_HEIGHT, 0, false,
|
||||
.paste(taskSchematic, plot, 0, area.MIN_BUILD_HEIGHT, 0, false,
|
||||
new RunnableVal<Boolean>() {
|
||||
@Override public void run(Boolean value) {
|
||||
plot.removeRunning();
|
||||
if (value) {
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
sendMessage(player, Captions.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
sendMessage(player, Captions.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -94,7 +98,7 @@ import java.util.List;
|
||||
return true;
|
||||
}
|
||||
plot.removeRunning();
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot load <index>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot load <index>");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -107,7 +111,7 @@ import java.util.List;
|
||||
List<String> schematics1 = SchematicHandler.manager.getSaves(player.getUUID());
|
||||
plot.removeRunning();
|
||||
if ((schematics1 == null) || schematics1.isEmpty()) {
|
||||
MainUtil.sendMessage(player, C.LOAD_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.LOAD_FAILED);
|
||||
return;
|
||||
}
|
||||
player.setMeta("plot_schematics", schematics1);
|
||||
@ -141,7 +145,7 @@ import java.util.List;
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.LOAD_LIST);
|
||||
MainUtil.sendMessage(player, Captions.LOAD_LIST);
|
||||
}
|
||||
|
||||
public String secToTime(long time) {
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
@ -69,7 +70,6 @@ public class MainCommand extends Command {
|
||||
new DebugPaste();
|
||||
new Unlink();
|
||||
new Kick();
|
||||
new Rate();
|
||||
new DebugClaimTest();
|
||||
new Inbox();
|
||||
new Comment();
|
||||
@ -99,6 +99,14 @@ public class MainCommand extends Command {
|
||||
new SetHome();
|
||||
new Cluster();
|
||||
new DebugImportWorlds();
|
||||
|
||||
if (Settings.Ratings.USE_LIKES) {
|
||||
new Like();
|
||||
new Dislike();
|
||||
} else {
|
||||
new Rate();
|
||||
}
|
||||
|
||||
// Referenced commands
|
||||
instance.toggle = new Toggle();
|
||||
instance.help = new Help(instance);
|
||||
@ -131,10 +139,8 @@ public class MainCommand extends Command {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval =
|
||||
area.PRICES.get(cmd.getFullId());
|
||||
Double price =
|
||||
priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != null
|
||||
&& EconHandler.manager.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
@ -181,13 +187,6 @@ public class MainCommand extends Command {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @Deprecated legacy
|
||||
*/ public void addCommand(SubCommand command) {
|
||||
PlotSquared.debug("Command registration is now done during instantiation");
|
||||
}
|
||||
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
@ -201,8 +200,8 @@ public class MainCommand extends Command {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
Plot newPlot = Plot.fromString(area, args[0]);
|
||||
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea()
|
||||
.equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot
|
||||
.isDenied(player.getUUID())) {
|
||||
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN))
|
||||
&& !newPlot.isDenied(player.getUUID())) {
|
||||
Location newLoc = newPlot.getCenter();
|
||||
if (player.canTeleport(newLoc)) {
|
||||
// Save meta
|
||||
@ -213,7 +212,7 @@ public class MainCommand extends Command {
|
||||
player.setMeta(PlotPlayer.META_LOCATION, newLoc);
|
||||
player.setMeta(PlotPlayer.META_LAST_PLOT, newPlot);
|
||||
} else {
|
||||
C.BORDER.send(player);
|
||||
Captions.BORDER.send(player);
|
||||
}
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
@ -243,7 +242,7 @@ public class MainCommand extends Command {
|
||||
};
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
} else {
|
||||
C.INVALID_COMMAND_FLAG.send(player);
|
||||
Captions.INVALID_COMMAND_FLAG.send(player);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
}
|
||||
@ -256,9 +255,9 @@ public class MainCommand extends Command {
|
||||
e.printStackTrace();
|
||||
String message = e.getLocalizedMessage();
|
||||
if (message != null) {
|
||||
C.ERROR.send(player, message);
|
||||
Captions.ERROR.send(player, message);
|
||||
} else {
|
||||
C.ERROR.send(player);
|
||||
Captions.ERROR.send(player);
|
||||
}
|
||||
}
|
||||
// Reset command scope //
|
||||
@ -277,7 +276,7 @@ public class MainCommand extends Command {
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
|
||||
@Override public boolean canExecute(PlotPlayer player, boolean message) {
|
||||
@Override public boolean canExecute(CommandCaller player, boolean message) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,19 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Expression;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EconHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -43,35 +52,34 @@ public class Merge extends SubCommand {
|
||||
Location loc = player.getLocationFull();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
UUID uuid = player.getUUID();
|
||||
if (!plot.isOwner(uuid)) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
} else {
|
||||
uuid = plot.guessOwner();
|
||||
}
|
||||
}
|
||||
final PlotArea plotArea = plot.getArea();
|
||||
Expression<Double> priceExr =
|
||||
plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null;
|
||||
Expression<Double> priceExr = plotArea.PRICES.getOrDefault("merge", null);
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d
|
||||
&& EconHandler.manager.getMoney(player) < price) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return false;
|
||||
}
|
||||
final int maxSize =
|
||||
Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
|
||||
if (size - 1 > maxSize) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION, "plots.merge." + (size + 1));
|
||||
return false;
|
||||
}
|
||||
int direction = -1;
|
||||
@ -96,19 +104,21 @@ public class Merge extends SubCommand {
|
||||
if (args.length == 2) {
|
||||
terrain = "true".equalsIgnoreCase(args[1]);
|
||||
}
|
||||
if(!terrain && !Permissions.hasPermission(player, C.PERMISSION_MERGE_KEEPROAD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_MERGE_KEEPROAD.s());
|
||||
if (!terrain && !Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_MERGE_KEEP_ROAD.s());
|
||||
return true;
|
||||
}
|
||||
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
|
||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
|
||||
}
|
||||
@ -120,10 +130,10 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (direction == -1) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot merge <" + StringMan.join(values, "|") + "> [removeroads]");
|
||||
MainUtil
|
||||
.sendMessage(player, C.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||
MainUtil.sendMessage(player,
|
||||
Captions.DIRECTION.s().replaceAll("%dir%", direction(loc.getYaw())));
|
||||
return false;
|
||||
}
|
||||
final boolean terrain;
|
||||
@ -132,26 +142,27 @@ public class Merge extends SubCommand {
|
||||
} else {
|
||||
terrain = true;
|
||||
}
|
||||
if(!terrain && !Permissions.hasPermission(player, C.PERMISSION_MERGE_KEEPROAD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_MERGE_KEEPROAD.s());
|
||||
if (!terrain && !Permissions.hasPermission(player, Captions.PERMISSION_MERGE_KEEP_ROAD)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_MERGE_KEEP_ROAD.s());
|
||||
return true;
|
||||
}
|
||||
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
|
||||
return true;
|
||||
}
|
||||
Plot adjacent = plot.getRelative(direction);
|
||||
if (adjacent == null || !adjacent.hasOwner() || adjacent.getMerged((direction + 2) % 4)
|
||||
|| adjacent.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
|
||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_MERGE_OTHER);
|
||||
return false;
|
||||
}
|
||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||
@ -164,35 +175,35 @@ public class Merge extends SubCommand {
|
||||
isOnline = true;
|
||||
final int dir = direction;
|
||||
Runnable run = () -> {
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
MainUtil.sendMessage(accepter, Captions.MERGE_ACCEPTED);
|
||||
plot.autoMerge(dir, maxSize - size, owner, terrain);
|
||||
PlotPlayer plotPlayer = UUIDHandler.getPlayer(player.getUUID());
|
||||
if (plotPlayer == null) {
|
||||
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||
sendMessage(accepter, Captions.MERGE_NOT_VALID);
|
||||
return;
|
||||
}
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < price) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
sendMessage(player, Captions.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(player, price);
|
||||
sendMessage(player, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
sendMessage(player, Captions.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SUCCESS_MERGE);
|
||||
MainUtil.sendMessage(player, Captions.SUCCESS_MERGE);
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(accepter,
|
||||
C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", player.getName()), run);
|
||||
Captions.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", player.getName()), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
if (!isOnline) {
|
||||
MainUtil.sendMessage(player, C.NO_AVAILABLE_AUTOMERGE);
|
||||
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.MERGE_REQUESTED);
|
||||
MainUtil.sendMessage(player, Captions.MERGE_REQUESTED);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -18,10 +18,10 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT);
|
||||
return sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(player, C.PLOT_UNOWNED);
|
||||
return sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
}
|
||||
player.teleport(plot.getCenter());
|
||||
return true;
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
@ -12,17 +12,17 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
|
||||
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot",
|
||||
aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE) public class Move extends SubCommand {
|
||||
requiredType = RequiredType.PLAYER) public class Move extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
boolean override = false;
|
||||
@ -31,7 +31,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
override = true;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
|
||||
@ -45,19 +45,19 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
plot2 = area.getPlotAbs(plot1.getId());
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea()) && (!override || !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN.s()))) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN.s()))) {
|
||||
Captions.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.move(plot2, () -> MainUtil.sendMessage(player, C.MOVE_SUCCESS), false)) {
|
||||
if (plot1.move(plot2, () -> MainUtil.sendMessage(player, Captions.MOVE_SUCCESS), false)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REQUIRES_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.REQUIRES_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
|
||||
@ -14,18 +14,19 @@ import java.util.Locale;
|
||||
category = CommandCategory.APPEARANCE, requiredType = RequiredType.PLAYER) public class Music
|
||||
extends SubCommand {
|
||||
|
||||
private static final Collection<String> DISCS = Arrays.asList("music_disc_13", "music_disc_cat",
|
||||
"music_disc_blocks", "music_disc_chirp", "music_disc_far", "music_disc_mall", "music_disc_mellohi",
|
||||
"music_disc_stal", "music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait");
|
||||
private static final Collection<String> DISCS = Arrays
|
||||
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",
|
||||
"music_disc_far", "music_disc_mall", "music_disc_mellohi", "music_disc_stal",
|
||||
"music_disc_strad", "music_disc_ward", "music_disc_11", "music_disc_wait");
|
||||
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isAdded(player.getUUID())) {
|
||||
sendMessage(player, C.NO_PLOT_PERMS);
|
||||
sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") {
|
||||
@ -36,12 +37,12 @@ import java.util.Locale;
|
||||
}
|
||||
if (item.getPlotBlock().equalsAny(7, "bedrock")) {
|
||||
plot.removeFlag(Flags.MUSIC);
|
||||
C.FLAG_REMOVED.send(player);
|
||||
Captions.FLAG_REMOVED.send(player);
|
||||
} else if (item.name.toLowerCase(Locale.ENGLISH).contains("disc")) {
|
||||
plot.setFlag(Flags.MUSIC, item.getPlotBlock().getRawId());
|
||||
C.FLAG_ADDED.send(player);
|
||||
Captions.FLAG_ADDED.send(player);
|
||||
} else {
|
||||
C.FLAG_NOT_ADDED.send(player);
|
||||
Captions.FLAG_NOT_ADDED.send(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
@ -12,7 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players",
|
||||
usage = "/plot near", category = CommandCategory.INFO) public class Near extends Command {
|
||||
usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
|
||||
public class Near extends Command {
|
||||
public Near() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
@ -20,8 +21,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
C.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", "));
|
||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
||||
Captions.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", "));
|
||||
return CompletableFuture.completedFuture(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,15 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
@ -27,14 +31,14 @@ import java.util.UUID;
|
||||
}
|
||||
} else {
|
||||
uuid = UUIDHandler.getUUID(value, null);
|
||||
name = UUIDHandler.getName(uuid);
|
||||
name = uuid == null ? value : UUIDHandler.getName(uuid);
|
||||
name = name == null ? value : name;
|
||||
}
|
||||
if (uuid == null || value.equalsIgnoreCase("-")) {
|
||||
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value
|
||||
.equalsIgnoreCase("-")) {
|
||||
if (!Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER.s(), true)) {
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER.s(), true)) {
|
||||
return false;
|
||||
}
|
||||
Set<Plot> connected = plot.getConnectedPlots();
|
||||
@ -43,20 +47,20 @@ import java.util.UUID;
|
||||
current.unclaim();
|
||||
current.removeSign();
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SET_OWNER);
|
||||
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
||||
return true;
|
||||
}
|
||||
C.INVALID_PLAYER.send(player, value);
|
||||
Captions.INVALID_PLAYER.send(player, value);
|
||||
return false;
|
||||
}
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
||||
if (plot.isOwner(uuid)) {
|
||||
C.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||
Captions.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER)) {
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SET_OWNER)) {
|
||||
if (other == null) {
|
||||
C.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||
Captions.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||
return false;
|
||||
}
|
||||
int size = plots.size();
|
||||
@ -64,7 +68,7 @@ import java.util.UUID;
|
||||
other.getPlotCount() :
|
||||
other.getPlotCount(plot.getWorldName())) + size;
|
||||
if (currentPlots > other.getAllowedPlots()) {
|
||||
sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
|
||||
sendMessage(player, Captions.CANT_TRANSFER_MORE_PLOTS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -77,13 +81,14 @@ import java.util.UUID;
|
||||
if (removeDenied)
|
||||
plot.removeDenied(finalUUID);
|
||||
plot.setSign(finalName);
|
||||
MainUtil.sendMessage(player, C.SET_OWNER);
|
||||
MainUtil.sendMessage(player, Captions.SET_OWNER);
|
||||
if (other != null) {
|
||||
MainUtil
|
||||
.sendMessage(other, C.NOW_OWNER, plot.getArea() + ";" + plot.getId());
|
||||
MainUtil.sendMessage(other, Captions.NOW_OWNER,
|
||||
plot.getArea() + ";" + plot.getId());
|
||||
}
|
||||
} else
|
||||
MainUtil.sendMessage(player, C.SET_OWNER_CANCELLED);
|
||||
} else {
|
||||
MainUtil.sendMessage(player, Captions.SET_OWNER_CANCELLED);
|
||||
}
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -38,7 +38,7 @@ import java.util.UUID;
|
||||
for (String arg : args) {
|
||||
String[] split = arg.split(":");
|
||||
if (split.length != 2) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
switch (split[0].toLowerCase()) {
|
||||
@ -50,15 +50,16 @@ import java.util.UUID;
|
||||
case "a":
|
||||
area = PlotSquared.get().getPlotAreaByString(split[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case "plotid":
|
||||
case "id":
|
||||
id = PlotId.fromString(split[1]);
|
||||
if (id == null) {
|
||||
C.NOT_VALID_PLOT_ID.send(player, split[1]);
|
||||
try {
|
||||
id = PlotId.fromString(split[1]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
Captions.NOT_VALID_PLOT_ID.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -66,7 +67,7 @@ import java.util.UUID;
|
||||
case "o":
|
||||
owner = UUIDHandler.getUUID(split[1], null);
|
||||
if (owner == null) {
|
||||
C.INVALID_PLAYER.send(player, split[1]);
|
||||
Captions.INVALID_PLAYER.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -74,7 +75,7 @@ import java.util.UUID;
|
||||
case "s":
|
||||
added = UUIDHandler.getUUID(split[1], null);
|
||||
if (added == null) {
|
||||
C.INVALID_PLAYER.send(player, split[1]);
|
||||
Captions.INVALID_PLAYER.send(player, split[1]);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
@ -84,7 +85,7 @@ import java.util.UUID;
|
||||
unknown = Boolean.parseBoolean(split[1]);
|
||||
break;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -108,9 +109,7 @@ import java.util.UUID;
|
||||
if (unknown && UUIDHandler.getName(plot.owner) != null) {
|
||||
continue;
|
||||
}
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
toDelete.add(current);
|
||||
}
|
||||
toDelete.addAll(plot.getConnectedPlots());
|
||||
}
|
||||
if (PlotSquared.get().plots_tmp != null) {
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : PlotSquared.get().plots_tmp
|
||||
@ -138,28 +137,26 @@ import java.util.UUID;
|
||||
}
|
||||
}
|
||||
if (toDelete.isEmpty()) {
|
||||
C.FOUND_NO_PLOTS.send(player);
|
||||
Captions.FOUND_NO_PLOTS.send(player);
|
||||
return false;
|
||||
}
|
||||
String cmd =
|
||||
"/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
||||
Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
PlotSquared.debug("Calculating plots to purge, please wait...");
|
||||
HashSet<Integer> ids = new HashSet<>();
|
||||
for (Plot plot : toDelete) {
|
||||
if (plot.temp != Integer.MAX_VALUE) {
|
||||
ids.add(plot.temp);
|
||||
plot.getArea().removePlot(plot.getId());
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
PlotListener.plotEntry(pp, plot);
|
||||
}
|
||||
plot.removeSign();
|
||||
Runnable run = () -> {
|
||||
PlotSquared.debug("Calculating plots to purge, please wait...");
|
||||
HashSet<Integer> ids = new HashSet<>();
|
||||
for (Plot plot : toDelete) {
|
||||
if (plot.temp != Integer.MAX_VALUE) {
|
||||
ids.add(plot.temp);
|
||||
plot.getArea().removePlot(plot.getId());
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
PlotListener.plotEntry(pp, plot);
|
||||
}
|
||||
plot.removeSign();
|
||||
}
|
||||
DBFunc.purgeIds(ids);
|
||||
C.PURGE_SUCCESS.send(player, ids.size() + "/" + toDelete.size());
|
||||
}
|
||||
DBFunc.purgeIds(ids);
|
||||
Captions.PURGE_SUCCESS.send(player, ids.size() + "/" + toDelete.size());
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, cmd, run);
|
||||
|
@ -3,44 +3,44 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot",
|
||||
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO,
|
||||
requiredType = RequiredType.NONE) public class Rate extends SubCommand {
|
||||
requiredType = RequiredType.PLAYER) public class Rate extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 1) {
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "next": {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getBasePlots());
|
||||
Collections.sort(plots, new Comparator<Plot>() {
|
||||
@Override public int compare(Plot p1, Plot p2) {
|
||||
double v1 = 0;
|
||||
if (!p1.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
v1 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
plots.sort((p1, p2) -> {
|
||||
double v1 = 0;
|
||||
if (!p1.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p1.getRatings().entrySet()) {
|
||||
v1 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
}
|
||||
double v2 = 0;
|
||||
if (!p2.getRatings().isEmpty()) {
|
||||
for (Entry<UUID, Rating> entry : p2.getRatings().entrySet()) {
|
||||
v2 -= 11 - entry.getValue().getAverageRating();
|
||||
}
|
||||
}
|
||||
if (v1 == v2) {
|
||||
return -0;
|
||||
}
|
||||
return v2 > v1 ? 1 : -1;
|
||||
});
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot p : plots) {
|
||||
@ -48,48 +48,50 @@ import java.util.Map.Entry;
|
||||
.isBasePlot() && (!p.getRatings().containsKey(uuid)) && !p
|
||||
.isAdded(uuid)) {
|
||||
p.teleportPlayer(player);
|
||||
MainUtil.sendMessage(player, C.RATE_THIS);
|
||||
MainUtil.sendMessage(player, Captions.RATE_THIS);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
case "purge": {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_RATE, true)) {
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_RATE, true)) {
|
||||
return false;
|
||||
}
|
||||
plot.clearRatings();
|
||||
C.RATINGS_PURGED.send(player);
|
||||
Captions.RATINGS_PURGED.send(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(player, C.RATING_NOT_OWNED);
|
||||
sendMessage(player, Captions.RATING_NOT_OWNED);
|
||||
return false;
|
||||
}
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
sendMessage(player, C.RATING_NOT_YOUR_OWN);
|
||||
sendMessage(player, Captions.RATING_NOT_YOUR_OWN);
|
||||
return false;
|
||||
}
|
||||
if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) {
|
||||
sendMessage(player, C.RATING_NOT_DONE);
|
||||
sendMessage(player, Captions.RATING_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
|
||||
final Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (plot.getRatings().containsKey(player.getUUID())) {
|
||||
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
sendMessage(player, Captions.RATING_ALREADY_EXISTS,
|
||||
plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
final MutableInt index = new MutableInt(0);
|
||||
@ -105,14 +107,14 @@ import java.util.Map.Entry;
|
||||
EventUtil.manager.callRating(this.player, plot, new Rating(rV));
|
||||
if (result != null) {
|
||||
plot.addRating(this.player.getUUID(), result);
|
||||
sendMessage(this.player, C.RATING_APPLIED,
|
||||
sendMessage(this.player, Captions.RATING_APPLIED,
|
||||
plot.getId().toString());
|
||||
if (Permissions
|
||||
.hasPermission(this.player, C.PERMISSION_COMMENT)) {
|
||||
.hasPermission(this.player, Captions.PERMISSION_COMMENT)) {
|
||||
Command command =
|
||||
MainCommand.getInstance().getCommand(Comment.class);
|
||||
if (command != null) {
|
||||
MainUtil.sendMessage(this.player, C.COMMENT_THIS,
|
||||
MainUtil.sendMessage(this.player, Captions.COMMENT_THIS,
|
||||
command.getUsage());
|
||||
}
|
||||
}
|
||||
@ -137,11 +139,9 @@ import java.util.Map.Entry;
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
run.run();
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
@ -151,7 +151,7 @@ import java.util.Map.Entry;
|
||||
return true;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
sendMessage(player, Captions.RATING_NOT_VALID);
|
||||
return true;
|
||||
}
|
||||
String arg = args[0];
|
||||
@ -159,34 +159,30 @@ import java.util.Map.Entry;
|
||||
if (MathMan.isInteger(arg) && arg.length() < 3 && !arg.isEmpty()) {
|
||||
rating = Integer.parseInt(arg);
|
||||
if (rating > 10 || rating < 1) {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
sendMessage(player, Captions.RATING_NOT_VALID);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
sendMessage(player, C.RATING_NOT_VALID);
|
||||
sendMessage(player, Captions.RATING_NOT_VALID);
|
||||
return false;
|
||||
}
|
||||
final UUID uuid = player.getUUID();
|
||||
final Runnable run = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (plot.getRatings().containsKey(uuid)) {
|
||||
sendMessage(player, C.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
if (result != null) {
|
||||
plot.addRating(uuid, result);
|
||||
sendMessage(player, C.RATING_APPLIED, plot.getId().toString());
|
||||
}
|
||||
final Runnable run = () -> {
|
||||
if (plot.getRatings().containsKey(uuid)) {
|
||||
sendMessage(player, Captions.RATING_ALREADY_EXISTS, plot.getId().toString());
|
||||
return;
|
||||
}
|
||||
Rating result = EventUtil.manager.callRating(player, plot, new Rating(rating));
|
||||
if (result != null) {
|
||||
plot.addRating(uuid, result);
|
||||
sendMessage(player, Captions.RATING_APPLIED, plot.getId().toString());
|
||||
}
|
||||
};
|
||||
if (plot.getSettings().ratings == null) {
|
||||
if (!Settings.Enabled_Components.RATING_CACHE) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
run.run();
|
||||
}
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
plot.getSettings().ratings = DBFunc.getRatings(plot);
|
||||
run.run();
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridPlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
@ -22,24 +22,25 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
try {
|
||||
height = Integer.parseInt(args[1]);
|
||||
} catch (NumberFormatException ignored) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil
|
||||
.sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
} else if (args.length != 1) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[0]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[0]);
|
||||
return false;
|
||||
}
|
||||
String name = args[0];
|
||||
PlotManager manager = area.getPlotManager();
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
//Set<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
@ -20,7 +20,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
C.NOT_IN_PLOT.send(player);
|
||||
Captions.NOT_IN_PLOT.send(player);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
final LocalBlockQueue queue = plot.getArea().getQueue(false);
|
||||
@ -30,7 +30,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
}
|
||||
}, () -> {
|
||||
plot.refreshChunks();
|
||||
C.SET_BLOCK_ACTION_FINISHED.send(player);
|
||||
Captions.SET_BLOCK_ACTION_FINISHED.send(player);
|
||||
}, 5);
|
||||
|
||||
return CompletableFuture.completedFuture(true);
|
||||
|
@ -5,10 +5,8 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti
|
||||
import com.github.intellectualsites.plotsquared.configuration.MemorySection;
|
||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -23,61 +21,59 @@ import java.util.Objects;
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
PlotSquared.get().setupConfigs();
|
||||
C.load(PlotSquared.get().translationFile);
|
||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override public void run(PlotArea area) {
|
||||
ConfigurationSection worldSection = PlotSquared.get().worlds
|
||||
.getConfigurationSection("worlds." + area.worldname);
|
||||
if (worldSection == null) {
|
||||
return;
|
||||
Captions.load(PlotSquared.get().translationFile);
|
||||
PlotSquared.get().forEachPlotArea(area -> {
|
||||
ConfigurationSection worldSection =
|
||||
PlotSquared.get().worlds.getConfigurationSection("worlds." + area.worldname);
|
||||
if (worldSection == null) {
|
||||
return;
|
||||
}
|
||||
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
||||
area.saveConfiguration(worldSection);
|
||||
area.loadDefaultConfiguration(worldSection);
|
||||
} else {
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(
|
||||
"areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
||||
YamlConfiguration clone = new YamlConfiguration();
|
||||
for (String key : areaSection.getKeys(true)) {
|
||||
if (areaSection.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
if (!clone.contains(key)) {
|
||||
clone.set(key, areaSection.get(key));
|
||||
}
|
||||
}
|
||||
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
||||
area.saveConfiguration(worldSection);
|
||||
area.loadDefaultConfiguration(worldSection);
|
||||
} else {
|
||||
ConfigurationSection areaSection = worldSection.getConfigurationSection(
|
||||
"areas." + area.id + "-" + area.getMin() + "-" + area.getMax());
|
||||
YamlConfiguration clone = new YamlConfiguration();
|
||||
for (String key : areaSection.getKeys(true)) {
|
||||
if (areaSection.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
if (!clone.contains(key)) {
|
||||
clone.set(key, areaSection.get(key));
|
||||
}
|
||||
for (String key : worldSection.getKeys(true)) {
|
||||
if (worldSection.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
for (String key : worldSection.getKeys(true)) {
|
||||
if (worldSection.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
if (!key.startsWith("areas") && !clone.contains(key)) {
|
||||
clone.set(key, worldSection.get(key));
|
||||
}
|
||||
if (!key.startsWith("areas") && !clone.contains(key)) {
|
||||
clone.set(key, worldSection.get(key));
|
||||
}
|
||||
area.saveConfiguration(clone);
|
||||
// netSections is the combination of
|
||||
for (String key : clone.getKeys(true)) {
|
||||
if (clone.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
if (!worldSection.contains(key)) {
|
||||
worldSection.set(key, clone.get(key));
|
||||
} else {
|
||||
Object value = worldSection.get(key);
|
||||
if (Objects.equals(value, clone.get(key))) {
|
||||
areaSection.set(key, clone.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
area.loadDefaultConfiguration(clone);
|
||||
}
|
||||
area.saveConfiguration(clone);
|
||||
// netSections is the combination of
|
||||
for (String key : clone.getKeys(true)) {
|
||||
if (clone.get(key) instanceof MemorySection) {
|
||||
continue;
|
||||
}
|
||||
if (!worldSection.contains(key)) {
|
||||
worldSection.set(key, clone.get(key));
|
||||
} else {
|
||||
Object value = worldSection.get(key);
|
||||
if (Objects.equals(value, clone.get(key))) {
|
||||
areaSection.set(key, clone.get(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
area.loadDefaultConfiguration(clone);
|
||||
}
|
||||
});
|
||||
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
|
||||
MainUtil.sendMessage(player, C.RELOADED_CONFIGS);
|
||||
MainUtil.sendMessage(player, Captions.RELOADED_CONFIGS);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, C.RELOAD_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.RELOAD_FAILED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -30,25 +30,25 @@ import java.util.UUID;
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_REMOVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_REMOVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
int count = 0;
|
||||
switch (args[0]) {
|
||||
case "unknown": {
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
HashSet<UUID> all = new HashSet<>();
|
||||
all.addAll(plot.getMembers());
|
||||
all.addAll(plot.getTrusted());
|
||||
all.addAll(plot.getDenied());
|
||||
ArrayList<UUID> toRemove = new ArrayList<>();
|
||||
for (UUID uuid : all) {
|
||||
if (UUIDHandler.getName(uuid) == null) {
|
||||
toRemove.add(uuid);
|
||||
@ -98,10 +98,10 @@ import java.util.UUID;
|
||||
break;
|
||||
}
|
||||
if (count == 0) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.REMOVED_PLAYERS, count + "");
|
||||
MainUtil.sendMessage(player, Captions.REMOVED_PLAYERS, count + "");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -6,11 +6,9 @@ public enum RequiredType {
|
||||
CONSOLE, PLAYER, NONE;
|
||||
|
||||
public boolean allows(CommandCaller player) {
|
||||
switch (this) {
|
||||
case NONE:
|
||||
return true;
|
||||
default:
|
||||
return this == player.getSuperCaller();
|
||||
if (this == RequiredType.NONE) {
|
||||
return true;
|
||||
}
|
||||
return this == player.getSuperCaller();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
@ -21,23 +21,23 @@ import java.util.UUID;
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String world = player.getLocation().getWorld();
|
||||
if (!PlotSquared.get().hasPlotArea(world)) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SAVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
@ -58,13 +58,13 @@ import java.util.UUID;
|
||||
@Override public void run(URL url) {
|
||||
plot.removeRunning();
|
||||
if (url == null) {
|
||||
MainUtil.sendMessage(player, C.SAVE_FAILED);
|
||||
MainUtil.sendMessage(player, Captions.SAVE_FAILED);
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SAVE_SUCCESS);
|
||||
MainUtil.sendMessage(player, Captions.SAVE_SUCCESS);
|
||||
List<String> schematics = player.getMeta("plot_schematics");
|
||||
if (schematics != null) {
|
||||
schematics.add(file + ".schematic");
|
||||
schematics.add(file + ".schem");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -2,11 +2,21 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.ConsolePlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
@ -22,32 +32,33 @@ public class SchematicCmd extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
}
|
||||
String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
case "paste": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SCHEMATIC_PASTE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SCHEMATIC_PASTE);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
@ -66,7 +77,7 @@ public class SchematicCmd extends SubCommand {
|
||||
schematic = SchematicHandler.manager.getSchematic(url);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sendMessage(player, C.SCHEMATIC_INVALID,
|
||||
sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||
"non-existent url: " + location);
|
||||
SchematicCmd.this.running = false;
|
||||
return;
|
||||
@ -80,7 +91,7 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
if (schematic == null) {
|
||||
SchematicCmd.this.running = false;
|
||||
sendMessage(player, C.SCHEMATIC_INVALID,
|
||||
sendMessage(player, Captions.SCHEMATIC_INVALID,
|
||||
"non-existent or not in gzip format");
|
||||
return;
|
||||
}
|
||||
@ -89,9 +100,9 @@ public class SchematicCmd extends SubCommand {
|
||||
@Override public void run(Boolean value) {
|
||||
SchematicCmd.this.running = false;
|
||||
if (value) {
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_SUCCESS);
|
||||
sendMessage(player, Captions.SCHEMATIC_PASTE_SUCCESS);
|
||||
} else {
|
||||
sendMessage(player, C.SCHEMATIC_PASTE_FAILED);
|
||||
sendMessage(player, Captions.SCHEMATIC_PASTE_FAILED);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -101,39 +112,39 @@ public class SchematicCmd extends SubCommand {
|
||||
// TODO test
|
||||
// case "test": {
|
||||
// if (!Permissions.hasPermission(plr, "plots.schematic.test")) {
|
||||
// MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.test");
|
||||
// MainUtil.sendMessage(plr, Captions.NO_PERMISSION, "plots.schematic.test");
|
||||
// return false;
|
||||
// }
|
||||
// if (args.length < 2) {
|
||||
// sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
// sendMessage(plr, Captions.SCHEMATIC_MISSING_ARG);
|
||||
// return false;
|
||||
// }
|
||||
// final Location loc = plr.getLocation();
|
||||
// final Plot plot = MainUtil.getPlot(loc);
|
||||
// if (plot == null) {
|
||||
// sendMessage(plr, C.NOT_IN_PLOT);
|
||||
// sendMessage(plr, Captions.NOT_IN_PLOT);
|
||||
// return false;
|
||||
// }
|
||||
// file = args[1];
|
||||
// schematic = SchematicHandler.manager.getSchematic(file);
|
||||
// if (schematic == null) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
|
||||
// sendMessage(plr, Captions.SCHEMATIC_INVALID, "non-existent");
|
||||
// return false;
|
||||
// }
|
||||
// final int l1 = schematic.getSchematicDimension().getX();
|
||||
// final int l2 = schematic.getSchematicDimension().getZ();
|
||||
// final int length = MainUtil.getPlotWidth(loc.getWorld(), plot.id);
|
||||
// if ((l1 < length) || (l2 < length)) {
|
||||
// sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
// sendMessage(plr, Captions.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
// break;
|
||||
// }
|
||||
// sendMessage(plr, C.SCHEMATIC_VALID);
|
||||
// sendMessage(plr, Captions.SCHEMATIC_VALID);
|
||||
// break;
|
||||
// }
|
||||
case "saveall":
|
||||
case "exportall": {
|
||||
if (!(player instanceof ConsolePlayer)) {
|
||||
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||
MainUtil.sendMessage(player, Captions.NOT_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
@ -143,7 +154,7 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
PlotArea area = PlotSquared.get().getPlotAreaByString(args[1]);
|
||||
if (area == null) {
|
||||
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
Captions.NOT_VALID_PLOT_WORLD.send(player, args[1]);
|
||||
return false;
|
||||
}
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
@ -167,8 +178,9 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
case "export":
|
||||
case "save":
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SCHEMATIC_SAVE);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SCHEMATIC_SAVE);
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
@ -178,20 +190,18 @@ public class SchematicCmd extends SubCommand {
|
||||
Location location = player.getLocation();
|
||||
Plot plot = location.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
location.getWorld();
|
||||
Collection<Plot> plots = new ArrayList<>();
|
||||
plots.add(plot);
|
||||
ArrayList<Plot> plots = Lists.newArrayList(plot);
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, () -> {
|
||||
MainUtil.sendMessage(player, "&aFinished export");
|
||||
SchematicCmd.this.running = false;
|
||||
@ -204,17 +214,18 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "list": {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SCHEMATIC_LIST)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SCHEMATIC_LIST);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SCHEMATIC_LIST)) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SCHEMATIC_LIST);
|
||||
return false;
|
||||
}
|
||||
final String string =
|
||||
StringMan.join(SchematicHandler.manager.getShematicNames(), "$2, $1");
|
||||
C.SCHEMATIC_LIST.send(player, string);
|
||||
StringMan.join(SchematicHandler.manager.getSchematicNames(), "$2, $1");
|
||||
Captions.SCHEMATIC_LIST.send(player, string);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sendMessage(player, C.SCHEMATIC_MISSING_ARG);
|
||||
sendMessage(player, Captions.SCHEMATIC_MISSING_ARG);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
@ -2,19 +2,30 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration.UnknownBlockException;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.FlagManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
@CommandDeclaration(command = "set", description = "Set a plot value", aliases = {"s"},
|
||||
usage = "/plot set <biome|alias|home|flag> <value...>", permission = "plots.set",
|
||||
@ -36,7 +47,7 @@ import java.util.HashSet;
|
||||
@Override public boolean set(PlotPlayer player, final Plot plot, String value) {
|
||||
PlotArea plotArea = player.getLocation().getPlotArea();
|
||||
PlotManager manager = player.getLocation().getPlotManager();
|
||||
String[] components = manager.getPlotComponents(plotArea, plot.getId());
|
||||
String[] components = manager.getPlotComponents(plot.getId());
|
||||
boolean allowUnsafe = DebugAllowUnsafe.unsafeAllowed.contains(player.getUUID());
|
||||
|
||||
String[] args = value.split(" ");
|
||||
@ -45,34 +56,32 @@ import java.util.HashSet;
|
||||
|
||||
for (String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions
|
||||
.hasPermission(player, C.PERMISSION_SET_COMPONENT.f(component))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_SET_COMPONENT.f(component));
|
||||
if (!Permissions.hasPermission(player,
|
||||
Captions.PERMISSION_SET_COMPONENT.f(component))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_SET_COMPONENT.f(component));
|
||||
return false;
|
||||
}
|
||||
// PlotBlock[] blocks;
|
||||
BlockBucket bucket;
|
||||
try {
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(player, C.NEED_BLOCK);
|
||||
MainUtil.sendMessage(player, Captions.NEED_BLOCK);
|
||||
return true;
|
||||
}
|
||||
String[] split = material.split(",");
|
||||
// blocks = Configuration.BLOCKLIST.parseString(material);
|
||||
|
||||
try {
|
||||
bucket = Configuration.BLOCK_BUCKET.parseString(material);
|
||||
} catch (final UnknownBlockException unknownBlockException) {
|
||||
final String unknownBlock = unknownBlockException.getUnknownValue();
|
||||
C.NOT_VALID_BLOCK.send(player, unknownBlock);
|
||||
Captions.NOT_VALID_BLOCK.send(player, unknownBlock);
|
||||
StringComparison<PlotBlock>.ComparisonResult match =
|
||||
WorldUtil.IMP.getClosestBlock(unknownBlock);
|
||||
if (match != null) {
|
||||
final String found =
|
||||
WorldUtil.IMP.getClosestMatchingName(match.best);
|
||||
if (found != null) {
|
||||
MainUtil.sendMessage(player, C.DID_YOU_MEAN,
|
||||
MainUtil.sendMessage(player, Captions.DID_YOU_MEAN,
|
||||
found.toLowerCase());
|
||||
}
|
||||
}
|
||||
@ -82,29 +91,25 @@ import java.util.HashSet;
|
||||
if (!allowUnsafe) {
|
||||
for (final PlotBlock block : bucket.getBlocks()) {
|
||||
if (!block.isAir() && !WorldUtil.IMP.isBlockSolid(block)) {
|
||||
C.NOT_ALLOWED_BLOCK.send(player, block.toString());
|
||||
Captions.NOT_ALLOWED_BLOCK.send(player, block.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_BLOCK, material);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_BLOCK, material);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
MainUtil.sendMessage(player, C.WAIT_FOR_TIMER);
|
||||
MainUtil.sendMessage(player, Captions.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
plot.addRunning();
|
||||
for (Plot current : plot.getConnectedPlots()) {
|
||||
current.setComponent(component, bucket);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.GENERATING_COMPONENT);
|
||||
GlobalBlockQueue.IMP.addTask(new Runnable() {
|
||||
@Override public void run() {
|
||||
plot.removeRunning();
|
||||
}
|
||||
});
|
||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||
GlobalBlockQueue.IMP.addTask(plot::removeRunning);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -114,15 +119,15 @@ import java.util.HashSet;
|
||||
}
|
||||
|
||||
public boolean noArgs(PlotPlayer player) {
|
||||
ArrayList<String> newValues = new ArrayList<>();
|
||||
newValues.addAll(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
ArrayList<String> newValues =
|
||||
new ArrayList<>(Arrays.asList("biome", "alias", "home", "flag"));
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot != null) {
|
||||
newValues.addAll(
|
||||
Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
|
||||
Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
|
||||
}
|
||||
MainUtil.sendMessage(player, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan
|
||||
.join(newValues, C.BLOCK_LIST_SEPARATER.formatted()));
|
||||
MainUtil.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan
|
||||
.join(newValues, Captions.BLOCK_LIST_SEPARATER.formatted()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -141,25 +146,24 @@ import java.util.HashSet;
|
||||
// Additional checks
|
||||
Plot plot = player.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
// components
|
||||
HashSet<String> components = new HashSet<>(
|
||||
Arrays.asList(plot.getManager().getPlotComponents(plot.getArea(), plot.getId())));
|
||||
Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
|
||||
if (components.contains(args[0].toLowerCase())) {
|
||||
return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length));
|
||||
}
|
||||
// flag
|
||||
Flag<?> flag = FlagManager.getFlag(args[0].toLowerCase());
|
||||
if (Flags.getFlags().contains(flag)) {
|
||||
StringBuilder a = new StringBuilder();
|
||||
String a = "";
|
||||
if (args.length > 1) {
|
||||
for (int x = 1; x < args.length; x++) {
|
||||
a.append(" ").append(args[x]);
|
||||
}
|
||||
a = IntStream.range(1, args.length).mapToObj(x -> " " + args[x])
|
||||
.collect(Collectors.joining());
|
||||
}
|
||||
MainCommand.onCommand(player, ("flag set " + args[0] + a.toString()).split(" "));
|
||||
MainCommand.onCommand(player, ("flag set " + args[0] + a).split(" "));
|
||||
return true;
|
||||
}
|
||||
return noArgs(player);
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -14,21 +14,23 @@ public abstract class SetCommand extends SubCommand {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION,
|
||||
C.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
if (!Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PERMISSION,
|
||||
Captions.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockLoc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
@ -21,7 +21,7 @@ public class SetHome extends SetCommand {
|
||||
case "none": {
|
||||
Plot base = plot.getBasePlot(false);
|
||||
base.setHome(null);
|
||||
return MainUtil.sendMessage(player, C.POSITION_UNSET);
|
||||
return MainUtil.sendMessage(player, Captions.POSITION_UNSET);
|
||||
}
|
||||
case "":
|
||||
Plot base = plot.getBasePlot(false);
|
||||
@ -31,9 +31,9 @@ public class SetHome extends SetCommand {
|
||||
new BlockLoc(loc.getX() - bot.getX(), loc.getY(), loc.getZ() - bot.getZ(),
|
||||
loc.getYaw(), loc.getPitch());
|
||||
base.setHome(rel);
|
||||
return MainUtil.sendMessage(player, C.POSITION_SET);
|
||||
return MainUtil.sendMessage(player, Captions.POSITION_SET);
|
||||
default:
|
||||
MainUtil.sendMessage(player, C.HOME_ARGUMENT);
|
||||
MainUtil.sendMessage(player, Captions.HOME_ARGUMENT);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2,11 +2,15 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Configuration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
||||
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -43,7 +47,7 @@ import java.util.Map.Entry;
|
||||
object = new SetupObject();
|
||||
player.setMeta("setup", object);
|
||||
SetupUtils.manager.updateGenerators();
|
||||
sendMessage(player, C.SETUP_INIT);
|
||||
sendMessage(player, Captions.SETUP_INIT);
|
||||
displayGenerators(player);
|
||||
return false;
|
||||
}
|
||||
@ -57,8 +61,9 @@ import java.util.Map.Entry;
|
||||
if (object.setup_index > 0) {
|
||||
object.setup_index--;
|
||||
ConfigurationNode node = object.step[object.setup_index];
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, node.getDescription(),
|
||||
node.getType().getType(), String.valueOf(node.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
node.getDescription(), node.getType().getType(),
|
||||
String.valueOf(node.getDefaultValue()));
|
||||
return false;
|
||||
} else if (object.current > 0) {
|
||||
object.current--;
|
||||
@ -75,7 +80,7 @@ import java.util.Map.Entry;
|
||||
.join(SetupUtils.generators.keySet(), prefix)
|
||||
.replaceAll(PlotSquared.imp().getPluginName(),
|
||||
"&2" + PlotSquared.imp().getPluginName()));
|
||||
sendMessage(player, C.SETUP_INIT);
|
||||
sendMessage(player, Captions.SETUP_INIT);
|
||||
return false;
|
||||
}
|
||||
object.setupGenerator = args[0];
|
||||
@ -129,8 +134,9 @@ import java.util.Map.Entry;
|
||||
return true;
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(),
|
||||
step.getType().getType(), String.valueOf(step.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
} else {
|
||||
if (gen.isFull()) {
|
||||
object.plotManager = object.setupGenerator;
|
||||
@ -182,8 +188,9 @@ import java.util.Map.Entry;
|
||||
MainUtil.sendMessage(player, "&6What should be the minimum Plot Id?");
|
||||
break;
|
||||
case 3: // min
|
||||
object.min = PlotId.fromString(args[0]);
|
||||
if (object.min == null) {
|
||||
try {
|
||||
object.min = PlotId.fromString(args[0]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cYou must choose a valid minimum PlotId!");
|
||||
return false;
|
||||
}
|
||||
@ -192,8 +199,10 @@ import java.util.Map.Entry;
|
||||
break;
|
||||
case 4:
|
||||
// max
|
||||
PlotId id = PlotId.fromString(args[0]);
|
||||
if (id == null) {
|
||||
PlotId id;
|
||||
try {
|
||||
id = PlotId.fromString(args[0]);
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
MainUtil.sendMessage(player, "&cYou must choose a valid maximum PlotId!");
|
||||
return false;
|
||||
}
|
||||
@ -228,8 +237,9 @@ import java.util.Map.Entry;
|
||||
.getSettingNodes();
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(),
|
||||
step.getType().getType(), String.valueOf(step.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
break;
|
||||
}
|
||||
case 6: // world setup
|
||||
@ -241,8 +251,9 @@ import java.util.Map.Entry;
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
if (args.length < 1) {
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(),
|
||||
step.getType().getType(), String.valueOf(step.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -250,10 +261,10 @@ import java.util.Map.Entry;
|
||||
try {
|
||||
valid = step.isValid(args[0]);
|
||||
} catch (final Configuration.UnsafeBlockException e) {
|
||||
C.NOT_ALLOWED_BLOCK.send(player, e.getUnsafeBlock().toString());
|
||||
Captions.NOT_ALLOWED_BLOCK.send(player, e.getUnsafeBlock().toString());
|
||||
}
|
||||
if (valid) {
|
||||
sendMessage(player, C.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||
sendMessage(player, Captions.SETUP_VALID_ARG, step.getConstant(), args[0]);
|
||||
step.setValue(args[0]);
|
||||
object.setup_index++;
|
||||
if (object.setup_index == object.step.length) {
|
||||
@ -261,13 +272,15 @@ import java.util.Map.Entry;
|
||||
return false;
|
||||
}
|
||||
step = object.step[object.setup_index];
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(),
|
||||
step.getType().getType(), String.valueOf(step.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
} else {
|
||||
sendMessage(player, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||
sendMessage(player, C.SETUP_STEP, object.setup_index + 1, step.getDescription(),
|
||||
step.getType().getType(), String.valueOf(step.getDefaultValue()));
|
||||
sendMessage(player, Captions.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||
sendMessage(player, Captions.SETUP_STEP, object.setup_index + 1,
|
||||
step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
}
|
||||
case 7:
|
||||
@ -299,7 +312,7 @@ import java.util.Map.Entry;
|
||||
player.sendMessage("&cAn error occurred. See console for more information");
|
||||
e.printStackTrace();
|
||||
}
|
||||
sendMessage(player, C.SETUP_FINISHED, object.world);
|
||||
sendMessage(player, Captions.SETUP_FINISHED, object.world);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -336,7 +349,7 @@ import java.util.Map.Entry;
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override public boolean parseInut(String input) {
|
||||
@Override public boolean parseInput(String input) {
|
||||
this.generator = input.toLowerCase();
|
||||
return true;
|
||||
}
|
||||
@ -376,7 +389,7 @@ import java.util.Map.Entry;
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override public boolean parseInut(String input) {
|
||||
@Override public boolean parseInput(String input) {
|
||||
if (!WORLD_TYPES.keySet().contains(input.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
@ -407,7 +420,7 @@ import java.util.Map.Entry;
|
||||
|
||||
public abstract Collection<PlotMessage> showDescriptionMessage();
|
||||
|
||||
public abstract boolean parseInut(String input);
|
||||
public abstract boolean parseInput(String input);
|
||||
|
||||
public final PlotMessage getUsage() {
|
||||
return new PlotMessage("Usage: ").color("$1")
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
||||
@ -25,6 +25,11 @@ public abstract class SubCommand extends Command {
|
||||
setRequiredArguments(arguments);
|
||||
}
|
||||
|
||||
public static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
|
||||
message.send(player, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
@ -32,9 +37,4 @@ public abstract class SubCommand extends Command {
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(PlotPlayer player, String[] args);
|
||||
|
||||
public boolean sendMessage(PlotPlayer player, C message, Object... args) {
|
||||
message.send(player, args);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -9,22 +9,22 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
|
||||
@CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots",
|
||||
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE)
|
||||
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
Location loc = player.getLocation();
|
||||
Plot plot1 = loc.getPlotAbs();
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !MainUtil.sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlotFromString(player, args[0], true);
|
||||
@ -32,22 +32,22 @@ public class Swap extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (!plot1.getArea().isCompatible(plot2.getArea())) {
|
||||
C.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
Captions.PLOTWORLD_INCOMPATIBLE.send(player);
|
||||
return false;
|
||||
}
|
||||
if (plot1.move(plot2, new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, C.SWAP_SUCCESS);
|
||||
MainUtil.sendMessage(player, Captions.SWAP_SUCCESS);
|
||||
}
|
||||
}, true)) {
|
||||
return true;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.SWAP_OVERLAP);
|
||||
MainUtil.sendMessage(player, Captions.SWAP_OVERLAP);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Argument;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -22,7 +22,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
Location location = player.getLocation();
|
||||
if (!location.isPlotArea()) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, Captions.NOT_IN_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
Plot target = null;
|
||||
@ -36,14 +36,14 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
}
|
||||
}
|
||||
if (target == null) {
|
||||
MainUtil.sendMessage(player, C.FOUND_NO_PLOTS);
|
||||
MainUtil.sendMessage(player, Captions.FOUND_NO_PLOTS);
|
||||
return false;
|
||||
}
|
||||
} else if ((target = MainUtil.getPlotFromString(player, args[0], true)) == null) {
|
||||
return false;
|
||||
}
|
||||
player.setCompassTarget(target.getCenter());
|
||||
MainUtil.sendMessage(player, C.COMPASS_TARGET);
|
||||
MainUtil.sendMessage(player, Captions.COMPASS_TARGET);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.configuration.ConfigurationSecti
|
||||
import com.github.intellectualsites.plotsquared.configuration.InvalidConfigurationException;
|
||||
import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
@ -33,11 +33,11 @@ import java.util.zip.ZipOutputStream;
|
||||
if (!folder.exists()) {
|
||||
return false;
|
||||
}
|
||||
File input = new File(folder + File.separator + template + ".template");
|
||||
File output = PlotSquared.get().IMP.getDirectory();
|
||||
if (!output.exists()) {
|
||||
output.mkdirs();
|
||||
}
|
||||
File input = new File(folder + File.separator + template + ".template");
|
||||
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(input))) {
|
||||
ZipEntry ze = zis.getNextEntry();
|
||||
byte[] buffer = new byte[2048];
|
||||
@ -63,9 +63,6 @@ import java.util.zip.ZipOutputStream;
|
||||
zis.closeEntry();
|
||||
}
|
||||
return true;
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
@ -107,15 +104,16 @@ import java.util.zip.ZipOutputStream;
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot template export <world>");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("import")) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot template import <world> <template>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot template <import|export> <world> [template]");
|
||||
return true;
|
||||
}
|
||||
@ -123,12 +121,12 @@ import java.util.zip.ZipOutputStream;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot template import <world> <template>");
|
||||
return false;
|
||||
}
|
||||
if (PlotSquared.get().hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(player, C.SETUP_WORLD_TAKEN, world);
|
||||
MainUtil.sendMessage(player, Captions.SETUP_WORLD_TAKEN, world);
|
||||
return false;
|
||||
}
|
||||
boolean result = extractAllFiles(world, args[2]);
|
||||
@ -161,40 +159,37 @@ import java.util.zip.ZipOutputStream;
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = world;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
GlobalBlockQueue.IMP.addTask(new Runnable() {
|
||||
@Override public void run() {
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
}
|
||||
GlobalBlockQueue.IMP.addTask(() -> {
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
player.teleport(WorldUtil.IMP.getSpawn(world));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
case "export":
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
|
||||
"/plot template export <world>");
|
||||
return false;
|
||||
}
|
||||
final PlotArea area = PlotSquared.get().getPlotAreaByString(world);
|
||||
if (area == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final PlotManager manager = area.getPlotManager();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override public void run() {
|
||||
try {
|
||||
manager.exportTemplate(area);
|
||||
} catch (Exception e) { // Must recover from any exception thrown a third party template manager
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, "Failed: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
TaskManager.runTaskAsync(() -> {
|
||||
try {
|
||||
manager.exportTemplate();
|
||||
} catch (Exception e) { // Must recover from any exception thrown a third party template manager
|
||||
e.printStackTrace();
|
||||
MainUtil.sendMessage(player, "Failed: " + e.getMessage());
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, "Done!");
|
||||
});
|
||||
return true;
|
||||
default:
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
|
||||
@ -22,9 +22,9 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "chatspy")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,9 +34,9 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "worldedit")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,9 +46,9 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,9 +58,9 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "ignoreExpireTask")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -70,11 +70,11 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
boolean chat = area == null ? false : area.PLOT_CHAT;
|
||||
boolean chat = area != null && area.PLOT_CHAT;
|
||||
if (toggle(player, "disabletitles") != chat) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
@ -95,8 +95,7 @@ import java.util.Set;
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(null, "Collecting region data...");
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PlotSquared.get().getPlots(world));
|
||||
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.get().getPlots(world));
|
||||
if (ExpireManager.IMP != null) {
|
||||
plots.removeAll(ExpireManager.IMP.getPendingExpired());
|
||||
}
|
||||
@ -107,8 +106,8 @@ import java.util.Set;
|
||||
MainUtil.sendMessage(null, " - TIME ESTIMATE: 12 Parsecs");
|
||||
TaskManager.objectTask(plots, new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot plot) {
|
||||
Location pos1 = plot.getBottom();
|
||||
Location pos2 = plot.getTop();
|
||||
Location pos1 = plot.getCorners()[0];
|
||||
Location pos2 = plot.getCorners()[1];
|
||||
int ccx1 = pos1.getX() >> 9;
|
||||
int ccz1 = pos1.getZ() >> 9;
|
||||
int ccx2 = pos2.getX() >> 9;
|
||||
@ -128,16 +127,16 @@ import java.util.Set;
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
if (args.length == 0) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
final String world = args[0];
|
||||
if (!WorldUtil.IMP.isWorld(world) || !PlotSquared.get().hasPlotArea(world)) {
|
||||
MainUtil.sendMessage(player, C.NOT_VALID_WORLD);
|
||||
MainUtil.sendMessage(player, Captions.NOT_VALID_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (Trim.TASK) {
|
||||
C.TRIM_IN_PROGRESS.send(player);
|
||||
Captions.TRIM_IN_PROGRESS.send(player);
|
||||
return false;
|
||||
}
|
||||
Trim.TASK = true;
|
||||
@ -198,11 +197,9 @@ import java.util.Set;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
regenTask = new Runnable() {
|
||||
@Override public void run() {
|
||||
Trim.TASK = false;
|
||||
player.sendMessage("Trim done!");
|
||||
}
|
||||
regenTask = () -> {
|
||||
Trim.TASK = false;
|
||||
player.sendMessage("Trim done!");
|
||||
};
|
||||
}
|
||||
ChunkManager.manager.deleteRegionFiles(world, viable, regenTask);
|
||||
|
@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
@ -17,7 +17,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.NONE,
|
||||
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER,
|
||||
usage = "/plot trust <player>",
|
||||
description = "Allow a user to build in a plot while you are offline",
|
||||
category = CommandCategory.SETTINGS) public class Trust extends Command {
|
||||
@ -29,52 +29,57 @@ import java.util.concurrent.CompletableFuture;
|
||||
@Override public CompletableFuture<Boolean> execute(final PlotPlayer player, String[] args,
|
||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
final Plot currentPlot = player.getCurrentPlot();
|
||||
if (currentPlot == null) {
|
||||
throw new CommandException(Captions.NOT_IN_PLOT);
|
||||
}
|
||||
checkTrue(currentPlot.hasOwner(), Captions.PLOT_UNOWNED);
|
||||
checkTrue(currentPlot.isOwner(player.getUUID()) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||
Captions.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
||||
Iterator<UUID> iterator = uuids.iterator();
|
||||
int size = currentPlot.getTrusted().size() + currentPlot.getMembers().size();
|
||||
while (iterator.hasNext()) {
|
||||
UUID uuid = iterator.next();
|
||||
if (uuid == DBFunc.EVERYONE && !(
|
||||
Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
Permissions.hasPermission(player, Captions.PERMISSION_TRUST_EVERYONE) || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, Captions.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
if (currentPlot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (plot.getTrusted().contains(uuid)) {
|
||||
MainUtil.sendMessage(player, C.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
if (currentPlot.getTrusted().contains(uuid)) {
|
||||
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
size += plot.getMembers().contains(uuid) ? 0 : 1;
|
||||
size += currentPlot.getMembers().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
||||
checkTrue(size <= currentPlot.getArea().MAX_PLOT_MEMBERS || Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||
Captions.PLOT_MAX_MEMBERS);
|
||||
// Success
|
||||
confirm.run(this, () -> {
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid != DBFunc.EVERYONE) {
|
||||
if (!plot.removeMember(uuid)) {
|
||||
if (plot.getDenied().contains(uuid)) {
|
||||
plot.removeDenied(uuid);
|
||||
if (!currentPlot.removeMember(uuid)) {
|
||||
if (currentPlot.getDenied().contains(uuid)) {
|
||||
currentPlot.removeDenied(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
plot.addTrusted(uuid);
|
||||
EventUtil.manager.callTrusted(player, plot, uuid, true);
|
||||
MainUtil.sendMessage(player, C.TRUSTED_ADDED);
|
||||
currentPlot.addTrusted(uuid);
|
||||
EventUtil.manager.callTrusted(player, currentPlot, uuid, true);
|
||||
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
||||
}
|
||||
}, null);
|
||||
|
||||
|
@ -1,52 +1,50 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||
|
||||
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
|
||||
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS, confirmation = true) public class Unlink
|
||||
extends SubCommand {
|
||||
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]",
|
||||
requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
|
||||
Location loc = player.getLocation();
|
||||
final Plot plot = loc.getPlotAbs();
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
return !sendMessage(player, Captions.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(player, C.PLOT_UNOWNED);
|
||||
return !sendMessage(player, Captions.PLOT_UNOWNED);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_UNLINK)) {
|
||||
return sendMessage(player, C.NO_PLOT_PERMS);
|
||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_UNLINK)) {
|
||||
return sendMessage(player, Captions.NO_PLOT_PERMS);
|
||||
}
|
||||
if (!plot.isMerged()) {
|
||||
return sendMessage(player, C.UNLINK_IMPOSSIBLE);
|
||||
return sendMessage(player, Captions.UNLINK_IMPOSSIBLE);
|
||||
}
|
||||
final boolean createRoad;
|
||||
if (args.length != 0) {
|
||||
if (args.length != 1 || !StringMan.isEqualIgnoreCaseToAny(args[0], "true", "false")) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
createRoad = Boolean.parseBoolean(args[0]);
|
||||
} else {
|
||||
createRoad = true;
|
||||
}
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override public void run() {
|
||||
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
||||
MainUtil.sendMessage(player, "&cUnlink has been cancelled");
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, C.UNLINK_SUCCESS);
|
||||
Runnable runnable = () -> {
|
||||
if (!plot.unlinkPlot(createRoad, createRoad)) {
|
||||
MainUtil.sendMessage(player, "&cUnlink has been cancelled");
|
||||
return;
|
||||
}
|
||||
MainUtil.sendMessage(player, Captions.UNLINK_SUCCESS);
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, "/plot unlink " + plot.getId(), runnable);
|
||||
|
@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.commands;
|
||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.C;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
@ -16,7 +16,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandDeclaration(command = "visit", permission = "plots.visit",
|
||||
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
|
||||
aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.NONE,
|
||||
aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.TELEPORT) public class Visit extends Command {
|
||||
|
||||
public Visit() {
|
||||
@ -40,8 +40,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
switch (args.length) {
|
||||
case 3:
|
||||
if (!MathMan.isInteger(args[1])) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
page = Integer.parseInt(args[2]);
|
||||
@ -49,13 +49,13 @@ import java.util.concurrent.CompletableFuture;
|
||||
if (page != Integer.MIN_VALUE || !MathMan.isInteger(args[1])) {
|
||||
sortByArea = PlotSquared.get().getPlotAreaByString(args[1]);
|
||||
if (sortByArea == null) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
UUID user = UUIDHandler.getUUIDFromString(args[0]);
|
||||
if (user == null) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
Captions.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
unsorted = PlotSquared.get().getBasePlots(user);
|
||||
@ -65,8 +65,9 @@ import java.util.concurrent.CompletableFuture;
|
||||
page = Integer.parseInt(args[1]);
|
||||
case 1:
|
||||
UUID user = args[0].length() >= 2 ? UUIDHandler.getUUIDFromString(args[0]) : null;
|
||||
if (user != null && !PlotSquared.get().hasPlot(user))
|
||||
if (user != null && !PlotSquared.get().hasPlot(user)) {
|
||||
user = null;
|
||||
}
|
||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||
page = Integer.parseInt(args[0]);
|
||||
unsorted = PlotSquared.get().getBasePlots(player);
|
||||
@ -92,13 +93,15 @@ import java.util.concurrent.CompletableFuture;
|
||||
page = 1;
|
||||
}
|
||||
if (unsorted == null || unsorted.isEmpty()) {
|
||||
C.FOUND_NO_PLOTS.send(player);
|
||||
Captions.FOUND_NO_PLOTS.send(player);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
unsorted = new ArrayList<>(unsorted);
|
||||
unsorted.removeIf(plot -> !plot.isBasePlot());
|
||||
if (unsorted.size() > 1) {
|
||||
unsorted.removeIf(plot -> !plot.isBasePlot());
|
||||
}
|
||||
if (page < 1 || page > unsorted.size()) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
||||
Captions.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
List<Plot> plots;
|
||||
@ -110,24 +113,24 @@ import java.util.concurrent.CompletableFuture;
|
||||
}
|
||||
final Plot plot = plots.get(page - 1);
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_UNOWNED)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_UNOWNED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_UNOWNED)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_UNOWNED);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
} else if (plot.isOwner(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_OWNED) && !Permissions
|
||||
.hasPermission(player, C.PERMISSION_HOME)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_OWNED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OWNED) && !Permissions
|
||||
.hasPermission(player, Captions.PERMISSION_HOME)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OWNED);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
} else if (plot.isAdded(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SHARED)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_SHARED);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_SHARED)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_SHARED);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
} else {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_OTHER)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_OTHER);
|
||||
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER)) {
|
||||
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER);
|
||||
return CompletableFuture.completedFuture(false);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -105,10 +105,10 @@ public class Config {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
}
|
||||
PrintWriter writer = new PrintWriter(file);
|
||||
Object instance = root.newInstance();
|
||||
save(writer, root, instance, 0);
|
||||
writer.close();
|
||||
try (PrintWriter writer = new PrintWriter(file)) {
|
||||
Object instance = root.newInstance();
|
||||
save(writer, root, instance, 0);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -183,7 +183,6 @@ public class Config {
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(
|
||||
field.get(instance), spacing) + lineSeparator);
|
||||
@ -281,55 +280,53 @@ public class Config {
|
||||
Class<?> clazz = root == null ? MethodHandles.lookup().lookupClass() : root;
|
||||
Object instance = clazz.newInstance();
|
||||
while (split.length > 0) {
|
||||
switch (split.length) {
|
||||
case 1:
|
||||
return instance;
|
||||
default:
|
||||
Class found = null;
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
if (current.getSimpleName().equalsIgnoreCase(toFieldName(split[0]))) {
|
||||
found = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Field instanceField = clazz.getDeclaredField(toFieldName(split[0]));
|
||||
setAccessible(instanceField);
|
||||
if (instanceField.getType() != ConfigBlock.class) {
|
||||
Object value = instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = found.newInstance();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
clazz = found;
|
||||
instance = value;
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
continue;
|
||||
}
|
||||
ConfigBlock value = (ConfigBlock) instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = new ConfigBlock();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
instance = value.get(split[1]);
|
||||
if (instance == null) {
|
||||
instance = found.newInstance();
|
||||
value.put(split[1], instance);
|
||||
}
|
||||
clazz = found;
|
||||
split = Arrays.copyOfRange(split, 2, split.length);
|
||||
continue;
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
}
|
||||
if (found != null) {
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
clazz = found;
|
||||
instance = clazz.newInstance();
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
if (split.length == 1) {
|
||||
return instance;
|
||||
}
|
||||
Class found = null;
|
||||
Class<?>[] classes = clazz.getDeclaredClasses();
|
||||
for (Class current : classes) {
|
||||
if (current.getSimpleName().equalsIgnoreCase(toFieldName(split[0]))) {
|
||||
found = current;
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
Field instanceField = clazz.getDeclaredField(toFieldName(split[0]));
|
||||
setAccessible(instanceField);
|
||||
if (instanceField.getType() != ConfigBlock.class) {
|
||||
Object value = instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = found.newInstance();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
clazz = found;
|
||||
instance = value;
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
continue;
|
||||
}
|
||||
ConfigBlock value = (ConfigBlock) instanceField.get(instance);
|
||||
if (value == null) {
|
||||
value = new ConfigBlock();
|
||||
instanceField.set(instance, value);
|
||||
}
|
||||
instance = value.get(split[1]);
|
||||
if (instance == null) {
|
||||
instance = found.newInstance();
|
||||
value.put(split[1], instance);
|
||||
}
|
||||
clazz = found;
|
||||
split = Arrays.copyOfRange(split, 2, split.length);
|
||||
continue;
|
||||
} catch (NoSuchFieldException ignore) {
|
||||
}
|
||||
if (found != null) {
|
||||
split = Arrays.copyOfRange(split, 1, split.length);
|
||||
clazz = found;
|
||||
instance = clazz.newInstance();
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -80,8 +80,8 @@ public class Configuration {
|
||||
WorldUtil.IMP.getClosestBlock(block);
|
||||
if (value == null) {
|
||||
throw new UnknownBlockException(block);
|
||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir() &&
|
||||
!WorldUtil.IMP.isBlockSolid(value.best)) {
|
||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir()
|
||||
&& !WorldUtil.IMP.isBlockSolid(value.best)) {
|
||||
throw new UnsafeBlockException(value.best);
|
||||
}
|
||||
blockBucket.addBlock(value.best, chance);
|
||||
@ -114,7 +114,8 @@ public class Configuration {
|
||||
WorldUtil.IMP.getClosestBlock(block);
|
||||
if (value == null || value.match > 1) {
|
||||
return false;
|
||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir() && !WorldUtil.IMP.isBlockSolid(value.best)) {
|
||||
} else if (Settings.Enabled_Components.PREVENT_UNSAFE && !value.best.isAir()
|
||||
&& !WorldUtil.IMP.isBlockSolid(value.best)) {
|
||||
throw new UnsafeBlockException(value.best);
|
||||
}
|
||||
}
|
||||
|
@ -179,10 +179,10 @@ public class Settings extends Config {
|
||||
public static final class Auto_Clear extends ConfigBlock {
|
||||
@Create // This value has to be generated since an instance isn't static
|
||||
public CALIBRATION CALIBRATION = null;
|
||||
public int THRESHOLD = 1;
|
||||
public int THRESHOLD = -1;
|
||||
public int REQUIRED_PLOTS = -1;
|
||||
public boolean CONFIRMATION = true;
|
||||
public int DAYS = 7;
|
||||
public int DAYS = 90;
|
||||
public int SKIP_ACCOUNT_AGE_DAYS = -1;
|
||||
public List<String> WORLDS = new ArrayList<>(Collections.singletonList("*"));
|
||||
|
||||
@ -221,8 +221,17 @@ public class Settings extends Config {
|
||||
@Ignore public static boolean NATIVE_UUID_PROVIDER = false;
|
||||
}
|
||||
|
||||
|
||||
@Comment("General settings") public static final class General {
|
||||
@Comment("Display scientific numbers (4.2E8)") public static boolean SCIENTIFIC = false;
|
||||
@Comment("Replace wall when merging") public static boolean MERGE_REPLACE_WALL = true;
|
||||
}
|
||||
|
||||
|
||||
@Comment("Schematic Settings") public static final class Schematics {
|
||||
@Comment(
|
||||
"Whether schematic based generation should paste schematic on top of plots, or from Y=1")
|
||||
public static boolean PASTE_ON_TOP = true;
|
||||
}
|
||||
|
||||
|
||||
@ -271,6 +280,7 @@ public class Settings extends Config {
|
||||
MAX_PLOTS = 127;
|
||||
}
|
||||
|
||||
|
||||
public static final class Confirmation {
|
||||
@Comment("Teleport to your plot on death") public static int CONFIRMATION_TIMEOUT_SECONDS =
|
||||
20;
|
||||
@ -280,6 +290,7 @@ public class Settings extends Config {
|
||||
public static final class Teleport {
|
||||
@Comment("Teleport to your plot on death") public static boolean ON_DEATH = false;
|
||||
@Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false;
|
||||
@Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true;
|
||||
@Comment("Add a teleportation delay to all commands") public static int DELAY = 0;
|
||||
@Comment("The visit command is ordered by world instead of globally") public static boolean
|
||||
PER_WORLD_VISIT = false;
|
||||
@ -304,7 +315,9 @@ public class Settings extends Config {
|
||||
|
||||
|
||||
public static final class Ratings {
|
||||
public static List<String> CATEGORIES = new ArrayList<>();
|
||||
@Comment("Replace the rating system with a like system. Will add /plot like/dislike,"
|
||||
+ " and remove the rating command") public static boolean USE_LIKES = false;
|
||||
@Comment("Rating categories") public static List<String> CATEGORIES = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
||||
@ -342,7 +355,7 @@ public class Settings extends Config {
|
||||
@Comment("Actively purge invalid database entries") public static boolean DATABASE_PURGER =
|
||||
false;
|
||||
@Comment("Delete plots when a player is banned") public static boolean BAN_DELETER = false;
|
||||
@Comment("Prevent possibly unsafe blocks from being used in plot components") public static
|
||||
boolean PREVENT_UNSAFE = true;
|
||||
@Comment("Prevent possibly unsafe blocks from being used in plot components")
|
||||
public static boolean PREVENT_UNSAFE = true;
|
||||
}
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.flag.Flag;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.comment.PlotComment;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.*;
|
||||
|
||||
public interface AbstractDB {
|
||||
@ -14,7 +15,7 @@ public interface AbstractDB {
|
||||
UUID everyone = UUID.fromString("1-1-3-3-7");
|
||||
|
||||
/**
|
||||
* Set Plot owner.
|
||||
* Sets Plot owner.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param uuid the uuid of the new owner
|
||||
@ -22,7 +23,7 @@ public interface AbstractDB {
|
||||
void setOwner(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* Create all settings, and create default helpers, trusted + denied lists.
|
||||
* Creates all settings, and create default helpers, trusted + denied lists.
|
||||
*
|
||||
* @param plots Plots for which the default table entries should be created
|
||||
* @param whenDone the task to run when the method is finished executing
|
||||
@ -30,7 +31,7 @@ public interface AbstractDB {
|
||||
void createPlotsAndData(List<Plot> plots, Runnable whenDone);
|
||||
|
||||
/**
|
||||
* Create a plot.
|
||||
* Creates a plot.
|
||||
*
|
||||
* @param plot the plot to create
|
||||
*/
|
||||
@ -44,7 +45,7 @@ public interface AbstractDB {
|
||||
void createTables() throws Exception;
|
||||
|
||||
/**
|
||||
* Delete a plot.
|
||||
* Deletes a plot.
|
||||
*
|
||||
* @param plot the plot to delete
|
||||
*/
|
||||
@ -57,14 +58,14 @@ public interface AbstractDB {
|
||||
void deleteTrusted(Plot plot);
|
||||
|
||||
/**
|
||||
* Remove all denied players from the plot.
|
||||
* Removes all denied players from the plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
*/
|
||||
void deleteDenied(Plot plot);
|
||||
|
||||
/**
|
||||
* Delete all comments from the plot.
|
||||
* Deletes all comments from the plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
*/
|
||||
@ -81,7 +82,7 @@ public interface AbstractDB {
|
||||
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
|
||||
|
||||
/**
|
||||
* Create the plot settings.
|
||||
* Creates the plot settings.
|
||||
*
|
||||
* @param id the plot entry id
|
||||
* @param plot the plot
|
||||
@ -89,7 +90,7 @@ public interface AbstractDB {
|
||||
void createPlotSettings(int id, Plot plot);
|
||||
|
||||
/**
|
||||
* Get the table entry ID.
|
||||
* Gets the table entry ID.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @return {@code Integer} = Plot Entry Id
|
||||
@ -97,7 +98,7 @@ public interface AbstractDB {
|
||||
int getId(Plot plot);
|
||||
|
||||
/**
|
||||
* Get the id of a given plot cluster.
|
||||
* Gets the id of a given plot cluster.
|
||||
*
|
||||
* @param cluster PlotCluster Object
|
||||
* @return Integer = Cluster Entry Id
|
||||
@ -120,7 +121,7 @@ public interface AbstractDB {
|
||||
HashMap<String, Set<PlotCluster>> getClusters();
|
||||
|
||||
/**
|
||||
* Set the merged status for a plot.
|
||||
* Sets the merged status for a plot.
|
||||
*
|
||||
* @param plot The plot to set the merged status of
|
||||
* @param merged boolean[]
|
||||
@ -128,7 +129,7 @@ public interface AbstractDB {
|
||||
void setMerged(Plot plot, boolean[] merged);
|
||||
|
||||
/**
|
||||
* Swap the settings, helpers etc. of two plots.
|
||||
* Swaps the settings, helpers etc. of two plots.
|
||||
*
|
||||
* @param plot1 Plot1
|
||||
* @param plot2 Plot2
|
||||
@ -136,7 +137,7 @@ public interface AbstractDB {
|
||||
void swapPlots(Plot plot1, Plot plot2);
|
||||
|
||||
/**
|
||||
* Set plot flags.
|
||||
* Sets plot flags.
|
||||
*
|
||||
* @param plot Plot Object
|
||||
* @param flags flags to set
|
||||
@ -144,15 +145,7 @@ public interface AbstractDB {
|
||||
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags);
|
||||
|
||||
/**
|
||||
* Set cluster flags.
|
||||
*
|
||||
* @param cluster PlotCluster Object
|
||||
* @param flags flags to set (flag[])
|
||||
*/
|
||||
void setFlags(PlotCluster cluster, HashMap<Flag<?>, Object> flags);
|
||||
|
||||
/**
|
||||
* Rename a cluster to the given name.
|
||||
* Renames a cluster to the given name.
|
||||
*
|
||||
* @param cluster the cluster to rename
|
||||
* @param name the new cluster name
|
||||
@ -160,7 +153,7 @@ public interface AbstractDB {
|
||||
void setClusterName(PlotCluster cluster, String name);
|
||||
|
||||
/**
|
||||
* Set the plot alias.
|
||||
* Sets the plot alias.
|
||||
*
|
||||
* @param plot Plot for which the alias should be set
|
||||
* @param alias Plot Alias
|
||||
@ -168,14 +161,14 @@ public interface AbstractDB {
|
||||
void setAlias(Plot plot, String alias);
|
||||
|
||||
/**
|
||||
* Purge a plot.
|
||||
* Purges a plot.
|
||||
*
|
||||
* @param uniqueIds list of plot id (db) to be purged
|
||||
*/
|
||||
void purgeIds(Set<Integer> uniqueIds);
|
||||
|
||||
/**
|
||||
* Purge a whole world.
|
||||
* Purges a whole world.
|
||||
*
|
||||
* @param area World in which the plots should be purged
|
||||
* @param plotIds the {@code PlotId}s of {@code Plot}s to purge
|
||||
@ -183,7 +176,7 @@ public interface AbstractDB {
|
||||
void purge(PlotArea area, Set<PlotId> plotIds);
|
||||
|
||||
/**
|
||||
* Set the plot home position.
|
||||
* Sets the plot home position.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param position the position of plot home
|
||||
@ -247,7 +240,7 @@ public interface AbstractDB {
|
||||
void setInvited(PlotCluster cluster, UUID uuid);
|
||||
|
||||
/**
|
||||
* Remove the specified player from the denied list of the specified plot.
|
||||
* Removes the specified player from the denied list of the specified plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param uuid the uuid of the player to remove
|
||||
@ -255,7 +248,7 @@ public interface AbstractDB {
|
||||
void removeDenied(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* Deny the specified player from the given plot.
|
||||
* Denies the specified player from the given plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param uuid the uuid of the player to deny
|
||||
@ -263,7 +256,7 @@ public interface AbstractDB {
|
||||
void setDenied(Plot plot, UUID uuid);
|
||||
|
||||
/**
|
||||
* Get the ratings from the specified plot.
|
||||
* Gets the ratings from the specified plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @return the plot ratings (pre-calculated)
|
||||
@ -271,7 +264,7 @@ public interface AbstractDB {
|
||||
HashMap<UUID, Integer> getRatings(Plot plot);
|
||||
|
||||
/**
|
||||
* Set a rating for a plot.
|
||||
* Sets a rating for a plot.
|
||||
*
|
||||
* @param plot
|
||||
* @param rater
|
||||
@ -280,7 +273,7 @@ public interface AbstractDB {
|
||||
void setRating(Plot plot, UUID rater, int value);
|
||||
|
||||
/**
|
||||
* Remove the specified comment from the given plot.
|
||||
* Removes the specified comment from the given plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param comment the comment to remove
|
||||
@ -288,7 +281,7 @@ public interface AbstractDB {
|
||||
void removeComment(Plot plot, PlotComment comment);
|
||||
|
||||
/**
|
||||
* Clear the specified inbox on the given plot.
|
||||
* Clears the specified inbox on the given plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param inbox the inbox to clear
|
||||
@ -296,7 +289,7 @@ public interface AbstractDB {
|
||||
void clearInbox(Plot plot, String inbox);
|
||||
|
||||
/**
|
||||
* Add the specified comment to the given plot.
|
||||
* Adds the specified comment to the given plot.
|
||||
*
|
||||
* @param plot the plot
|
||||
* @param comment the comment to add
|
||||
@ -304,11 +297,11 @@ public interface AbstractDB {
|
||||
void setComment(Plot plot, PlotComment comment);
|
||||
|
||||
/**
|
||||
* Get Plot Comments.
|
||||
* Gets Plot Comments.
|
||||
*
|
||||
* @param plot The Plot to get comments from
|
||||
*/
|
||||
void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
|
||||
void getComments(@Nonnull Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone);
|
||||
|
||||
void createPlotAndSettings(Plot plot, Runnable whenDone);
|
||||
|
||||
@ -319,7 +312,7 @@ public interface AbstractDB {
|
||||
void movePlot(Plot originalPlot, Plot newPlot);
|
||||
|
||||
/**
|
||||
* Replace a old uuid with a new one in the database.
|
||||
* Replaces a old uuid with a new one in the database.
|
||||
*
|
||||
* <ul>
|
||||
* <li> Useful for replacing a few uuids (not the entire database).</li>
|
||||
@ -339,7 +332,7 @@ public interface AbstractDB {
|
||||
boolean deleteTables();
|
||||
|
||||
/**
|
||||
* Close the database. Generally not recommended to be used by add-ons.
|
||||
* Closes the database. Generally not recommended to be used by add-ons.
|
||||
*/
|
||||
void close();
|
||||
|
||||
|
@ -19,6 +19,7 @@ public class DBFunc {
|
||||
*/
|
||||
// TODO: Use this instead. public static final UUID EVERYONE = UUID.fromString("4aa2aaa4-c06b-485c-bc58-186aa1780d9b");
|
||||
public static final UUID EVERYONE = UUID.fromString("1-1-3-3-7");
|
||||
public static final UUID SERVER = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
/**
|
||||
* Abstract Database Manager
|
||||
@ -298,13 +299,6 @@ public class DBFunc {
|
||||
DBFunc.dbManager.setFlags(plot, flags);
|
||||
}
|
||||
|
||||
public static void setFlags(PlotCluster cluster, HashMap<Flag<?>, Object> flags) {
|
||||
if (dbManager == null) {
|
||||
return;
|
||||
}
|
||||
DBFunc.dbManager.setFlags(cluster, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param plot
|
||||
* @param alias
|
||||
|
@ -45,7 +45,7 @@ public class MySQL extends Database {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
@Override public Connection openConnection() throws SQLException, ClassNotFoundException {
|
||||
@Override public Connection openConnection() throws SQLException {
|
||||
if (checkConnection()) {
|
||||
return this.connection;
|
||||
}
|
||||
@ -69,7 +69,7 @@ public class MySQL extends Database {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public ResultSet querySQL(String query) throws SQLException, ClassNotFoundException {
|
||||
@Override public ResultSet querySQL(String query) throws SQLException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
@ -78,7 +78,7 @@ public class MySQL extends Database {
|
||||
}
|
||||
}
|
||||
|
||||
@Override public int updateSQL(String query) throws SQLException, ClassNotFoundException {
|
||||
@Override public int updateSQL(String query) throws SQLException {
|
||||
if (checkConnection()) {
|
||||
openConnection();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,6 +4,8 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public abstract class StmtMod<T> {
|
||||
|
||||
@ -19,12 +21,9 @@ public abstract class StmtMod<T> {
|
||||
}
|
||||
|
||||
public String getCreateSQLite(int size, String query, int params) {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("UNION SELECT ").append(modParams).append(' ');
|
||||
}
|
||||
return statement.toString();
|
||||
return IntStream.range(0, size - 1).mapToObj(i -> "UNION SELECT " + modParams + ' ')
|
||||
.collect(Collectors.joining("", query, ""));
|
||||
}
|
||||
|
||||
public abstract String getCreateSQLite(int size);
|
||||
|
@ -2,12 +2,16 @@ package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotSettings;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.Permissions;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Flag Manager Utility.
|
||||
@ -141,13 +145,6 @@ public class FlagManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static <V> boolean addClusterFlag(PlotCluster cluster, Flag<V> flag, V value) {
|
||||
getSettingFlag(cluster.area, cluster.settings, flag);
|
||||
cluster.settings.flags.put(flag, value);
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of the {@link Flag}s and their values for the specified plot.
|
||||
*
|
||||
@ -217,20 +214,6 @@ public class FlagManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean removeClusterFlag(PlotCluster cluster, Flag id) {
|
||||
Object object = cluster.settings.flags.remove(id);
|
||||
if (object == null) {
|
||||
return false;
|
||||
}
|
||||
boolean result = EventUtil.manager.callFlagRemove(id, object, cluster);
|
||||
if (!result) {
|
||||
cluster.settings.flags.put(id, object);
|
||||
return false;
|
||||
}
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setPlotFlags(Plot origin, HashMap<Flag<?>, Object> flags) {
|
||||
for (Plot plot : origin.getConnectedPlots()) {
|
||||
if (flags != null && !flags.isEmpty()) {
|
||||
@ -248,20 +231,6 @@ public class FlagManager {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setClusterFlags(PlotCluster cluster, Set<Flag> flags) {
|
||||
if (flags != null && !flags.isEmpty()) {
|
||||
cluster.settings.flags.clear();
|
||||
for (Flag flag : flags) {
|
||||
cluster.settings.flags.put(flag, flag);
|
||||
}
|
||||
} else if (cluster.settings.flags.isEmpty()) {
|
||||
return;
|
||||
} else {
|
||||
cluster.settings.flags.clear();
|
||||
}
|
||||
DBFunc.setFlags(cluster, cluster.settings.flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of registered {@link Flag} objects based on player permissions.
|
||||
*
|
||||
@ -269,13 +238,9 @@ public class FlagManager {
|
||||
* @return a list of flags the specified player can use
|
||||
*/
|
||||
public static List<Flag> getFlags(PlotPlayer player) {
|
||||
List<Flag> returnFlags = new ArrayList<>();
|
||||
for (Flag flag : Flags.getFlags()) {
|
||||
if (Permissions
|
||||
.hasPermission(player, "plots.set.flag." + flag.getName().toLowerCase())) {
|
||||
returnFlags.add(flag);
|
||||
}
|
||||
}
|
||||
List<Flag> returnFlags = Flags.getFlags().stream().filter(flag -> Permissions
|
||||
.hasPermission(player, "plots.set.flag." + flag.getName().toLowerCase()))
|
||||
.collect(Collectors.toList());
|
||||
return returnFlags;
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Plot;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||
@ -31,6 +28,8 @@ public final class Flags {
|
||||
public static final BooleanFlag NOTIFY_LEAVE = new BooleanFlag("notify-leave");
|
||||
public static final BooleanFlag TITLES = new BooleanFlag("titles");
|
||||
public static final BooleanFlag NOTIFY_ENTER = new BooleanFlag("notify-enter");
|
||||
public static final BooleanFlag HIDE_INFO = new BooleanFlag("hide-info");
|
||||
public static final BooleanFlag SERVER_PLOT = new BooleanFlag("server-plot");
|
||||
public static final LongFlag TIME = new LongFlag("time");
|
||||
public static final PlotWeatherFlag WEATHER = new PlotWeatherFlag("weather");
|
||||
public static final DoubleFlag PRICE = new DoubleFlag("price") {
|
||||
@ -163,42 +162,37 @@ public final class Flags {
|
||||
public static void registerFlag(final Flag<?> flag) {
|
||||
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
||||
if (duplicate != null) {
|
||||
PlotSquared.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||
@Override public void run(PlotArea value) {
|
||||
Object remove;
|
||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||
try {
|
||||
if (remove instanceof Collection
|
||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||
== Object.class) {
|
||||
value.DEFAULT_FLAGS.put(flag,
|
||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.DEFAULT_FLAGS.put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
PlotSquared.get().forEachPlotArea(value -> {
|
||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||
Object remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||
try {
|
||||
if (remove instanceof Collection
|
||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||
== Object.class) {
|
||||
value.DEFAULT_FLAGS.put(flag,
|
||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.DEFAULT_FLAGS.put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
PlotSquared.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override public void run(Plot value) {
|
||||
if (value.getFlags().containsKey(duplicate)) {
|
||||
Object remove = value.getFlags().remove(duplicate);
|
||||
try {
|
||||
if (remove instanceof Collection
|
||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||
== Object.class) {
|
||||
value.getFlags().put(flag,
|
||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.getFlags().put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
PlotSquared.get().forEachPlotRaw(value -> {
|
||||
if (value.hasFlag(duplicate)) {
|
||||
Object remove = value.getFlags().remove(duplicate);
|
||||
try {
|
||||
if (remove instanceof Collection
|
||||
&& remove.getClass().getMethod("toString").getDeclaringClass()
|
||||
== Object.class) {
|
||||
value.getFlags().put(flag,
|
||||
flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.getFlags().put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,17 +1,20 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.flag;
|
||||
|
||||
public class IntervalFlag extends Flag<Integer[]> {
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
public class IntervalFlag extends Flag<IntervalFlag.Interval> {
|
||||
|
||||
public IntervalFlag(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override public String valueToString(Object value) {
|
||||
Integer[] value1 = (Integer[]) value;
|
||||
return value1[0] + " " + value1[1];
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
@Override public Integer[] parseValue(String value) {
|
||||
@Override public Interval parseValue(String value) {
|
||||
int seconds;
|
||||
int amount;
|
||||
String[] values = value.split(" ");
|
||||
@ -32,10 +35,22 @@ public class IntervalFlag extends Flag<Integer[]> {
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return new Integer[] {amount, seconds};
|
||||
return new Interval(amount, seconds);
|
||||
}
|
||||
|
||||
@Override public String getValueDescription() {
|
||||
return "Value(s) must be numeric. /plot set flag <flag> <interval> [amount]";
|
||||
}
|
||||
|
||||
@EqualsAndHashCode @RequiredArgsConstructor @Getter public static final class Interval {
|
||||
|
||||
private final int val1;
|
||||
private final int val2;
|
||||
|
||||
public String toString() {
|
||||
return String.format("%d %d", this.val1, this.val2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
|
||||
return StringMan.join((HashSet<PlotBlock>) value, ",");
|
||||
}
|
||||
|
||||
@Override public HashSet<PlotBlock> parseValue(String value) {
|
||||
HashSet<PlotBlock> list = new HashSet<>();
|
||||
for (String item : value.split(",")) {
|
||||
PlotBlock block = PlotSquared.get().IMP.getLegacyMappings().fromAny(item);
|
||||
@Override public HashSet<PlotBlock> parseValue(final String value) {
|
||||
final HashSet<PlotBlock> list = new HashSet<>();
|
||||
for (final String item : value.split(",")) {
|
||||
final PlotBlock block = PlotSquared.get().IMP.getLegacyMappings().fromAny(item);
|
||||
if (block != null) {
|
||||
list.add(block);
|
||||
}
|
||||
|
@ -1,11 +1,17 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.Location;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.StringPlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@ -19,15 +25,15 @@ public class AugmentedUtils {
|
||||
enabled = true;
|
||||
}
|
||||
|
||||
public static boolean generate(final String world, final int cx, final int cz,
|
||||
public static boolean generate(@NotNull final String world, final int chunkX, final int chunkZ,
|
||||
LocalBlockQueue queue) {
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final int bx = cx << 4;
|
||||
final int bz = cz << 4;
|
||||
RegionWrapper region = new RegionWrapper(bx, bx + 15, bz, bz + 15);
|
||||
final int blockX = chunkX << 4;
|
||||
final int blockZ = chunkZ << 4;
|
||||
RegionWrapper region = new RegionWrapper(blockX, blockX + 15, blockZ, blockZ + 15);
|
||||
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
|
||||
if (areas.isEmpty()) {
|
||||
return false;
|
||||
@ -49,17 +55,17 @@ public class AugmentedUtils {
|
||||
queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
||||
}
|
||||
LocalBlockQueue primaryMask;
|
||||
// coords
|
||||
// coordinates
|
||||
int bxx;
|
||||
int bzz;
|
||||
int txx;
|
||||
int tzz;
|
||||
// gen
|
||||
if (area.TYPE == 2) {
|
||||
bxx = Math.max(0, area.getRegion().minX - bx);
|
||||
bzz = Math.max(0, area.getRegion().minZ - bz);
|
||||
txx = Math.min(15, area.getRegion().maxX - bx);
|
||||
tzz = Math.min(15, area.getRegion().maxZ - bz);
|
||||
bxx = Math.max(0, area.getRegion().minX - blockX);
|
||||
bzz = Math.max(0, area.getRegion().minZ - blockZ);
|
||||
txx = Math.min(15, area.getRegion().maxX - blockX);
|
||||
tzz = Math.min(15, area.getRegion().maxZ - blockZ);
|
||||
primaryMask = new DelegateLocalBlockQueue(queue) {
|
||||
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
|
||||
if (area.contains(x, z)) {
|
||||
@ -88,9 +94,9 @@ public class AugmentedUtils {
|
||||
boolean has = false;
|
||||
for (int x = bxx; x <= txx; x++) {
|
||||
for (int z = bzz; z <= tzz; z++) {
|
||||
int rx = x + bx;
|
||||
int rz = z + bz;
|
||||
boolean can = manager.getPlotId(area, rx, 0, rz) == null;
|
||||
int rx = x + blockX;
|
||||
int rz = z + blockZ;
|
||||
boolean can = manager.getPlotId(rx, 0, rz) == null;
|
||||
if (can) {
|
||||
for (int y = 1; y < 128; y++) {
|
||||
queue.setBlock(rx, y, rz, air);
|
||||
@ -106,7 +112,7 @@ public class AugmentedUtils {
|
||||
toReturn = true;
|
||||
secondaryMask = new DelegateLocalBlockQueue(primaryMask) {
|
||||
@Override public boolean setBlock(int x, int y, int z, PlotBlock id) {
|
||||
if (canPlace[x - bx][z - bz]) {
|
||||
if (canPlace[x - blockX][z - blockZ]) {
|
||||
return super.setBlock(x, y, z, id);
|
||||
}
|
||||
return false;
|
||||
@ -121,15 +127,15 @@ public class AugmentedUtils {
|
||||
for (int x = bxx; x <= txx; x++) {
|
||||
for (int z = bzz; z <= tzz; z++) {
|
||||
for (int y = 1; y < 128; y++) {
|
||||
queue.setBlock(bx + x, y, bz + z, air);
|
||||
queue.setBlock(blockX + x, y, blockZ + z, air);
|
||||
}
|
||||
}
|
||||
}
|
||||
toReturn = true;
|
||||
}
|
||||
ScopedLocalBlockQueue scoped =
|
||||
new ScopedLocalBlockQueue(secondaryMask, new Location(area.worldname, bx, 0, bz),
|
||||
new Location(area.worldname, bx + 15, 255, bz + 15));
|
||||
ScopedLocalBlockQueue scoped = new ScopedLocalBlockQueue(secondaryMask,
|
||||
new Location(area.worldname, blockX, 0, blockZ),
|
||||
new Location(area.worldname, blockX + 15, 255, blockZ + 15));
|
||||
generator.generateChunk(scoped, area);
|
||||
generator.populateChunk(scoped, area);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
||||
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
|
||||
@ -12,55 +13,60 @@ import java.util.List;
|
||||
*/
|
||||
public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override public boolean setComponent(PlotArea plotArea, PlotId plotId, String component,
|
||||
BlockBucket blocks) {
|
||||
private final ClassicPlotWorld classicPlotWorld;
|
||||
|
||||
public ClassicPlotManager(ClassicPlotWorld classicPlotWorld) {
|
||||
super(classicPlotWorld);
|
||||
this.classicPlotWorld = classicPlotWorld;
|
||||
}
|
||||
|
||||
@Override public boolean setComponent(PlotId plotId, String component,
|
||||
BlockBucket blocks) {
|
||||
switch (component) {
|
||||
case "floor":
|
||||
setFloor(plotArea, plotId, blocks);
|
||||
setFloor(plotId, blocks);
|
||||
return true;
|
||||
case "wall":
|
||||
setWallFilling(plotArea, plotId, blocks);
|
||||
setWallFilling(plotId, blocks);
|
||||
return true;
|
||||
case "all":
|
||||
setAll(plotArea, plotId, blocks);
|
||||
setAll(plotId, blocks);
|
||||
return true;
|
||||
case "air":
|
||||
setAir(plotArea, plotId, blocks);
|
||||
setAir(plotId, blocks);
|
||||
return true;
|
||||
case "main":
|
||||
setMain(plotArea, plotId, blocks);
|
||||
setMain(plotId, blocks);
|
||||
return true;
|
||||
case "middle":
|
||||
setMiddle(plotArea, plotId, blocks);
|
||||
setMiddle(plotId, blocks);
|
||||
return true;
|
||||
case "outline":
|
||||
setOutline(plotArea, plotId, blocks);
|
||||
setOutline(plotId, blocks);
|
||||
return true;
|
||||
case "border":
|
||||
setWall(plotArea, plotId, blocks);
|
||||
setWall(plotId, blocks);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public boolean unclaimPlot(PlotArea plotArea, Plot plot, Runnable whenDone) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
setWallFilling(dpw, plot.getId(), dpw.WALL_FILLING);
|
||||
setWall(dpw, plot.getId(), dpw.WALL_BLOCK);
|
||||
@Override public boolean unClaimPlot(Plot plot, Runnable whenDone) {
|
||||
setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING);
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||
GlobalBlockQueue.IMP.addTask(whenDone);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setFloor(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
public boolean setFloor(PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
if (plot.isBasePlot()) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 =
|
||||
new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT, region.minZ);
|
||||
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT, region.minZ);
|
||||
Location pos2 =
|
||||
new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT, region.maxZ);
|
||||
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
@ -68,120 +74,116 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAll(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
public boolean setAll(PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
int maxY = getWorldHeight();
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ);
|
||||
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setAir(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
public boolean setAir(PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
int maxY = getWorldHeight();
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 =
|
||||
new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ);
|
||||
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMain(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
public boolean setMain(PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
|
||||
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 =
|
||||
new Location(plotArea.worldname, region.maxX, dpw.PLOT_HEIGHT - 1, region.maxZ);
|
||||
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setMiddle(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
public boolean setMiddle(PlotId plotId, BlockBucket blocks) {
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
if (!plot.isBasePlot()) {
|
||||
return false;
|
||||
}
|
||||
Location[] corners = plot.getCorners();
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
|
||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||
queue.setBlock(x, dpw.PLOT_HEIGHT, z, blocks.getBlock());
|
||||
queue.setBlock(x, classicPlotWorld.PLOT_HEIGHT, z, blocks.getBlock());
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setOutline(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
public boolean setOutline(PlotId plotId, BlockBucket blocks) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
Location bottom = plot.getBottomAbs();
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
if (!plot.getMerged(0)) {
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
int maxY = classicPlotWorld.getPlotManager().getWorldHeight();
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bottom.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
if (!plot.getMerged(Direction.WEST)) {
|
||||
int x = bottom.getX();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!plot.getMerged(2)) {
|
||||
if (!plot.getMerged(Direction.SOUTH)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
if (!plot.getMerged(Direction.EAST)) {
|
||||
int x = top.getX();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
for (int y = classicPlotWorld.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.isBasePlot()) {
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, maxY, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ);
|
||||
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, maxY, region.minZ);
|
||||
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
@ -189,44 +191,46 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWallFilling(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
public boolean setWallFilling(PlotId plotId, BlockBucket blocks) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
Location bot = plot.getExtendedBottomAbs()
|
||||
.subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
if (!plot.getMerged(0)) {
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
if (!plot.getMerged(Direction.WEST)) {
|
||||
int x = bot.getX();
|
||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(2)) {
|
||||
if (!plot.getMerged(Direction.SOUTH)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
for (int x = bot.getX();
|
||||
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
if (!plot.getMerged(Direction.EAST)) {
|
||||
int x = top.getX();
|
||||
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
for (int z = bot.getZ();
|
||||
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
||||
for (int y = 1; y <= classicPlotWorld.WALL_HEIGHT; y++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
@ -235,39 +239,40 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean setWall(PlotArea plotArea, PlotId plotId, BlockBucket blocks) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
if (dpw.ROAD_WIDTH == 0) {
|
||||
public boolean setWall(PlotId plotId, BlockBucket blocks) {
|
||||
if (classicPlotWorld.ROAD_WIDTH == 0) {
|
||||
return false;
|
||||
}
|
||||
Plot plot = plotArea.getPlotAbs(plotId);
|
||||
Plot plot = classicPlotWorld.getPlotAbs(plotId);
|
||||
Location bot = plot.getExtendedBottomAbs()
|
||||
.subtract(plot.getMerged(3) ? 0 : 1, 0, plot.getMerged(0) ? 0 : 1);
|
||||
.subtract(plot.getMerged(Direction.WEST) ? 0 : 1, 0,
|
||||
plot.getMerged(Direction.NORTH) ? 0 : 1);
|
||||
Location top = plot.getExtendedTopAbs().add(1, 0, 1);
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int y = dpw.WALL_HEIGHT + 1;
|
||||
if (!plot.getMerged(0)) {
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
int y = classicPlotWorld.WALL_HEIGHT + 1;
|
||||
if (!plot.getMerged(Direction.NORTH)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
if (!plot.getMerged(Direction.WEST)) {
|
||||
int x = bot.getX();
|
||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(2)) {
|
||||
if (!plot.getMerged(Direction.SOUTH)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
|
||||
for (int x = bot.getX();
|
||||
x < top.getX() + (plot.getMerged(Direction.EAST) ? 0 : 1); x++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
if (!plot.getMerged(Direction.EAST)) {
|
||||
int x = top.getX();
|
||||
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
|
||||
for (int z = bot.getZ();
|
||||
z < top.getZ() + (plot.getMerged(Direction.SOUTH) ? 0 : 1); z++) {
|
||||
queue.setBlock(x, y, z, blocks.getBlock());
|
||||
}
|
||||
}
|
||||
@ -278,145 +283,139 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
/**
|
||||
* PLOT MERGING.
|
||||
*/
|
||||
@Override public boolean createRoadEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
@Override public boolean createRoadEast(Plot plot) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 2;
|
||||
int ez = pos2.getZ() + 2;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
int maxY = getWorldHeight();
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1,
|
||||
sz + 1), new Location(plotArea.worldname, ex, maxY, ez - 1),
|
||||
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
|
||||
sz + 1), new Location(classicPlotWorld.worldname, ex, maxY, ez - 1),
|
||||
PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 0, sz + 1),
|
||||
new Location(plotArea.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz + 1),
|
||||
new Location(plotArea.worldname, sx, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(plotArea.worldname, sx, dpw.WALL_HEIGHT + 1, ez - 1), dpw.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, ex, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.WALL_HEIGHT, ez - 1), dpw.WALL_FILLING);
|
||||
queue.setCuboid(new Location(plotArea.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.WALL_HEIGHT + 1, ez - 1), dpw.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 0, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, sx, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.WALL_HEIGHT + 1, ez - 1), classicPlotWorld.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
@Override public boolean createRoadSouth(Plot plot) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 2;
|
||||
int ex = pos2.getX() + 2;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1,
|
||||
new Location(classicPlotWorld.worldname, sx + 1, Math.min(classicPlotWorld.WALL_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
|
||||
sz),
|
||||
new Location(plotArea.worldname, ex - 1, plotArea.getPlotManager().getWorldHeight(),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(),
|
||||
ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, sz), dpw.WALL_FILLING);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, sz), dpw.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, ez),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT, ez), dpw.WALL_FILLING);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.WALL_HEIGHT + 1, ez),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.WALL_HEIGHT + 1, ez), dpw.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, sz),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, sz), classicPlotWorld.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, ez),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT, ez), classicPlotWorld.WALL_FILLING);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.WALL_HEIGHT + 1, ez),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean createRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
@Override public boolean createRoadSouthEast(Plot plot) {
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.getPlotManager().getWorldHeight(), ez - 1),
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.getPlotManager().getWorldHeight(), ez - 1),
|
||||
PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez - 1),
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, 0, ez - 1),
|
||||
PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.ROAD_HEIGHT, ez - 1), dpw.ROAD_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
@Override public boolean removeRoadEast(Plot plot) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sx = pos2.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = pos1.getZ() - 1;
|
||||
int ez = pos2.getZ() + 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1,
|
||||
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
|
||||
sz),
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT, ez - 1), dpw.TOP_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT - 1, ez - 1), classicPlotWorld.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.PLOT_HEIGHT, sz + 1),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.PLOT_HEIGHT, ez - 1), classicPlotWorld.TOP_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouth(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location pos1 = getPlotBottomLocAbs(plotArea, plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plotArea, plot.getId());
|
||||
@Override public boolean removeRoadSouth(Plot plot) {
|
||||
Location pos1 = getPlotBottomLocAbs(plot.getId());
|
||||
Location pos2 = getPlotTopLocAbs(plot.getId());
|
||||
int sz = pos2.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sx = pos1.getX() - 1;
|
||||
int ex = pos2.getX() + 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1,
|
||||
new Location(classicPlotWorld.worldname, sx, Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1,
|
||||
sz),
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, 1, sz),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx + 1, classicPlotWorld.PLOT_HEIGHT, sz),
|
||||
new Location(classicPlotWorld.worldname, ex - 1, classicPlotWorld.PLOT_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean removeRoadSouthEast(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
Location location = getPlotTopLocAbs(dpw, plot.getId());
|
||||
@Override public boolean removeRoadSouthEast(Plot plot) {
|
||||
Location location = getPlotTopLocAbs(plot.getId());
|
||||
int sx = location.getX() + 1;
|
||||
int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
int ex = sx + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
int sz = location.getZ() + 1;
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez),
|
||||
int ez = sz + classicPlotWorld.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = classicPlotWorld.getQueue(false);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT + 1, sz),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.getPlotManager().getWorldHeight(), ez),
|
||||
PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz),
|
||||
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz),
|
||||
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, 1, sz),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(classicPlotWorld.worldname, sx, classicPlotWorld.ROAD_HEIGHT, sz),
|
||||
new Location(classicPlotWorld.worldname, ex, classicPlotWorld.ROAD_HEIGHT, ez), classicPlotWorld.TOP_BLOCK);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
@ -424,44 +423,58 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
/**
|
||||
* Finishing off plot merging by adding in the walls surrounding the plot (OPTIONAL)(UNFINISHED).
|
||||
*/
|
||||
@Override public boolean finishPlotMerge(PlotArea plotArea, List<PlotId> plotIds) {
|
||||
final BlockBucket block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
plotIds.forEach(id -> setWall(plotArea, id, block));
|
||||
@Override public boolean finishPlotMerge(List<PlotId> plotIds) {
|
||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
plotIds.forEach(id -> setWall(id, block));
|
||||
if (Settings.General.MERGE_REPLACE_WALL) {
|
||||
final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING;
|
||||
plotIds.forEach(id -> setWallFilling(id, wallBlock));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean finishPlotUnlink(PlotArea plotArea, List<PlotId> plotIds) {
|
||||
final BlockBucket block = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
plotIds.forEach(id -> setWall(plotArea, id, block));
|
||||
@Override public boolean finishPlotUnlink(List<PlotId> plotIds) {
|
||||
final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
plotIds.forEach(id -> setWall(id, block));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean startPlotMerge(PlotArea plotArea, List<PlotId> plotIds) {
|
||||
@Override public boolean regenerateAllPlotWalls() {
|
||||
for (Plot plot : classicPlotWorld.getPlots()) {
|
||||
if (plot.hasOwner()) {
|
||||
setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK);
|
||||
} else {
|
||||
setWall(plot.getId(), classicPlotWorld.WALL_BLOCK);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean startPlotUnlink(PlotArea plotArea, List<PlotId> plotIds) {
|
||||
@Override public boolean startPlotMerge(List<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean claimPlot(PlotArea plotArea, Plot plot) {
|
||||
final BlockBucket claim = ((ClassicPlotWorld) plotArea).CLAIMED_WALL_BLOCK;
|
||||
setWall(plotArea, plot.getId(), claim);
|
||||
@Override public boolean startPlotUnlink(List<PlotId> plotIds) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public String[] getPlotComponents(PlotArea plotArea, PlotId plotId) {
|
||||
@Override public boolean claimPlot(Plot plot) {
|
||||
final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK;
|
||||
setWall(plot.getId(), claim);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public String[] getPlotComponents(PlotId plotId) {
|
||||
return new String[] {"main", "floor", "air", "all", "border", "wall", "outline", "middle"};
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove sign for a plot.
|
||||
*/
|
||||
@Override public Location getSignLoc(PlotArea plotArea, Plot plot) {
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
@Override public Location getSignLoc(Plot plot) {
|
||||
plot = plot.getBasePlot(false);
|
||||
Location bot = plot.getBottomAbs();
|
||||
return new Location(plotArea.worldname, bot.getX() - 1, dpw.ROAD_HEIGHT + 1,
|
||||
return new Location(classicPlotWorld.worldname, bot.getX() - 1, classicPlotWorld.ROAD_HEIGHT + 1,
|
||||
bot.getZ() - 2);
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Locale;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
@SuppressWarnings("WeakerAccess") public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
|
||||
public int ROAD_HEIGHT = 62;
|
||||
public int PLOT_HEIGHT = 62;
|
||||
@ -33,7 +33,8 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
// PlotBlock.get((short) 155, (byte) 0);
|
||||
public boolean PLOT_BEDROCK = true;
|
||||
|
||||
public ClassicPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
|
||||
public ClassicPlotWorld(String worldName, String id,
|
||||
@NotNull IndependentPlotGenerator generator,
|
||||
PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
}
|
||||
@ -94,11 +95,12 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
||||
|
||||
// Dump world settings
|
||||
if (Settings.DEBUG) {
|
||||
PlotSquared.debug(String.format("- Dumping settings for ClassicPlotWorld with name %s", this.worldname));
|
||||
PlotSquared.debug(String
|
||||
.format("- Dumping settings for ClassicPlotWorld with name %s", this.worldname));
|
||||
final Field[] fields = this.getClass().getFields();
|
||||
for (final Field field : fields) {
|
||||
final String name = field.getName().toLowerCase(Locale.ENGLISH);
|
||||
if(name.equalsIgnoreCase("g_sch")) {
|
||||
if (name.equalsIgnoreCase("g_sch")) {
|
||||
continue;
|
||||
}
|
||||
Object value;
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
|
||||
|
||||
/**
|
||||
* A plot manager where plots tessellate in a grid formation symmetrical about x=z.
|
||||
*/
|
||||
public abstract class GridPlotManager extends PlotManager {
|
||||
|
||||
public GridPlotManager(PlotArea plotArea) {
|
||||
super(plotArea);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,13 @@ package com.github.intellectualsites.plotsquared.plot.generator;
|
||||
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
|
||||
import com.github.intellectualsites.plotsquared.plot.object.PlotId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class GridPlotWorld extends PlotArea {
|
||||
|
||||
public short SIZE;
|
||||
|
||||
public GridPlotWorld(String worldName, String id, IndependentPlotGenerator generator,
|
||||
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||
PlotId min, PlotId max) {
|
||||
super(worldName, id, generator, min, max);
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user