SteamWar/BauSystem2.0
Archiviert
12
0

CustomCommandListener on steroids

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-07-10 14:54:13 +02:00
Ursprung 78ad3cf7a3
Commit d77deffcc9
3 geänderte Dateien mit 10 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -35,7 +35,10 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Linked(LinkageType.LISTENER)
public class CustomCommandListener implements Listener {
@ -126,20 +129,6 @@ public class CustomCommandListener implements Listener {
}
customCommands.stream().map(customCommand -> customCommand.execute(e)).filter(b -> !b).findFirst();
/*String[] command = e.getMessage().split(" ");
BookMeta bookMeta = bookMetaMap.get(e.getMessage());
if (bookMeta == null) {
return;
}
e.setCancelled(true);
try {
new ScriptExecutor(bookMeta, e.getPlayer());
} catch (StackOverflowError exception) {
// Ignored
}*/
}
private boolean isNoBook(ItemStack item) {

Datei anzeigen

@ -52,7 +52,7 @@ public final class ScriptExecutor {
command = command.replaceAll(" +", " ");
if (command.startsWith("#") || command.trim().isEmpty()) {
if (initial && command.startsWith("#!CMD /")) {
specialCommand = command.substring(7);
specialCommand = command.substring(7).split(" ")[0];
}
initial = false;
continue;
@ -102,7 +102,7 @@ public final class ScriptExecutor {
}
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + (command.equals(specialCommand) ? "script:" : "") + command);
PlayerCommandPreprocessEvent preprocessEvent = new PlayerCommandPreprocessEvent(player, "/" + (specialCommand != null && command.startsWith(specialCommand) ? "script:" : "") + command);
Bukkit.getServer().getPluginManager().callEvent(preprocessEvent);
if (preprocessEvent.isCancelled()) {
continue;

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.bausystem.features.script.variables;
import lombok.AllArgsConstructor;
import lombok.ToString;
public interface Value {
long asLong();
@ -12,6 +13,7 @@ public interface Value {
void fromString(String value);
@AllArgsConstructor
@ToString
class LongValue implements Value {
private long value;
@ -52,6 +54,7 @@ public interface Value {
}
@AllArgsConstructor
@ToString
class BooleanValue implements Value {
private boolean value;
@ -88,6 +91,7 @@ public interface Value {
}
@AllArgsConstructor
@ToString
class StringValue implements Value {
private String value;