SteamWar/BauSystem2.0
Archiviert
12
0

Fix ScriptExecutor for WorldEdit commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Add new expression system
Dieser Commit ist enthalten in:
yoyosource 2022-12-23 18:42:40 +01:00
Ursprung 28424698d6
Commit cef0111fdf
53 geänderte Dateien mit 1601 neuen und 993 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,40 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.linkage.types;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import javax.lang.model.element.TypeElement;
public class Operator_GENERIC implements LinkageType {
@Override
public String method() {
return "linkScriptCommands";
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) {
buildPlan.addImport("de.steamwar.bausystem.features.script.expression.Expression");
methodBuilder.addLine("Expression.registerOperator(" + s + ");");
}
}

Datei anzeigen

@ -217,45 +217,42 @@ GUI_EDITOR_TITLE_MORE=Select item
# Script # Script
## Errors ## Errors
SCRIPT_SLEEP_ERROR = §cInsert a sleep into your script SCRIPT_SLEEP_ERROR = §cInsert a sleep into your script
SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnknown variable {0}
SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression error with: {0}
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cThe first argument is missing and should be a variable SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cThe first argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cThe first argument is missing and should be a number SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cThe first argument is missing and should be a number
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cThe first argument is missing and should be a variable or a number SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cThe first argument is missing and should be a variable or a number
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cThe first argument is missing and should be a jump-point SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cThe first argument is missing and should be a jump-point
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cThe second argument is missing and should be a variable SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cThe second argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR_OR_VALUE = §cThe second argument is missing and should be a variable or a number
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cThe econd argument is missing and should be a value SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cThe econd argument is missing and should be a value
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cThe second argument is missing and should be a jump-point
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cThe third argument is missing and should be a variable SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cThe third argument is missing and should be a variable
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cThe third argument is missing and should be a value SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cThe third argument is missing and should be a value
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cThe third argument is missing and should be a variable or a number SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cThe third argument is missing and should be a variable or a number
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOJUMPPOINT = §cThe third argument is missing and should be a jump-point
SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cThe fourth argument is missing and should be a value SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cThe fourth argument is missing and should be a value
SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cOnly booleans can be compared SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cOnly booleans can be compared
SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cOnly numbers can be compared SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cOnly numbers can be compared
SCRIPT_COMMAND_ERROR_NO_BOOLEAN = §cThe value is not a boolean
SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cOnly strings are allowed SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cOnly strings are allowed
SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cOnly numbers are allowed SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cOnly numbers are allowed
SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnknown operation: {0}
## Commands ## Commands
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_1 = §eadd §8<§7variable§8> §8<§7variable§8|§7value§8> SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cOnly numbers or strings can be added
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_2 = §eadd §8<§7variable§8> §8<§7variable§8§8|§7value> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_3 = Addition between the two last variables and writes the result in the first one
SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cOnly numbers can be added
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_1 = §ediv §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_2 = §ediv §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_3 = Division between the two last variables and writes the result in the first one
SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cOnly numbers can be divided SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cOnly numbers can be divided
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_1 = §emul §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_2 = §emul §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_3 = Multiplication between the two last variables and writes the result in the first one
SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cOnly numbers can be multiplied SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cOnly numbers can be multiplied
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_1 = §esub §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_2 = §esub §8<§7variable§8> §8<§7variable§8§8|§7value§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_3 = Subtraction between the two last variables and writes the result in the first one
SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cOnly numbers can be subtracted SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cOnly numbers can be subtracted
SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cOnly numbers can be raised to a power
SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cOnly whole numbers can be used for modulo
SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cOnly whole numbers and booleans can be used for and
SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cOnly whole numbers and booleans can be used for or
SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cOnly whole numbers and booleans can be used for xor
SCRIPT_COMMAND_ARITHMETIC_BIT_LEFT_ERROR = §cOnly whole numbers can be used for left shift value
SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_ERROR = §cOnly whole numbers can be used for right shift value
SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_LOGIC_ERROR = §cOnly whole numbers can be used for logic right shift value
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8> SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7variable§8> §8<§7variable§8|§7value§8> §8<§7variable§8|§7value§8>
@ -285,38 +282,10 @@ SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Send a message to the player to the
SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7variable§8> §8<§7text§8> SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7variable§8> §8<§7text§8>
SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Request an input from the player, which will be written in the variable. The text is optional SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Request an input from the player, which will be written in the variable. The text is optional
SCRIPT_COMMAND_LOGIC_AND_HELP_1 = §eand §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_AND_HELP_2 = §eand §8<§7variable§8> §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_AND_HELP_3 = The logic and between the last two variables and writes it in the first
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_1 = §eequal §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_2 = §eequal §8<§7variable§8> §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_3 = Compares the last two variables and writes it in the first
SCRIPT_COMMAND_LOGIC_GREATER_HELP_1 = §egreater §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_GREATER_HELP_2 = §egreater §8<§7variable§8> §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_GREATER_HELP_3 = Compares the last two variables and writes it in the first
SCRIPT_COMMAND_LOGIC_LESS_HELP_1 = §eless §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_LESS_HELP_2 = §eless §8<§7variable§8> §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_LESS_HELP_3 = Compares the last two variables and writes it in the first
SCRIPT_COMMAND_LOGIC_NOT_HELP_1 = §enot §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_NOT_HELP_2 = §enot §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_NOT_HELP_3 = The logic not of the last variable and writes it in the first
SCRIPT_COMMAND_LOGIC_OR_HELP_1 = §eor §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_OR_HELP_2 = §eor §8<§7variable§8> §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_LOGIC_OR_HELP_3 = The logic or between the last two variables and writes it in the first
SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7number§8> SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7variable§8> §8<§7number§8> SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7variable§8> §8<§7variable§8> §8<§7variable§8> §8<§7number§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Insert something into a String at a given index. The number is the index and the variable is the string. Optionally the result can be written in another or a new variable SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Insert something into a String at a given index. The number is the index and the variable is the string. Optionally the result can be written in another or a new variable
SCRIPT_COMMAND_STRING_LENGTH_HELP_1 = §elength §8<§7variable§8>
SCRIPT_COMMAND_STRING_LENGTH_HELP_2 = §elength §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_STRING_LENGTH_HELP_3 = Returns the text length.
SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7variable§8> §8<§7from variable§8> SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7variable§8> §8<§7from variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8> SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7variable§8> §8<§7variable§8> §8<§7from variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Removes all occurrences of a string from another string. SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Removes all occurrences of a string from another string.
@ -338,9 +307,6 @@ SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Converts a value to 'number' if it's a
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7variable§8> §8[§7value§8(§7s§8)§8] SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7variable§8> §8[§7value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string
SCRIPT_COMMAND_VARIABLE_ISSET_HELP_1 = §eisset §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_VARIABLE_ISSET_HELP_2 = Writes true/false in a variable, depending on whether the second variable exists
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7variable§8> SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7variable§8>
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Deletes a global variable. SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Deletes a global variable.
@ -350,9 +316,6 @@ SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Deletes a local variable.
SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7variable§8> §8[§7value§8(§7s§8)§8] SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7variable§8> §8[§7value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Writes a value in a variable, which can be a number, a boolean or a string
SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_1 = §evartype §8<§7variable§8> §8<§7variable§8>
SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_2 = Writes the type of the second variable in the first. If the second variable does not exist, the first variable will have the value 'false'. Otherwise it will have any of the following types: 'number', 'boolean', 'text'
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8> SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7variable§8> §8<§7number§8> §8<§7number§8> §8<§7number§8>
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Writes the material of a block in the world in the variable SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Writes the material of a block in the world in the variable
@ -362,8 +325,8 @@ SCRIPT_COMMAND_WORLD_SETMATERIAL_HELP_2 = Sets a block in the world with the giv
SCRIPT_COMMAND_EXIT_HELP_1 = §eexit SCRIPT_COMMAND_EXIT_HELP_1 = §eexit
SCRIPT_COMMAND_EXIT_HELP_2 = Exits the script SCRIPT_COMMAND_EXIT_HELP_2 = Exits the script
SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7variable§8/§7value§8> §8<§7variable§8/§7value§8> §8<§7jump-point§8> SCRIPT_COMMAND_IF_HELP_1 = §eif §8<§7true/false§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7variable§8/§7value§8> §8<§7variable§8/§7value§8> §8<§7jump-point§8> §8<§7jump-point§8> SCRIPT_COMMAND_IF_HELP_2 = §eif §8<§7true/false§8> §8<§7jump-point§8> §8<§7jump-point§8>
SCRIPT_COMMAND_IF_HELP_3 = §7Jump to a jump-point if the given values are equal or another jump-point otherwise. SCRIPT_COMMAND_IF_HELP_3 = §7Jump to a jump-point if the given values are equal or another jump-point otherwise.
SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7jump-point§8> SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7jump-point§8>
@ -429,14 +392,28 @@ SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Everything in brackets is only set if the variable before is set on §etrue§7. SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Everything in brackets is only set if the variable before is set on §etrue§7.
SCRIPT_GUI_OTHER = §eOther SCRIPT_GUI_OTHER = §eOther
SCRIPT_GUI_OTHER_LORE_1 = §7comments start with §e#§7. SCRIPT_GUI_OTHER_LORE_1 = §7Comments start with §e#§7.
SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points start with §e.§7. SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points start with §e.§7.
SCRIPT_GUI_OTHER_LORE_3 = §7A variable name encased in '<>' is replaced, up to two times. SCRIPT_GUI_OTHER_LORE_3 = §7A variable name enclosed in '§e{}§7' is replaced by its value. A variable can be prefixed with '§econst.§7' or '§elocal.§7' or '§eglobal.§7'.
SCRIPT_GUI_OTHER_LORE_4 = §7A variable in '<>' can be prefixed with 'const.', 'local.' or 'global.' for the exact type where it should be searched for. SCRIPT_GUI_OTHER_LORE_4 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_5 = §7If it is suffixed by '.type', the type of the variable will be returned. SCRIPT_GUI_OTHER_LORE_5 = §7- Local variables are only available in the script book.
SCRIPT_GUI_OTHER_LORE_6 = §7- Global variables are available in every script book.
SCRIPT_GUI_OTHER_LORE_7 = §7- Constant variables are variables from the server (e.g. player name, TPS, etc.)
SCRIPT_GUI_OTHER_LORE_8 = §7A variable can be appended with '§e.length§7' or '§e.type§7' or '§e.isset§7'.
SCRIPT_GUI_OTHER_LORE_9 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_10 = §7- Length returns the length of the variable as a number.
SCRIPT_GUI_OTHER_LORE_11 = §7- Type returns the type (number, floating_number, text or boolean) as text.
SCRIPT_GUI_OTHER_LORE_12 = §7- Isset returns as a boolean whether the variable exists.
SCRIPT_GUI_OTHER_LORE_13 = §7Mathematical as well as logical operations can be specified in '§e{}§7'.
SCRIPT_GUI_OTHER_LORE_14 = §7The following applies:
SCRIPT_GUI_OTHER_LORE_15 = §7- arithmetic operators: §e+ * - /§7 as well as §e%§7 for modulo
SCRIPT_GUI_OTHER_LORE_16 = §7- Logical operators: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (this is the character for or)
SCRIPT_GUI_OTHER_LORE_17 = §7- Bitwise operators: §e&§7; §e|§7; §e^
SCRIPT_GUI_OTHER_LORE_18 = §7- Shift operators: §e<<§7; §e>>§7; §e>>>§7
SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0} SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0}
@ -453,7 +430,7 @@ SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 if the auto trace is activated.
SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt
SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 if tnt is not deactivated. SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 if tnt is not deactivated.
SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt-onlytb SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb
SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 if tnt no build is activated. SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 if tnt no build is activated.
SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze
@ -498,9 +475,15 @@ SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the c
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the off hand SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 of the item in the off hand
SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion-type SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type
SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eregion type§7 of the current region SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eregion type§7 of the current region
SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps
SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 of the server
SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit
SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 of the server
# Unsign Book # Unsign Book
UNSIGN_HELP=§8/§eunsign §8- §7Make a signed book writable again UNSIGN_HELP=§8/§eunsign §8- §7Make a signed book writable again

