mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-17 12:54:43 +02:00
Several changes:
- Several API improvements - persistent WorldEdit bypass toggle - persistent plot chat toggle - Plot BO3 exporting (useful f - Fix fastmode clearing unclaim border - Add player-interact flag for NPC interaction etc. Fixes #543 - Several fixes for sponge - some code cleanup - Closes #529
This commit is contained in:
@ -153,7 +153,7 @@ public class Auto extends SubCommand {
|
||||
sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
|
||||
MainUtil.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
return true;
|
||||
}
|
||||
|
@ -0,0 +1,90 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||
// /
|
||||
// This program is free software; you can redistribute it and/or modify /
|
||||
// it under the terms of the GNU General Public License as published by /
|
||||
// the Free Software Foundation; either version 3 of the License, or /
|
||||
// (at your option) any later version. /
|
||||
// /
|
||||
// This program is distributed in the hope that it will be useful, /
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||
// GNU General Public License for more details. /
|
||||
// /
|
||||
// You should have received a copy of the GNU General Public License /
|
||||
// along with this program; if not, write to the Free Software Foundation, /
|
||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||
// /
|
||||
// You can contact us via: support@intellectualsites.com /
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.BO3Handler;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "bo3",
|
||||
aliases = {"bo2"},
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.done",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE
|
||||
)
|
||||
public class BO3 extends SubCommand {
|
||||
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer plr, final String[] args) {
|
||||
final Location loc = plr.getLocation();
|
||||
final Plot plot = MainUtil.getPlot(loc);
|
||||
if (plot == null || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.bo3")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
if (args.length == 0) {
|
||||
noArgs(plr);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "output":
|
||||
case "save":
|
||||
case "export": {
|
||||
return BO3Handler.saveBO3(plr, plot);
|
||||
}
|
||||
case "paste":
|
||||
case "load":
|
||||
case "import":
|
||||
case "input": {
|
||||
// TODO NOT IMPLEMENTED YET
|
||||
MainUtil.sendMessage(plr, "NOT IMPLEMENTED YET!!!");
|
||||
return false;
|
||||
}
|
||||
default: {
|
||||
noArgs(plr);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,25 +17,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
public class Chat extends SubCommand {
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
boolean enable = !(plr.getMeta("chat") != null && (Boolean) plr.getMeta("chat"));
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("on")) {
|
||||
enable = true;
|
||||
} else if (args[0].equalsIgnoreCase("off")) {
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
||||
if (!enable && plotworld.PLOT_CHAT) {
|
||||
return !sendMessage(plr, C.PLOT_CHAT_FORCED);
|
||||
}
|
||||
plr.setMeta("chat", enable);
|
||||
return sendMessage(plr, enable ? C.PLOT_CHAT_ON : C.PLOT_CHAT_OFF);
|
||||
public boolean onCommand(final PlotPlayer player, final String ... args) {
|
||||
return MainCommand.onCommand(player, "plot", new String[] {"toggle", "chat"});
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ public class Claim extends SubCommand {
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
}
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !plr.hasPermission("plots.admin.command.schematic")) {
|
||||
if (!Permissions.hasPermission(plr, "plots.claim." + schematic) && !Permissions.hasPermission(plr, "plots.admin.command.schematic")) {
|
||||
return sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
@CommandDeclaration(
|
||||
command = "continue",
|
||||
description = "Continue a plot that was previously marked as done",
|
||||
permission = "plots.done",
|
||||
permission = "plots.continue",
|
||||
category = CommandCategory.ACTIONS,
|
||||
requiredType = RequiredType.NONE
|
||||
)
|
||||
@ -52,7 +52,7 @@ public class Continue extends SubCommand {
|
||||
if (plot == null || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.continue")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ public class Copy extends SubCommand {
|
||||
if (plot1 == null) {
|
||||
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN.s)) {
|
||||
if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -157,9 +157,6 @@ public class DebugExec extends SubCommand {
|
||||
for (Enum<?> value : C.values()) {
|
||||
scope.put("C_" + value.name(), value);
|
||||
}
|
||||
for (Enum<?> value : Permissions.values()) {
|
||||
scope.put("Permissions_" + value.name(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +53,7 @@ public class Done extends SubCommand {
|
||||
if (plot == null || !plot.hasOwner()) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
|
||||
if ((!plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.done")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public class FlagCmd extends SubCommand {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isAdded(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
|
||||
return false;
|
||||
}
|
||||
|
@ -129,6 +129,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Chat());
|
||||
createCommand(new Trim());
|
||||
createCommand(new Done());
|
||||
createCommand(new Continue());
|
||||
createCommand(new BO3());
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
}
|
||||
@ -419,7 +421,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
}
|
||||
return CommandHandlingOutput.CALLER_OF_WRONG_TYPE;
|
||||
}
|
||||
if (!plr.hasPermission(cmd.getPermission())) {
|
||||
if (!Permissions.hasPermission(plr, cmd.getPermission())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission());
|
||||
return CommandHandlingOutput.NOT_PERMITTED;
|
||||
}
|
||||
|
@ -175,8 +175,8 @@ public class Merge extends SubCommand {
|
||||
multiUUID.add(u2);
|
||||
}
|
||||
if (multiMerge) {
|
||||
if (!Permissions.hasPermission(plr, Permissions.MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, Permissions.MERGE_OTHER.s);
|
||||
if (!Permissions.hasPermission(plr, C.PERMISSION_MERGE_OTHER)) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER.s());
|
||||
return false;
|
||||
}
|
||||
for (final UUID uuid : multiUUID) {
|
||||
|
@ -56,7 +56,7 @@ public class Move extends SubCommand {
|
||||
if (plot1 == null) {
|
||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN.s)) {
|
||||
if (!plot1.isAdded(plr.getUUID()) && !Permissions.hasPermission(plr, C.PERMISSION_ADMIN.s())) {
|
||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class Set extends SubCommand {
|
||||
sendMessage(plr, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isAdded(plr.getUUID())) {
|
||||
if (!plot.isOwner(plr.getUUID())) {
|
||||
if (!Permissions.hasPermission(plr, "plots.set.other")) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set.other");
|
||||
return false;
|
||||
|
@ -20,17 +20,25 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
// TOGGLE("toggle", "attribute"),
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "toggle",
|
||||
aliases = {"attribute"},
|
||||
permission = "plots.toggle",
|
||||
permission = "plots.use",
|
||||
description = "Toggle per user settings",
|
||||
usage = "/plot toggle <setting>",
|
||||
requiredType = RequiredType.NONE,
|
||||
@ -40,7 +48,66 @@ public class Toggle extends SubCommand {
|
||||
|
||||
public void noArgs(PlotPlayer plr) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot toggle <setting>");
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + "titles");
|
||||
ArrayList<String> options = new ArrayList<>();
|
||||
for (Entry<String, Command<PlotPlayer>> entry : toggles.entrySet()) {
|
||||
if (Permissions.hasPermission(plr, entry.getValue().getPermission())) {
|
||||
options.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
if (options.size() > 0) {
|
||||
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + StringMan.join(options, ","));
|
||||
}
|
||||
}
|
||||
|
||||
private HashMap<String, Command<PlotPlayer>> toggles;
|
||||
|
||||
public Toggle() {
|
||||
toggles = new HashMap<>();
|
||||
toggles.put("titles",
|
||||
new Command<PlotPlayer>("titles", "/plot toggle titles", "Toggle titles for yourself", C.PERMISSION_PLOT_TOGGLE_TITLES.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, getCommand());
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, getCommand());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
toggles.put("chat",
|
||||
new Command<PlotPlayer>("chat", "/plot toggle chat", "Toggle plot chat for yourself", C.PERMISSION_PLOT_TOGGLE_CHAT.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.PLOT_CHAT_OFF);
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(player, C.PLOT_CHAT_ON);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if (BukkitMain.worldEdit != null) {
|
||||
toggles.put("worldedit",
|
||||
new Command<PlotPlayer>("worldedit", "/plot toggle worldedit", "Toggle worldedit bypass", C.PERMISSION_WORLDEDIT_BYPASS.s()) {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
if (toggle(player, "worldedit")) {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,20 +116,16 @@ public class Toggle extends SubCommand {
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "titles": {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, args[0]);
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, args[0]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
Command<PlotPlayer> cmd = toggles.get(args[0].toLowerCase());
|
||||
if (cmd == null) {
|
||||
noArgs(player);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, cmd.getPermission())) {
|
||||
C.NO_PERMISSION.send(player, cmd.getPermission());
|
||||
return false;
|
||||
}
|
||||
return cmd.onCommand(player, Arrays.copyOfRange(args, 1, args.length));
|
||||
}
|
||||
|
||||
public boolean toggle(PlotPlayer player, String key) {
|
||||
|
@ -37,25 +37,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.DEBUG
|
||||
)
|
||||
|
||||
@Deprecated
|
||||
public class WE_Anywhere extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
if (BukkitMain.worldEdit == null) {
|
||||
MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server");
|
||||
return true;
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.worldedit.bypass")) {
|
||||
if (WEManager.bypass.contains(player.getName())) {
|
||||
WEManager.bypass.remove(player.getName());
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_RESTRICTED);
|
||||
}
|
||||
else {
|
||||
WEManager.bypass.add(player.getName());
|
||||
MainUtil.sendMessage(player, C.WORLDEDIT_UNMASKED);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return MainCommand.onCommand(player, "plot", new String[] {"toggle", "worldedit"});
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user