SteamWar/BauSystem2.0
Archiviert
12
0

Remove ScriptVarsCommand.java
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Update BlockCounter

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-04-16 21:18:38 +02:00
Ursprung bcd354bbf2
Commit 0a9fd70929
4 geänderte Dateien mit 4 neuen und 152 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

@ -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.*;

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<String, Value> 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<String> 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<String> clearStringTypeMapper() {
List<String> 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<Boolean> integerTypeMapper() {
List<String> 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);
}
}

Datei anzeigen

@ -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;