Datei anzeigen

@ -215,17 +215,18 @@ GUI_EDITOR_TITLE_MORE=Item auswählen
# Script # Script
## Errors ## Errors
SCRIPT_SLEEP_ERROR = §cFüge ein sleep in dein Script ein SCRIPT_SLEEP_ERROR = §cFüge ein sleep in dein Script ein
SCRIPT_COMMAND_ERROR_UNKNOWN_VAR = §cUnbekannte Variable {0}
SCRIPT_COMMAND_ERROR_EXPRESSION = §cExpression fehler in: {0}
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cDas erste Argument fehlt und sollte eine Variable sein SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR = §cDas erste Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cDas erste Argument fehlt und sollte eine Zahl sein SCRIPT_COMMAND_ERROR_FIRST_ARG_NONUMER = §cDas erste Argument fehlt und sollte eine Zahl sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cDas erste Argument fehlt und sollte eine Variable oder ein Wert sein SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE = §cDas erste Argument fehlt und sollte eine Variable oder ein Wert sein
SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cDas erste Argument fehlt und sollte ein Jump-Point sein SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT = §cDas erste Argument fehlt und sollte ein Jump-Point sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cDas zweite Argument fehlt und sollte eine Variable sein SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR = §cDas zweite Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR_OR_VALUE = §cDas zweite Argument fehlt und sollte eine Variable oder ein Wert sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cDas zweite Argument fehlt und sollte ein Wert sein SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVALUE = §cDas zweite Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT = §cDas dritte Argument fehlt und sollte ein Jump-Point sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cDas dritte Argument fehlt und sollte eine Variable sein SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR = §cDas dritte Argument fehlt und sollte eine Variable sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cDas dritte Argument fehlt und sollte ein Wert sein SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVALUE = §cDas dritte Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cDas dritte Argument fehlt und sollte eine Variable/Zahl sein SCRIPT_COMMAND_ERROR_THIRD_ARG_NOVAR_OR_NUMBER = §cDas dritte Argument fehlt und sollte eine Variable/Zahl sein
SCRIPT_COMMAND_ERROR_THIRD_ARG_NOJUMPPOINT = §cDas dritte Argument fehlt und sollte ein Jump-Point sein
SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cDas vierte Argument fehlt und sollte ein Wert sein SCRIPT_COMMAND_ERROR_FOURTH_ARG_NOVALUE = §cDas vierte Argument fehlt und sollte ein Wert sein
SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cNur Booleans können verglichen werden SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE = §cNur Booleans können verglichen werden
@ -234,26 +235,18 @@ SCRIPT_COMMAND_ERROR_NUMBER_COMPARE = §cNur Zahlen können verglichen werden
SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cNur Strings können verwendet werden SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED = §cNur Strings können verwendet werden
SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cNur Zahlen können verwendet werden SCRIPT_COMMAND_ERROR_ONLY_NUMBERS_ALLOWED = §cNur Zahlen können verwendet werden
SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION = §cUnbekannte Operation: {0}
## Commands ## Commands
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_1 = §eadd §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_2 = §eadd §8<§7Variable§8> §8<§7Variable§8§8|§7Wert> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_3 = Addition zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cNur Zahlen können addiert werden SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR = §cNur Zahlen können addiert werden
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_1 = §ediv §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_2 = §ediv §8<§7Variable§8> §8<§7Variable§8§8|§7Wert> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_3 = Division zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cNur Zahlen können dividiert werden SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR = §cNur Zahlen können dividiert werden
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_1 = §emul §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_2 = §emul §8<§7Variable§8> §8<§7Variable§8§8|§7Wert§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_3 = Multiplikation zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cNur Zahlen können multipliziert werden SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR = §cNur Zahlen können multipliziert werden
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_1 = §esub §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_2 = §esub §8<§7Variable§8> §8<§7Variable§8§8|§7Wert> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_3 = Subtraktion zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cNur Zahlen können subtrahiert werden SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR = §cNur Zahlen können subtrahiert werden
SCRIPT_COMMAND_ARITHMETIC_POW_ERROR = §cNur Zahlen können potenziert werden
SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR = §cNur ganze Zahlen können für modulo verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR = §cNur ganze Zahlen und booleans können für und verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR = §cNur ganze Zahlen und booleans können für oder verwendet werden
SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR = §cNur ganze Zahlen und booleans können für xor verwendet werden
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_1 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8>
SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8> SCRIPT_COMMAND_ARITHMETIC_OTHER_CEIL_HELP_2 = §eceil §8<§7Variable§8> §8<§7Variable§8|§7Wert§8> §8<§7Variable§8|§7Wert§8>
@ -283,38 +276,10 @@ SCRIPT_COMMAND_IO_ECHOACTIONBAR_HELP_2 = §7Schreibe etwas dem Spieler in der Ac
SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7Variable§8> §8<§7Text§8> SCRIPT_COMMAND_IO_INPUT_HELP_1 = §einput §8<§7Variable§8> §8<§7Text§8>
SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Fordere eine Eingabe von dem Spieler, welche in die Variable geschrieben wird. Der Text ist optional. SCRIPT_COMMAND_IO_INPUT_HELP_2 = §7Fordere eine Eingabe von dem Spieler, welche in die Variable geschrieben wird. Der Text ist optional.
SCRIPT_COMMAND_LOGIC_AND_HELP_1 = §eand §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_AND_HELP_2 = §eand §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_AND_HELP_3 = Das logische Und zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_1 = §eequal §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_2 = §eequal §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_EQUAL_HELP_3 = Vergleiche die letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_LOGIC_GREATER_HELP_1 = §egreater §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_GREATER_HELP_2 = §egreater §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_GREATER_HELP_3 = Vergleiche die letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_LOGIC_LESS_HELP_1 = §eless §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_LESS_HELP_2 = §eless §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_LESS_HELP_3 = Vergleiche die letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_LOGIC_NOT_HELP_1 = §enot §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_NOT_HELP_2 = §enot §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_NOT_HELP_3 = Das logische Nicht von der letzten Variable und schreibt es in die erste.
SCRIPT_COMMAND_LOGIC_OR_HELP_1 = §eor §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_OR_HELP_2 = §eor §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_LOGIC_OR_HELP_3 = Das logische Oder zwischen den letzten beiden Variablen und schreibt es in die erste.
SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8> SCRIPT_COMMAND_STRING_INSERT_HELP_1 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8> SCRIPT_COMMAND_STRING_INSERT_HELP_2 = §einsert §8<§7Variable§8> §8<§7Variable§8> §8<§7Variable§8> §8<§7Zahl§8>
SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Füge etwas in einen String an einer Stelle ein. Die Zahl ist für die Position und die Variable davor für was. Schreibe optional dies in eine neue oder andere Variable. SCRIPT_COMMAND_STRING_INSERT_HELP_3 = Füge etwas in einen String an einer Stelle ein. Die Zahl ist für die Position und die Variable davor für was. Schreibe optional dies in eine neue oder andere Variable.
SCRIPT_COMMAND_STRING_LENGTH_HELP_1 = §elength §8<§7Variable§8>
SCRIPT_COMMAND_STRING_LENGTH_HELP_2 = §elength §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_STRING_LENGTH_HELP_3 = Ermittle die Länge eines Textes.
SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7Variable§8> §8<§7Von Variable§8> SCRIPT_COMMAND_STRING_REMOVE_HELP_1 = §eremove §8<§7Variable§8> §8<§7Von Variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8> SCRIPT_COMMAND_STRING_REMOVE_HELP_2 = §eremove §8<§7Variable§8> §8<§7Variable§8> §8<§7Von Variable§8>
SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Lösche eine Zeichenkette aus dem Ursprung. Dies ersetzt nicht nur die erste Stelle sondern alle. SCRIPT_COMMAND_STRING_REMOVE_HELP_3 = Lösche eine Zeichenkette aus dem Ursprung. Dies ersetzt nicht nur die erste Stelle sondern alle.
@ -336,9 +301,6 @@ SCRIPT_COMMAND_VARIABLE_CONVERT_HELP_2 = Konvertiere den Value zu 'number' wenn
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7Variable§8> §8[§7Value§8(§7s§8)§8] SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_1 = §eglobal §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text. SCRIPT_COMMAND_VARIABLE_GLOBAL_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text.
SCRIPT_COMMAND_VARIABLE_ISSET_HELP_1 = §eisset §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_VARIABLE_ISSET_HELP_2 = Schreibt in eine Variable true/false rein, ob in die zweiten Variable existiert.
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7Variable§8> SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_1 = §eunglobal §8<§7Variable§8>
SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Lösche eine Globale variable. SCRIPT_COMMAND_VARIABLE_UNGLOBAL_HELP_2 = Lösche eine Globale variable.
@ -348,9 +310,6 @@ SCRIPT_COMMAND_VARIABLE_UNVAR_HELP_2 = Lösche eine Locale variable.
SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7Variable§8> §8[§7Value§8(§7s§8)§8] SCRIPT_COMMAND_VARIABLE_VAR_HELP_1 = §evar §8<§7Variable§8> §8[§7Value§8(§7s§8)§8]
SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text. SCRIPT_COMMAND_VARIABLE_VAR_HELP_2 = Schreibt in eine Variable einen Wert rein, welcher eine Zahl sein kann, ein Boolscher Wert oder ein Text.
SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_1 = §evartype §8<§7Variable§8> §8<§7Variable§8>
SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_2 = Schreibt in eine Variable den Type der zweiten Variable rein. Wenn die zweite Variable nicht gesetzt ist wird false in die erste geschrieben. Ansonsten gibt es die Werte: 'text', 'number' und 'boolean'
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8> SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_1 = §egetmaterial §8<§7Variable§8> §8<§7Zahl§8> §8<§7Zahl§8> §8<§7Zahl§8>
SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Schreibt das material von einem Block in der Welt in die Variable. SCRIPT_COMMAND_WORLD_GETMATERIAL_HELP_2 = Schreibt das material von einem Block in der Welt in die Variable.
@ -427,14 +386,28 @@ SCRIPT_GUI_CUSTOM_EVENTS_LORE_13 = §eTNTExplodeInBuild §8-§7 x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName SCRIPT_GUI_CUSTOM_EVENTS_LORE_14 = §eSelfJoin §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName SCRIPT_GUI_CUSTOM_EVENTS_LORE_15 = §eSelfLeave §8-§7 x, y, z, playerName
SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z SCRIPT_GUI_CUSTOM_EVENTS_LORE_16 = §eDropItem §8-§7 material, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_17 = §eEntityDeath §8-§7 entityType, x, y, z
SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt, wenn die Variable davor auf §etrue§7 gesetzt ist. SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1 = §e* §8-§7 Alles in den Klammern ist nur gesetzt, wenn die Variable davor auf §etrue§7 gesetzt ist.
SCRIPT_GUI_OTHER = §eOther SCRIPT_GUI_OTHER = §eOther
SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an. SCRIPT_GUI_OTHER_LORE_1 = §7Kommentare fangen mit §e#§7 an.
SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points fangen mit §e.§7 an. SCRIPT_GUI_OTHER_LORE_2 = §7Jump_Points fangen mit §e.§7 an.
SCRIPT_GUI_OTHER_LORE_3 = §7Eine Variablen Namen in '<>' eingeschlossen wird ersetzt, bis zu zwei mal. SCRIPT_GUI_OTHER_LORE_3 = §7Einen Variablennamen, der in '§e{}§7' eingeschlossen ist wird durch seinen Wert ersetzt. Eine Variable kann mit den Präfixen '§econst.§7' oder '§elocal.§7' oder '§eglobal.§7' versehen werden.
SCRIPT_GUI_OTHER_LORE_4 = §7Eine Variable in '<>' kann mit 'const.' oder 'local.' oder 'global.' prefixed werden für den genauen type wo nach geguckt werden soll. SCRIPT_GUI_OTHER_LORE_4 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_5 = §7Wenn man nach dem namen noch ein '.type' schreibt wird direkt der Type der Variable ausgegeben. SCRIPT_GUI_OTHER_LORE_5 = §7- Lokalevariablen sind nur in dem Script-Buch verfügbar.
SCRIPT_GUI_OTHER_LORE_6 = §7- Gloablevariablen sind in jedem Script-Buch verfügbar.
SCRIPT_GUI_OTHER_LORE_7 = §7- Konstantevariablen sind Variablen vom Server (z.B. Spielername, TPS usw.)
SCRIPT_GUI_OTHER_LORE_8 = §7Eine Variable kann mit den Appendixen '§e.length§7' oder '§e.type§7' oder '§e.isset§7' versehen werden.
SCRIPT_GUI_OTHER_LORE_9 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_10 = §7- Length gibt die Länge der variable als Zahl zurück.
SCRIPT_GUI_OTHER_LORE_11 = §7- Type gibt den typen (number, floating number, text oder boolean) als Text zurück.
SCRIPT_GUI_OTHER_LORE_12 = §7- Isset gibt als boolean zurück, ob die Variable existiert.
SCRIPT_GUI_OTHER_LORE_13 = §7Mathematische sowie logische Operationsvorgänge können in '§e{}§7' angegeben werden.
SCRIPT_GUI_OTHER_LORE_14 = §7Dabei gilt:
SCRIPT_GUI_OTHER_LORE_15 = §7- Rechenoperatoren: §e+ * - /§7 sowie §e%§7 für Modulo
SCRIPT_GUI_OTHER_LORE_16 = §7- Logische Operatoren: §e==§7; §e!=§7; §e<=§7; §e>=§7; §e<§7; §e>§7; §e&&§7; §e||§7 (Dies ist das Zeichen für oder)
SCRIPT_GUI_OTHER_LORE_17 = §7- Bitweise Operatoren: §e&§7; §e|§7; §e^
SCRIPT_GUI_OTHER_LORE_18 = §7- Shift Operatoren: §e<<§7; §e>>§7; §e>>>§7
SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0} SCRIPT_GUI_COMMAND_NAME = §7Command: §e{0}
@ -451,7 +424,7 @@ SCRIPT_GUI_CONSTANT_AUTO_TRACE_LORE = §etrue§7 wenn gerade der AutoTracer an i
SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt SCRIPT_GUI_CONSTANT_TNT_NAME = §7Constant §etnt
SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 wenn TNT nicht ausgeschaltet ist. SCRIPT_GUI_CONSTANT_TNT_LORE = §etrue§7 wenn TNT nicht ausgeschaltet ist.
SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt-onlytb SCRIPT_GUI_CONSTANT_ONLY_TB_NAME = §7Constant §etnt_onlytb
SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 wenn TNT Nur Testblock an ist. SCRIPT_GUI_CONSTANT_ONLY_TB_LORE = §etrue§7 wenn TNT Nur Testblock an ist.
SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze SCRIPT_GUI_CONSTANT_FREEZE_NAME = §7Constant §efreeze
@ -496,9 +469,15 @@ SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE = §eName§7 des Items im Slot
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME = §7Constant §eoffmaterialname
SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 des Items in der Off Hand SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE = §eName§7 des Items in der Off Hand
SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion-type SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME = §7Constant §eregion_type
SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eRegionstype§7 der jetztigen Region SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE = §eRegionstype§7 der jetztigen Region
SCRIPT_GUI_CONSTANT_TPS_NAME = §7Constant §etps
SCRIPT_GUI_CONSTANT_TPS_LORE = §etps§7 vom Server
SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME = §7Constant §etps_limit
SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE = §etps_limit§7 vom Server
# Unsign Book # Unsign Book
UNSIGN_HELP=§8/§eunsign §8- §7Mache ein Buch beschreibbar UNSIGN_HELP=§8/§eunsign §8- §7Mache ein Buch beschreibbar

Datei anzeigen

@ -20,7 +20,6 @@
package de.steamwar.bausystem.features.attributescopy.impl; package de.steamwar.bausystem.features.attributescopy.impl;
import de.steamwar.bausystem.features.attributescopy.BlockAttribute; import de.steamwar.bausystem.features.attributescopy.BlockAttribute;
import de.steamwar.bausystem.features.script.command.logic.Or;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Axis; import org.bukkit.Axis;
import org.bukkit.block.data.Orientable; import org.bukkit.block.data.Orientable;

Datei anzeigen

@ -25,6 +25,7 @@ import org.bukkit.Location;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
@ -98,7 +99,14 @@ public enum EventType {
valueMap.put("material", new Value.StringValue(event.getItemDrop().getItemStack().getType().name())); valueMap.put("material", new Value.StringValue(event.getItemDrop().getItemStack().getType().name()));
addXYZ(valueMap, event.getItemDrop().getLocation()); addXYZ(valueMap, event.getItemDrop().getLocation());
return valueMap; return valueMap;
}); }),
EntityDeath(EntityDeathEvent.class, event -> {
Map<String, Value> valueMap = new HashMap<>();
valueMap.put("entityType", new Value.StringValue(event.getEntityType().name()));
addXYZ(valueMap, event.getEntity().getLocation());
return valueMap;
}),
;
private static void addXYZ(Map<String, Value> valueMap, Location location) { private static void addXYZ(Map<String, Value> valueMap, Location location) {
valueMap.put("x", new Value.DoubleValue(location.getX())); valueMap.put("x", new Value.DoubleValue(location.getX()));

Datei anzeigen

@ -38,11 +38,11 @@ public class ScriptCommand extends SWCommand {
List<SWListInv.SWListEntry<SpecialCommand>> swItems = new ArrayList<>(); List<SWListInv.SWListEntry<SpecialCommand>> swItems = new ArrayList<>();
addEmptyItems(swItems, 3); addEmptyItems(swItems, 3);
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_COMMANDS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2")), null)); swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_COMMANDS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_1", "SCRIPT_GUI_CUSTOM_COMMANDS_LORE_2")), null));
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_EVENTS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_1", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_2", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_3", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_4", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_5", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_6", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_7", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_8", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_9", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_10", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_11", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_12", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_13", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_14", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_15", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_16", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1")), null)); swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_EVENTS", loreBuilder(p, "SCRIPT_GUI_CUSTOM_EVENTS_LORE_1", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_2", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_3", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_4", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_5", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_6", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_7", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_8", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_9", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_10", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_11", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_12", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_13", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_14", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_15", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_16", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_17", "SCRIPT_GUI_CUSTOM_EVENTS_LORE_STAR_1")), null));
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_OTHER", loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_1", "SCRIPT_GUI_OTHER_LORE_2", "SCRIPT_GUI_OTHER_LORE_3", "SCRIPT_GUI_OTHER_LORE_4", "SCRIPT_GUI_OTHER_LORE_5")), null)); swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_OTHER", loreBuilder(p, "SCRIPT_GUI_OTHER_LORE_1", "SCRIPT_GUI_OTHER_LORE_2", "SCRIPT_GUI_OTHER_LORE_3", "SCRIPT_GUI_OTHER_LORE_4", "SCRIPT_GUI_OTHER_LORE_5", "SCRIPT_GUI_OTHER_LORE_6", "SCRIPT_GUI_OTHER_LORE_7", "SCRIPT_GUI_OTHER_LORE_8", "SCRIPT_GUI_OTHER_LORE_9", "SCRIPT_GUI_OTHER_LORE_10", "SCRIPT_GUI_OTHER_LORE_11", "SCRIPT_GUI_OTHER_LORE_12", "SCRIPT_GUI_OTHER_LORE_13", "SCRIPT_GUI_OTHER_LORE_14", "SCRIPT_GUI_OTHER_LORE_15", "SCRIPT_GUI_OTHER_LORE_16", "SCRIPT_GUI_OTHER_LORE_17", "SCRIPT_GUI_OTHER_LORE_18")), null));
addEmptyItems(swItems, 3); addEmptyItems(swItems, 3);
addCustomScriptsItems(swItems, p); addCustomScriptsItems(swItems, p);
addEmptyItems(swItems, 44 + 4); addEmptyItems(swItems, 16);
swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_VARIABLES", new ArrayList<>()), null)); swItems.add(new SWListInv.SWListEntry<>(createItem(p, Material.BOOK, "SCRIPT_GUI_CUSTOM_VARIABLES", new ArrayList<>()), null));
addEmptyItems(swItems, 4); addEmptyItems(swItems, 4);
addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_NAME", "SCRIPT_GUI_CONSTANT_TRACE_LORE", false); addConstantItem(swItems, p, Material.TNT_MINECART, "SCRIPT_GUI_CONSTANT_TRACE_NAME", "SCRIPT_GUI_CONSTANT_TRACE_LORE", false);
@ -64,7 +64,9 @@ public class ScriptCommand extends SWCommand {
addConstantItem(swItems, p, Material.BIRCH_SIGN, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE", false); addConstantItem(swItems, p, Material.BIRCH_SIGN, "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_SLOT_MATERIAL_DISPLAY_LORE", false);
addConstantItem(swItems, p, Material.ACACIA_SIGN, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE", false); addConstantItem(swItems, p, Material.ACACIA_SIGN, "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_NAME", "SCRIPT_GUI_CONSTANT_OFF_HAND_MATERIAL_DISPLAY_LORE", false);
addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", "SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE", false); addConstantItem(swItems, p, Material.MAP, "SCRIPT_GUI_CONSTANT_REGION_TYPE_NAME", "SCRIPT_GUI_CONSTANT_REGION_TYPE_LORE", false);
addEmptyItems(swItems, 2 * 9 - 2); addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_NAME", "SCRIPT_GUI_CONSTANT_TPS_LORE", false);
addConstantItem(swItems, p, Material.COMPASS, "SCRIPT_GUI_CONSTANT_TPS_LIMIT_NAME", "SCRIPT_GUI_CONSTANT_TPS_LIMIT_LORE", false);
addEmptyItems(swItems, 2 * 9 - 3);
SWListInv<SpecialCommand> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> { SWListInv<SpecialCommand> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("SCRIPT_GUI_NAME", p), swItems, (clickType, o) -> {
if (o != null) { if (o != null) {

Datei anzeigen

@ -33,6 +33,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntitySpawnEvent; import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.*; import org.bukkit.event.player.*;
@ -133,4 +134,11 @@ public class ScriptEventListener implements Listener {
ignore.add(event.getPlayer()); ignore.add(event.getPlayer());
customScriptManager.callEvent(EventType.DropItem, event.getPlayer(), event); customScriptManager.callEvent(EventType.DropItem, event.getPlayer(), event);
} }
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
customScriptManager.callEvent(EventType.EntityDeath, player, event);
}
}
} }

Datei anzeigen

@ -1,10 +1,22 @@
package de.steamwar.bausystem.features.script; package de.steamwar.bausystem.features.script;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.event.platform.CommandEvent;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.session.SessionKey;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.expression.Expression;
import de.steamwar.bausystem.features.script.expression.UnknownOperatorException;
import de.steamwar.bausystem.features.script.expression.VarNotFoundException;
import de.steamwar.bausystem.features.script.variables.Constants; import de.steamwar.bausystem.features.script.variables.Constants;
import de.steamwar.bausystem.features.script.variables.Context; import de.steamwar.bausystem.features.script.variables.Context;
import de.steamwar.bausystem.features.script.variables.Value; import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.bausystem.features.world.WorldEditListener;
import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.LinkageUtils;
import de.steamwar.bausystem.utils.WorldEditUtils;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -23,6 +35,8 @@ public final class ScriptExecutor {
LinkageUtils.linkScriptCommands(); LinkageUtils.linkScriptCommands();
} }
private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null;
private String specialCommand = null; private String specialCommand = null;
@Getter @Getter
@ -123,7 +137,7 @@ public final class ScriptExecutor {
return; return;
} }
String[] strings = replaceVariables(command); String[] strings = replaceExpressions(command);
if (strings.length == 0) { if (strings.length == 0) {
return; return;
} }
@ -154,12 +168,22 @@ public final class ScriptExecutor {
command = String.join(" ", strings); command = String.join(" ", strings);
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command); Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
Bukkit.getServer().dispatchCommand(player, command); if (hasFAWE && WorldEditListener.isWorldEditCommand("/" + strings[0])) {
EditSession editSession = WorldEditUtils.getEditSession(player.getWorld());
WorldEditUtils.addToPlayer(player, editSession);
Actor actor = BukkitAdapter.adapt(player);
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));
editSession.close();
WorldEdit.getInstance().flushBlockBag(actor, editSession);
} else {
Bukkit.getServer().dispatchCommand(player, command);
}
} }
} }
private String[] replaceVariables(String s) { private String[] replaceExpressions(String s) {
s = s.replaceAll(" +", " "); s = s.replaceAll(" +", " ");
// TODO: Remove this code as the Expression System below will replace it!
Set<String> variables = new HashSet<>(localVariables.allVariables()); Set<String> variables = new HashSet<>(localVariables.allVariables());
variables.addAll(Constants.allVariables()); variables.addAll(Constants.allVariables());
variables.addAll(globalVariables.allVariables()); variables.addAll(globalVariables.allVariables());
@ -182,28 +206,49 @@ public final class ScriptExecutor {
s = s.replace("<global." + globalVariable + ".type>", globalVariables.getValue(globalVariable).type()); s = s.replace("<global." + globalVariable + ".type>", globalVariables.getValue(globalVariable).type());
} }
} }
return s.split(" ");
}
public Value parse(String varValue) { StringBuilder result = new StringBuilder();
try { int depth = 0;
return new Value.LongValue(Long.parseLong(varValue)); StringBuilder st = new StringBuilder();
} catch (NumberFormatException ne) { for (int i = 0; i < s.length(); i++) {
try { char c = s.charAt(i);
return new Value.DoubleValue(Double.parseDouble(varValue)); if (c == '{') {
} catch (NumberFormatException e) { st.append(c);
if (varValue.equalsIgnoreCase("true") || varValue.equalsIgnoreCase("false")) { depth++;
return new Value.BooleanValue(varValue.equalsIgnoreCase("true")); } else if (c == '}') {
} else { st.append(c);
return new Value.StringValue(varValue); depth--;
if (depth == 0) {
try {
Expression expression = new Expression(player, st.toString(), this);
result.append(expression.eval().asString());
st = new StringBuilder();
} catch (IllegalArgumentException e) {
BauSystem.MESSAGE.send(e.getMessage(), player);
return new String[0];
} catch (VarNotFoundException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_VAR", player, e.getMessage());
return new String[0];
} catch (IndexOutOfBoundsException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_EXPRESSION", player, st.toString());
return new String[0];
} catch (UnknownOperatorException e) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_UNKNOWN_OPERATION", player, e.getMessage());
return new String[0];
}
} }
} else if (st.length() > 0) {
st.append(c);
} else {
result.append(c);
} }
} }
return result.toString().split(" ");
} }
public Value getOrItselfValue(String variable) { public Value getOrItselfValue(String variable) {
if (!isVariable(variable)) { if (!isVariable(variable)) {
return parse(variable); return Value.parse(variable);
} }
if (Constants.isConstant(variable)) { if (Constants.isConstant(variable)) {
@ -215,6 +260,19 @@ public final class ScriptExecutor {
return localVariables.getValue(variable); return localVariables.getValue(variable);
} }
public Value getValueOrNull(String variable) {
if (Constants.isConstant(variable)) {
return Constants.getConstant(variable, player);
}
if (globalVariables.hasValue(variable)) {
return globalVariables.getValue(variable);
}
if (localVariables.hasValue(variable)) {
return localVariables.getValue(variable);
}
return null;
}
public String getOrItself(String variable) { public String getOrItself(String variable) {
if (isVariable(variable)) { if (isVariable(variable)) {
return getValue(variable); return getValue(variable);

Datei anzeigen

@ -32,43 +32,24 @@ public class If implements SpecialCommand {
@Override @Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) { public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) { if (command.length < 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE", scriptExecutor.getPlayer()); BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR_OR_VALUE", scriptExecutor.getPlayer());
return true; return true;
} }
if (command.length <= 2) { if (command.length < 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR_OR_VALUE", scriptExecutor.getPlayer()); BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 3) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_THIRD_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
return true; return true;
} }
if (command[2].equals("exists")) { Value v = scriptExecutor.getOrItselfValue(command[1]);
if (scriptExecutor.isVariable(command[1])) { if (!(v instanceof Value.BooleanValue)) {
jumpToIndex(scriptExecutor, command[3]); BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NO_BOOLEAN", scriptExecutor.getPlayer());
} else { return false;
if (command.length > 4) {
jumpToIndex(scriptExecutor, command[4]);
}
}
return true;
} }
if (v.asBoolean()) {
Value v1 = scriptExecutor.getOrItselfValue(command[1]); jumpToIndex(scriptExecutor, command[2]);
Value v2 = scriptExecutor.getOrItselfValue(command[2]); } else if (command.length > 3) {
if (v1.getClass() != v2.getClass()) {
// This is intended
if (command.length > 4) {
jumpToIndex(scriptExecutor, command[4]);
}
return true;
}
if (v1.asString().equals(v2.asString())) {
jumpToIndex(scriptExecutor, command[3]); jumpToIndex(scriptExecutor, command[3]);
} else if (command.length > 4) {
jumpToIndex(scriptExecutor, command[4]);
} }
return true; return true;
} }

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Add implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_ADD_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE;
}
@Override
public String command() {
return "add";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR", scriptExecutor.getPlayer());
return true;
}
if (v1 instanceof Value.DoubleValue || v2 instanceof Value.DoubleValue) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(v1.asDouble() + v2.asDouble()));
} else {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() + v2.asLong()));
}
return true;
}
}

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Div implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_DIV_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE;
}
@Override
public String command() {
return "div";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR", scriptExecutor.getPlayer());
return true;
}
if (v1 instanceof Value.DoubleValue || v2 instanceof Value.DoubleValue) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(v1.asDouble() / v2.asDouble()));
} else {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() / v2.asLong()));
}
return true;
}
}

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Mul implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_MUL_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE;
}
@Override
public String command() {
return "mul";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR", scriptExecutor.getPlayer());
return true;
}
if (v1 instanceof Value.DoubleValue || v2 instanceof Value.DoubleValue) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(v1.asDouble() * v2.asDouble()));
} else {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() * v2.asLong()));
}
return true;
}
}

Datei anzeigen

@ -1,62 +0,0 @@
package de.steamwar.bausystem.features.script.command.arithmetic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Sub implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_1",
"SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_2",
"",
"SCRIPT_COMMAND_ARITHMETIC_SUB_HELP_3"
};
}
@Override
public Material material() {
return Material.REDSTONE;
}
@Override
public String command() {
return "sub";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR", scriptExecutor.getPlayer());
return true;
}
if (v1 instanceof Value.DoubleValue || v2 instanceof Value.DoubleValue) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.DoubleValue(v1.asDouble() - v2.asDouble()));
} else {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.LongValue(v1.asLong() - v2.asLong()));
}
return true;
}
}

Datei anzeigen

@ -1,64 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class And implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_AND_HELP_1",
"SCRIPT_COMMAND_LOGIC_AND_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_AND_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "and";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE", scriptExecutor.getPlayer());
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,58 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Equal implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_EQUAL_HELP_1",
"SCRIPT_COMMAND_LOGIC_EQUAL_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_EQUAL_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "equal";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
Value result;
if (!v1.getClass().isInstance(v2.getClass()) && !v2.getClass().isInstance(v1.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,64 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Greater implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_GREATER_HELP_1",
"SCRIPT_COMMAND_LOGIC_GREATER_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_GREATER_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "greater";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE", scriptExecutor.getPlayer());
return true;
}
Value result;
if (v1.asDouble() > v2.asDouble()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,64 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Less implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_LESS_HELP_1",
"SCRIPT_COMMAND_LOGIC_LESS_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_LESS_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "less";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.LongValue) && !(v1 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.LongValue) && !(v2 instanceof Value.DoubleValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE", scriptExecutor.getPlayer());
return true;
}
Value result;
if (v1.asDouble() < v2.asDouble()) {
result = new Value.BooleanValue(true);
} else {
result = new Value.BooleanValue(false);
}
scriptExecutor.getLocalVariables().putValue(command[1], result);
return true;
}
}

Datei anzeigen

@ -1,48 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Not implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_NOT_HELP_1",
"SCRIPT_COMMAND_LOGIC_NOT_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_NOT_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "not";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], new Value.BooleanValue(!v1.asBoolean()));
return true;
}
}

Datei anzeigen

@ -1,64 +0,0 @@
package de.steamwar.bausystem.features.script.command.logic;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Or implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_LOGIC_OR_HELP_1",
"SCRIPT_COMMAND_LOGIC_OR_HELP_2",
"",
"SCRIPT_COMMAND_LOGIC_OR_HELP_3"
};
}
@Override
public Material material() {
return Material.COMPARATOR;
}
@Override
public String command() {
return "or";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
Value v1 = scriptExecutor.getOrItselfValue(command[command.length - 2]);
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v1 instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE", scriptExecutor.getPlayer());
return true;
}
if (!(v2 instanceof Value.BooleanValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE", scriptExecutor.getPlayer());
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,74 +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.command.string;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Length implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_STRING_LENGTH_HELP_1",
"SCRIPT_COMMAND_STRING_LENGTH_HELP_2",
"",
"SCRIPT_COMMAND_STRING_LENGTH_HELP_3"
};
}
@Override
public Material material() {
return Material.REPEATER;
}
@Override
public String command() {
return "length";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
String resultName = command[1];
Value v2 = scriptExecutor.getOrItselfValue(command[command.length - 1]);
if (!(v2 instanceof Value.StringValue)) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_ONLY_STRINGS_ALLOWED", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(resultName, new Value.LongValue(v2.asString().length()));
return true;
}
}

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Constants; import de.steamwar.bausystem.features.script.variables.Constants;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
@ -66,7 +67,7 @@ public class Const implements SpecialCommand {
} }
varValue.append(command[i]); varValue.append(command[i]);
} }
Constants.getConstant(varName, scriptExecutor.getPlayer()).fromValue(scriptExecutor.parse(varValue.toString())); Constants.getConstant(varName, scriptExecutor.getPlayer()).fromValue(Value.parse(varValue.toString()));
return true; return true;
} }
} }

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
@ -58,7 +59,7 @@ public class Convert implements SpecialCommand {
return true; return true;
} }
scriptExecutor.getLocalVariables().putValue(command[1], scriptExecutor.parse(command[2])); scriptExecutor.getLocalVariables().putValue(command[1], Value.parse(command[2]));
return true; return true;
} }
} }

Datei anzeigen

@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
@ -46,7 +47,7 @@ public class Global implements SpecialCommand {
} }
varValue.append(command[i]); varValue.append(command[i]);
} }
scriptExecutor.getGlobalVariables().putValue(varName, scriptExecutor.parse(varValue.toString())); scriptExecutor.getGlobalVariables().putValue(varName, Value.parse(varValue.toString()));
return true; return true;
} }
} }

Datei anzeigen

@ -1,65 +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.command.variable;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Isset implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_ISSET_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_ISSET_HELP_2"
};
}
@Override
public Material material() {
return Material.REDSTONE_TORCH;
}
@Override
public String command() {
return "isset";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
scriptExecutor.getLocalVariables().putValue(command[1], scriptExecutor.isVariable(command[2]) ? new Value.BooleanValue(true) : new Value.BooleanValue(false));
return true;
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.script.command.variable;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.ScriptExecutor; import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.SpecialCommand; import de.steamwar.bausystem.features.script.SpecialCommand;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import org.bukkit.Material; import org.bukkit.Material;
@ -46,7 +47,7 @@ public class Var implements SpecialCommand {
} }
varValue.append(command[i]); varValue.append(command[i]);
} }
scriptExecutor.getLocalVariables().putValue(varName, scriptExecutor.parse(varValue.toString())); scriptExecutor.getLocalVariables().putValue(varName, Value.parse(varValue.toString()));
return true; return true;
} }
} }

Datei anzeigen

@ -1,69 +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.command.variable;
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.linkage.Linked;
import org.bukkit.Material;
@Linked
public class Vartype implements SpecialCommand {
@Override
public String[] description() {
return new String[]{
"SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_1",
"",
"SCRIPT_COMMAND_VARIABLE_VARTYPE_HELP_2"
};
}
@Override
public Material material() {
return Material.CHEST;
}
@Override
public String command() {
return "vartype";
}
@Override
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
if (command.length <= 1) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (command.length <= 2) {
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_SECOND_ARG_NOVAR", scriptExecutor.getPlayer());
return true;
}
if (!scriptExecutor.isVariable(command[2])) {
scriptExecutor.getLocalVariables().putValue(command[1], new Value.BooleanValue(false));
}
Value value = scriptExecutor.getOrItselfValue(command[2]);
scriptExecutor.getLocalVariables().putValue(command[1], new Value.StringValue(value.type()));
return true;
}
}

Datei anzeigen

@ -0,0 +1,242 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression;
import de.steamwar.bausystem.features.script.ScriptExecutor;
import de.steamwar.bausystem.features.script.variables.Constants;
import de.steamwar.bausystem.features.script.variables.Value;
import org.bukkit.entity.Player;
import java.util.*;
public class Expression {
private static int highestPrecedence = 1;
private static final Map<String, Operator> OPERATORS = new HashMap<>();
public static void registerOperator(Operator operator) {
highestPrecedence = Math.max(highestPrecedence, operator.getPriority()) + 1;
OPERATORS.put(operator.getOperator(), operator);
}
private Player p;
private ScriptExecutor scriptExecutor;
private String s;
public Expression(Player p, String s, ScriptExecutor scriptExecutor) {
s = s.substring(1, s.length() - 1);
this.p = p;
this.s = s;
this.scriptExecutor = scriptExecutor;
}
public Value eval() {
List<Object> tokens = new ArrayList<>(tokenize(s));
List<Integer> priorities = priorities(tokens);
while (true) {
int toCalc = getToCalc(priorities);
if (priorities.get(toCalc) == 0) break;
if (priorities.get(toCalc) == highestPrecedence) {
String s = (String) tokens.get(toCalc);
if (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")) {
tokens.set(toCalc, new Value.BooleanValue(Boolean.parseBoolean(s)));
priorities.set(toCalc, 0);
continue;
}
String[] strings = s.split("\\.");
if (strings.length == 1) {
Value value = scriptExecutor.getValueOrNull(strings[0]);
if (value == null) {
throw new VarNotFoundException(strings[0]);
}
tokens.set(toCalc, value);
priorities.set(toCalc, 0);
} else {
boolean searchGlobal = false;
boolean searchConst = false;
boolean searchLocal = false;
if (strings[0].equals("global")) {
searchGlobal = true;
strings = Arrays.copyOfRange(strings, 1, strings.length);
} else if (strings[0].equals("const")) {
searchConst = true;
strings = Arrays.copyOfRange(strings, 1, strings.length);
} else if (strings[0].equals("local")) {
searchLocal = true;
strings = Arrays.copyOfRange(strings, 1, strings.length);
}
String varName = strings[0];
Value value;
if (searchGlobal) {
value = scriptExecutor.getGlobalVariables().getValue(varName);
} else if (searchConst) {
value = Constants.getConstant(varName, p);
} else if (searchLocal) {
value = scriptExecutor.getLocalVariables().getValue(varName);
} else {
value = scriptExecutor.getValueOrNull(varName);
}
for (int i = 1; i < strings.length; i++) {
switch (strings[i]) {
case "isset":
value = new Value.BooleanValue(value != null);
break;
case "type":
value = new Value.StringValue(value == null ? "" : value.type());
break;
case "length":
value = new Value.LongValue(value == null ? 0 : value.asString().length());
break;
}
}
if (value == null) {
throw new VarNotFoundException(strings[0]);
}
tokens.set(toCalc, value);
priorities.set(toCalc, 0);
}
} else {
Value first = parse(tokens.get(toCalc - 1));
Value second = parse(tokens.get(toCalc + 1));
String op = (String) tokens.get(toCalc);
Operator operation = OPERATORS.get(op);
if (operation == null) {
throw new UnknownOperatorException(op);
}
Value result = operation.operate(first, second);
tokens.set(toCalc - 1, result);
tokens.remove(toCalc);
tokens.remove(toCalc);
priorities.remove(toCalc);
priorities.remove(toCalc);
priorities.set(toCalc - 1, 0);
}
}
return (Value) tokens.get(0);
}
private Value parse(Object token) {
if (token instanceof Value) {
return (Value) token;
} else if (token instanceof String) {
String s = (String) token;
if (s.startsWith("{") && s.endsWith("}")) {
return new Expression(p, s, scriptExecutor).eval();
} else {
return Value.parse(s);
}
} else {
throw new IllegalArgumentException("Unknown token: " + token);
}
}
private String getExpressionString(String s, int index) {
StringBuilder result = new StringBuilder();
int depth = 0;
for (int i = index; i < s.length(); i++) {
char c = s.charAt(i);
if (c == '{') {
depth++;
} else if (c == '}') {
result.append(c);
depth--;
if (depth == 0) {
return result.toString();
}
}
if (depth > 0) {
result.append(c);
}
}
return result.toString();
}
private List<String> tokenize(String s) {
List<String> tokens = new ArrayList<>();
StringBuilder token = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
if (c == ' ') continue;
if (c == '{') {
String subExpression = getExpressionString(s, i);
tokens.add(subExpression);
i += subExpression.length() - 1;
continue;
}
StringBuilder op = new StringBuilder();
for (int j = i; j < s.length(); j++) {
char k = s.charAt(j);
if (k == '+' || k == '-' || k == '*' || k == '/' || k == '%' || k == '^' || k == '&' || k == '|' || k == '>' || k == '<' || k == '=' || k == '!') {
op.append(k);
} else {
break;
}
}
if (op.length() > 0) {
if (token.length() > 0) {
tokens.add(token.toString());
token = new StringBuilder();
}
tokens.add(op.toString());
i += op.length() - 1;
continue;
}
token.append(c);
}
if (token.length() > 0) {
tokens.add(token.toString());
}
return tokens;
}
private List<Integer> priorities(List<Object> tokens) {
List<Integer> priorities = new ArrayList<>();
for (Object obj : tokens) {
String token = (String) obj;
Operator operator = OPERATORS.get(token);
if (token.startsWith("{") && token.endsWith("}")) {
priorities.add(0);
} else if (!token.matches("[0-9]+([.,][0-9]+)?") && operator == null) {
priorities.add(highestPrecedence);
} else if (operator != null) {
priorities.add(operator.getPriority());
} else {
priorities.add(0);
}
}
return priorities;
}
private int getToCalc(List<Integer> priorities) {
int max = 0;
int index = 0;
for (int i = 0; i < priorities.size(); i++) {
if (priorities.get(i) > max) {
max = priorities.get(i);
index = i;
}
}
return index;
}
}

Datei anzeigen

@ -0,0 +1,37 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression;
import de.steamwar.bausystem.features.script.variables.Value;
public interface Operator {
String getOperator();
int getPriority();
Value operate(Value value, Value value2);
default boolean is(Value value, Class<?>... classes) {
for (Class<?> clazz : classes) {
if (clazz.isInstance(value)) {
return true;
}
}
return false;
}
}

Datei anzeigen

@ -0,0 +1,27 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression;
public class UnknownOperatorException extends RuntimeException{
public UnknownOperatorException(String message) {
super(message);
}
}

Datei anzeigen

