mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
commit
This commit is contained in:
parent
dce25ba07a
commit
a39ec22c8c
@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -44,7 +44,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
usage = "/plot add <player>",
|
||||
category = CommandCategory.ACTIONS,
|
||||
permission = "plots.add",
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Add extends SubCommand {
|
||||
|
||||
@ -55,8 +55,7 @@ public class Add extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -34,13 +34,13 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "auto",
|
||||
permission = "plots.auto",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Claim the nearest plot",
|
||||
aliases = {"a"},
|
||||
usage = "/plot auto"
|
||||
@ -77,8 +77,8 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
|
||||
String world;
|
||||
int size_x = 1;
|
||||
int size_z = 1;
|
||||
|
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "buy",
|
||||
@ -45,13 +45,13 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
usage = "/plot buy",
|
||||
permission = "plots.buy",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Buy extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
if (EconHandler.manager == null) {
|
||||
return sendMessage(plr, C.ECON_DISABLED);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "chat",
|
||||
@ -13,13 +13,13 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
usage = "/plot chat [on|off]",
|
||||
permission = "plots.chat",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Chat extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
final String world = plr.getLocation().getWorld();
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
|
@ -35,14 +35,14 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "claim",
|
||||
aliases = {"c"},
|
||||
description = "Claim the current plot you're standing on",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.claim",
|
||||
usage = "/plot claim"
|
||||
)
|
||||
@ -96,8 +96,8 @@ public class Claim extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
String schematic = "";
|
||||
if (args.length >= 1) {
|
||||
schematic = args[0];
|
||||
|
@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "clear",
|
||||
@ -48,39 +48,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
if (plr == null) {
|
||||
// Is console
|
||||
if (args.length < 2) {
|
||||
PS.log("You need to specify two arguments: ID (0;0) & World (world)");
|
||||
} else {
|
||||
final PlotId id = PlotId.fromString(args[0]);
|
||||
final String world = args[1];
|
||||
if (id == null) {
|
||||
PS.log("Invalid Plot ID: " + args[0]);
|
||||
} else {
|
||||
if (!PS.get().isPlotWorld(world)) {
|
||||
PS.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
if (plot == null) {
|
||||
PS.log("Could not find plot " + args[0] + " in world " + world);
|
||||
} else {
|
||||
Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.clear(plot, plot.owner == null, null);
|
||||
PS.log("Plot " + plot.getId().toString() + " cleared.");
|
||||
}
|
||||
};
|
||||
TaskManager.runTask(runnable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot;
|
||||
if (args.length == 2) {
|
||||
|
@ -29,12 +29,6 @@ import org.bukkit.generator.ChunkGenerator;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -48,21 +42,25 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.generator.HybridGen;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "cluser",
|
||||
aliases = {"clusters"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.cluster",
|
||||
description = "Manage a plot cluster"
|
||||
)
|
||||
public class Cluster extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
|
||||
if (args.length == 0) {
|
||||
// return arguments
|
||||
|
@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -41,14 +41,13 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
aliases = {"msg"},
|
||||
description = "Comment on a plot",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plot.comment"
|
||||
)
|
||||
public class Comment extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (args.length < 2) {
|
||||
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||
return false;
|
||||
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
permission = "plots.admin",
|
||||
description = "Condense a plotworld",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PS.class
|
||||
requiredType = RequiredType.CONSOLE
|
||||
)
|
||||
public class Condense extends SubCommand {
|
||||
|
||||
@ -54,8 +54,7 @@ public class Condense extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, String ... args) {
|
||||
final PlotPlayer plr = null;
|
||||
public boolean onCommand(final PlotPlayer plr, String ... args) {
|
||||
if ((args.length != 2) && (args.length != 3)) {
|
||||
MainUtil.sendMessage(plr, "/plot condense <world> <start|stop|info> [radius]");
|
||||
return false;
|
||||
|
@ -20,7 +20,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.CmdInstance;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "confirm",
|
||||
@ -39,8 +39,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Confirm extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
CmdInstance command = CmdConfirm.getPending(plr);
|
||||
if (command == null) {
|
||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "copy",
|
||||
@ -38,7 +38,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
category = CommandCategory.ACTIONS,
|
||||
description = "Copy a plot",
|
||||
usage = "/plot copy <X;Z>",
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Copy extends SubCommand {
|
||||
|
||||
@ -49,8 +49,7 @@ public class Copy extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = MainUtil.getPlot(loc);
|
||||
if (plot1 == null) {
|
||||
|
@ -29,13 +29,13 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "createroadschematic",
|
||||
aliases = {"crs"},
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.createroadschematic",
|
||||
description = "Add a road schematic to your world using the roads around your current plot",
|
||||
usage = "/plot createroadschematic"
|
||||
@ -43,8 +43,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class CreateRoadSchematic extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String ... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.database.MySQL;
|
||||
import com.intellectualcrafters.plot.database.SQLManager;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -16,7 +16,7 @@ import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "database",
|
||||
@ -24,7 +24,9 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
category = CommandCategory.DEBUG,
|
||||
permission = "plots.database",
|
||||
description = "Convert/Backup Storage",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plots database <type> [details...]"
|
||||
|
||||
)
|
||||
public class Database extends SubCommand {
|
||||
|
||||
@ -73,8 +75,7 @@ public class Database extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if (args.length < 1) {
|
||||
return sendMessage(plr, "/plot database [sqlite/mysql]");
|
||||
}
|
||||
|
@ -21,13 +21,13 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Lag;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debug",
|
||||
@ -39,8 +39,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Debug extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
for (final C c : C.values()) {
|
||||
|
@ -9,14 +9,14 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugallowunsafe",
|
||||
description = "Allow unsafe actions until toggled off",
|
||||
usage = "/plot debugallowunsafe",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.debugallowunsafe"
|
||||
)
|
||||
public class DebugAllowUnsafe extends SubCommand {
|
||||
@ -24,8 +24,8 @@ public class DebugAllowUnsafe extends SubCommand {
|
||||
public static final List<UUID> unsafeAllowed = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
if (unsafeAllowed.contains(plr.getUUID())) {
|
||||
unsafeAllowed.remove(plr.getUUID());
|
||||
sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF);
|
||||
|
@ -41,13 +41,13 @@ import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugclaimtest",
|
||||
description = "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot sighs. Execution time may vary",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.debugclaimtest"
|
||||
)
|
||||
public class DebugClaimTest extends SubCommand {
|
||||
@ -70,7 +70,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
if (args.length < 3) {
|
||||
return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}");
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugclear",
|
||||
@ -44,46 +44,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class DebugClear extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
if (plr == null) {
|
||||
// Is console
|
||||
if (args.length < 2) {
|
||||
PS.log("You need to specify two arguments: ID (0;0) & World (world)");
|
||||
} else {
|
||||
final PlotId id = PlotId.fromString(args[0]);
|
||||
final String world = args[1];
|
||||
if (id == null) {
|
||||
PS.log("Invalid Plot ID: " + args[0]);
|
||||
} else {
|
||||
if (!PS.get().isPlotWorld(world) || !(PS.get().getPlotWorld(world) instanceof SquarePlotWorld)) {
|
||||
PS.log("Invalid plot world: " + world);
|
||||
} else {
|
||||
final Plot plot = MainUtil.getPlot(world, id);
|
||||
if (plot == null) {
|
||||
PS.log("Could not find plot " + args[0] + " in world " + world);
|
||||
} else {
|
||||
final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1);
|
||||
final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||
if (MainUtil.runners.containsKey(plot)) {
|
||||
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER);
|
||||
return false;
|
||||
}
|
||||
MainUtil.runners.put(plot, 1);
|
||||
ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.runners.remove(plot);
|
||||
PS.log("Plot " + plot.getId().toString() + " cleared.");
|
||||
PS.log("&aDone!");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !(PS.get().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) {
|
||||
@ -109,8 +70,6 @@ public class DebugClear extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&aDone!");
|
||||
}
|
||||
});
|
||||
// sign
|
||||
// wall
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,9 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -64,17 +64,12 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
public class DebugExec extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer player = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
final List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check");
|
||||
if (args.length > 0) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
case "analyze": {
|
||||
if (player == null) {
|
||||
MainUtil.sendMessage(player, C.IS_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(player.getLocation());
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(player, C.NOT_IN_PLOT);
|
||||
|
@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "fill",
|
||||
@ -39,13 +39,12 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
usage = "/plot fill",
|
||||
aliases = {"debugfill"},
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class DebugFill extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String ... args) {
|
||||
if (args.length != 1 || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill <outline|all>");
|
||||
return true;
|
||||
|
@ -35,14 +35,14 @@ import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugfixflags",
|
||||
usage = "/plot debugfixflags <world>",
|
||||
permission = "plots.debugfixflags",
|
||||
description = "Attempt to fix all flags for a world",
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
public class DebugFixFlags extends SubCommand {
|
||||
@ -54,8 +54,7 @@ public class DebugFixFlags extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = null;
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
final String world = args[0];
|
||||
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]);
|
||||
|
@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugloadtest",
|
||||
@ -35,12 +35,12 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "This debug command will force the reload of all plots in the DB",
|
||||
usage = "/plot debugloadtest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PS.class
|
||||
requiredType = RequiredType.CONSOLE
|
||||
)
|
||||
public class DebugLoadTest extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
try {
|
||||
final Field fPlots = PS.class.getDeclaredField("plots");
|
||||
fPlots.setAccessible(true);
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -26,7 +26,7 @@ import java.io.IOException;
|
||||
public class DebugPaste extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -36,7 +36,7 @@ public class DebugPaste extends SubCommand {
|
||||
try {
|
||||
latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log"));
|
||||
} catch(final Exception e) {
|
||||
caller.message("&clatest.log is too big to be pasted, will ignore");
|
||||
plr.sendMessage("&clatest.log is too big to be pasted, will ignore");
|
||||
latestLOG = "too big :(";
|
||||
}
|
||||
StringBuilder b = new StringBuilder();
|
||||
@ -65,7 +65,7 @@ public class DebugPaste extends SubCommand {
|
||||
b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
|
||||
|
||||
String link = HastebinUtility.upload(b.toString());
|
||||
caller.message(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
|
||||
plr.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -29,12 +29,12 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugroadregen",
|
||||
usage = "/plot debugroadregen",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Regenerate all roads based on the road schematic",
|
||||
category = CommandCategory.DEBUG,
|
||||
permission = "plots.debugroadregen"
|
||||
@ -42,8 +42,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class DebugRoadRegen extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String ... args) {
|
||||
final Location loc = player.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
if (!(PS.get().getPlotWorld(world) instanceof HybridPlotWorld)) {
|
||||
|
@ -28,20 +28,20 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "debugsavetest",
|
||||
permission = "plots.debugsavetest",
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plot debugsavetest",
|
||||
description = "This command will force the recreation of all plots in the DB"
|
||||
)
|
||||
public class DebugSaveTest extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||
plots.addAll(PS.get().getPlots());
|
||||
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
|
||||
|
@ -30,7 +30,7 @@ import java.util.UUID;
|
||||
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@ -57,7 +57,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
permission = "plots.admin",
|
||||
description = "Debug UUID conversion",
|
||||
usage = "/plot uuidconvert <lower|offline|online>",
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
public class DebugUUID extends SubCommand {
|
||||
@ -69,7 +69,7 @@ public class DebugUUID extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
PlotPlayer player = null;
|
||||
|
||||
UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
|
||||
|
@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "delete",
|
||||
@ -42,13 +42,13 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "Delete a plot",
|
||||
usage = "/plot delete",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Delete extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -43,7 +43,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
description = "Deny a user from a plot",
|
||||
usage = "/plot deny <player>",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
@ -54,8 +54,8 @@ public class Deny extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -14,21 +14,21 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "download",
|
||||
aliases = {"dl"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Download your plot",
|
||||
permission = "plots.download"
|
||||
)
|
||||
public class Download extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
|
@ -25,7 +25,7 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -45,14 +45,14 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
aliases = {"f"},
|
||||
description = "Manage plot flags",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.flag"
|
||||
)
|
||||
public class FlagCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String ... args) {
|
||||
|
||||
/*
|
||||
* plot flag set fly true
|
||||
* plot flag remove fly
|
||||
|
@ -8,7 +8,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "help",
|
||||
@ -20,7 +20,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Help extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "home",
|
||||
@ -36,7 +36,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "Go to your plot",
|
||||
usage = "/plot home [id|alias]",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Home extends SubCommand {
|
||||
|
||||
@ -50,8 +50,8 @@ public class Home extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, String[] args) {
|
||||
|
||||
final ArrayList<Plot> plots = PS.get().sortPlotsByWorld(PS.get().getPlots(plr));
|
||||
if (plots.size() == 1) {
|
||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
|
@ -24,7 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
usage = "/plot inbox [inbox] [delete <index>|clear|page]",
|
||||
permission = "plots.inbox",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
@ -86,8 +86,8 @@ public class Inbox extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
|
||||
|
||||
final Plot plot = MainUtil.getPlot(player.getLocation());
|
||||
if (args.length == 0) {
|
||||
|
@ -25,10 +25,10 @@ import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@ -88,9 +88,7 @@ public class Info extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, String[] args) {
|
||||
final PlotPlayer player = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
String arg = null;
|
||||
Plot plot;
|
||||
if (args.length > 0) arg = args[0] + "";
|
||||
|
@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "kick",
|
||||
@ -37,13 +37,13 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "Kick a player from your plot",
|
||||
permission = "plots.kick",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Kick extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -17,13 +17,13 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "load",
|
||||
aliases = {"restore"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Load your plot",
|
||||
permission = "plots.load",
|
||||
usage = "/plot restore"
|
||||
@ -31,8 +31,8 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Load extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
|
@ -24,22 +24,23 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.ConsoleCaller;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.Command;
|
||||
import com.intellectualsites.commands.CommandHandlingOutput;
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualsites.commands.util.StringUtil;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
/**
|
||||
* PlotSquared command class
|
||||
@ -92,13 +93,12 @@ public class MainCommand extends CommandManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||
final List<Command> cmds = new ArrayList<>();
|
||||
for (final Command c : instance.commands.values()) {
|
||||
if (c.getRequiredType().isInstance(PlotPlayer.class)) {
|
||||
if ((category == null || (c.getCategory().equals(category))) && player.hasPermission(c.getPermission())) {
|
||||
cmds.add(c);
|
||||
}
|
||||
public static ArrayList<Command> getCommands(final CommandCategory category, final PlotPlayer player) {
|
||||
ArrayList<Command> cmds = instance.getCommands();
|
||||
for (Iterator<Command> iter = cmds.iterator(); iter.hasNext();){
|
||||
Command cmd = iter.next();
|
||||
if ((category != null && (cmd.getCategory().equals(category))) || !player.hasPermission(cmd.getPermission())) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
return cmds;
|
||||
@ -142,106 +142,134 @@ public class MainCommand extends CommandManager {
|
||||
return help;
|
||||
}
|
||||
|
||||
public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) {
|
||||
if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) {
|
||||
if (args.length < 2) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands"));
|
||||
return MainUtil.sendMessage(player, builder.toString());
|
||||
}
|
||||
final String cat = args[1];
|
||||
CommandCategory cato = null;
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
if (cat.equalsIgnoreCase(category.toString())) {
|
||||
cato = category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((cato == null) && !cat.equalsIgnoreCase("all")) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
return MainUtil.sendMessage(player, builder.toString(), false);
|
||||
}
|
||||
final StringBuilder help = new StringBuilder();
|
||||
int page = 0;
|
||||
boolean digit = true;
|
||||
String arg2;
|
||||
if (args.length > 2) {
|
||||
arg2 = args[2];
|
||||
} else {
|
||||
arg2 = "1";
|
||||
}
|
||||
for (final char c : arg2.toCharArray()) {
|
||||
if (!Character.isDigit(c)) {
|
||||
digit = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (digit) {
|
||||
page = Integer.parseInt(arg2);
|
||||
if (--page < 0) {
|
||||
page = 0;
|
||||
}
|
||||
}
|
||||
for (final String string : helpMenu(player, cato, page)) {
|
||||
help.append(string).append("\n");
|
||||
}
|
||||
MainUtil.sendMessage(player, help.toString());
|
||||
// return PlayerFunctions.sendMessage(player, help.toString());
|
||||
} else {
|
||||
CommandCaller caller;
|
||||
if (player != null) {
|
||||
caller = new PlotPlayerCaller(player);
|
||||
} else {
|
||||
caller = new ConsoleCaller();
|
||||
}
|
||||
StringBuilder builder = new StringBuilder(cmd).append(" ");
|
||||
Iterator<String> iterator = Arrays.asList(args).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
builder.append(iterator.next());
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(" ");
|
||||
}
|
||||
}
|
||||
instance.handle(caller, builder.toString());
|
||||
// for (final SubCommand command : subCommands) {
|
||||
// if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
|
||||
// final String[] arguments = new String[args.length - 1];
|
||||
// System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
||||
// if (command.permission.hasPermissipon(player)) {
|
||||
// if ((player != null) || !command.isPlayer) {
|
||||
// return command.execute(player, arguments);
|
||||
// } else {
|
||||
// return !MainUtil.sendMessage(null, C.IS_CONSOLE);
|
||||
// }
|
||||
// } else {
|
||||
// return no_permission(player, command.permission.permission.toLowerCase());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
// final String[] commands = new String[subCommands.size()];
|
||||
// for (int x = 0; x < subCommands.size(); x++) {
|
||||
// commands[x] = subCommands.get(x).cmd;
|
||||
// }
|
||||
// /* Let's try to get a proper usage string */
|
||||
// final String command = new StringComparison(args[0], commands).getBestMatch();
|
||||
// return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
|
||||
// PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new
|
||||
// StringComparsion(args[0], commands).getBestMatch());
|
||||
public static void displayHelp(PlotPlayer player, String cat, int page) {
|
||||
if (cat != null && StringMan.isEqualIgnoreCase(cat, "all")) {
|
||||
cat = null;
|
||||
}
|
||||
if (cat == null && page == 0) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands"));
|
||||
MainUtil.sendMessage(player, builder.toString());
|
||||
return;
|
||||
}
|
||||
CommandCategory cato = null;
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
if (cat.equalsIgnoreCase(category.toString())) {
|
||||
cato = category;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((cato == null) && !cat.equalsIgnoreCase("all")) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.HELP_INFO.s());
|
||||
for (final CommandCategory category : CommandCategory.values()) {
|
||||
builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString()));
|
||||
}
|
||||
MainUtil.sendMessage(player, builder.toString(), false);
|
||||
return;
|
||||
}
|
||||
final StringBuilder help = new StringBuilder();
|
||||
for (final String string : helpMenu(player, cato, page)) {
|
||||
help.append(string).append("\n");
|
||||
}
|
||||
MainUtil.sendMessage(player, help.toString());
|
||||
}
|
||||
|
||||
public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) {
|
||||
int help_index = -1;
|
||||
String category = null;
|
||||
if (args.length == 0) {
|
||||
help_index = 0;
|
||||
}
|
||||
else if (StringMan.isEqualIgnoreCaseToAny(args[0], "he", "help", "?")) {
|
||||
help_index = 0;
|
||||
switch (args.length) {
|
||||
case 3: {
|
||||
category = args[1];
|
||||
}
|
||||
case 2: {
|
||||
if (MathMan.isInteger(args[args.length - 1])) {
|
||||
category = null;
|
||||
try {
|
||||
help_index = Integer.parseInt(args[1]) - 1;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
}
|
||||
if (category == null) {
|
||||
category = args[1];
|
||||
}
|
||||
}
|
||||
case 1: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if (MathMan.isInteger(args[args.length - 1])) {
|
||||
category = null;
|
||||
try {
|
||||
help_index = Integer.parseInt(args[1]) - 1;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
}
|
||||
else {
|
||||
category = args[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (MathMan.isInteger(args[args.length - 1])) {
|
||||
try {
|
||||
help_index = Integer.parseInt(args[args.length - 1]) - 1;
|
||||
}
|
||||
catch (NumberFormatException e) {}
|
||||
}
|
||||
if (help_index != -1) {
|
||||
displayHelp(player, category, help_index);
|
||||
return true;
|
||||
}
|
||||
PlotPlayer caller;
|
||||
StringBuilder builder = new StringBuilder(cmd).append(" ");
|
||||
Iterator<String> iterator = Arrays.asList(args).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
builder.append(iterator.next());
|
||||
if (iterator.hasNext()) {
|
||||
builder.append(" ");
|
||||
}
|
||||
}
|
||||
instance.handle(player, builder.toString());
|
||||
// for (final SubCommand command : subCommands) {
|
||||
// if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) {
|
||||
// final String[] arguments = new String[args.length - 1];
|
||||
// System.arraycopy(args, 1, arguments, 0, args.length - 1);
|
||||
// if (command.permission.hasPermissipon(player)) {
|
||||
// if ((player != null) || !command.isPlayer) {
|
||||
// return command.execute(player, arguments);
|
||||
// } else {
|
||||
// return !MainUtil.sendMessage(null, C.IS_CONSOLE);
|
||||
// }
|
||||
// } else {
|
||||
// return no_permission(player, command.permission.permission.toLowerCase());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND);
|
||||
// final String[] commands = new String[subCommands.size()];
|
||||
// for (int x = 0; x < subCommands.size(); x++) {
|
||||
// commands[x] = subCommands.get(x).cmd;
|
||||
// }
|
||||
// /* Let's try to get a proper usage string */
|
||||
// final String command = new StringComparison(args[0], commands).getBestMatch();
|
||||
// return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command);
|
||||
// PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new
|
||||
// StringComparsion(args[0], commands).getBestMatch());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int handle(CommandCaller caller, String input) {
|
||||
public int handle(PlotPlayer plr, String input) {
|
||||
String[] parts = input.split(" ");
|
||||
String[] args;
|
||||
String command = parts[0].toLowerCase();
|
||||
@ -252,29 +280,31 @@ public class MainCommand extends CommandManager {
|
||||
System.arraycopy(parts, 1, args, 0, args.length);
|
||||
}
|
||||
Command cmd = null;
|
||||
System.out.print(command);
|
||||
System.out.print(StringMan.join(commands.entrySet(), ", "));
|
||||
cmd = this.commands.get(command);
|
||||
if (cmd == null) {
|
||||
caller.message(C.NOT_VALID_SUBCOMMAND);
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND);
|
||||
{
|
||||
final String[] commands = new String[this.commands.size()];
|
||||
for (int i = 0; i < commands.length; i++) {
|
||||
commands[i] = this.commands.get(i).getCommand();
|
||||
}
|
||||
final String bestMatch = new StringComparison<String>(args[0], commands).getBestMatch();
|
||||
caller.message(C.DID_YOU_MEAN, "/plot " + bestMatch);
|
||||
MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot " + bestMatch);
|
||||
}
|
||||
return CommandHandlingOutput.NOT_FOUND;
|
||||
}
|
||||
if (!cmd.getRequiredType().isInstance(caller.getSuperCaller())) {
|
||||
if (caller instanceof PlotPlayerCaller) {
|
||||
caller.message(C.NOT_CONSOLE);
|
||||
if (cmd.getRequiredType().allows(plr)) {
|
||||
if (ConsolePlayer.isConsole(plr)) {
|
||||
MainUtil.sendMessage(plr, C.IS_CONSOLE);
|
||||
} else {
|
||||
caller.message(C.IS_CONSOLE);
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
|
||||
}
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
}
|
||||
if (!caller.hasPermission(cmd.getPermission())) {
|
||||
caller.message(C.NO_PERMISSION, cmd.getPermission());
|
||||
if (!plr.hasPermission(cmd.getPermission())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission());
|
||||
return CommandHandlingOutput.NOT_PERMITTED;
|
||||
}
|
||||
Argument[] requiredArguments = cmd.getRequiredArguments();
|
||||
@ -291,16 +321,16 @@ public class MainCommand extends CommandManager {
|
||||
}
|
||||
}
|
||||
if (!success) {
|
||||
caller.sendRequiredArgumentsList(this, cmd, requiredArguments);
|
||||
C.COMMAND_SYNTAX.send(plr, cmd.getUsage());
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean a = cmd.onCommand(caller, args);
|
||||
if (!a) {
|
||||
boolean result = cmd.onCommand(plr, args);
|
||||
if (!result) {
|
||||
String usage = cmd.getUsage();
|
||||
if (usage != null && !usage.isEmpty()) {
|
||||
caller.message(usage);
|
||||
MainUtil.sendMessage(plr, usage);
|
||||
}
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ import java.util.UUID;
|
||||
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@ -51,7 +51,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
permission = "plots.merge",
|
||||
usage = "/plot merge [direction]",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Merge extends SubCommand {
|
||||
public final static String[] values = new String[] { "north", "east", "south", "west" };
|
||||
@ -86,8 +86,8 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocationFull();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "move",
|
||||
@ -39,7 +39,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
aliases = {"debugmove"},
|
||||
permission = "plots.move",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Move extends SubCommand {
|
||||
|
||||
@ -50,8 +50,8 @@ public class Move extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot1 = MainUtil.getPlot(loc);
|
||||
if (plot1 == null) {
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "music",
|
||||
@ -40,13 +40,13 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "Player music in a plot",
|
||||
usage = "/plot music",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class MusicSubcommand extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
|
||||
final Location loc = player.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -41,7 +41,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
permission = "plots.admin",
|
||||
description = "Purge all plots for a world",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PS.class
|
||||
requiredType = RequiredType.CONSOLE
|
||||
)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@ -55,45 +55,45 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
final PlotId id = getId(arg);
|
||||
if (id != null) {
|
||||
caller.message("/plot purxe x;z &l<world>");
|
||||
MainUtil.sendMessage(plr, "/plot purxe x;z &l<world>");
|
||||
return false;
|
||||
}
|
||||
final UUID uuid = UUIDHandler.getUUID(args[0], null);
|
||||
if (uuid != null) {
|
||||
caller.message("/plot purge " + args[0] + " &l<world>");
|
||||
MainUtil.sendMessage(plr, "/plot purge " + args[0] + " &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("player")) {
|
||||
caller.message("/plot purge &l<player> <world>");
|
||||
MainUtil.sendMessage(plr, "/plot purge &l<player> <world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("unowned")) {
|
||||
caller.message("/plot purge unowned &l<world>");
|
||||
MainUtil.sendMessage(plr, "/plot purge unowned &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("unknown")) {
|
||||
caller.message("/plot purge unknown &l<world>");
|
||||
MainUtil.sendMessage(plr, "/plot purge unknown &l<world>");
|
||||
return false;
|
||||
}
|
||||
if (arg.equals("all")) {
|
||||
caller.message("/plot purge all &l<world>");
|
||||
MainUtil.sendMessage(plr, "/plot purge all &l<world>");
|
||||
return false;
|
||||
}
|
||||
caller.message(C.PURGE_SYNTAX);
|
||||
MainUtil.sendMessage(plr, C.PURGE_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
caller.message(C.PURGE_SYNTAX);
|
||||
MainUtil.sendMessage(plr, C.PURGE_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
final String worldname = args[1];
|
||||
if (!PS.get().getAllPlotsRaw().containsKey(worldname)) {
|
||||
caller.message("INVALID WORLD");
|
||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||
return false;
|
||||
}
|
||||
final String arg = args[0].toLowerCase();
|
||||
@ -160,7 +160,7 @@ public class Purge extends SubCommand {
|
||||
DBFunc.purge(worldname, ids);
|
||||
return finishPurge(length);
|
||||
}
|
||||
caller.message(C.PURGE_SYNTAX);
|
||||
MainUtil.sendMessage(plr, C.PURGE_SYNTAX);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.mutable.MutableInt;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -53,14 +53,12 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
usage = "/plot rate [#|next]",
|
||||
aliases = {"rt"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("next")) {
|
||||
ArrayList<Plot> plots = new ArrayList<>(PS.get().getPlots());
|
||||
|
@ -30,16 +30,17 @@ import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "regenallroads",
|
||||
description = "Regenerate all roads in the map using the set road schematic",
|
||||
aliases = {"rgar"},
|
||||
category = CommandCategory.DEBUG,
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
permission = "plots.regenallroads"
|
||||
)
|
||||
public class RegenAllRoads extends SubCommand {
|
||||
@ -51,22 +52,22 @@ public class RegenAllRoads extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
int height = 0;
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
height = Integer.parseInt(args[1]);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
caller.message(C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
caller.message(C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads <world> [height]");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final String name = args[0];
|
||||
final PlotManager manager = PS.get().getPlotManager(name);
|
||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
||||
caller.message(C.NOT_VALID_PLOT_WORLD);
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
final List<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(name);
|
||||
|
@ -23,9 +23,9 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "reload",
|
||||
@ -37,7 +37,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
try {
|
||||
// The following won't affect world generation, as that has to be
|
||||
// loaded during startup unfortunately.
|
||||
@ -48,9 +48,9 @@ public class Reload extends SubCommand {
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(pw);
|
||||
plotworld.loadDefaultConfiguration(PS.get().config.getConfigurationSection("worlds." + pw));
|
||||
}
|
||||
caller.message(C.RELOADED_CONFIGS);
|
||||
MainUtil.sendMessage(plr, C.RELOADED_CONFIGS);
|
||||
} catch (final Exception e) {
|
||||
caller.message(C.RELOAD_FAILED);
|
||||
MainUtil.sendMessage(plr, C.RELOAD_FAILED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -42,7 +41,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.remove"
|
||||
)
|
||||
public class Remove extends SubCommand {
|
||||
@ -54,8 +53,7 @@ public class Remove extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length != 1) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot remove <player>");
|
||||
return true;
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
public enum RequiredType {
|
||||
CONSOLE,
|
||||
PLAYER,
|
||||
NONE;
|
||||
|
||||
public boolean allows(PlotPlayer player) {
|
||||
switch (this) {
|
||||
case NONE:
|
||||
return true;
|
||||
case PLAYER:
|
||||
return !ConsolePlayer.isConsole(player);
|
||||
case CONSOLE:
|
||||
return ConsolePlayer.isConsole(player);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -17,21 +17,21 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "save",
|
||||
aliases = {"backup"},
|
||||
description = "Save your plot",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.save"
|
||||
)
|
||||
public class Save extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
if (!Settings.METRICS) {
|
||||
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
|
||||
return false;
|
||||
|
@ -27,7 +27,7 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
// TODO Add sub-subcommands
|
||||
|
||||
@ -61,8 +61,7 @@ public class SchematicCmd extends SubCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SCHEMATIC_MISSING_ARG);
|
||||
return true;
|
||||
@ -72,10 +71,6 @@ public class SchematicCmd extends SubCommand {
|
||||
final Schematic schematic;
|
||||
switch (arg) {
|
||||
case "paste": {
|
||||
if (plr == null) {
|
||||
PS.log(C.IS_CONSOLE.s());
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.schematic.paste")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste");
|
||||
return false;
|
||||
|
@ -25,7 +25,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@ -61,15 +61,15 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
usage = "/plot set <arg> <value(s)...>",
|
||||
permission = "plots.set",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Set extends SubCommand {
|
||||
public final static String[] values = new String[] { "biome", "alias", "home", "flag" };
|
||||
public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" };
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "setowner",
|
||||
@ -45,7 +45,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
usage = "/plot setowner <player>",
|
||||
aliases = {"so"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class SetOwner extends SubCommand {
|
||||
|
||||
@ -60,8 +60,7 @@ public class SetOwner extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller;
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
|
@ -25,9 +25,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@ -74,9 +74,7 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = (caller instanceof PlotPlayerCaller) ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
// going through setup
|
||||
String name;
|
||||
if (plr == null) {
|
||||
@ -219,7 +217,7 @@ public class Setup extends SubCommand {
|
||||
step.setValue(args[0]);
|
||||
object.setup_index++;
|
||||
if (object.setup_index == object.step.length) {
|
||||
onCommand(caller, args);
|
||||
onCommand(plr, args);
|
||||
return false;
|
||||
}
|
||||
step = object.step[object.setup_index];
|
||||
|
@ -34,20 +34,20 @@ import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "swap",
|
||||
description = "Swap two plots",
|
||||
aliases = {"switch"},
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = PlotPlayer.class
|
||||
requiredType = RequiredType.PLAYER
|
||||
)
|
||||
public class Swap extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue.");
|
||||
if (args.length < 1) {
|
||||
MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
|
||||
|
@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
description = "Teleport to a plot",
|
||||
permission = "plots.tp",
|
||||
usage = "/plot tp <alias|id>",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.TELEPORT
|
||||
)
|
||||
public class TP extends SubCommand {
|
||||
@ -53,8 +53,7 @@ public class TP extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final String id = args[0];
|
||||
PlotId plotid;
|
||||
final Location loc = plr.getLocation();
|
||||
|
@ -28,14 +28,14 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "target",
|
||||
usage = "/plot target <X;Z>",
|
||||
description = "Target a plot with your compass",
|
||||
permission = "plots.target",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Target extends SubCommand {
|
||||
@ -47,8 +47,7 @@ public class Target extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location ploc = plr.getLocation();
|
||||
if (!PS.get().isPlotWorld(ploc.getWorld())) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
|
@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
@ -119,25 +119,21 @@ public class Template extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("export")) {
|
||||
caller.message(C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export <world>");
|
||||
return true;
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("import")) {
|
||||
caller.message(C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template import <world> <template>");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
caller.message(C.COMMAND_SYNTAX, "/plot template <import|explort> <world> [template]");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template <import|explort> <world> [template]");
|
||||
return true;
|
||||
}
|
||||
PlotPlayer plr = null;
|
||||
if (caller.getSuperCaller() instanceof PlotPlayer) {
|
||||
plr = (PlotPlayer) caller.getSuperCaller();
|
||||
}
|
||||
final String world = args[1];
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "import": {
|
||||
|
@ -24,7 +24,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
// TOGGLE("toggle", "attribute"),
|
||||
|
||||
@ -34,21 +34,20 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
permission = "plots.toggle",
|
||||
description = "Toggle per user settings",
|
||||
usage = "/plot toggle <setting>",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Toggle extends SubCommand {
|
||||
|
||||
public void noArgs(CommandCaller caller) {
|
||||
caller.message(C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||
caller.message(C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + "titles");
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + "titles");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer player, final String[] args) {
|
||||
if (args.length == 0) {
|
||||
noArgs(caller);
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
|
@ -40,14 +40,14 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trim",
|
||||
permission = "plots.admin",
|
||||
description = "Delete unmodified portions of your plotworld",
|
||||
usage = "/plot trim",
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
public class Trim extends SubCommand {
|
||||
@ -174,8 +174,7 @@ public class Trim extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = null;
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length == 1) {
|
||||
final String arg = args[0].toLowerCase();
|
||||
final PlotId id = getId(arg);
|
||||
|
@ -34,13 +34,13 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "trust",
|
||||
aliases = {"t"},
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
usage = "/plot trust <player>",
|
||||
description = "Allow a player to build in a plot",
|
||||
category = CommandCategory.ACTIONS
|
||||
@ -54,8 +54,8 @@ public class Trust extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -30,20 +30,20 @@ import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "unclaim",
|
||||
usage = "/plot unclaim",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
description = "Unclaim a plot",
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Unclaim extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -40,7 +40,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
||||
aliases = {"ud"},
|
||||
description = "Remove a denied user from a plot",
|
||||
usage = "/plot undeny <player>",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Undeny extends SubCommand {
|
||||
@ -52,8 +52,8 @@ public class Undeny extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String ... args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String ... args) {
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -30,21 +30,21 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "unlink",
|
||||
aliases = {"u"},
|
||||
description = "Unlink a mega-plot",
|
||||
usage = "/plot unlink",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
|
||||
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
// UNTRUST("untrust", "ut"),
|
||||
|
||||
@ -42,7 +42,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
permission = "plot.untrust",
|
||||
description = "Remove a trusted user from a plot",
|
||||
usage = "/plot untrust <player>",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.ACTIONS
|
||||
)
|
||||
public class Untrust extends SubCommand {
|
||||
@ -54,8 +54,7 @@ public class Untrust extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
|
@ -28,14 +28,14 @@ import com.intellectualcrafters.plot.config.C;
|
||||
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin",
|
||||
description = "Update PlotSquared",
|
||||
usage = "/plot update",
|
||||
requiredType = PS.class,
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
aliases = {"updateplugin"},
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
@ -44,7 +44,7 @@ public class Update extends SubCommand {
|
||||
public static String version;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
URL url;
|
||||
if (args.length == 0) {
|
||||
url = PS.get().update;
|
||||
@ -59,12 +59,12 @@ public class Update extends SubCommand {
|
||||
}
|
||||
}
|
||||
else {
|
||||
caller.message(C.COMMAND_SYNTAX, getUsage());
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, getUsage());
|
||||
return false;
|
||||
}
|
||||
if (url == null) {
|
||||
caller.message("&cNo update found!");
|
||||
caller.message("&cTo manually specify an update URL: /plot update <url>");
|
||||
MainUtil.sendMessage(plr, "&cNo update found!");
|
||||
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>");
|
||||
return false;
|
||||
}
|
||||
if (PS.get().update(null, url) && url == PS.get().update) {
|
||||
|
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "visit",
|
||||
@ -41,7 +41,7 @@ import com.intellectualsites.commands.CommandCaller;
|
||||
description = "Visit someones plot",
|
||||
usage = "/plot visit <player|aliases|world|id> [#]",
|
||||
aliases = {"v}"},
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.TELEPORT
|
||||
)
|
||||
public class Visit extends SubCommand {
|
||||
@ -63,8 +63,7 @@ public class Visit extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] args) {
|
||||
PlotPlayer plr = (PlotPlayer) caller.getSuperCaller();
|
||||
public boolean onCommand(PlotPlayer plr, String[] args) {
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
UUID user = UUIDHandler.getUUID(args[0], null);
|
||||
if (user != null ) {
|
||||
|
@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
@ -35,18 +35,17 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
description = "Force bypass of WorldEdit",
|
||||
aliases = {"wea"},
|
||||
usage = "/plot weanywhere",
|
||||
requiredType = PlotPlayer.class,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
public class WE_Anywhere extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandCaller caller, String[] arguments) {
|
||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
if (PS.get().worldEdit == null) {
|
||||
caller.message("&cWorldEdit is not enabled on this server");
|
||||
MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server");
|
||||
return true;
|
||||
}
|
||||
PlotPlayer player = (PlotPlayer) caller.getSuperCaller();
|
||||
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
||||
if (WEManager.bypass.contains(player.getName())) {
|
||||
WEManager.bypass.remove(player.getName());
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands.callers;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.Command;
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
|
||||
public class ConsoleCaller implements CommandCaller<PS> {
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(String message) {
|
||||
MainUtil.sendConsoleMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PS getSuperCaller() {
|
||||
return PS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(C c, String... args) {
|
||||
MainUtil.sendConsoleMessage(c, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required) {
|
||||
message(C.COMMAND_SYNTAX, cmd.getUsage());
|
||||
}
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands.callers;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.Command;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
|
||||
public class PlotPlayerCaller implements CommandCaller<PlotPlayer> {
|
||||
|
||||
private final PlotPlayer player;
|
||||
|
||||
public PlotPlayerCaller(final PlotPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return player.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(String message) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotPlayer getSuperCaller() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void message(C c, String... args) {
|
||||
MainUtil.sendMessage(getSuperCaller(), c, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required) {
|
||||
message(C.COMMAND_SYNTAX, cmd.getUsage());
|
||||
message("Argument list is yet to be implemented");
|
||||
}
|
||||
}
|
@ -29,9 +29,9 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -119,9 +119,7 @@ public class list extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null;
|
||||
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
if (args.length < 1) {
|
||||
noArgs(plr);
|
||||
return false;
|
||||
|
@ -27,14 +27,14 @@ import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualsites.commands.CommandDeclaration;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "plugin",
|
||||
@ -70,7 +70,7 @@ public class plugin extends SubCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandCaller caller, final String[] args) {
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -85,7 +85,7 @@ public class plugin extends SubCommand {
|
||||
}
|
||||
};
|
||||
for (final String s : strings) {
|
||||
MainUtil.sendMessage(caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null, StringMan.replaceFromMap(s, C.replacements), false);
|
||||
plr.sendMessage(s);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -33,6 +33,8 @@ import org.bukkit.ChatColor;
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
/**
|
||||
@ -689,4 +691,13 @@ public enum C {
|
||||
public String getCat() {
|
||||
return cat;
|
||||
}
|
||||
|
||||
public void send(PlotPlayer plr, String... args) {
|
||||
if (plr == null) {
|
||||
MainUtil.sendConsoleMessage(this, args);
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(plr, this, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,126 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
||||
|
||||
public class ConsolePlayer implements PlotPlayer {
|
||||
|
||||
private static ConsolePlayer instance;
|
||||
private Location loc;
|
||||
private final HashMap<String, Object> meta;
|
||||
|
||||
public static ConsolePlayer getConsole() {
|
||||
if (instance == null) {
|
||||
instance = new ConsolePlayer();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ConsolePlayer() {
|
||||
String world;
|
||||
Set<String> plotworlds = PS.get().getPlotWorlds();
|
||||
if (plotworlds.size() > 0) {
|
||||
world = plotworlds.iterator().next();
|
||||
}
|
||||
else {
|
||||
world = "world";
|
||||
}
|
||||
this.loc = new Location(world, 0, 0, 0);
|
||||
this.meta = new HashMap<>();
|
||||
}
|
||||
|
||||
public static boolean isConsole(PlotPlayer plr) {
|
||||
return instance == plr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getPreviousLogin() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocationFull() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return DBFunc.everyone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
PS.log(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(Location loc) {
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "*";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location loc) {}
|
||||
|
||||
@Override
|
||||
public void loadData() {}
|
||||
|
||||
@Override
|
||||
public void saveData() {}
|
||||
|
||||
@Override
|
||||
public void setAttribute(String key) {}
|
||||
|
||||
@Override
|
||||
public boolean getAttribute(String key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAttribute(String key) {}
|
||||
|
||||
@Override
|
||||
public void setMeta(String key, Object value) {
|
||||
this.meta.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getMeta(String key) {
|
||||
return this.meta.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMeta(String key) {
|
||||
this.meta.remove(key);
|
||||
}
|
||||
|
||||
}
|
@ -606,6 +606,9 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
final Plot other = (Plot) obj;
|
||||
if (this.hashCode() != other.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
return ((this.id.x.equals(other.id.x)) && (this.id.y.equals(other.id.y)) && (this.world.equals(other.world)));
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualsites.commands.CommandCaller;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.listeners.PlotListener;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
@ -1421,15 +1421,6 @@ public class MainUtil {
|
||||
return sendMessage(plr, msg, true);
|
||||
}
|
||||
|
||||
public static boolean sendCallerMessage(final CommandCaller plr, final String msg) {
|
||||
if (plr.getSuperCaller() instanceof PlotPlayer) {
|
||||
sendMessage((PlotPlayer) plr.getSuperCaller(), msg);
|
||||
} else {
|
||||
sendConsoleMessage(msg);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendConsoleMessage(String msg) {
|
||||
sendMessage(null, msg);
|
||||
}
|
||||
@ -1516,15 +1507,6 @@ public class MainUtil {
|
||||
return lines.toArray(new String[lines.size()]);
|
||||
}
|
||||
|
||||
public static boolean sendCallerMessage(final CommandCaller caller, final C c, final String... args) {
|
||||
if (caller.getSuperCaller() instanceof PlotPlayer) {
|
||||
sendMessage((PlotPlayer) caller.getSuperCaller(), c, args);
|
||||
} else {
|
||||
sendConsoleMessage(c, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message to the player
|
||||
*
|
||||
|
@ -152,23 +152,49 @@ public class StringMan {
|
||||
|
||||
public static String join(Object[] array, String delimiter) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
System.out.print(array.getClass().getName());
|
||||
for (int i = 0, j = array.length; i < j; i++) {
|
||||
if (i > 0) {
|
||||
result.append(delimiter);
|
||||
}
|
||||
System.out.print(array[i].getClass().getName());
|
||||
result.append(array[i]);
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String join(int[] array, String delimiter) {
|
||||
return join(Arrays.asList(array), delimiter);
|
||||
Integer[] wrapped = new Integer[array.length];
|
||||
for (int i = 0; i < array.length; i++) wrapped[i] = array[i];
|
||||
return join(wrapped, delimiter);
|
||||
}
|
||||
|
||||
public static boolean isEqual(String a, String b ) {
|
||||
public static boolean isEqualToAny(String a, String... args) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqual(a, arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualIgnoreCaseToAny(String a, String... args) {
|
||||
for (String arg : args) {
|
||||
if (StringMan.isEqualIgnoreCase(a, arg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqual(String a, String b) {
|
||||
return (a == b || (a.length() == b.length() && a.hashCode() == b.hashCode() && a.equals(b)));
|
||||
}
|
||||
|
||||
public static boolean isEqualIgnoreCase(String a, String b) {
|
||||
return (a == b || (a.length() == b.length() && a.equalsIgnoreCase(b)));
|
||||
}
|
||||
|
||||
public static String repeat(String s, int n) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for(int i = 0; i < n; i++) {
|
||||
|
@ -79,8 +79,8 @@ public class UUIDHandler {
|
||||
implementation.setUUIDWrapper(wrapper);
|
||||
}
|
||||
|
||||
public static void startCaching() {
|
||||
implementation.startCaching();
|
||||
public static void startCaching(Runnable whenDone) {
|
||||
implementation.startCaching(whenDone);
|
||||
}
|
||||
|
||||
public static void cache(final BiMap<StringWrapper, UUID> toAdd) {
|
||||
|
@ -40,7 +40,7 @@ public abstract class UUIDHandlerImplementation {
|
||||
* Start UUID caching (this should be an async task)
|
||||
* Recommended to override this is you want to cache offline players
|
||||
*/
|
||||
public boolean startCaching() {
|
||||
public boolean startCaching(Runnable whenDone) {
|
||||
if (CACHED) {
|
||||
return false;
|
||||
}
|
||||
@ -55,6 +55,11 @@ public abstract class UUIDHandlerImplementation {
|
||||
this.uuidWrapper = wrapper;
|
||||
}
|
||||
|
||||
public void rename(UUID uuid, StringWrapper name) {
|
||||
uuidMap.inverse().remove(uuid);
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
|
||||
public void add(final BiMap<StringWrapper, UUID> toAdd) {
|
||||
if (uuidMap.size() == 0) {
|
||||
uuidMap = toAdd;
|
||||
@ -63,7 +68,20 @@ public abstract class UUIDHandlerImplementation {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Map.Entry<StringWrapper, UUID> entry : toAdd.entrySet()) {
|
||||
add(entry.getKey(), entry.getValue());
|
||||
UUID uuid = entry.getValue();
|
||||
StringWrapper name = entry.getKey();
|
||||
if ((uuid == null) || (name == null)) {
|
||||
continue;
|
||||
}
|
||||
BiMap<UUID, StringWrapper> inverse = uuidMap.inverse();
|
||||
if (inverse.containsKey(uuid)) {
|
||||
if (uuidMap.containsKey(name)) {
|
||||
continue;
|
||||
}
|
||||
rename(uuid, name);
|
||||
continue;
|
||||
}
|
||||
uuidMap.put(name, uuid);
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&6Cached a total of: " + uuidMap.size() + " UUIDs");
|
||||
}
|
||||
@ -79,7 +97,8 @@ public abstract class UUIDHandlerImplementation {
|
||||
if (uuidMap.containsKey(name)) {
|
||||
return false;
|
||||
}
|
||||
inverse.remove(uuid);
|
||||
rename(uuid, name);
|
||||
return false;
|
||||
}
|
||||
uuidMap.put(name, uuid);
|
||||
return true;
|
||||
|
@ -1,7 +1,9 @@
|
||||
package com.intellectualsites.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
public abstract class Argument<T> {
|
||||
|
||||
@ -28,7 +30,7 @@ public abstract class Argument<T> {
|
||||
return this.example;
|
||||
}
|
||||
|
||||
public static final Argument<Integer> Integer = new Argument<java.lang.Integer>("int", 16) {
|
||||
public static final Argument<Integer> Integer = new Argument<Integer>("int", 16) {
|
||||
@Override
|
||||
public Integer parse(String in) {
|
||||
Integer value = null;
|
||||
@ -39,7 +41,7 @@ public abstract class Argument<T> {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Argument<Boolean> Boolean = new Argument<java.lang.Boolean>("boolean", true) {
|
||||
public static final Argument<Boolean> Boolean = new Argument<Boolean>("boolean", true) {
|
||||
@Override
|
||||
public Boolean parse(String in) {
|
||||
Boolean value = null;
|
||||
@ -52,33 +54,31 @@ public abstract class Argument<T> {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Argument<String> String = new Argument<java.lang.String>("String", "Example") {
|
||||
public static final Argument<String> String = new Argument<String>("String", "Example") {
|
||||
@Override
|
||||
public String parse(String in) {
|
||||
return in;
|
||||
}
|
||||
};
|
||||
|
||||
public static Argument<String> PlayerName = new Argument<java.lang.String>("PlayerName", "Dinnerbone") {
|
||||
public static Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
|
||||
@Override
|
||||
public String parse(String in) {
|
||||
return in.length() < 16 ? in : null;
|
||||
}
|
||||
};
|
||||
|
||||
public static Argument<PlotId> PlotID = new Argument<com.intellectualcrafters.plot.object.PlotId>("PlotID", new PlotId(3, -32)) {
|
||||
public static Argument<PlotId> PlotID = new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
|
||||
@Override
|
||||
public PlotId parse(String in) {
|
||||
PlotId plotID;
|
||||
try {
|
||||
String[] parts = in.split(";");
|
||||
int i1 = java.lang.Integer.parseInt(parts[0]);
|
||||
int i2 = java.lang.Integer.parseInt(parts[1]);
|
||||
plotID = new PlotId(i1, i2);
|
||||
} catch(final Exception e) {
|
||||
return null;
|
||||
}
|
||||
return plotID;
|
||||
return PlotId.fromString(in);
|
||||
}
|
||||
};
|
||||
|
||||
public static Argument<Plot> Plot = new Argument<Plot>("Plot", new Plot("plotworld", new PlotId(3, -6), null)) {
|
||||
@Override
|
||||
public Plot parse(String in) {
|
||||
return MainUtil.getPlotFromString(ConsolePlayer.getConsole(), in, false);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -7,10 +7,13 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
||||
public abstract class Command extends CommandManager {
|
||||
|
||||
private Class requiredType = Object.class;
|
||||
private RequiredType requiredType = RequiredType.NONE;
|
||||
private String command, usage = "", description = "", permission = "";
|
||||
private Set<String> aliases = new HashSet<>();
|
||||
private CommandCategory category;
|
||||
@ -59,7 +62,7 @@ public abstract class Command extends CommandManager {
|
||||
this.aliases = new HashSet<>(Arrays.asList(aliases));
|
||||
}
|
||||
|
||||
public Command(String command, String usage, String description, String permission, String[] aliases, Class requiredType) {
|
||||
public Command(String command, String usage, String description, String permission, String[] aliases, RequiredType requiredType) {
|
||||
super(null, new ArrayList<Command>());
|
||||
this.command = command;
|
||||
this.usage = usage;
|
||||
@ -69,7 +72,7 @@ public abstract class Command extends CommandManager {
|
||||
this.requiredType = requiredType;
|
||||
}
|
||||
|
||||
final public Class getRequiredType() {
|
||||
final public RequiredType getRequiredType() {
|
||||
return this.requiredType;
|
||||
}
|
||||
|
||||
@ -93,23 +96,19 @@ public abstract class Command extends CommandManager {
|
||||
final public String toString() {
|
||||
return this.command;
|
||||
}
|
||||
@Override
|
||||
final public int hashCode() {
|
||||
return this.command.hashCode();
|
||||
}
|
||||
|
||||
public abstract boolean onCommand(CommandCaller caller, String[] arguments);
|
||||
public abstract boolean onCommand(PlotPlayer plr, String[] arguments);
|
||||
|
||||
final public int handle(CommandCaller caller, String[] args) {
|
||||
final public int handle(PlotPlayer plr, String[] args) {
|
||||
if (args.length == 0) {
|
||||
return super.handle(caller, "");
|
||||
return super.handle(plr, "");
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (String s : args) {
|
||||
builder.append(s).append(" ");
|
||||
}
|
||||
String s = builder.substring(0, builder.length() - 1);
|
||||
return super.handle(caller, s);
|
||||
return super.handle(plr, s);
|
||||
}
|
||||
|
||||
final public String getCommand() {
|
||||
@ -139,4 +138,32 @@ public abstract class Command extends CommandManager {
|
||||
final public CommandCategory getCategory() {
|
||||
return this.category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final Command other = (Command) obj;
|
||||
if (this.hashCode() != other.hashCode()) {
|
||||
return false;
|
||||
}
|
||||
return this.command.equals(other.command);
|
||||
}
|
||||
|
||||
private int hash;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0) {
|
||||
hash = getCommand().hashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
package com.intellectualsites.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualsites.commands.Argument;
|
||||
import com.intellectualsites.commands.Command;
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
|
||||
public interface CommandCaller<T> {
|
||||
|
||||
boolean hasPermission(String permission);
|
||||
|
||||
void message(String message);
|
||||
|
||||
T getSuperCaller();
|
||||
|
||||
void message(C c, String ... args);
|
||||
|
||||
void sendRequiredArgumentsList(CommandManager manager, Command cmd, Argument[] required);
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualsites.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@ -21,7 +22,7 @@ public @interface CommandDeclaration {
|
||||
|
||||
String description() default "";
|
||||
|
||||
Class requiredType() default Object.class;
|
||||
RequiredType requiredType() default RequiredType.NONE;
|
||||
|
||||
CommandCategory category();
|
||||
}
|
||||
|
@ -7,7 +7,11 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.intellectualsites.commands.util.StringUtil;
|
||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CommandManager {
|
||||
@ -68,8 +72,8 @@ public class CommandManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int handle(CommandCaller caller, String input) {
|
||||
if (initialCharacter != null && !StringUtil.startsWith(initialCharacter, input)) {
|
||||
public int handle(PlotPlayer plr, String input) {
|
||||
if (initialCharacter != null && !input.startsWith(initialCharacter + "")) {
|
||||
return CommandHandlingOutput.NOT_COMMAND;
|
||||
}
|
||||
input = initialCharacter == null ? input : input.substring(1);
|
||||
@ -87,10 +91,10 @@ public class CommandManager {
|
||||
if (cmd == null) {
|
||||
return CommandHandlingOutput.NOT_FOUND;
|
||||
}
|
||||
if (!cmd.getRequiredType().isInstance(caller.getSuperCaller())) {
|
||||
if (!cmd.getRequiredType().allows(plr)) {
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
}
|
||||
if (!caller.hasPermission(cmd.getPermission())) {
|
||||
if (!plr.hasPermission(cmd.getPermission())) {
|
||||
return CommandHandlingOutput.NOT_PERMITTED;
|
||||
}
|
||||
Argument[] requiredArguments = cmd.getRequiredArguments();
|
||||
@ -108,16 +112,16 @@ public class CommandManager {
|
||||
}
|
||||
if (!success) {
|
||||
String usage = cmd.getUsage();
|
||||
caller.sendRequiredArgumentsList(this, cmd, requiredArguments);
|
||||
C.COMMAND_SYNTAX.send(plr, cmd.getUsage());
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
}
|
||||
try {
|
||||
boolean a = cmd.onCommand(caller, args);
|
||||
boolean a = cmd.onCommand(plr, args);
|
||||
if (!a) {
|
||||
String usage = cmd.getUsage();
|
||||
if (usage != null && !usage.isEmpty()) {
|
||||
caller.message(usage);
|
||||
MainUtil.sendMessage(plr, usage);
|
||||
}
|
||||
return CommandHandlingOutput.WRONG_USAGE;
|
||||
}
|
||||
|
@ -1,26 +0,0 @@
|
||||
package com.intellectualsites.commands.util;
|
||||
|
||||
public class StringUtil {
|
||||
|
||||
public static final String[] emptyArray = new String[0];
|
||||
|
||||
public static boolean startsWith(char c, String s) {
|
||||
return !(s == null || s.isEmpty()) && s.toCharArray()[0] == c;
|
||||
}
|
||||
|
||||
public static boolean inArray(String s, String[] a, boolean matchCase) {
|
||||
for (String aS : a) {
|
||||
if (matchCase) {
|
||||
if (s.equals(aS)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (s.equalsIgnoreCase(aS)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -92,7 +92,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
List<World> worlds = Bukkit.getWorlds();
|
||||
if (worlds.size() > 0) {
|
||||
UUIDHandler.startCaching();
|
||||
UUIDHandler.startCaching(null);
|
||||
for (World world : worlds) {
|
||||
try {
|
||||
SetGenCB.setGenerator(world);
|
||||
@ -456,9 +456,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
||||
} else {
|
||||
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
||||
if (UUIDHandler.getUUIDWrapper() instanceof DefaultUUIDWrapper) {
|
||||
if (wrapper instanceof DefaultUUIDWrapper) {
|
||||
Settings.TWIN_MODE_UUID = true;
|
||||
} else if (UUIDHandler.getUUIDWrapper() instanceof OfflineUUIDWrapper && !Bukkit.getOnlineMode()) {
|
||||
} else if (wrapper instanceof OfflineUUIDWrapper && !Bukkit.getOnlineMode()) {
|
||||
Settings.TWIN_MODE_UUID = true;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.StringComparison;
|
||||
import com.plotsquared.bukkit.util.bukkit.BukkitUtil;
|
||||
@ -31,7 +32,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
|
||||
}
|
||||
return MainCommand.onCommand(null, commandLabel, args);
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -47,6 +47,6 @@ public class WorldEvents implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void worldLoad(final WorldLoadEvent event) {
|
||||
UUIDHandler.startCaching();
|
||||
UUIDHandler.startCaching(null);
|
||||
}
|
||||
}
|
||||
|
@ -35,10 +35,14 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCaching() {
|
||||
if (!super.startCaching()) {
|
||||
public boolean startCaching(Runnable whenDone) {
|
||||
if (!super.startCaching(whenDone)) {
|
||||
return false;
|
||||
}
|
||||
return cache(whenDone);
|
||||
}
|
||||
|
||||
public boolean cache(final Runnable whenDone) {
|
||||
final File container = Bukkit.getWorldContainer();
|
||||
List<World> worlds = Bukkit.getWorlds();
|
||||
final String world;
|
||||
@ -48,7 +52,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
else {
|
||||
world = worlds.get(0).getName();
|
||||
}
|
||||
CACHED = true;
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -88,6 +91,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
}
|
||||
add(toAdd);
|
||||
if (whenDone != null) whenDone.run();
|
||||
return;
|
||||
}
|
||||
final HashSet<String> worlds = new HashSet<>();
|
||||
@ -172,6 +176,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
}
|
||||
add(toAdd);
|
||||
if (whenDone != null) whenDone.run();
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -10,14 +10,15 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.google.common.collect.HashBiMap;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -43,13 +44,13 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
try {
|
||||
PreparedStatement stmt = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS `usercache` (cache_key INTEGER PRIMARY KEY, uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL)");
|
||||
PreparedStatement stmt = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS `usercache` (uuid VARCHAR(32) NOT NULL, username VARCHAR(32) NOT NULL, PRIMARY KEY (uuid, username))");
|
||||
stmt.execute();
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
startCaching();
|
||||
startCaching(null);
|
||||
}
|
||||
|
||||
private class SQLUUIDHandlerException extends RuntimeException {
|
||||
@ -71,97 +72,92 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startCaching() {
|
||||
if (!super.startCaching()) {
|
||||
public boolean startCaching(final Runnable whenDone) {
|
||||
if (!super.startCaching(whenDone)) {
|
||||
return false;
|
||||
}
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
StringWrapper username;
|
||||
UUID uuid;
|
||||
boolean found = false;
|
||||
while (resultSet.next()) {
|
||||
found = true;
|
||||
username = new StringWrapper(resultSet.getString("username"));
|
||||
uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||
add(new StringWrapper(username.value), uuid);
|
||||
toAdd.put(new StringWrapper(username.value), uuid);
|
||||
}
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
statement.close();
|
||||
if (!found) {
|
||||
PS.log(C.PREFIX.s() + "&cUsing player data files, couldn't find any cached UUIDs");
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
FileUUIDHandler fileHandler = new FileUUIDHandler(SQLUUIDHandler.this.uuidWrapper);
|
||||
fileHandler.startCaching();
|
||||
add(toAdd);
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
|
||||
// This should be called as long as there are some unknown plots
|
||||
final List<UUID> toFetch = new ArrayList<>();
|
||||
for (UUID u : UUIDHandler.getAllUUIDS()) {
|
||||
if (!uuidExists(u)) {
|
||||
toFetch.add(u);
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&cWill fetch the uuids for all plots!");
|
||||
List<UUID> toFetch = new ArrayList<>();
|
||||
for (UUID u : UUIDHandler.getAllUUIDS()) {
|
||||
if (!uuidExists(u)) {
|
||||
toFetch.add(u);
|
||||
}
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&cFetching &6" + toFetch.size() + "&c uuids!");
|
||||
List<UUID> fetched = new ArrayList<>();
|
||||
for (UUID u : toFetch) {
|
||||
OfflinePlayer plr = Bukkit.getOfflinePlayer(u);
|
||||
if (plr != null) {
|
||||
if (plr.getName() != null) {
|
||||
add(new StringWrapper(plr.getName()), u);
|
||||
fetched.add(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&cFetched &6" + fetched.size() + "&c from player files!");
|
||||
toFetch.removeAll(fetched);
|
||||
if (!Settings.OFFLINE_MODE) {
|
||||
if (toFetch.isEmpty()) {
|
||||
}
|
||||
if (toFetch.isEmpty()) {
|
||||
if (whenDone != null) whenDone.run();
|
||||
return;
|
||||
}
|
||||
FileUUIDHandler fileHandler = new FileUUIDHandler(SQLUUIDHandler.this.uuidWrapper);
|
||||
fileHandler.startCaching(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// If the file based UUID handler didn't cache it, then we can't cache offline mode
|
||||
// Also, trying to cache based on files again, is useless as that's what the file based uuid cacher does
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
if (whenDone != null) whenDone.run();
|
||||
return;
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
|
||||
int i = 0;
|
||||
Iterator<UUID> iterator = toFetch.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
StringBuilder url = new StringBuilder("http://api.intellectualsites.com/uuid/?user=");
|
||||
List<UUID> currentIteration = new ArrayList<>();
|
||||
while (i++ <= 15 && iterator.hasNext()) {
|
||||
UUID _uuid = iterator.next();
|
||||
url.append(_uuid.toString());
|
||||
if (iterator.hasNext()) {
|
||||
url.append(",");
|
||||
}
|
||||
currentIteration.add(_uuid);
|
||||
}
|
||||
PS.log(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url.toString()).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
reader.close();
|
||||
JSONObject object = new JSONObject(rawJSON.toString());
|
||||
for (UUID _u : currentIteration) {
|
||||
Object o = object.getJSONObject(_u.toString().replace("-", "")).get("username");
|
||||
if (o == null || !(o instanceof String)) {
|
||||
continue;
|
||||
if (!Settings.OFFLINE_MODE) {
|
||||
PS.log(C.PREFIX.s() + "&cWill fetch &6" + toFetch.size() + "&c from mojang!");
|
||||
int i = 0;
|
||||
Iterator<UUID> iterator = toFetch.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
StringBuilder url = new StringBuilder("http://api.intellectualsites.com/uuid/?user=");
|
||||
List<UUID> currentIteration = new ArrayList<>();
|
||||
while (i++ <= 15 && iterator.hasNext()) {
|
||||
UUID _uuid = iterator.next();
|
||||
url.append(_uuid.toString());
|
||||
if (iterator.hasNext()) {
|
||||
url.append(",");
|
||||
}
|
||||
add(new StringWrapper(o.toString()), _u);
|
||||
currentIteration.add(_uuid);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.log(C.PREFIX.s() + "&cWill attempt to fetch &6" + currentIteration.size() + "&c uuids from: &6" + url.toString());
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url.toString()).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
StringBuilder rawJSON = new StringBuilder();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
rawJSON.append(line);
|
||||
}
|
||||
reader.close();
|
||||
JSONObject object = new JSONObject(rawJSON.toString());
|
||||
for (UUID _u : currentIteration) {
|
||||
Object o = object.getJSONObject(_u.toString().replace("-", "")).get("username");
|
||||
if (o == null || !(o instanceof String)) {
|
||||
continue;
|
||||
}
|
||||
add(new StringWrapper(o.toString()), _u);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
i = 0;
|
||||
}
|
||||
if (whenDone != null) whenDone.run();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
throw new SQLUUIDHandlerException("Couldn't select :s", e);
|
||||
}
|
||||
@ -211,7 +207,7 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
@Override
|
||||
public boolean add(final StringWrapper name, final UUID uuid) {
|
||||
// Ignoring duplicates
|
||||
if (!super.add(name, uuid)) {
|
||||
if (super.add(name, uuid)) {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -226,9 +222,9 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -263,4 +259,23 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rename(final UUID uuid, final StringWrapper name) {
|
||||
super.rename(uuid, name);
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
PreparedStatement statement = getConnection().prepareStatement("UPDATE usercache SET `username`=? WHERE `uuid`=?");
|
||||
statement.setString(1, name.value);
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.execute();
|
||||
PS.log(C.PREFIX.s() + "Name change for '" + uuid + "' to '" + name.value + "'");
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
||||
Collection<World> worlds = server.getWorlds();
|
||||
if (worlds.size() > 0) {
|
||||
log("INJECTING WORLDS!!!!!!!");
|
||||
UUIDHandler.startCaching();
|
||||
UUIDHandler.startCaching(null);
|
||||
for (World world : server.getWorlds()) {
|
||||
log("INJECTING WORLD: " + world.getName());
|
||||
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
||||
|
Loading…
Reference in New Issue
Block a user