Merge remote-tracking branch 'origin/master'

Dieser Commit ist enthalten in:
Chaoscaot 2021-05-02 15:29:37 +02:00
Commit 23aa8c94a9
29 geänderte Dateien mit 733 neuen und 61 gelöschten Zeilen

Datei anzeigen

@ -41,9 +41,14 @@ public class InfoCommand extends SWCommand {
public void sendBauInfo(Player p) {
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation());
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.get(Flag.TNT).getChatValue().toUpperCase() + " §eFire§8: " + region.get(Flag.FIRE).getChatValue().toUpperCase() + " §eFreeze§8: " + region.get(Flag.FREEZE).getChatValue().toUpperCase());
if (region.getFloorLevel() != 0) {
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + region.get(Flag.PROTECT).getChatValue().toUpperCase());
for (Flag flag : Flag.getFlags()) {
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
continue;
}
Flag.Value<?> value = region.get(flag);
if (value != null) {
p.sendMessage(BauSystem.PREFIX + "§e" + flag.getChatValue() + "§8: §7" + value.getChatValue());
}
}
List<BauweltMember> members = BauweltMember.getMembers(bauServer.getOwnerID());

Datei anzeigen

@ -7,6 +7,7 @@ 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.flagvalues.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
@ -53,7 +54,7 @@ public class RegionCommand extends SWCommand {
if(checkGlobalRegion(region, p)) return;
if (region.undo()) {
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
RegionUtils.message(region, BauSystem.PREFIX + "§7Letzte Aktion rückgangig gemacht");
} else {
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
}
@ -70,7 +71,7 @@ public class RegionCommand extends SWCommand {
}
if (region.redo()) {
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Letzte Aktion wiederhohlt");
} else {
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
}
@ -94,7 +95,7 @@ public class RegionCommand extends SWCommand {
try {
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
@ -114,7 +115,7 @@ public class RegionCommand extends SWCommand {
}
try {
region.reset(schem, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);

Datei anzeigen

@ -6,6 +6,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.Schematic;
@ -35,7 +36,7 @@ public class ResetCommand extends SWCommand {
if (region == null) return;
try {
region.reset(null, RegionType.NORMAL);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
@ -54,7 +55,7 @@ public class ResetCommand extends SWCommand {
}
try {
region.reset(schem, RegionType.NORMAL);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);

Datei anzeigen

@ -5,6 +5,7 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand;
@ -46,14 +47,13 @@ public class TestblockCommand extends SWCommand {
if (region == null) return;
try {
region.reset(RegionType.TESTBLOCK, regionExtensionType);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@Register
public void schematicTestblockCommand(Player p, String s) {
schematicTestblockCommand(p, s, RegionExtensionType.NORMAL);
@ -76,7 +76,7 @@ public class TestblockCommand extends SWCommand {
}
try {
region.reset(schem, RegionType.TESTBLOCK, regionExtensionType);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
RegionUtils.message(region, BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
@ -111,5 +111,4 @@ public class TestblockCommand extends SWCommand {
}
return region;
}
}

Datei anzeigen

@ -106,17 +106,19 @@ public final class ScriptExecutor {
variables.addAll(Constants.allVariables());
variables.addAll(globalVariables.allVariables());
for (String variable : variables) {
s = s.replace("<" + variable + ">", getValue(variable) + "");
}
for (String constVariable : Constants.allVariables()) {
s = s.replace("<const." + constVariable + ">", getConstant(constVariable) + "");
}
for (String localVariable : localVariables.allVariables()) {
s = s.replace("<local." + localVariable + ">", getLocal(localVariable) + "");
}
for (String globalVariable : globalVariables.allVariables()) {
s = s.replace("<global." + globalVariable + ">", getGlobal(globalVariable) + "");
for (int i = 0; i < 2; i++) {
for (String variable : variables) {
s = s.replace("<" + variable + ">", getValue(variable) + "");
}
for (String constVariable : Constants.allVariables()) {
s = s.replace("<const." + constVariable + ">", getConstant(constVariable) + "");
}
for (String localVariable : localVariables.allVariables()) {
s = s.replace("<local." + localVariable + ">", getLocal(localVariable) + "");
}
for (String globalVariable : globalVariables.allVariables()) {
s = s.replace("<global." + globalVariable + ">", getGlobal(globalVariable) + "");
}
}
return s.split(" ");
}

Datei anzeigen

@ -0,0 +1,141 @@
/*
* 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.*;
@Linked(LinkageType.COMMAND)
public class ScriptVarsCommand extends SWCommand {
public ScriptVarsCommand() {
super("scriptvars");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable");
}
@Register
public void genericCommand(Player p) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
int i = 0;
p.sendMessage(BauSystem.PREFIX + context.allVariables().size() + " Variable(n)");
for (Map.Entry<String, Value> var : context.entrySet()) {
if (i++ >= 40) break;
p.sendMessage("- " + var.getKey() + "=" + var.getValue().asString());
}
}
@Register
public void getCommand(Player p, String varName) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
if (!context.hasValue(varName)) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable");
return;
}
p.sendMessage(BauSystem.PREFIX + varName + "=" + context.getValue(varName).asString());
}
@Register
public void setValueCommand(Player p, String varName, long value) {
Context context = ScriptListener.getGlobalContext(p);
context.putValue(varName, new Value.LongValue(value));
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
}
@Register
public void setValueCommand(Player p, String varName, boolean value) {
Context context = ScriptListener.getGlobalContext(p);
context.putValue(varName, new Value.BooleanValue(value));
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
}
@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));
p.sendMessage(BauSystem.PREFIX + varName + " auf " + s + " gesetzt");
}
@Register
public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) {
Context context = ScriptListener.getGlobalContext(p);
if (context.allVariables().isEmpty()) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
context.removeValue(varName);
p.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht");
}
@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

@ -1,4 +1,53 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
public class Add {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Add implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eadd §8<§7Variable§8> §8<§7Variable§8>",
"§eadd §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Addition zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "add";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können addiert werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können addiert werden");
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() + v2.asLong()));
return true;
}
}

Datei anzeigen

@ -1,4 +1,53 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
public class Div {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Div implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§ediv §8<§7Variable§8> §8<§7Variable§8>",
"§ediv §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Division zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "div";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können dividiert werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können dividiert werden");
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() / v2.asLong()));
return true;
}
}

Datei anzeigen

@ -1,4 +1,53 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
public class Mul {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Mul implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§emul §8<§7Variable§8> §8<§7Variable§8>",
"§emul §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Multiplikation zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "mul";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können multipliziert werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können multipliziert werden");
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() * v2.asLong()));
return true;
}
}

Datei anzeigen

@ -1,4 +1,53 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
public class Sub {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Sub implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§esub §8<§7Variable§8> §8<§7Variable§8>",
"§esub §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Subtraktion zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "sub";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können subtrahiert werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können subtrahiert werden");
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() - v2.asLong()));
return true;
}
}

Datei anzeigen

@ -4,9 +4,12 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.inventory.SWAnvilInv;
import org.bukkit.ChatColor;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Input implements SpecialCommand {
@Override
@ -26,7 +29,7 @@ public class Input implements SpecialCommand {
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name sein");
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
StringBuilder st = new StringBuilder();

Datei anzeigen

@ -1,4 +1,59 @@
package de.steamwar.bausystem.features.script.command.logic;
public class And {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class And implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eand §8<§7Variable§8> §8<§7Variable§8>",
"§eand §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Das logische Und zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "and";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.BooleanValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Booleans können verglichen werden");
return true;
}
if (v2.getClass() != Value.BooleanValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Booleans können verglichen werden");
return true;
}
Value result;
if (v1.asBoolean() && v2.asBoolean()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,4 +1,53 @@
package de.steamwar.bausystem.features.script.command.logic;
public class Equal {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Equal implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eequal §8<§7Variable§8> §8<§7Variable§8>",
"§eequal §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Vergleiche die letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "equal";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
Value result;
if (v1.getClass() != v2.getClass()) {
result = new Value.BooleanValue(false);
} else if (v1.asString().equals(v2.asString())) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,4 +1,59 @@
package de.steamwar.bausystem.features.script.command.logic;
public class Greater {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Greater implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§egreater §8<§7Variable§8> §8<§7Variable§8>",
"§egreater §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Vergleiche die letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "greater";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
return true;
}
Value result;
if (v1.asLong() > v2.asLong()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,4 +1,59 @@
package de.steamwar.bausystem.features.script.command.logic;
public class Less {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Less implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eless §8<§7Variable§8> §8<§7Variable§8>",
"§eless §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Vergleiche die letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "less";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
return true;
}
if (v2.getClass() != Value.LongValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Zahlen können verglichen werden");
return true;
}
Value result;
if (v1.asLong() < v2.asLong()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,4 +1,43 @@
package de.steamwar.bausystem.features.script.command.logic;
public class Not {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Not implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§enot §8<§7Variable§8>",
"§enot §8<§7Variable§8> §8<§7Variable§8>",
"",
"Das logische Nicht von der letzten Variable und schreibe es in die erste."
};
}
@Override
public String command() {
return "not";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.BooleanValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Booleans können genichtet werden");
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.BooleanValue(!v1.asBoolean()));
return true;
}
}

Datei anzeigen

@ -1,4 +1,59 @@
package de.steamwar.bausystem.features.script.command.logic;
public class Or {
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
@Linked(LinkageType.SCRIPT_COMMAND)
public class Or implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eor §8<§7Variable§8> §8<§7Variable§8>",
"§eor §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>",
"",
"Das logische Oder zwischen den letzten beiden Variablen und schreibe es in die erste."
};
}
@Override
public String command() {
return "or";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas zweite Argument fehlt und sollte eine Variable sein");
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (v1.getClass() != Value.BooleanValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Booleans können verglichen werden");
return true;
}
if (v2.getClass() != Value.BooleanValue.class) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cNur Booleans können verglichen werden");
return true;
}
Value result;
if (v1.asBoolean() || v2.asBoolean()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -13,7 +13,7 @@ public class Global implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eglobal §8<§7Name§8> §8[§7Value§8(§7s§8)§8]",
"§eglobal §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]",
"",
"Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text."
};
@ -27,7 +27,7 @@ public class Global implements SpecialCommand {
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name sein");
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {

Datei anzeigen

@ -12,7 +12,7 @@ public class Unglobal implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eunglobal §8<§7Name§8>",
"§eunglobal §8<§7Variable§8>",
"",
"§7Lösche eine Globale variable."
};
@ -26,7 +26,7 @@ public class Unglobal implements SpecialCommand {
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name sein");
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
scriptExecutor.getGlobalVariables().removeValue(command[1]);

Datei anzeigen

@ -12,7 +12,7 @@ public class Unvar implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§eunvar §8<§7Name§8>",
"§eunvar §8<§7Variable§8>",
"",
"§7Lösche eine Locale variable."
};
@ -26,7 +26,7 @@ public class Unvar implements SpecialCommand {
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name sein");
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
scriptExecutor.getLocalVariables().removeValue(command[1]);

Datei anzeigen

@ -13,7 +13,7 @@ public class Var implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"§evar §8<§7Name§8> §8[§7Value§8(§7s§8)§8]",
"§evar §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]",
"",
"Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text."
};
@ -27,7 +27,7 @@ public class Var implements SpecialCommand {
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte ein Name sein");
scriptExecutor.getPlayer().sendMessage(BauSystem.PREFIX + "§cDas erste Argument fehlt und sollte eine Variable sein");
return true;
}
if (command.length <= 2) {

Datei anzeigen

@ -27,4 +27,8 @@ public class Context {
public Set<String> allVariables() {
return variables.keySet();
}
public Set<Map.Entry<String, Value>> entrySet() {
return variables.entrySet();
}
}

Datei anzeigen

@ -33,6 +33,7 @@ import java.util.Set;
public class Depth {
private int tntCount = 1;
private Vector minVector = null;
private Vector maxVector = null;
@ -62,7 +63,7 @@ public class Depth {
dimensions.setZ(Math.abs(dimensions.getZ()));
if (dimensions.getX() != 0 && dimensions.getY() != 0 && dimensions.getZ() != 0) {
RegionUtils.message(region, player -> DepthCounter.getMessage(player, dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()));
RegionUtils.message(region, player -> DepthCounter.getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
}
Set<Depth> depthSet = DepthCounter.depthMap.get(region);
@ -74,11 +75,11 @@ public class Depth {
DepthCounter.depthMap.remove(region);
}
}
}, 2, 2);
}, 1, 1);
}
public boolean update(List<Block> blocks) {
boolean expand = blocks.stream().anyMatch(block -> {
long overlappingBlocks = blocks.stream().filter(block -> {
Vector vector = DepthCounter.blockVector(block.getLocation().toVector());
return vector.getX() >= minVector.getX()
&& vector.getY() >= minVector.getY()
@ -86,12 +87,13 @@ public class Depth {
&& vector.getX() <= maxVector.getX()
&& vector.getY() <= maxVector.getY()
&& vector.getZ() <= maxVector.getZ();
});
if (!expand) {
}).count();
if (overlappingBlocks < 4) {
return false;
}
lastUpdate = TPSUtils.currentTick.get();
blocks.forEach(this::internalUpdate);
tntCount++;
return true;
}

Datei anzeigen

@ -97,7 +97,7 @@ public class DepthCounter {
return values.stream().max(Integer::compare).orElse(0);
}
public String getMessage(Player player, int x, int y, int z) {
public String getMessage(Player player, int x, int y, int z, int tntCount) {
final boolean xActive = DepthCounter.isActive(player, CountMode.X);
final boolean yActive = DepthCounter.isActive(player, CountMode.Y);
final boolean zActive = DepthCounter.isActive(player, CountMode.Z);
@ -106,7 +106,7 @@ public class DepthCounter {
return null;
}
final StringBuilder result = new StringBuilder(BauSystem.PREFIX).append("Schadensdimensionen ").append(ColorConfig.OTHER).append("> ").append(ColorConfig.BASE);
final StringBuilder result = new StringBuilder(BauSystem.PREFIX).append("Schaden ").append(ColorConfig.OTHER).append("> ").append(ColorConfig.BASE);
final Set<Integer> dimensions = new HashSet<>();
if (xActive) {
@ -145,6 +145,7 @@ public class DepthCounter {
}
}
result.append(ColorConfig.BASE).append("TNT").append(ColorConfig.OTHER).append(": ").append(ColorConfig.HIGHLIGHT).append(tntCount);
return result.toString();
}
}

Datei anzeigen

@ -44,9 +44,9 @@ public class RamUsage implements Listener {
long presumableFreeMemory = Runtime.getRuntime().maxMemory() - allocatedMemory;
double percentageFree = presumableFreeMemory / (double) Runtime.getRuntime().maxMemory();
bossBar.setProgress(1 - percentageFree);
if (mode && percentageFree > 0.7) {
if (mode && percentageFree > 0.6) {
mode = false;
} else if (!mode && percentageFree < 0.5) {
} else if (!mode && percentageFree < 0.4) {
mode = true;
}
if (mode) {

Datei anzeigen

@ -140,7 +140,7 @@ public class Region {
this.maxPointTestblock = this.minPointTestblock.add(prototype.getTestblock().getSizeX() - 1, prototype.getTestblock().getSizeY() - 1, prototype.getTestblock().getSizeZ() - 1);
this.minPointTestblockExtension = this.minPointTestblock.substract(prototype.getTestblock().getExtensionNegativeX(), prototype.getTestblock().getExtensionNegativeY(), prototype.getTestblock().getExtensionNegativeZ());
this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX() - 1, prototype.getTestblock().getExtensionPositiveY() - 1, prototype.getTestblock().getExtensionPositiveZ() - 1);
this.maxPointTestblockExtension = this.maxPointTestblock.add(prototype.getTestblock().getExtensionPositiveX(), prototype.getTestblock().getExtensionPositiveY(), prototype.getTestblock().getExtensionPositiveZ());
}
if (prototype.getBuild() != null) {
@ -148,7 +148,7 @@ public class Region {
this.maxPointBuild = this.minPointBuild.add(prototype.getBuild().getSizeX() - 1, prototype.getBuild().getSizeY() - 1, prototype.getBuild().getSizeZ() - 1);
this.minPointBuildExtension = this.minPointBuild.substract(prototype.getBuild().getExtensionNegativeX(), prototype.getBuild().getExtensionNegativeY(), prototype.getBuild().getExtensionNegativeZ());
this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX() - 1, prototype.getBuild().getExtensionPositiveY() - 1, prototype.getBuild().getExtensionPositiveZ() - 1);
this.maxPointBuildExtension = this.maxPointBuild.add(prototype.getBuild().getExtensionPositiveX(), prototype.getBuild().getExtensionPositiveY(), prototype.getBuild().getExtensionPositiveZ());
}
if (prototype.getFloorOffset() != 0) {

Datei anzeigen

@ -27,13 +27,13 @@ import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.Getter;
@Getter
public enum Flag {
public enum Flag implements EnumDisplay {
COLOR(ColorMode.class, ColorMode.YELLOW),
TNT(TNTMode.class, TNTMode.ONLY_TB),
FIRE(FireMode.class, FireMode.ALLOW),
FREEZE(FreezeMode.class, FreezeMode.INACTIVE),
PROTECT(ProtectMode.class, ProtectMode.INACTIVE);
COLOR("Color", ColorMode.class, ColorMode.YELLOW),
TNT("TNT", TNTMode.class, TNTMode.ONLY_TB),
FIRE("Fire", FireMode.class, FireMode.ALLOW),
FREEZE("Freeze", FreezeMode.class, FreezeMode.INACTIVE),
PROTECT("Protect", ProtectMode.class, ProtectMode.INACTIVE);
@Getter
private static final Set<Flag> flags;
@ -42,11 +42,13 @@ public enum Flag {
flags = EnumSet.allOf(Flag.class);
}
private final String chatValue;
private final Class<? extends Value<?>> valueType;
private final Flag.Value<?> defaultValue;
private final Value<?>[] values;
<T extends Enum<T> & Value<T>> Flag(final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) {
<T extends Enum<T> & Value<T>> Flag(String chatValue, final Class<? extends Value<T>> valueType, final Flag.Value<T> defaultValue) {
this.chatValue = chatValue;
this.valueType = valueType;
this.defaultValue = defaultValue;
this.values = defaultValue.getValues();
@ -56,11 +58,18 @@ public enum Flag {
return this.defaultValue.getValueOf(name);
}
@Override
public String toString() {
return this.name().toLowerCase();
}
@Override
public String getChatValue() {
return chatValue;
}
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
T getValue();