mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-23 05:36:45 +01:00
Port blocked-cmds flag
This commit is contained in:
parent
d274dcbae6
commit
95a1b0612f
@ -13,7 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Anima
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DisablePhysicsFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DoneFlag;
|
||||||
@ -672,10 +672,10 @@ import java.util.regex.Pattern;
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Optional<List<String>> flag = plot.getFlag(Flags.BLOCKED_CMDS);
|
|
||||||
if (flag.isPresent() && !Permissions
|
List<String> blockedCommands = plot.getFlag(BlockedCmdsFlag.class);
|
||||||
|
if (!blockedCommands.isEmpty() && !Permissions
|
||||||
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
.hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
|
||||||
List<String> blockedCommands = flag.get();
|
|
||||||
String part = parts[0];
|
String part = parts[0];
|
||||||
if (parts[0].contains(":")) {
|
if (parts[0].contains(":")) {
|
||||||
part = parts[0].split(":")[1];
|
part = parts[0].split(":")[1];
|
||||||
|
@ -632,6 +632,7 @@ public enum Captions implements Caption {
|
|||||||
FLAG_DESCRIPTION_DENY_TELEPORT("Deny a certain group from teleporting to the plot. Available groups: members, nonmembers, trusted, nontrusted, nonowners", "Flags"),
|
FLAG_DESCRIPTION_DENY_TELEPORT("Deny a certain group from teleporting to the plot. Available groups: members, nonmembers, trusted, nontrusted, nonowners", "Flags"),
|
||||||
FLAG_DESCRIPTION_GAMEMODE("Determines the gamemode in the plot.", "Flags"),
|
FLAG_DESCRIPTION_GAMEMODE("Determines the gamemode in the plot.", "Flags"),
|
||||||
FLAG_DESCRIPTION_GUEST_GAMEMODE("Determines the guest gamemode in the plot.", "Flags"),
|
FLAG_DESCRIPTION_GUEST_GAMEMODE("Determines the guest gamemode in the plot.", "Flags"),
|
||||||
|
FLAG_DESCRIPTION_BLOCKED_CMDS("A list of commands that are blocked in the plot.", "Flags"),
|
||||||
//</editor-fold>
|
//</editor-fold>
|
||||||
//<editor-fold desc="Flag category errors">
|
//<editor-fold desc="Flag category errors">
|
||||||
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"),
|
||||||
|
@ -7,7 +7,6 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
|
|||||||
public final class Flags {
|
public final class Flags {
|
||||||
|
|
||||||
public static final LongFlag TIME = new LongFlag("time");
|
public static final LongFlag TIME = new LongFlag("time");
|
||||||
public static final StringListFlag BLOCKED_CMDS = new StringListFlag("blocked-cmds");
|
|
||||||
public static final Flag<?> KEEP = new Flag(Captions.FLAG_CATEGORY_MIXED, "keep") {
|
public static final Flag<?> KEEP = new Flag(Captions.FLAG_CATEGORY_MIXED, "keep") {
|
||||||
@Override public String valueToString(Object value) {
|
@Override public String valueToString(Object value) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
|
@ -6,6 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.flags.implementations.Anima
|
|||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.AnimalInteractFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockBurnFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockIgnitionFlag;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BlockedCmdsFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.BreakFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyExitFlag;
|
||||||
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
import com.github.intellectualsites.plotsquared.plot.flags.implementations.DenyTeleportFlag;
|
||||||
@ -169,6 +170,7 @@ public final class GlobalFlagContainer extends FlagContainer {
|
|||||||
// Misc
|
// Misc
|
||||||
this.addFlag(GamemodeFlag.GAMEMODE_FLAG_DEFAULT);
|
this.addFlag(GamemodeFlag.GAMEMODE_FLAG_DEFAULT);
|
||||||
this.addFlag(GuestGamemodeFlag.GUEST_GAMEMODE_FLAG_DEFAULT);
|
this.addFlag(GuestGamemodeFlag.GUEST_GAMEMODE_FLAG_DEFAULT);
|
||||||
|
this.addFlag(BlockedCmdsFlag.BLOCKED_CMDS_FLAG_NONE);
|
||||||
|
|
||||||
// Internal flags
|
// Internal flags
|
||||||
this.addFlag(new AnalysisFlag(Collections.emptyList()));
|
this.addFlag(new AnalysisFlag(Collections.emptyList()));
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.github.intellectualsites.plotsquared.plot.flags.implementations;
|
||||||
|
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.config.Captions;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
|
||||||
|
import com.github.intellectualsites.plotsquared.plot.flags.types.ListFlag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class BlockedCmdsFlag extends ListFlag<String, BlockedCmdsFlag> {
|
||||||
|
|
||||||
|
public static final BlockedCmdsFlag BLOCKED_CMDS_FLAG_NONE = new BlockedCmdsFlag(Collections.emptyList());
|
||||||
|
|
||||||
|
protected BlockedCmdsFlag(List<String> valueList) {
|
||||||
|
super(valueList, Captions.FLAG_CATEGORY_STRING_LIST, Captions.FLAG_DESCRIPTION_BLOCKED_CMDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public BlockedCmdsFlag parse(@NotNull String input) throws FlagParseException {
|
||||||
|
return flagOf(Arrays.asList(input.split(",")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getExample() {
|
||||||
|
return "gamemode survival, spawn";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected BlockedCmdsFlag flagOf(@NotNull List<String> value) {
|
||||||
|
return new BlockedCmdsFlag(value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user