mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
cmd
This commit is contained in:
parent
50c80ba5c4
commit
1eb0ba47b4
@ -1,34 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions;
|
||||
|
||||
/**
|
||||
* Created 2014-11-09 for PlotSquared
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public class Ban extends SubCommand {
|
||||
public Ban() {
|
||||
super(Command.BAN, "Alias for /plot denied add", "/plot ban [player]", CommandCategory.ACTIONS, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (args.length < 1) {
|
||||
return MainUtil.sendMessage(plr, "&cUsage: &c" + this.usage);
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(plr.getLocation());
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isAdded(plr.getUUID())) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
|
||||
return plr.performCommand("plot denied add " + args[0]);
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -45,10 +46,11 @@ public class Buy extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
if (!PlotSquared.useEconomy) {
|
||||
if (PlotSquared.economy == null) {
|
||||
return sendMessage(plr, C.ECON_DISABLED);
|
||||
}
|
||||
final World world = plr.getWorld();
|
||||
Location loc = plr.getLocation();
|
||||
final String world = loc.getWorld();
|
||||
if (!PlotSquared.isPlotWorld(world)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
@ -62,7 +64,7 @@ public class Buy extends SubCommand {
|
||||
return sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
}
|
||||
} else {
|
||||
plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
plot = MainUtil.getPlot(loc);
|
||||
}
|
||||
if (plot == null) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
|
@ -92,7 +92,7 @@ public class Claim extends SubCommand {
|
||||
if (BukkitPlayerFunctions.getPlayerPlotCount(plr.getWorld(), plr) >= BukkitPlayerFunctions.getAllowedPlots(plr)) {
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot.hasOwner()) {
|
||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Clear extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Comment extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasOwner()) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Copy extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.copy")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
|
@ -43,7 +43,7 @@ public class CreateRoadSchematic extends SubCommand {
|
||||
if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) {
|
||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
|
||||
manager.setupRoadSchematic(plot);
|
||||
MainUtil.update(BukkitUtil.getLocation(entity));
|
||||
|
@ -24,7 +24,7 @@ public class DEOP extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasRights(plr)) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class DebugClear extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr) || !(PlotSquared.getPlotWorld(plr.getWorld()) instanceof SquarePlotWorld)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Delete extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class Denied extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
@ -93,7 +93,7 @@ public class Denied extends SubCommand {
|
||||
}
|
||||
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
|
||||
if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) {
|
||||
final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
final Plot pl = MainUtil.getPlot(loc);
|
||||
if ((pl != null) && pl.id.equals(plot.id)) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED);
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
|
@ -56,7 +56,7 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null) {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
|
||||
return false;
|
||||
|
@ -48,7 +48,7 @@ public class Helpers extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
|
@ -54,7 +54,7 @@ public class Inbox extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot != null) && !plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
|
@ -66,7 +66,7 @@ public class Info extends SubCommand {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
plot = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
plot = MainUtil.getPlot(loc);
|
||||
} else {
|
||||
if (args.length < 2) {
|
||||
MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE);
|
||||
|
@ -42,7 +42,7 @@ public class Kick extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "You're not in a plot.");
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
@ -56,7 +56,7 @@ public class Kick extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final Player player = Bukkit.getPlayer(args[0]);
|
||||
if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (BukkitPlayerFunctions.getCurrentPlot(player) == null) || !BukkitPlayerFunctions.getCurrentPlot(player).equals(plot)) {
|
||||
if (!player.getWorld().equals(plr.getWorld()) || !BukkitPlayerFunctions.isInPlot(player) || (MainUtil.getPlot(loc) == null) || !MainUtil.getPlot(loc).equals(plot)) {
|
||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
||||
return false;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class Merge extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
|
@ -44,7 +44,7 @@ public class MusicSubcommand extends SubCommand {
|
||||
sendMessage(player, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasRights(player)) {
|
||||
sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
|
@ -24,7 +24,7 @@ public class OP extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasRights(plr)) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class Paste extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.paste")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
|
@ -47,7 +47,7 @@ public class Rate extends SubCommand {
|
||||
sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(plr, C.RATING_NOT_OWNED);
|
||||
return true;
|
||||
|
@ -98,7 +98,7 @@ public class Schematic extends SubCommand {
|
||||
}
|
||||
final int x;
|
||||
final int z;
|
||||
final Plot plot2 = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot2 = MainUtil.getPlot(loc);
|
||||
final Dimension dem = schematic.getSchematicDimension();
|
||||
final Location bot = MainUtil.getPlotBottomLoc(plr.getWorld(), plot2.id).add(1, 0, 1);
|
||||
final int length2 = MainUtil.getPlotWidth(plr.getWorld(), plot2.id);
|
||||
@ -165,7 +165,7 @@ public class Schematic extends SubCommand {
|
||||
}
|
||||
final int l1 = schematic.getSchematicDimension().getX();
|
||||
final int l2 = schematic.getSchematicDimension().getZ();
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
final int length = MainUtil.getPlotWidth(plr.getWorld(), plot.id);
|
||||
if ((l1 < length) || (l2 < length)) {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, String.format("Wrong size (x: %s, z: %d) vs %d ", l1, l2, length));
|
||||
@ -251,7 +251,7 @@ public class Schematic extends SubCommand {
|
||||
sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot myplot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot myplot = MainUtil.getPlot(loc);
|
||||
if (!myplot.hasRights(plr)) {
|
||||
sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
|
@ -68,7 +68,7 @@ public class Set extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasOwner()) {
|
||||
sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
|
@ -51,7 +51,7 @@ public class SetOwner extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || (plot.owner == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
|
@ -53,7 +53,7 @@ public class Swap extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return false;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
|
@ -49,7 +49,7 @@ public class Trusted extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
return true;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
|
@ -24,7 +24,7 @@ public class Unban extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!plot.hasRights(plr)) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class Unclaim extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (!BukkitPlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(BukkitPlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class Unlink extends SubCommand {
|
||||
if (!BukkitPlayerFunctions.isInPlot(plr)) {
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(plr);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ public class ForceFieldListener implements Listener {
|
||||
if (!BukkitPlayerFunctions.isInPlot(player)) {
|
||||
return;
|
||||
}
|
||||
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player);
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||
if (!PlotListener.booleanFlag(plot, "forcefield", false)) {
|
||||
UUID uuid = UUIDHandler.getUUID(player);
|
||||
|
Loading…
Reference in New Issue
Block a user