From 07a7de7f21cd871ba8ed9e98dc03c4306fed83bb Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 3 Aug 2021 13:53:50 +0200 Subject: [PATCH] Fix ColorCommand Fix RegionCommand Signed-off-by: yoyosource --- .../steamwar/bausystem/region/Region_15.java | 19 +++++++++++------- BauSystem_Main/src/BauSystem.properties | 5 ++--- .../features/region/ColorCommand.java | 20 ++++++++++++------- .../features/region/RegionCommand.java | 6 +++--- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java b/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java index 805aa5e9..c1c267f3 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/region/Region_15.java @@ -30,8 +30,6 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.function.mask.AbstractExtentMask; -import com.sk89q.worldedit.function.mask.BlockMask; -import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask2D; import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.Operations; @@ -40,7 +38,6 @@ import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.world.block.BaseBlock; -import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; @@ -50,9 +47,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.logging.Level; @UtilityClass @@ -101,11 +96,21 @@ public class Region_15 { changeColor(clipboard, pasteOptions.getColor()); } if (pasteOptions.isOnlyColors()) { + Set blocks = new HashSet<>(); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_wool"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_terracotta"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_stained_glass_pane"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_concrete_powder"); + blocks.add("minecraft:" + pasteOptions.getColor().name().toLowerCase() + "_carpet"); + e.setMask(new AbstractExtentMask(clipboard) { @Override public boolean test(BlockVector3 blockVector3) { BaseBlock block = getExtent().getFullBlock(blockVector3); - return !(block.equals(WOOL) || block.equals(CLAY) || block.equals(GLASS) || block.equals(GLASS2) || block.equals(GLASS_PANE) || block.equals(CARPET) || block.equals(CONCRETE) || block.equals(CONCRETE2) || block.equals(CONCRETE_POWDER)); + String blockName = block.toString().toLowerCase(); + return blocks.contains(blockName); } @Nullable diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 60cac58f..8606af77 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -415,10 +415,7 @@ REGION_COLOR_HELP_1=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Re REGION_COLOR_HELP_2=§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global REGION_COLOR_GLOBAL=§7Alle Regions farben auf §e{0}§7 gesetzt REGION_COLOR_NO_REGION=§cDu befindest dich derzeit in keiner Region -REGION_COLOR_REGION=§7Regions farben auf §e{0}§7 gesetzt REGION_COLOR_NO_PERMS=§cDies ist nicht deine Welt! -REGION_COLOR_UPDATE=§7Klicke §e§lHIER §7um die Farbe anzuwenden -REGION_COLOR_UPDATE_HOVER=§8/§eregion restore REGION_DAMAGE_HELP_1=§8/§edamage §8- §7Toggle Spielerschaden REGION_DAMAGE_NO_PERMS=§cDu darfst hier nicht Spielerschaden (de-)aktivieren REGION_DAMAGE_ENABLED=§cRegions Spielerschaden deaktiviert @@ -450,6 +447,8 @@ REGION_REGION_NOTHING_REDO=§cNichts zum wiederhohlen REGION_REGION_REDID=§7Letzte Aktion wiederhohlt REGION_REGION_RESTORED=§7Region zurückgesetzt REGION_REGION_FAILED_RESTORE=§cFehler beim Zurücksetzen der Region +REGION_REGION_COLORED=§7Region umgefärbt +REGION_REGION_FAILED_COLORED=§cFehler beim umfärben der Region REGION_REGION_NO_SCHEM=§cSchematic nicht gefunden REGION_REGION_TP_COPY=§7Zum Kopierpunkt teleportiert REGION_REGION_NO_REGION=§cDu bist in keiner Region diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java index d596d595..9f7eca54 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/ColorCommand.java @@ -20,17 +20,25 @@ package de.steamwar.bausystem.features.region; import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; +import de.steamwar.bausystem.region.utils.RegionExtensionType; +import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.command.SWCommand; import net.md_5.bungee.api.chat.ClickEvent; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.io.IOException; +import java.util.logging.Level; + @Linked(LinkageType.COMMAND) public class ColorCommand extends SWCommand { @@ -69,9 +77,11 @@ public class ColorCommand extends SWCommand { return; } region.set(Flag.COLOR, color); - BauSystem.MESSAGE.send("REGION_COLOR_REGION", p, color.name().toLowerCase()); - if (colorizationType == ColorizationType.LOCAL) { - sendHowToUpdate(p); + try { + region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, true); + RegionUtils.message(region, "REGION_REGION_COLORED"); + } catch (IOException e) { + BauSystem.MESSAGE.send("REGION_REGION_FAILED_COLORED", p); } } @@ -88,10 +98,6 @@ public class ColorCommand extends SWCommand { return false; } - private void sendHowToUpdate(Player p) { - BauSystem.MESSAGE.send("REGION_COLOR_UPDATE", p, BauSystem.MESSAGE.parse("REGION_COLOR_UPDATE_HOVER", p), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/region restore")); - } - public enum ColorizationType { LOCAL, GLOBAL diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java index caa76bda..7126fc32 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -131,11 +131,11 @@ public class RegionCommand extends SWCommand { if(checkGlobalRegion(region, p)) return; try { - region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, true); + region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, false); RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (IOException e) { BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); - Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e); + Bukkit.getLogger().log(Level.WARNING, "Failed restore", e); } } @@ -160,7 +160,7 @@ public class RegionCommand extends SWCommand { RegionUtils.message(region, "REGION_REGION_RESTORED"); } catch (IOException e) { BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); - Bukkit.getLogger().log(Level.WARNING, "Failed reset", e); + Bukkit.getLogger().log(Level.WARNING, "Failed restore", e); } }