@ -0,0 +1,27 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression;
public class VarNotFoundException extends RuntimeException{
public VarNotFoundException(String message) {
super(message);
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class EqualOperator implements Operator {
@Override
public String getOperator() {
return "==";
}
@Override
public int getPriority() {
return 6;
}
@Override
public Value operate(Value value, Value value2) {
if (!value.type().equals(value2.type())) {
return new Value.BooleanValue(false);
}
if (value instanceof Value.StringValue) {
return new Value.BooleanValue(value.asString().equals(value2.asString()));
}
if (value instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() == value2.asDouble());
}
if (value instanceof Value.LongValue) {
return new Value.BooleanValue(value.asLong() == value2.asLong());
}
return new Value.BooleanValue(value.asBoolean() == value2.asBoolean());
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class GreaterOperator implements Operator {
@Override
public String getOperator() {
return ">";
}
@Override
public int getPriority() {
return 7;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() > value2.asDouble());
} else {
return new Value.BooleanValue(value.asLong() > value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class GreaterOrEqualOperator implements Operator {
@Override
public String getOperator() {
return ">=";
}
@Override
public int getPriority() {
return 7;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() >= value2.asDouble());
} else {
return new Value.BooleanValue(value.asLong() >= value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class LessOperator implements Operator {
@Override
public String getOperator() {
return "<";
}
@Override
public int getPriority() {
return 7;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() < value2.asDouble());
} else {
return new Value.BooleanValue(value.asLong() < value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class LessOrEqualOperator implements Operator {
@Override
public String getOperator() {
return "<=";
}
@Override
public int getPriority() {
return 7;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_NUMBER_COMPARE");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() <= value2.asDouble());
} else {
return new Value.BooleanValue(value.asLong() <= value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.comparison;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class NotEqualOperator implements Operator {
@Override
public String getOperator() {
return "!=";
}
@Override
public int getPriority() {
return 6;
}
@Override
public Value operate(Value value, Value value2) {
if (!value.type().equals(value2.type())) {
return new Value.BooleanValue(false);
}
if (value instanceof Value.StringValue) {
return new Value.BooleanValue(!value.asString().equals(value2.asString()));
}
if (value instanceof Value.DoubleValue) {
return new Value.BooleanValue(value.asDouble() != value2.asDouble());
}
if (value instanceof Value.LongValue) {
return new Value.BooleanValue(value.asLong() != value2.asLong());
}
return new Value.BooleanValue(value.asBoolean() != value2.asBoolean());
}
}

Datei anzeigen

@ -0,0 +1,47 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.logic;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class AndOperator implements Operator {
@Override
public String getOperator() {
return "&&";
}
@Override
public int getPriority() {
return 2;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.DoubleValue.class, Value.LongValue.class) || is(value2, Value.StringValue.class, Value.DoubleValue.class, Value.LongValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE");
}
return new Value.BooleanValue(value.asBoolean() && value2.asBoolean());
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.logic;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseAndOperator implements Operator {
@Override
public String getOperator() {
return "&";
}
@Override
public int getPriority() {
return 5;
}
@Override
public Value operate(Value value, Value value2) {
if (value instanceof Value.StringValue || value2 instanceof Value.StringValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR");
}
if (value.getClass() != value2.getClass()) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_AND_ERROR");
}
if (value instanceof Value.BooleanValue && value2 instanceof Value.BooleanValue) {
return new Value.BooleanValue(value.asBoolean() && value2.asBoolean());
}
return new Value.LongValue(value.asLong() & value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.logic;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseOrOperator implements Operator {
@Override
public String getOperator() {
return "|";
}
@Override
public int getPriority() {
return 4;
}
@Override
public Value operate(Value value, Value value2) {
if (value instanceof Value.StringValue || value2 instanceof Value.StringValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR");
}
if (value.getClass() != value2.getClass()) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_OR_ERROR");
}
if (value instanceof Value.BooleanValue && value2 instanceof Value.BooleanValue) {
return new Value.BooleanValue(value.asBoolean() || value2.asBoolean());
}
return new Value.LongValue(value.asLong() | value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.logic;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseXorOperator implements Operator {
@Override
public String getOperator() {
return "^";
}
@Override
public int getPriority() {
return 3;
}
@Override
public Value operate(Value value, Value value2) {
if (value instanceof Value.StringValue || value2 instanceof Value.StringValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR");
}
if (value.getClass() != value2.getClass()) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_XOR_ERROR");
}
if (value instanceof Value.BooleanValue && value2 instanceof Value.BooleanValue) {
return new Value.BooleanValue(value.asBoolean() ^ value2.asBoolean());
}
return new Value.LongValue(value.asLong() ^ value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,47 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.logic;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class OrOperator implements Operator {
@Override
public String getOperator() {
return "||";
}
@Override
public int getPriority() {
return 1;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.DoubleValue.class, Value.LongValue.class) || is(value2, Value.StringValue.class, Value.DoubleValue.class, Value.LongValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ERROR_BOOLEAN_COMPARE");
}
return new Value.BooleanValue(value.asBoolean() || value2.asBoolean());
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseLeftOperator implements Operator {
@Override
public String getOperator() {
return "<<";
}
@Override
public int getPriority() {
return 8;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_LEFT_ERROR");
}
return new Value.LongValue(value.asLong() << value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseLogicRightOperator implements Operator {
@Override
public String getOperator() {
return ">>>";
}
@Override
public int getPriority() {
return 8;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_LOGIC_ERROR");
}
return new Value.LongValue(value.asLong() >>> value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class BitwiseRightOperator implements Operator {
@Override
public String getOperator() {
return ">>";
}
@Override
public int getPriority() {
return 8;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class, Value.DoubleValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_BIT_RIGHT_ERROR");
}
return new Value.LongValue(value.asLong() >> value2.asLong());
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class DivideOperator implements Operator {
@Override
public String getOperator() {
return "/";
}
@Override
public int getPriority() {
return 10;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_DIV_ERROR");
}
return new Value.DoubleValue(value.asDouble() / value2.asDouble());
}
}

Datei anzeigen

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class MinusOperator implements Operator {
@Override
public String getOperator() {
return "-";
}
@Override
public int getPriority() {
return 9;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_SUB_ERROR");
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.DoubleValue(value.asDouble() - value2.asDouble());
} else {
return new Value.LongValue(value.asLong() - value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class ModuloOperator implements Operator {
@Override
public String getOperator() {
return "%";
}
@Override
public int getPriority() {
return 10;
}
@Override
public Value operate(Value value, Value value2) {
if (value instanceof Value.LongValue && value2 instanceof Value.LongValue) {
return new Value.LongValue(value.asLong() % value2.asLong());
}
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_MOD_ERROR");
}
}

Datei anzeigen

@ -0,0 +1,57 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class MultiplyOperator implements Operator {
@Override
public String getOperator() {
return "*";
}
@Override
public int getPriority() {
return 10;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_MUL_ERROR");
}
if (value instanceof Value.StringValue) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < value2.asLong(); i++) {
sb.append(value.asString());
}
return new Value.StringValue(sb.toString());
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.DoubleValue(value.asDouble() * value2.asDouble());
} else {
return new Value.LongValue(value.asLong() * value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,53 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class PlusOperator implements Operator {
@Override
public String getOperator() {
return "+";
}
@Override
public int getPriority() {
return 9;
}
@Override
public Value operate(Value value, Value value2) {
if (value instanceof Value.BooleanValue || value2 instanceof Value.BooleanValue) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_ADD_ERROR");
}
if (value instanceof Value.StringValue || value2 instanceof Value.StringValue) {
return new Value.StringValue(value.asString() + value2.asString());
}
if (value instanceof Value.DoubleValue || value2 instanceof Value.DoubleValue) {
return new Value.DoubleValue(value.asDouble() + value2.asDouble());
} else {
return new Value.LongValue(value.asLong() + value2.asLong());
}
}
}

Datei anzeigen

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 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.expression.operator.math;
import de.steamwar.bausystem.features.script.expression.Operator;
import de.steamwar.bausystem.features.script.variables.Value;
import de.steamwar.linkage.Linked;
@Linked
public class PowerOperator implements Operator {
@Override
public String getOperator() {
return "**";
}
@Override
public int getPriority() {
return 11;
}
@Override
public Value operate(Value value, Value value2) {
if (is(value, Value.StringValue.class, Value.BooleanValue.class) || is(value2, Value.StringValue.class, Value.BooleanValue.class)) {
throw new IllegalArgumentException("SCRIPT_COMMAND_ARITHMETIC_POW_ERROR");
}
return new Value.DoubleValue(Math.pow(value.asDouble(), value2.asDouble()));
}
}

Datei anzeigen

@ -1,5 +1,7 @@
package de.steamwar.bausystem.features.script.variables; package de.steamwar.bausystem.features.script.variables;
import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.features.tracer.record.ActiveTracer; import de.steamwar.bausystem.features.tracer.record.ActiveTracer;
import de.steamwar.bausystem.features.tracer.record.AutoTraceRecorder; import de.steamwar.bausystem.features.tracer.record.AutoTraceRecorder;
import de.steamwar.bausystem.features.tracer.record.Recorder; import de.steamwar.bausystem.features.tracer.record.Recorder;
@ -9,6 +11,7 @@ import de.steamwar.bausystem.region.flags.flagvalues.FireMode;
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode; import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode; import de.steamwar.bausystem.region.flags.flagvalues.ProtectMode;
import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode;
import de.steamwar.core.TPSWatcher;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -236,7 +239,7 @@ public class Constants {
CONSTANTS.put("tnt", player -> { CONSTANTS.put("tnt", player -> {
return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY); return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.DENY);
}); });
CONSTANTS.put("tnt-onlytb", player -> { CONSTANTS.put("tnt_onlytb", player -> {
return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.ONLY_TB); return new ConstantBooleanValue(() -> Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class) != TNTMode.ONLY_TB);
}); });
CONSTANTS.put("freeze", player -> { CONSTANTS.put("freeze", player -> {
@ -313,13 +316,19 @@ public class Constants {
return itemMeta.getDisplayName(); return itemMeta.getDisplayName();
}); });
}); });
CONSTANTS.put("region-type", player -> { CONSTANTS.put("region_type", player -> {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) { if (region.isGlobal()) {
return new ConstantStringValue(() -> "global"); return new ConstantStringValue(() -> "global");
} }
return new ConstantStringValue(() -> region.getPrototype().getDisplayName().replace(' ', '_').toLowerCase()); return new ConstantStringValue(() -> region.getPrototype().getDisplayName().replace(' ', '_').toLowerCase());
}); });
CONSTANTS.put("tps", player -> {
return new ConstantDoubleValue(TPSWatcher::getTPS);
});
CONSTANTS.put("tps_limit", player -> {
return new ConstantDoubleValue(TPSLimitUtils::getCurrentTPSLimit);
});
} }
public Set<String> allVariables() { public Set<String> allVariables() {

Datei anzeigen

@ -4,6 +4,23 @@ import lombok.AllArgsConstructor;
import lombok.ToString; import lombok.ToString;
public interface Value { public interface Value {
static Value parse(String varValue) {
try {
return new Value.LongValue(Long.parseLong(varValue));
} catch (NumberFormatException ne) {
try {
return new Value.DoubleValue(Double.parseDouble(varValue));
} catch (NumberFormatException e) {
if (varValue.equalsIgnoreCase("true") || varValue.equalsIgnoreCase("false")) {
return new Value.BooleanValue(varValue.equalsIgnoreCase("true"));
} else {
return new Value.StringValue(varValue);
}
}
}
}
String type(); String type();
long asLong(); long asLong();
double asDouble(); double asDouble();

Datei anzeigen

@ -52,7 +52,7 @@ public class WorldEditListener implements Listener {
private static final Set<String> commands = new HashSet<>(); private static final Set<String> commands = new HashSet<>();
private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"}; private static final String[] shortcutCommands = {"//1", "//2", "//90", "//-90", "//180", "//p", "//c", "//flopy", "//floppy", "//flopyp", "//floppyp", "//u", "//r"};
private boolean isWorldEditCommand(String command) { public static boolean isWorldEditCommand(String command) {
for (String shortcut : shortcutCommands) { for (String shortcut : shortcutCommands) {
if (command.startsWith(shortcut)) return true; if (command.startsWith(shortcut)) return true;
} }