mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Type weakening and Direction changes
Signed-off-by: matt <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
parent
4c8457ad14
commit
56c24a6a56
@ -134,7 +134,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
|
|||||||
json.endObject();
|
json.endObject();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Bukkit.getLogger()
|
Bukkit.getLogger()
|
||||||
.log(Level.WARNING, "A problem occured during writing of JSON string", e);
|
.log(Level.WARNING, "A problem occurred during writing of JSON string", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ import java.util.*;
|
|||||||
*
|
*
|
||||||
* @param player the recipient of the message
|
* @param player the recipient of the message
|
||||||
* @param caption the message
|
* @param caption the message
|
||||||
* @see MainUtil#sendMessage(PlotPlayer, Captions, String...)
|
* @see MainUtil#sendMessage(com.github.intellectualsites.plotsquared.commands.CommandCaller, Captions, String...)
|
||||||
*/
|
*/
|
||||||
public static void sendMessage(Player player, Captions caption) {
|
public static void sendMessage(Player player, Captions caption) {
|
||||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
MainUtil.sendMessage(BukkitUtil.getPlayer(player), caption);
|
||||||
|
@ -13,7 +13,6 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -56,10 +55,9 @@ public abstract class Command {
|
|||||||
public Command(Command parent, boolean isStatic) {
|
public Command(Command parent, boolean isStatic) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.isStatic = isStatic;
|
this.isStatic = isStatic;
|
||||||
Annotation cdAnnotation = getClass().getAnnotation(CommandDeclaration.class);
|
CommandDeclaration cdAnnotation = getClass().getAnnotation(CommandDeclaration.class);
|
||||||
if (cdAnnotation != null) {
|
if (cdAnnotation != null) {
|
||||||
CommandDeclaration declaration = (CommandDeclaration) cdAnnotation;
|
init(cdAnnotation);
|
||||||
init(declaration);
|
|
||||||
}
|
}
|
||||||
for (final Method method : getClass().getDeclaredMethods()) {
|
for (final Method method : getClass().getDeclaredMethods()) {
|
||||||
if (method.isAnnotationPresent(CommandDeclaration.class)) {
|
if (method.isAnnotationPresent(CommandDeclaration.class)) {
|
||||||
@ -101,7 +99,7 @@ public abstract class Command {
|
|||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Command> getCommands(PlotPlayer player) {
|
public List<Command> getCommands(CommandCaller player) {
|
||||||
List<Command> commands = new ArrayList<>();
|
List<Command> commands = new ArrayList<>();
|
||||||
for (Command cmd : this.allCommands) {
|
for (Command cmd : this.allCommands) {
|
||||||
if (cmd.canExecute(player, false)) {
|
if (cmd.canExecute(player, false)) {
|
||||||
@ -111,10 +109,10 @@ public abstract class Command {
|
|||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Command> getCommands(CommandCategory cat, PlotPlayer player) {
|
public List<Command> getCommands(CommandCategory category, CommandCaller player) {
|
||||||
List<Command> commands = getCommands(player);
|
List<Command> commands = getCommands(player);
|
||||||
if (cat != null) {
|
if (category != null) {
|
||||||
commands.removeIf(command -> command.category != cat);
|
commands.removeIf(command -> command.category != category);
|
||||||
}
|
}
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
@ -123,7 +121,7 @@ public abstract class Command {
|
|||||||
return this.allCommands;
|
return this.allCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasConfirmation(PlotPlayer player) {
|
public boolean hasConfirmation(CommandCaller player) {
|
||||||
return this.confirmation && !player.hasPermission(getPermission() + ".confirm.bypass");
|
return this.confirmation && !player.hasPermission(getPermission() + ".confirm.bypass");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +270,7 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.allCommands == null || this.allCommands.isEmpty()) {
|
if (this.allCommands.isEmpty()) {
|
||||||
player.sendMessage(
|
player.sendMessage(
|
||||||
"Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues/new");
|
"Not Implemented: https://github.com/IntellectualSites/PlotSquared/issues/new");
|
||||||
return;
|
return;
|
||||||
@ -285,13 +283,13 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
// Help command
|
// Help command
|
||||||
try {
|
try {
|
||||||
if (args.length == 0 || MathMan.isInteger(args[0])
|
if (!MathMan.isInteger(args[0])) {
|
||||||
|| CommandCategory.valueOf(args[0].toUpperCase()) != null) {
|
CommandCategory.valueOf(args[0].toUpperCase());
|
||||||
|
}
|
||||||
// This will default certain syntax to the help command
|
// This will default certain syntax to the help command
|
||||||
// e.g. /plot, /plot 1, /plot claiming
|
// e.g. /plot, /plot 1, /plot claiming
|
||||||
MainCommand.getInstance().help.execute(player, args, null, null);
|
MainCommand.getInstance().help.execute(player, args, null, null);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
} catch (IllegalArgumentException ignored) {
|
} catch (IllegalArgumentException ignored) {
|
||||||
}
|
}
|
||||||
// Command recommendation
|
// Command recommendation
|
||||||
@ -328,7 +326,7 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
public boolean checkArgs(CommandCaller player, String[] args) {
|
||||||
Argument<?>[] reqArgs = getRequiredArguments();
|
Argument<?>[] reqArgs = getRequiredArguments();
|
||||||
if (reqArgs != null && reqArgs.length > 0) {
|
if (reqArgs != null && reqArgs.length > 0) {
|
||||||
boolean failed = args.length < reqArgs.length;
|
boolean failed = args.length < reqArgs.length;
|
||||||
@ -421,7 +419,7 @@ public abstract class Command {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canExecute(PlotPlayer player, boolean message) {
|
public boolean canExecute(CommandCaller player, boolean message) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -447,7 +445,6 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCommandString() {
|
public String getCommandString() {
|
||||||
String base;
|
|
||||||
if (this.parent == null) {
|
if (this.parent == null) {
|
||||||
return "/" + toString();
|
return "/" + toString();
|
||||||
} else {
|
} else {
|
||||||
@ -577,7 +574,7 @@ public abstract class Command {
|
|||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void perform(PlotPlayer player) {
|
public void perform(CommandCaller player) {
|
||||||
if (player != null && message != null) {
|
if (player != null && message != null) {
|
||||||
message.send(player, args);
|
message.send(player, args);
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||||||
@Override public void execute(final PlotPlayer player, String[] args,
|
@Override public void execute(final PlotPlayer player, String[] args,
|
||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
final RunnableVal2<Command, CommandResult> whenDone) {
|
final RunnableVal2<Command, CommandResult> whenDone) {
|
||||||
|
|
||||||
check(EconHandler.manager, Captions.ECON_DISABLED);
|
check(EconHandler.manager, Captions.ECON_DISABLED);
|
||||||
final Plot plot;
|
final Plot plot;
|
||||||
if (args.length != 0) {
|
if (args.length != 0) {
|
||||||
|
@ -4,8 +4,8 @@ import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
|
|
||||||
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off",
|
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off",
|
||||||
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT,
|
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
|
||||||
requiredType = RequiredType.NONE) public class Chat extends SubCommand {
|
public class Chat extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(PlotPlayer player, String[] args) {
|
||||||
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);
|
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);
|
||||||
|
@ -50,6 +50,8 @@ public enum CommandCategory {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ import java.util.*;
|
|||||||
private Bindings scope;
|
private Bindings scope;
|
||||||
|
|
||||||
public DebugExec() {
|
public DebugExec() {
|
||||||
|
init();
|
||||||
|
/*
|
||||||
try {
|
try {
|
||||||
if (PlotSquared.get() != null) {
|
if (PlotSquared.get() != null) {
|
||||||
File file = new File(PlotSquared.get().IMP.getDirectory(),
|
File file = new File(PlotSquared.get().IMP.getDirectory(),
|
||||||
@ -49,6 +51,7 @@ import java.util.*;
|
|||||||
} catch (IOException | ScriptException ignored) {
|
} catch (IOException | ScriptException ignored) {
|
||||||
ignored.printStackTrace();
|
ignored.printStackTrace();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScriptEngine getEngine() {
|
public ScriptEngine getEngine() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
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.commands.CommandDeclaration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
||||||
@ -18,7 +19,7 @@ public class Help extends Command {
|
|||||||
super(parent, true);
|
super(parent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean canExecute(PlotPlayer player, boolean message) {
|
@Override public boolean canExecute(CommandCaller player, boolean message) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public class Help extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayHelp(PlotPlayer player, String cat, int page) {
|
public void displayHelp(CommandCaller player, String cat, int page) {
|
||||||
CommandCategory catEnum = null;
|
CommandCategory catEnum = null;
|
||||||
if (cat != null) {
|
if (cat != null) {
|
||||||
if (StringMan.isEqualIgnoreCase(cat, "all")) {
|
if (StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.commands;
|
package com.github.intellectualsites.plotsquared.plot.commands;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
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.commands.CommandDeclaration;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.*;
|
import com.github.intellectualsites.plotsquared.plot.object.*;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
|
||||||
@ -126,15 +126,12 @@ public class MainCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||||
if (cmd.hasConfirmation(player)) {
|
if (cmd.hasConfirmation(player)) {
|
||||||
CmdConfirm.addPending(player, cmd.getUsage(), new Runnable() {
|
CmdConfirm.addPending(player, cmd.getUsage(), () -> {
|
||||||
@Override public void run() {
|
|
||||||
if (EconHandler.manager != null) {
|
if (EconHandler.manager != null) {
|
||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
Expression<Double> priceEval =
|
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||||
area.PRICES.get(cmd.getFullId());
|
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||||
Double price =
|
|
||||||
priceEval != null ? priceEval.evaluate(0d) : 0d;
|
|
||||||
if (price != null
|
if (price != null
|
||||||
&& EconHandler.manager.getMoney(player) < price) {
|
&& EconHandler.manager.getMoney(player) < price) {
|
||||||
if (failure != null) {
|
if (failure != null) {
|
||||||
@ -147,7 +144,6 @@ public class MainCommand extends Command {
|
|||||||
if (success != null) {
|
if (success != null) {
|
||||||
success.run();
|
success.run();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -180,13 +176,6 @@ public class MainCommand extends Command {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
/**
|
|
||||||
* @Deprecated legacy
|
|
||||||
*/ public void addCommand(SubCommand command) {
|
|
||||||
PlotSquared.debug("Command registration is now done during instantiation");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void execute(final PlotPlayer player, String[] args,
|
@Override public void execute(final PlotPlayer player, String[] args,
|
||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
RunnableVal2<Command, CommandResult> whenDone) {
|
RunnableVal2<Command, CommandResult> whenDone) {
|
||||||
@ -281,7 +270,7 @@ public class MainCommand extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean canExecute(PlotPlayer player, boolean message) {
|
@Override public boolean canExecute(CommandCaller player, boolean message) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ import java.util.Map.Entry;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot",
|
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot",
|
||||||
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO,
|
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
|
||||||
requiredType = RequiredType.NONE) public class Rate extends SubCommand {
|
public class Rate extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
@ -6,11 +6,9 @@ public enum RequiredType {
|
|||||||
CONSOLE, PLAYER, NONE;
|
CONSOLE, PLAYER, NONE;
|
||||||
|
|
||||||
public boolean allows(CommandCaller player) {
|
public boolean allows(CommandCaller player) {
|
||||||
switch (this) {
|
if (this == RequiredType.NONE) {
|
||||||
case NONE:
|
|
||||||
return true;
|
return true;
|
||||||
default:
|
}
|
||||||
return this == player.getSuperCaller();
|
return this == player.getSuperCaller();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import java.util.Iterator;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.NONE,
|
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER,
|
||||||
usage = "/plot trust <player>",
|
usage = "/plot trust <player>",
|
||||||
description = "Allow a user to build in a plot while you are offline",
|
description = "Allow a user to build in a plot while you are offline",
|
||||||
category = CommandCategory.SETTINGS) public class Trust extends Command {
|
category = CommandCategory.SETTINGS) public class Trust extends Command {
|
||||||
@ -28,16 +28,19 @@ import java.util.UUID;
|
|||||||
@Override public void execute(final PlotPlayer player, String[] args,
|
@Override public void execute(final PlotPlayer player, String[] args,
|
||||||
RunnableVal3<Command, Runnable, Runnable> confirm,
|
RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||||
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||||
final Plot plot = check(player.getCurrentPlot(), Captions.NOT_IN_PLOT);
|
final Plot currentPlot = player.getCurrentPlot();
|
||||||
checkTrue(plot.hasOwner(), Captions.PLOT_UNOWNED);
|
if (currentPlot == null) {
|
||||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions
|
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),
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||||
Captions.NO_PLOT_PERMS);
|
Captions.NO_PLOT_PERMS);
|
||||||
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
checkTrue(args.length == 1, Captions.COMMAND_SYNTAX, getUsage());
|
||||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
checkTrue(!uuids.isEmpty(), Captions.INVALID_PLAYER, args[0]);
|
||||||
Iterator<UUID> iter = uuids.iterator();
|
Iterator<UUID> iter = uuids.iterator();
|
||||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
int size = currentPlot.getTrusted().size() + currentPlot.getMembers().size();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
UUID uuid = iter.next();
|
UUID uuid = iter.next();
|
||||||
if (uuid == DBFunc.EVERYONE && !(
|
if (uuid == DBFunc.EVERYONE && !(
|
||||||
@ -47,34 +50,34 @@ import java.util.UUID;
|
|||||||
iter.remove();
|
iter.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plot.isOwner(uuid)) {
|
if (currentPlot.isOwner(uuid)) {
|
||||||
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
MainUtil.sendMessage(player, Captions.ALREADY_OWNER, MainUtil.getName(uuid));
|
||||||
iter.remove();
|
iter.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plot.getTrusted().contains(uuid)) {
|
if (currentPlot.getTrusted().contains(uuid)) {
|
||||||
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
MainUtil.sendMessage(player, Captions.ALREADY_ADDED, MainUtil.getName(uuid));
|
||||||
iter.remove();
|
iter.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
size += plot.getMembers().contains(uuid) ? 0 : 1;
|
size += currentPlot.getMembers().contains(uuid) ? 0 : 1;
|
||||||
}
|
}
|
||||||
checkTrue(!uuids.isEmpty(), null);
|
checkTrue(!uuids.isEmpty(), null);
|
||||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions
|
checkTrue(size <= currentPlot.getArea().MAX_PLOT_MEMBERS || Permissions
|
||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_TRUST),
|
||||||
Captions.PLOT_MAX_MEMBERS);
|
Captions.PLOT_MAX_MEMBERS);
|
||||||
// Success
|
// Success
|
||||||
confirm.run(this, () -> {
|
confirm.run(this, () -> {
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
if (uuid != DBFunc.EVERYONE) {
|
if (uuid != DBFunc.EVERYONE) {
|
||||||
if (!plot.removeMember(uuid)) {
|
if (!currentPlot.removeMember(uuid)) {
|
||||||
if (plot.getDenied().contains(uuid)) {
|
if (currentPlot.getDenied().contains(uuid)) {
|
||||||
plot.removeDenied(uuid);
|
currentPlot.removeDenied(uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.addTrusted(uuid);
|
currentPlot.addTrusted(uuid);
|
||||||
EventUtil.manager.callTrusted(player, plot, uuid, true);
|
EventUtil.manager.callTrusted(player, currentPlot, uuid, true);
|
||||||
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
MainUtil.sendMessage(player, Captions.TRUSTED_ADDED);
|
||||||
}
|
}
|
||||||
}, null);
|
}, null);
|
||||||
|
@ -8,8 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|||||||
import com.github.intellectualsites.plotsquared.plot.util.*;
|
import com.github.intellectualsites.plotsquared.plot.util.*;
|
||||||
|
|
||||||
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
|
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"},
|
||||||
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]",
|
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
|
||||||
requiredType = RequiredType.NONE, category = CommandCategory.SETTINGS, confirmation = true)
|
|
||||||
public class Unlink extends SubCommand {
|
public class Unlink extends SubCommand {
|
||||||
|
|
||||||
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
@Override public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||||
|
@ -14,8 +14,8 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@CommandDeclaration(command = "visit", permission = "plots.visit",
|
@CommandDeclaration(command = "visit", permission = "plots.visit",
|
||||||
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
|
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", aliases = {
|
||||||
aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.NONE,
|
"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.PLAYER,
|
||||||
category = CommandCategory.TELEPORT) public class Visit extends Command {
|
category = CommandCategory.TELEPORT) public class Visit extends Command {
|
||||||
|
|
||||||
public Visit() {
|
public Visit() {
|
||||||
|
@ -920,15 +920,15 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (this.area.TERRAIN != 3 && createRoad) {
|
if (this.area.TERRAIN != 3 && createRoad) {
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
if (current.getMerged(1)) {
|
if (current.getMerged(Direction.EAST)) {
|
||||||
manager.createRoadEast(current.area, current);
|
manager.createRoadEast(current.area, current);
|
||||||
if (current.getMerged(2)) {
|
if (getMerged(Direction.SOUTH)) {
|
||||||
manager.createRoadSouth(current.area, current);
|
manager.createRoadSouth(current.area, current);
|
||||||
if (current.getMerged(5)) {
|
if (getMerged(Direction.SOUTHEAST)) {
|
||||||
manager.createRoadSouthEast(current.area, current);
|
manager.createRoadSouthEast(current.area, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (current.getMerged(2)) {
|
} else if (getMerged(Direction.SOUTH)) {
|
||||||
manager.createRoadSouth(current.area, current);
|
manager.createRoadSouth(current.area, current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1624,11 +1624,11 @@ public class Plot {
|
|||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
if (this.getMerged(Direction.SOUTH.getIndex())) {
|
if (this.getMerged(Direction.SOUTH)) {
|
||||||
top.setZ(this.getRelative(Direction.SOUTH.getIndex()).getBottomAbs().getZ() - 1);
|
top.setZ(this.getRelative(Direction.SOUTH).getBottomAbs().getZ() - 1);
|
||||||
}
|
}
|
||||||
if (this.getMerged(Direction.EAST.getIndex())) {
|
if (this.getMerged(Direction.EAST)) {
|
||||||
top.setX(this.getRelative(Direction.SOUTH.getIndex()).getBottomAbs().getX() - 1);
|
top.setX(this.getRelative(Direction.SOUTH).getBottomAbs().getX() - 1);
|
||||||
}
|
}
|
||||||
return top;
|
return top;
|
||||||
}
|
}
|
||||||
@ -1645,11 +1645,11 @@ public class Plot {
|
|||||||
if (!this.isMerged()) {
|
if (!this.isMerged()) {
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
if (this.getMerged(Direction.NORTH.getIndex())) {
|
if (this.getMerged(Direction.NORTH)) {
|
||||||
bot.setZ(this.getRelative(Direction.NORTH.getIndex()).getTopAbs().getZ() + 1);
|
bot.setZ(this.getRelative(Direction.NORTH).getTopAbs().getZ() + 1);
|
||||||
}
|
}
|
||||||
if (this.getMerged(Direction.WEST.getIndex())) {
|
if (this.getMerged(Direction.WEST)) {
|
||||||
bot.setX(this.getRelative(Direction.WEST.getIndex()).getTopAbs().getX() + 1);
|
bot.setX(this.getRelative(Direction.WEST).getTopAbs().getX() + 1);
|
||||||
}
|
}
|
||||||
return bot;
|
return bot;
|
||||||
}
|
}
|
||||||
@ -1678,7 +1678,7 @@ public class Plot {
|
|||||||
if (this.area.TERRAIN == 3) {
|
if (this.area.TERRAIN == 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot other = this.getRelative(Direction.EAST.getIndex());
|
Plot other = this.getRelative(Direction.EAST);
|
||||||
Location bot = other.getBottomAbs();
|
Location bot = other.getBottomAbs();
|
||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
Location pos1 = new Location(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||||
@ -2147,7 +2147,7 @@ public class Plot {
|
|||||||
if (this.area.TERRAIN == 3) {
|
if (this.area.TERRAIN == 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot other = this.getRelative(2);
|
Plot other = this.getRelative(Direction.SOUTH);
|
||||||
Location bot = other.getBottomAbs();
|
Location bot = other.getBottomAbs();
|
||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
Location pos1 = new Location(this.getWorldName(), bot.getX(), 0, top.getZ());
|
||||||
@ -2192,8 +2192,8 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
visited.add(current);
|
visited.add(current);
|
||||||
Set<Plot> plots;
|
Set<Plot> plots;
|
||||||
if ((dir == -1 || dir == 0) && !current.getMerged(0)) {
|
if ((dir == -1 || dir == 0) && !getMerged(Direction.NORTH)) {
|
||||||
Plot other = current.getRelative(0);
|
Plot other = current.getRelative(Direction.NORTH);
|
||||||
if (other != null && other.isOwner(uuid) && (
|
if (other != null && other.isOwner(uuid) && (
|
||||||
other.getBasePlot(false).equals(current.getBasePlot(false))
|
other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
||||||
@ -2204,8 +2204,8 @@ public class Plot {
|
|||||||
toReturn = true;
|
toReturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(Direction.EAST)) {
|
||||||
Plot other = current.getRelative(1);
|
Plot other = current.getRelative(Direction.EAST);
|
||||||
if (other != null && other.isOwner(uuid) && (
|
if (other != null && other.isOwner(uuid) && (
|
||||||
other.getBasePlot(false).equals(current.getBasePlot(false))
|
other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
||||||
@ -2216,8 +2216,8 @@ public class Plot {
|
|||||||
toReturn = true;
|
toReturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max >= 0 && (dir == -1 || dir == 2) && !current.getMerged(2)) {
|
if (max >= 0 && (dir == -1 || dir == 2) && !getMerged(Direction.SOUTH)) {
|
||||||
Plot other = current.getRelative(2);
|
Plot other = current.getRelative(Direction.SOUTH);
|
||||||
if (other != null && other.isOwner(uuid) && (
|
if (other != null && other.isOwner(uuid) && (
|
||||||
other.getBasePlot(false).equals(current.getBasePlot(false))
|
other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
||||||
@ -2228,8 +2228,8 @@ public class Plot {
|
|||||||
toReturn = true;
|
toReturn = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (max >= 0 && (dir == -1 || dir == 3) && !current.getMerged(3)) {
|
if (max >= 0 && (dir == -1 || dir == 3) && !getMerged(Direction.WEST)) {
|
||||||
Plot other = current.getRelative(3);
|
Plot other = current.getRelative(Direction.WEST);
|
||||||
if (other != null && other.isOwner(uuid) && (
|
if (other != null && other.isOwner(uuid) && (
|
||||||
other.getBasePlot(false).equals(current.getBasePlot(false))
|
other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
|| (plots = other.getConnectedPlots()).size() <= max && frontier
|
||||||
@ -2344,6 +2344,21 @@ public class Plot {
|
|||||||
return this.area.getPlotAbs(this.id.getRelative(direction));
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the plot in a relative direction<br>
|
||||||
|
* 0 = north<br>
|
||||||
|
* 1 = east<br>
|
||||||
|
* 2 = south<br>
|
||||||
|
* 3 = west<br>
|
||||||
|
* Note: May be null if the partial plot area does not include the relative location
|
||||||
|
*
|
||||||
|
* @param direction
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Plot getRelative(Direction direction) {
|
||||||
|
return this.area.getPlotAbs(this.id.getRelative(direction));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set of plots connected (and including) this plot<br>
|
* Gets a set of plots connected (and including) this plot<br>
|
||||||
* - This result is cached globally
|
* - This result is cached globally
|
||||||
@ -2370,8 +2385,8 @@ public class Plot {
|
|||||||
tmpSet.add(this);
|
tmpSet.add(this);
|
||||||
Plot tmp;
|
Plot tmp;
|
||||||
if (merged[0]) {
|
if (merged[0]) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(0));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.NORTH));
|
||||||
if (!tmp.getMerged(2)) {
|
if (!tmp.getMerged(Direction.SOUTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.owner)) {
|
||||||
@ -2386,8 +2401,8 @@ public class Plot {
|
|||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
if (merged[1]) {
|
if (merged[1]) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(1));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.EAST));
|
||||||
if (!tmp.getMerged(3)) {
|
if (!tmp.getMerged(Direction.WEST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.owner)) {
|
||||||
@ -2402,8 +2417,8 @@ public class Plot {
|
|||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
if (merged[2]) {
|
if (merged[2]) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(2));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.SOUTH));
|
||||||
if (!tmp.getMerged(0)) {
|
if (!tmp.getMerged(Direction.NORTH)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.owner)) {
|
||||||
@ -2418,8 +2433,8 @@ public class Plot {
|
|||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
if (merged[3]) {
|
if (merged[3]) {
|
||||||
tmp = this.area.getPlotAbs(this.id.getRelative(3));
|
tmp = this.area.getPlotAbs(this.id.getRelative(Direction.WEST));
|
||||||
if (!tmp.getMerged(1)) {
|
if (!tmp.getMerged(Direction.EAST)) {
|
||||||
// invalid merge
|
// invalid merge
|
||||||
PlotSquared.debug("Fixing invalid merge: " + this);
|
PlotSquared.debug("Fixing invalid merge: " + this);
|
||||||
if (tmp.isOwnerAbs(this.owner)) {
|
if (tmp.isOwnerAbs(this.owner)) {
|
||||||
@ -2446,28 +2461,28 @@ public class Plot {
|
|||||||
queuecache.remove(current);
|
queuecache.remove(current);
|
||||||
merged = current.getMerged();
|
merged = current.getMerged();
|
||||||
if (merged[0]) {
|
if (merged[0]) {
|
||||||
tmp = current.area.getPlotAbs(current.id.getRelative(0));
|
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.NORTH));
|
||||||
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
||||||
queuecache.add(tmp);
|
queuecache.add(tmp);
|
||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (merged[1]) {
|
if (merged[1]) {
|
||||||
tmp = current.area.getPlotAbs(current.id.getRelative(1));
|
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.EAST));
|
||||||
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
||||||
queuecache.add(tmp);
|
queuecache.add(tmp);
|
||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (merged[2]) {
|
if (merged[2]) {
|
||||||
tmp = current.area.getPlotAbs(current.id.getRelative(2));
|
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.SOUTH));
|
||||||
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
||||||
queuecache.add(tmp);
|
queuecache.add(tmp);
|
||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (merged[3]) {
|
if (merged[3]) {
|
||||||
tmp = current.area.getPlotAbs(current.id.getRelative(3));
|
tmp = current.area.getPlotAbs(current.id.getRelative(Direction.WEST));
|
||||||
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
if (tmp != null && !queuecache.contains(tmp) && !tmpSet.contains(tmp)) {
|
||||||
queuecache.add(tmp);
|
queuecache.add(tmp);
|
||||||
frontier.add(tmp);
|
frontier.add(tmp);
|
||||||
@ -2516,7 +2531,8 @@ public class Plot {
|
|||||||
boolean tmp = true;
|
boolean tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
if (plot == null || !plot.getMerged(2) || visited.contains(plot.getId())) {
|
if (plot == null || !plot.getMerged(Direction.SOUTH) || visited
|
||||||
|
.contains(plot.getId())) {
|
||||||
tmp = false;
|
tmp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2529,7 +2545,8 @@ public class Plot {
|
|||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
if (plot == null || !plot.getMerged(3) || visited.contains(plot.getId())) {
|
if (plot == null || !plot.getMerged(Direction.WEST) || visited
|
||||||
|
.contains(plot.getId())) {
|
||||||
tmp = false;
|
tmp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2542,7 +2559,8 @@ public class Plot {
|
|||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
if (plot == null || !plot.getMerged(0) || visited.contains(plot.getId())) {
|
if (plot == null || !plot.getMerged(Direction.NORTH) || visited
|
||||||
|
.contains(plot.getId())) {
|
||||||
tmp = false;
|
tmp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2555,7 +2573,8 @@ public class Plot {
|
|||||||
tmp = true;
|
tmp = true;
|
||||||
for (PlotId id : ids) {
|
for (PlotId id : ids) {
|
||||||
Plot plot = this.area.getPlotAbs(id);
|
Plot plot = this.area.getPlotAbs(id);
|
||||||
if (plot == null || !plot.getMerged(1) || visited.contains(plot.getId())) {
|
if (plot == null || !plot.getMerged(Direction.EAST) || visited
|
||||||
|
.contains(plot.getId())) {
|
||||||
tmp = false;
|
tmp = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2569,14 +2588,14 @@ public class Plot {
|
|||||||
visited.addAll(MainUtil.getPlotSelectionIds(bot, top));
|
visited.addAll(MainUtil.getPlotSelectionIds(bot, top));
|
||||||
for (int x = bot.x; x <= top.x; x++) {
|
for (int x = bot.x; x <= top.x; x++) {
|
||||||
Plot plot = this.area.getPlotAbs(new PlotId(x, top.y));
|
Plot plot = this.area.getPlotAbs(new PlotId(x, top.y));
|
||||||
if (plot.getMerged(2)) {
|
if (plot.getMerged(Direction.SOUTH)) {
|
||||||
// south wedge
|
// south wedge
|
||||||
Location toploc = plot.getExtendedTopAbs();
|
Location toploc = plot.getExtendedTopAbs();
|
||||||
Location botabs = plot.getBottomAbs();
|
Location botabs = plot.getBottomAbs();
|
||||||
Location topabs = plot.getTopAbs();
|
Location topabs = plot.getTopAbs();
|
||||||
regions.add(new RegionWrapper(botabs.getX(), topabs.getX(), topabs.getZ() + 1,
|
regions.add(new RegionWrapper(botabs.getX(), topabs.getX(), topabs.getZ() + 1,
|
||||||
toploc.getZ()));
|
toploc.getZ()));
|
||||||
if (plot.getMerged(5)) {
|
if (plot.getMerged(Direction.SOUTHEAST)) {
|
||||||
regions.add(
|
regions.add(
|
||||||
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1,
|
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1,
|
||||||
toploc.getZ()));
|
toploc.getZ()));
|
||||||
@ -2587,14 +2606,14 @@ public class Plot {
|
|||||||
|
|
||||||
for (int y = bot.y; y <= top.y; y++) {
|
for (int y = bot.y; y <= top.y; y++) {
|
||||||
Plot plot = this.area.getPlotAbs(new PlotId(top.x, y));
|
Plot plot = this.area.getPlotAbs(new PlotId(top.x, y));
|
||||||
if (plot.getMerged(1)) {
|
if (plot.getMerged(Direction.EAST)) {
|
||||||
// east wedge
|
// east wedge
|
||||||
Location toploc = plot.getExtendedTopAbs();
|
Location toploc = plot.getExtendedTopAbs();
|
||||||
Location botabs = plot.getBottomAbs();
|
Location botabs = plot.getBottomAbs();
|
||||||
Location topabs = plot.getTopAbs();
|
Location topabs = plot.getTopAbs();
|
||||||
regions.add(new RegionWrapper(topabs.getX() + 1, toploc.getX(), botabs.getZ(),
|
regions.add(new RegionWrapper(topabs.getX() + 1, toploc.getX(), botabs.getZ(),
|
||||||
topabs.getZ()));
|
topabs.getZ()));
|
||||||
if (plot.getMerged(5)) {
|
if (plot.getMerged(Direction.SOUTHEAST)) {
|
||||||
regions.add(
|
regions.add(
|
||||||
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1,
|
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1,
|
||||||
toploc.getZ()));
|
toploc.getZ()));
|
||||||
@ -2776,7 +2795,7 @@ public class Plot {
|
|||||||
lesserPlot = greaterPlot;
|
lesserPlot = greaterPlot;
|
||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
}
|
}
|
||||||
if (!lesserPlot.getMerged(2)) {
|
if (!lesserPlot.getMerged(Direction.SOUTH)) {
|
||||||
lesserPlot.clearRatings();
|
lesserPlot.clearRatings();
|
||||||
greaterPlot.clearRatings();
|
greaterPlot.clearRatings();
|
||||||
lesserPlot.setMerged(2, true);
|
lesserPlot.setMerged(2, true);
|
||||||
@ -2784,13 +2803,13 @@ public class Plot {
|
|||||||
lesserPlot.mergeData(greaterPlot);
|
lesserPlot.mergeData(greaterPlot);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
lesserPlot.removeRoadSouth();
|
lesserPlot.removeRoadSouth();
|
||||||
Plot diagonal = greaterPlot.getRelative(1);
|
Plot diagonal = greaterPlot.getRelative(Direction.EAST);
|
||||||
if (diagonal.getMerged(7)) {
|
if (diagonal.getMerged(Direction.NORTHWEST)) {
|
||||||
lesserPlot.removeRoadSouthEast();
|
lesserPlot.removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
Plot below = greaterPlot.getRelative(3);
|
Plot below = greaterPlot.getRelative(Direction.WEST);
|
||||||
if (below.getMerged(4)) {
|
if (below.getMerged(Direction.NORTHEAST)) {
|
||||||
below.getRelative(0).removeRoadSouthEast();
|
below.getRelative(Direction.NORTH).removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2800,22 +2819,22 @@ public class Plot {
|
|||||||
lesserPlot = greaterPlot;
|
lesserPlot = greaterPlot;
|
||||||
greaterPlot = tmp;
|
greaterPlot = tmp;
|
||||||
}
|
}
|
||||||
if (!lesserPlot.getMerged(1)) {
|
if (!lesserPlot.getMerged(Direction.EAST)) {
|
||||||
lesserPlot.clearRatings();
|
lesserPlot.clearRatings();
|
||||||
greaterPlot.clearRatings();
|
greaterPlot.clearRatings();
|
||||||
lesserPlot.setMerged(1, true);
|
lesserPlot.setMerged(1, true);
|
||||||
greaterPlot.setMerged(3, true);
|
greaterPlot.setMerged(3, true);
|
||||||
lesserPlot.mergeData(greaterPlot);
|
lesserPlot.mergeData(greaterPlot);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
Plot diagonal = greaterPlot.getRelative(2);
|
Plot diagonal = greaterPlot.getRelative(Direction.SOUTH);
|
||||||
if (diagonal.getMerged(7)) {
|
if (diagonal.getMerged(Direction.NORTHWEST)) {
|
||||||
lesserPlot.removeRoadSouthEast();
|
lesserPlot.removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
lesserPlot.removeRoadEast();
|
lesserPlot.removeRoadEast();
|
||||||
}
|
}
|
||||||
Plot below = greaterPlot.getRelative(0);
|
Plot below = greaterPlot.getRelative(Direction.NORTH);
|
||||||
if (below.getMerged(6)) {
|
if (below.getMerged(Direction.SOUTHWEST)) {
|
||||||
below.getRelative(3).removeRoadSouthEast();
|
below.getRelative(Direction.WEST).removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -560,6 +560,7 @@ public abstract class PlotArea {
|
|||||||
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
|
return this.plots.entrySet().stream().anyMatch(entry -> entry.getValue().isOwner(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//todo check if this method is needed in this class
|
||||||
public int getPlotCount(@Nullable final PlotPlayer player) {
|
public int getPlotCount(@Nullable final PlotPlayer player) {
|
||||||
return player != null ? getPlotCount(player.getUUID()) : 0;
|
return player != null ? getPlotCount(player.getUUID()) : 0;
|
||||||
}
|
}
|
||||||
@ -876,19 +877,19 @@ public abstract class PlotArea {
|
|||||||
Plot plot2;
|
Plot plot2;
|
||||||
if (lx) {
|
if (lx) {
|
||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.getMerged(1) || !plot.getMerged(2)) {
|
if (!plot.getMerged(Direction.EAST) || !plot.getMerged(Direction.SOUTH)) {
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
plot.removeRoadSouthEast();
|
plot.removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(1)) {
|
if (!plot.getMerged(Direction.EAST)) {
|
||||||
plot2 = plot.getRelative(1, 0);
|
plot2 = plot.getRelative(1, 0);
|
||||||
plot.mergePlot(plot2, removeRoads);
|
plot.mergePlot(plot2, removeRoads);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ly) {
|
if (ly) {
|
||||||
if (!plot.getMerged(2)) {
|
if (!plot.getMerged(Direction.SOUTH)) {
|
||||||
plot2 = plot.getRelative(0, 1);
|
plot2 = plot.getRelative(0, 1);
|
||||||
plot.mergePlot(plot2, removeRoads);
|
plot.mergePlot(plot2, removeRoads);
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,9 @@ public class PlotId {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlotId getRelative(Direction direction) {
|
||||||
|
return getRelative(direction.getIndex());
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get the PlotId in a relative direction
|
* Get the PlotId in a relative direction
|
||||||
* 0 = north<br>
|
* 0 = north<br>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util;
|
package com.github.intellectualsites.plotsquared.plot.util;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||||
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
import com.github.intellectualsites.plotsquared.plot.config.Settings;
|
||||||
@ -576,7 +577,7 @@ public class MainUtil {
|
|||||||
* @param prefix If the message should be prefixed with the configured prefix
|
* @param prefix If the message should be prefixed with the configured prefix
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(PlotPlayer player, String msg, boolean prefix) {
|
public static boolean sendMessage(CommandCaller player, String msg, boolean prefix) {
|
||||||
if (!msg.isEmpty()) {
|
if (!msg.isEmpty()) {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
String message = (prefix ? Captions.PREFIX.s() : "") + msg;
|
String message = (prefix ? Captions.PREFIX.s() : "") + msg;
|
||||||
@ -595,7 +596,7 @@ public class MainUtil {
|
|||||||
* @param caption the message to send
|
* @param caption the message to send
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(PlotPlayer player, Captions caption, String... args) {
|
public static boolean sendMessage(CommandCaller player, Captions caption, String... args) {
|
||||||
return sendMessage(player, caption, (Object[]) args);
|
return sendMessage(player, caption, (Object[]) args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -606,20 +607,18 @@ public class MainUtil {
|
|||||||
* @param caption the message to send
|
* @param caption the message to send
|
||||||
* @return boolean success
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(final PlotPlayer player, final Captions caption,
|
public static boolean sendMessage(final CommandCaller player, final Captions caption,
|
||||||
final Object... args) {
|
final Object... args) {
|
||||||
if (caption.s().isEmpty()) {
|
if (caption.s().isEmpty()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(() -> {
|
||||||
@Override public void run() {
|
|
||||||
String m = Captions.format(caption, args);
|
String m = Captions.format(caption, args);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
PlotSquared.log(m);
|
PlotSquared.log(m);
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(m);
|
player.sendMessage(m);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.helpmenu;
|
package com.github.intellectualsites.plotsquared.plot.util.helpmenu;
|
||||||
|
|
||||||
import com.github.intellectualsites.plotsquared.commands.Command;
|
import com.github.intellectualsites.plotsquared.commands.Command;
|
||||||
|
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
import com.github.intellectualsites.plotsquared.plot.commands.MainCommand;
|
||||||
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class HelpMenu {
|
public class HelpMenu {
|
||||||
|
|
||||||
public static final int PER_PAGE = 5;
|
private static final int PER_PAGE = 5;
|
||||||
|
|
||||||
private final PlotPlayer player;
|
private final CommandCaller commandCaller;
|
||||||
private HelpPage page = new HelpPage(CommandCategory.INFO, 0, 0);
|
private HelpPage page = new HelpPage(CommandCategory.INFO, 0, 0);
|
||||||
private int maxPage;
|
private int maxPage;
|
||||||
private CommandCategory commandCategory;
|
private CommandCategory commandCategory;
|
||||||
private List<Command> commands;
|
private List<Command> commands;
|
||||||
|
|
||||||
public HelpMenu(PlotPlayer player) {
|
public HelpMenu(CommandCaller commandCaller) {
|
||||||
this.player = player;
|
this.commandCaller = commandCaller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HelpMenu setCategory(CommandCategory commandCategory) {
|
public HelpMenu setCategory(CommandCategory commandCategory) {
|
||||||
@ -27,7 +27,8 @@ public class HelpMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public HelpMenu getCommands() {
|
public HelpMenu getCommands() {
|
||||||
this.commands = MainCommand.getInstance().getCommands(this.commandCategory, this.player);
|
this.commands =
|
||||||
|
MainCommand.getInstance().getCommands(this.commandCategory, this.commandCaller);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +53,7 @@ public class HelpMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void render() {
|
public void render() {
|
||||||
this.page.render(this.player);
|
this.page.render(this.commandCaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.github.intellectualsites.plotsquared.plot.util.helpmenu;
|
package com.github.intellectualsites.plotsquared.plot.util.helpmenu;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.commands.CommandCaller;
|
||||||
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
import com.github.intellectualsites.plotsquared.plot.commands.CommandCategory;
|
||||||
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
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.MainUtil;
|
||||||
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
import com.github.intellectualsites.plotsquared.plot.util.StringMan;
|
||||||
|
|
||||||
@ -21,7 +21,7 @@ public class HelpPage {
|
|||||||
.replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + "");
|
.replace("%current%", (currentPage + 1) + "").replace("%max%", (maxPages + 1) + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(PlotPlayer player) {
|
public void render(CommandCaller player) {
|
||||||
if (this.helpObjects.size() < 1) {
|
if (this.helpObjects.size() < 1) {
|
||||||
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0)");
|
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0)");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user