SteamWar/BauSystem2.0
Archiviert
12
0

Fix stuff and rebuild
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-09-12 18:26:18 +02:00
Ursprung 50580f916a
Commit dfcaac5045
5 geänderte Dateien mit 65 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -1291,3 +1291,11 @@ XRAY_HELP = §8/§exray §8- §7Toggle Xray
XRAY_GLOBAL = §cNo xray in global region
XRAY_ON = §aXray activated
XRAY_OFF = §cXray deactivated
# WorldEdit
COLORREPLACE_HELP = §8/§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Replace all blocks of one color with another
COLORREPLACE_NO_PERMS = §cYou do not have the permission to use this command
TYPEREPLACE_HELP = §8/§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Replace all blocks of one type with another
TYPEREPLACE_NO_PERMS = §cYou do not have the permission to use this command

Datei anzeigen

@ -1270,3 +1270,11 @@ XRAY_HELP = §8/§exray §8- §7Xray umschalten
XRAY_GLOBAL = §cKein Xray in der globalen region
XRAY_ON = §aXray aktiviert
XRAY_OFF = §cXray deaktiviert
# WorldEdit
COLORREPLACE_HELP = §8/§ecolorreplace §8[§7color§8] §8[§7color§8] §8- §7Ersetzt eine Farbe mit einer anderen
COLORREPLACE_NO_PERMS = §cDu hast keine Rechte um Farben zu ersetzen
TYPEREPLACE_HELP = §8/§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Ersetzt einen Blockgruppe mit einer anderen
TYPEREPLACE_NO_PERMS = §cDu hast keine Rechte um Blockgruppen zu ersetzen

Datei anzeigen

@ -26,11 +26,13 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import lombok.SneakyThrows;
import org.bukkit.Material;
import org.bukkit.World;
@ -58,9 +60,9 @@ public class ColorReplaceCommand extends SWCommand {
}
}
@Register
@Register(description = "COLORREPLACE_HELP")
@SneakyThrows
public void genericCommand(Player player, Color from, Color to) {
public void genericCommand(@Validator Player player, Color from, Color to) {
if (from == to) {
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
return;
@ -81,4 +83,15 @@ public class ColorReplaceCommand extends SWCommand {
editSession.flushSession();
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;
};
}
}

Datei anzeigen

@ -20,13 +20,16 @@
package de.steamwar.bausystem.features.worldedit;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.blocks.SignBlock;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.Bukkit;
import org.bukkit.block.Sign;
import org.bukkit.block.data.BlockData;
import javax.annotation.Nullable;
@ -40,7 +43,8 @@ public class SpecialReplace implements Mask, Pattern {
private BiConsumer<BlockData, BlockData> blockDataMerger;
public SpecialReplace(EditSession editSession, Map<String, String> replacements) {
this(editSession, replacements, (_1, _2) -> {});
this(editSession, replacements, (_1, _2) -> {
});
}
public SpecialReplace(EditSession editSession, Map<String, String> replacements, BiConsumer<BlockData, BlockData> blockDataMerger) {
@ -62,7 +66,14 @@ public class SpecialReplace implements Mask, Pattern {
@Override
public BaseBlock applyBlock(BlockVector3 position) {
String s = BukkitAdapter.adapt(editSession.getFullBlock(position)).getAsString();
BaseBlock block = editSession.getFullBlock(position);
String[] signText = null;
if (block.getBlockType().getId().endsWith("sign")) {
Sign sign = (Sign) BukkitAdapter.adapt(editSession.getWorld()).getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ()).getState();
signText = sign.getLines();
}
BlockData blockData = BukkitAdapter.adapt(block);
String s = blockData.getAsString();
String rest = "";
if (s.contains("[")) {
int i = s.indexOf("[");
@ -70,7 +81,11 @@ public class SpecialReplace implements Mask, Pattern {
s = s.substring(0, i);
}
try {
return BukkitAdapter.adapt(Bukkit.createBlockData(replacements.getOrDefault(s, s) + rest)).toBaseBlock();
BaseBlock newBlock = BukkitAdapter.adapt(Bukkit.createBlockData(replacements.getOrDefault(s, s) + rest)).toBaseBlock();
if (newBlock.getBlockType().getId().endsWith("sign")) {
newBlock = new SignBlock(newBlock.toImmutableState(), signText).toBaseBlock();
}
return newBlock;
} catch (IllegalArgumentException e) {
try {
BlockData newBlockData = Bukkit.createBlockData(replacements.getOrDefault(s, s));

Datei anzeigen

@ -26,16 +26,19 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.linkage.MinVersion;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeValidator;
import lombok.AllArgsConstructor;
import lombok.SneakyThrows;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Sign;
import org.bukkit.block.data.type.Fence;
import org.bukkit.block.data.type.Wall;
import org.bukkit.entity.Player;
@ -53,9 +56,9 @@ public class TypeReplaceCommand extends SWCommand {
super("/typereplace", "/tr");
}
@Register
@Register(description = "TYPEREPLACE_HELP")
@SneakyThrows
public void genericCommand(Player player, Type from, Type to) {
public void genericCommand(@Validator Player player, Type from, Type to) {
if (from == to) {
BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)}));
return;
@ -91,6 +94,17 @@ public class TypeReplaceCommand extends SWCommand {
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
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),
@ -228,7 +242,6 @@ public class TypeReplaceCommand extends SWCommand {
if (leaves != null && from.leaves != null) {
replacements.put("minecraft:" + from.leaves.name().toLowerCase(), "minecraft:" + leaves.name().toLowerCase());
}
System.out.println(replacements);
return replacements;
}
}