SteamWar/BauSystem
Archiviert
13
0

Simplify Error messages for user

Dieser Commit ist enthalten in:
jojo 2020-12-16 11:31:27 +01:00
Ursprung 45eea9b26e
Commit 3cdfae7c86

Datei anzeigen

@ -44,8 +44,18 @@ public class ScriptListener implements Listener {
private Set<Player> playerSet = new HashSet<>();
public ScriptListener() {
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
playerSet.clear();
}, 1, 1);
}
@EventHandler(priority = EventPriority.HIGH)
public void onLeftClick(PlayerInteractEvent event) {
ItemStack item = event.getItem();
if(item == null || isNoBook(item) || item.getItemMeta() == null)
return;
if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) {
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
playerSet.add(event.getPlayer());
@ -56,10 +66,6 @@ public class ScriptListener implements Listener {
return;
}
ItemStack item = event.getItem();
if(item == null || isNoBook(item) || item.getItemMeta() == null)
return;
event.setCancelled(true);
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
}
@ -85,8 +91,7 @@ public class ScriptListener implements Listener {
for(String page : bookMeta.getPages()) {
for (String command : page.split("\n")) {
if (command.startsWith("#")) continue;
if (command.trim().isEmpty()) continue;
if (command.startsWith("#") || command.trim().isEmpty()) continue;
commands.add(command);
}
}
@ -121,7 +126,7 @@ public class ScriptListener implements Listener {
}
private static String[] generateArgumentArray(String command, String fullCommand) {
return fullCommand.substring(command.length() + 1).split(" ");
return fullCommand.substring(command.length()).trim().split(" ");
}
private static void sleepCommand(ScriptExecutor scriptExecutor, String[] args) {
@ -130,11 +135,11 @@ public class ScriptListener implements Listener {
try {
sleepTime = Integer.parseInt(args[0]);
if (sleepTime <= 0) {
scriptExecutor.player.sendMessage(scriptPrefix + "Sleep kleiner gleich 0, default 1 GameTick");
scriptExecutor.player.sendMessage(scriptPrefix + "Eine Sleep zeit von kleiner gleich 0 ist nicht erlaubt. Der default 1 Tick wird verwendet.");
sleepTime = 1;
}
} catch (NumberFormatException e) {
scriptExecutor.player.sendMessage(scriptPrefix + "Sleep ohne Zahl, default 1 GameTick");
scriptExecutor.player.sendMessage(scriptPrefix + "Eine Sleep zeit sollte keine Buchstaben oder sonstige Zeiten verwenden. Der default 1 Tick wird verwendet.");
}
}
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), scriptExecutor::resume, sleepTime);