From 0a9fd709293c7259d6a8c05e25efcc278ce856a8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Apr 2022 21:18:38 +0200 Subject: [PATCH] Remove ScriptVarsCommand.java Update BlockCounter Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 4 +- .../features/region/RegionCommand.java | 1 - .../features/script/ScriptVarsCommand.java | 147 ------------------ .../testblock/blockcounter/BlockCounter.java | 4 +- 4 files changed, 4 insertions(+), 152 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 56eb8ae4..ef15d8d8 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -647,8 +647,8 @@ SMART_PLACE_DISABLE = §cSmartPlace deaktiviert BLOCK_COUNTER_HELP_TOGGLE = §8/§eblockcounter §8- §7Wechsel zwischen an und aus BLOCK_COUNTER_HELP_ENABLE = §8/§eblockcounter enable §8- §7Schalte den BlockCounter an BLOCK_COUNTER_HELP_DISABLE = §8/§eblockcounter disable §8- §7Schalte den BlockCounter aus -BLOCK_COUNTER_MESSAGE = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick -BLOCK_COUNTER_MESSAGE_SECOND = §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s +BLOCK_COUNTER_MESSAGE = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/tick +BLOCK_COUNTER_MESSAGE_SECOND = §7Tiefe §8> §e{0} §7Blöcke §e{1} §7TNT §e{2} §7Blöcke/TNT §e{3} §7Blöcke/s BLOCK_COUNTER_ENABLE = §7BlockCounter angemacht BLOCK_COUNTER_DISABLE = §7BlockCounter ausgemacht 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 758a54a4..894e6619 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/RegionCommand.java @@ -28,7 +28,6 @@ import de.steamwar.bausystem.linkage.LinkedInstance; import de.steamwar.bausystem.region.Prototype; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.RegionUtils; -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.*; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java deleted file mode 100644 index 9ce3403e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/ScriptVarsCommand.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 SteamWar.de-Serverteam - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package de.steamwar.bausystem.features.script; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.script.variables.Context; -import de.steamwar.bausystem.features.script.variables.Value; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -@Linked(LinkageType.COMMAND) -public class ScriptVarsCommand extends SWCommand { - - public ScriptVarsCommand() { - super("scriptvars"); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP") - public void genericCommand(Player p) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - int i = 0; - if (context.allVariables().size() == 1) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ONE_VAR", p); - } else { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_MANY_VARS", p, context.allVariables().size()); - } - for (Map.Entry var : context.entrySet()) { - if (i++ >= 40) break; - BauSystem.MESSAGE.sendPrefixless("SCRIPT_COMMAND_VARS_ELEMENT_WITH_DASH", p, var.getKey(), var.getValue().asString()); - } - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_VAR") - public void getCommand(Player p, String varName) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - if (!context.hasValue(varName)) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_UNKNOWN_VARS", p); - return; - } - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_ELEMENT", p, varName, context.getValue(varName).asString()); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_SET") - public void setValueCommand(Player p, String varName, int value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.LongValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_SET") - public void setValueCommand(Player p, String varName, double value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.DoubleValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register - public void setValueCommand(Player p, String varName, boolean value) { - Context context = ScriptListener.getGlobalContext(p); - context.putValue(varName, new Value.BooleanValue(value)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, value); - } - - @Register - public void setValueCommand(Player p, String varName, String... value) { - Context context = ScriptListener.getGlobalContext(p); - String s = String.join(" ", value); - context.putValue(varName, new Value.StringValue(s)); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_SET_VALUE", p, varName, s); - } - - @Register(description = "SCRIPT_COMMAND_VARS_HELP_DELETE") - public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) { - Context context = ScriptListener.getGlobalContext(p); - if (context.allVariables().isEmpty()) { - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_NO_VARS", p); - return; - } - context.removeValue(varName); - BauSystem.MESSAGE.send("SCRIPT_COMMAND_VARS_REMOVE_VALUE", p, varName); - } - - @ClassMapper(value = String.class, local = true) - public TypeMapper stringTypeMapper() { - return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> { - if (commandSender instanceof Player) { - Player player = (Player) commandSender; - return new ArrayList<>(ScriptListener.getGlobalContext(player).allVariables()); - } - return null; - }); - } - - @Mapper(value = "Delete", local = true) - public TypeMapper clearStringTypeMapper() { - List tabCompletes = Arrays.asList("delete", "clear", "remove"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) { - return s; - } - return null; - }, s -> tabCompletes); - } - - @ClassMapper(value = boolean.class, local = true) - public TypeMapper integerTypeMapper() { - List tabCompletes = Arrays.asList("true", "false"); - return SWCommandUtils.createMapper(s -> { - if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null; - return s.equalsIgnoreCase("true"); - }, s -> tabCompletes); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java index 9cd0e5d4..cf34f6f1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/testblock/blockcounter/BlockCounter.java @@ -53,9 +53,9 @@ public class BlockCounter { double countPerTick = (double) count / Math.max((lastTick - tick), 1); if (isActive(player)) { if (countPerTick < 100) { - return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20); + return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE_SECOND", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0 * 20); } else { - return BauSystem.MESSAGE.parsePrefixed("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0); + return BauSystem.MESSAGE.parse("BLOCK_COUNTER_MESSAGE", player, count, tntCount, (int) (countPerTNT * 10) / 10.0, (int) (countPerTick * 100) / 100.0); } } return null;