Update how the validation work for the semi we commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
cca55fa115
Commit
74861f0797
@ -29,6 +29,9 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@Linked(LinkageType.LISTENER)
|
@Linked(LinkageType.LISTENER)
|
||||||
public class WorldEditListener implements Listener {
|
public class WorldEditListener implements Listener {
|
||||||
|
|
||||||
@ -43,12 +46,20 @@ public class WorldEditListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addOtherCommand(String s) {
|
||||||
|
commands.add(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Set<String> commands = new HashSet<>();
|
||||||
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
|
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
|
||||||
|
|
||||||
private boolean isWorldEditCommand(String command) {
|
private boolean isWorldEditCommand(String command) {
|
||||||
for (String shortcut : shortcutCommands) {
|
for (String shortcut : shortcutCommands) {
|
||||||
if (command.startsWith(shortcut)) return true;
|
if (command.startsWith(shortcut)) return true;
|
||||||
}
|
}
|
||||||
|
for (String s : commands) {
|
||||||
|
if (command.startsWith(s)) return true;
|
||||||
|
}
|
||||||
|
|
||||||
return FlatteningWrapper.impl.isWorldEditCommand(command);
|
return FlatteningWrapper.impl.isWorldEditCommand(command);
|
||||||
}
|
}
|
||||||
|
@ -26,13 +26,12 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.bausystem.region.Color;
|
import de.steamwar.bausystem.region.Color;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -42,7 +41,6 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Linked(LinkageType.COMMAND)
|
@Linked(LinkageType.COMMAND)
|
||||||
public class ColorReplaceCommand extends SWCommand {
|
public class ColorReplaceCommand extends SWCommand {
|
||||||
@ -53,6 +51,8 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
|
|
||||||
private Set<String> types = new HashSet<>();
|
private Set<String> types = new HashSet<>();
|
||||||
{
|
{
|
||||||
|
WorldEditListener.addOtherCommand("//colorreplace");
|
||||||
|
WorldEditListener.addOtherCommand("//cr");
|
||||||
for (Material value : Material.values()) {
|
for (Material value : Material.values()) {
|
||||||
if (value.name().startsWith("WHITE_")) {
|
if (value.name().startsWith("WHITE_")) {
|
||||||
types.add(value.name().substring(6));
|
types.add(value.name().substring(6));
|
||||||
@ -62,7 +62,7 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
|
|
||||||
@Register(description = "COLORREPLACE_HELP")
|
@Register(description = "COLORREPLACE_HELP")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void genericCommand(@Validator Player player, Color from, Color to) {
|
public void genericCommand(Player player, Color from, Color to) {
|
||||||
if (from == to) {
|
if (from == to) {
|
||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
||||||
return;
|
return;
|
||||||
@ -83,15 +83,4 @@ public class ColorReplaceCommand extends SWCommand {
|
|||||||
editSession.flushSession();
|
editSession.flushSession();
|
||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(affected)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(affected)}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(Player.class)
|
|
||||||
public TypeValidator<Player> playerValidator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
if (Permission.WORLDEDIT.hasPermission(player)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
messageSender.send("COLORREPLACE_NO_PERMS");
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -26,19 +26,17 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
import de.steamwar.bausystem.Permission;
|
import de.steamwar.bausystem.features.world.WorldEditListener;
|
||||||
import de.steamwar.bausystem.linkage.LinkageType;
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
import de.steamwar.bausystem.linkage.Linked;
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
import de.steamwar.bausystem.linkage.MinVersion;
|
import de.steamwar.bausystem.linkage.MinVersion;
|
||||||
import de.steamwar.bausystem.utils.WorldEditUtils;
|
import de.steamwar.bausystem.utils.WorldEditUtils;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Sign;
|
|
||||||
import org.bukkit.block.data.type.Fence;
|
import org.bukkit.block.data.type.Fence;
|
||||||
import org.bukkit.block.data.type.Wall;
|
import org.bukkit.block.data.type.Wall;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -56,9 +54,14 @@ public class TypeReplaceCommand extends SWCommand {
|
|||||||
super("/typereplace", "/tr");
|
super("/typereplace", "/tr");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
WorldEditListener.addOtherCommand("//typereplace");
|
||||||
|
WorldEditListener.addOtherCommand("//tr");
|
||||||
|
}
|
||||||
|
|
||||||
@Register(description = "TYPEREPLACE_HELP")
|
@Register(description = "TYPEREPLACE_HELP")
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void genericCommand(@Validator Player player, Type from, Type to) {
|
public void genericCommand(Player player, Type from, Type to) {
|
||||||
if (from == to) {
|
if (from == to) {
|
||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
|
||||||
return;
|
return;
|
||||||
@ -94,17 +97,6 @@ public class TypeReplaceCommand extends SWCommand {
|
|||||||
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(affected)}));
|
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(affected)}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassValidator(Player.class)
|
|
||||||
public TypeValidator<Player> playerValidator() {
|
|
||||||
return (commandSender, player, messageSender) -> {
|
|
||||||
if (Permission.WORLDEDIT.hasPermission(player)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
messageSender.send("TYPEREPLACE_NO_PERMS");
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
private enum Type {
|
private enum Type {
|
||||||
IRON(IRON_BLOCK, null, null, null, null, null, null, IRON_BARS, IRON_DOOR, IRON_TRAPDOOR, null, HEAVY_WEIGHTED_PRESSURE_PLATE, null, null, null, null),
|
IRON(IRON_BLOCK, null, null, null, null, null, null, IRON_BARS, IRON_DOOR, IRON_TRAPDOOR, null, HEAVY_WEIGHTED_PRESSURE_PLATE, null, null, null, null),
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren