Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
e8fa5ead91
Commit
3a5e0efa26
@ -375,6 +375,14 @@ SCRIPT_COMMAND_JUMP_HELP_1 = §ejump §8<§7Jump-Point§8>
|
|||||||
SCRIPT_COMMAND_JUMP_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor.
|
SCRIPT_COMMAND_JUMP_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor.
|
||||||
SCRIPT_COMMAND_JUMP_ERROR = §cDer Jump-Point ({0}) ist nicht definiert.
|
SCRIPT_COMMAND_JUMP_ERROR = §cDer Jump-Point ({0}) ist nicht definiert.
|
||||||
|
|
||||||
|
SCRIPT_COMMAND_CALL_HELP_1 = §ecall §8<§7Jump-Point§8>
|
||||||
|
SCRIPT_COMMAND_CALL_HELP_2 = §7Springe zu einer anderen Zeile. Hierbei ist ein Jump-Point eine Zeile mit §8'§7.§8'§7 vor. Hierbei wird auf den ReturnStack die jetzige Zeile geschrieben, dahin kann man wieder mit 'return' zurück springen.
|
||||||
|
SCRIPT_COMMAND_CALL_ERROR = §cDer Jump-Point ({0}) ist nicht definiert.
|
||||||
|
|
||||||
|
SCRIPT_COMMAND_RETURN_HELP_1 = §ereturn
|
||||||
|
SCRIPT_COMMAND_RETURN_HELP_2 = §7Springe zum letzten 'call' Befehl.
|
||||||
|
SCRIPT_COMMAND_RETURN_ERROR = §cEs wurde kein 'call' Befehl ausgeführt
|
||||||
|
|
||||||
SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7Time§8>
|
SCRIPT_COMMAND_SLEEP_HELP_1 = §esleep §8<§7Time§8>
|
||||||
SCRIPT_COMMAND_SLEEP_HELP_2 = Pausiert das Ausführen des Scripts. Das erste Argument ist in GameTicks.
|
SCRIPT_COMMAND_SLEEP_HELP_2 = Pausiert das Ausführen des Scripts. Das erste Argument ist in GameTicks.
|
||||||
SCRIPT_COMMAND_SLEEP_ERROR = §cDie Zeit muss eine Zahl großer 0 sein.
|
SCRIPT_COMMAND_SLEEP_ERROR = §cDie Zeit muss eine Zahl großer 0 sein.
|
||||||
|
@ -95,7 +95,7 @@ public class ScriptCommand extends SWCommand {
|
|||||||
});
|
});
|
||||||
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
|
swItems.add(new SWListInv.SWListEntry<>(swItem, specialCommand));
|
||||||
});
|
});
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 3 + 45; i++) {
|
||||||
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
|
swItems.add(new SWListInv.SWListEntry<>(new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§7", new ArrayList<>(), false, clickType -> {
|
||||||
}), null));
|
}), null));
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,9 @@ public final class ScriptExecutor {
|
|||||||
@Getter
|
@Getter
|
||||||
public final Map<String, Integer> jumpPoints = new HashMap<>();
|
public final Map<String, Integer> jumpPoints = new HashMap<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final LinkedList<Integer> returnStack = new LinkedList<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
@ -108,7 +111,8 @@ public final class ScriptExecutor {
|
|||||||
int executionPoints = 0;
|
int executionPoints = 0;
|
||||||
|
|
||||||
while (index < commands.size()) {
|
while (index < commands.size()) {
|
||||||
String command = commands.get(index++);
|
String command = commands.get(index);
|
||||||
|
index++;
|
||||||
if (executionPoints++ > 200) {
|
if (executionPoints++ > 200) {
|
||||||
BauSystem.MESSAGE.send("SCRIPT_SLEEP_ERROR", player);
|
BauSystem.MESSAGE.send("SCRIPT_SLEEP_ERROR", player);
|
||||||
return;
|
return;
|
||||||
|
@ -47,4 +47,22 @@ public interface SpecialCommand {
|
|||||||
}
|
}
|
||||||
scriptExecutor.setIndex(jp);
|
scriptExecutor.setIndex(jp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void jumpToIndexWithMessageAndReturnStack(ScriptExecutor scriptExecutor, String jumpPoint, String message) {
|
||||||
|
Integer jp = scriptExecutor.jumpPoints.getOrDefault(jumpPoint, null);
|
||||||
|
if (jp == null) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scriptExecutor.getReturnStack().add(scriptExecutor.getIndex());
|
||||||
|
scriptExecutor.setIndex(jp);
|
||||||
|
}
|
||||||
|
|
||||||
|
default void returnFromStackWithMessage(ScriptExecutor scriptExecutor, String message) {
|
||||||
|
if (scriptExecutor.getReturnStack().isEmpty()) {
|
||||||
|
scriptExecutor.getPlayer().sendMessage(message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
scriptExecutor.setIndex(scriptExecutor.getReturnStack().pop());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
package de.steamwar.bausystem.features.script.command;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
@Linked(LinkageType.SCRIPT_COMMAND)
|
||||||
|
public class Call implements SpecialCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] description() {
|
||||||
|
return new String[]{
|
||||||
|
"SCRIPT_COMMAND_CALL_HELP_1",
|
||||||
|
"",
|
||||||
|
"SCRIPT_COMMAND_CALL_HELP_2"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material material() {
|
||||||
|
return Material.LEATHER_BOOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String command() {
|
||||||
|
return "call";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
|
if (command.length <= 1) {
|
||||||
|
BauSystem.MESSAGE.send("SCRIPT_COMMAND_ERROR_FIRST_ARG_NOJUMPPOINT", scriptExecutor.getPlayer());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
jumpToIndexWithMessageAndReturnStack(scriptExecutor, command[1], BauSystem.MESSAGE.parse("SCRIPT_COMMAND_CALL_ERROR", scriptExecutor.getPlayer(), command[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package de.steamwar.bausystem.features.script.command;
|
||||||
|
|
||||||
|
import de.steamwar.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bausystem.features.script.ScriptExecutor;
|
||||||
|
import de.steamwar.bausystem.features.script.SpecialCommand;
|
||||||
|
import de.steamwar.bausystem.linkage.LinkageType;
|
||||||
|
import de.steamwar.bausystem.linkage.Linked;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
@Linked(LinkageType.SCRIPT_COMMAND)
|
||||||
|
public class Return implements SpecialCommand {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String[] description() {
|
||||||
|
return new String[]{
|
||||||
|
"SCRIPT_COMMAND_RETURN_HELP_1",
|
||||||
|
"",
|
||||||
|
"SCRIPT_COMMAND_RETURN_HELP_2"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Material material() {
|
||||||
|
return Material.DIAMOND_BOOTS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String command() {
|
||||||
|
return "return";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(String[] command, ScriptExecutor scriptExecutor) {
|
||||||
|
returnFromStackWithMessage(scriptExecutor, BauSystem.MESSAGE.parse("SCRIPT_COMMAND_RETURN_ERROR", scriptExecutor.getPlayer()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren