Simplify Error messages for user
Dieser Commit ist enthalten in:
Ursprung
45eea9b26e
Commit
3cdfae7c86
@ -44,8 +44,18 @@ public class ScriptListener implements Listener {
|
|||||||
|
|
||||||
private Set<Player> playerSet = new HashSet<>();
|
private Set<Player> playerSet = new HashSet<>();
|
||||||
|
|
||||||
|
public ScriptListener() {
|
||||||
|
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
|
||||||
|
playerSet.clear();
|
||||||
|
}, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onLeftClick(PlayerInteractEvent event) {
|
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.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
|
||||||
playerSet.add(event.getPlayer());
|
playerSet.add(event.getPlayer());
|
||||||
@ -56,10 +66,6 @@ public class ScriptListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack item = event.getItem();
|
|
||||||
if(item == null || isNoBook(item) || item.getItemMeta() == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
|
new ScriptExecutor((BookMeta) item.getItemMeta(), event.getPlayer());
|
||||||
}
|
}
|
||||||
@ -85,8 +91,7 @@ public class ScriptListener implements Listener {
|
|||||||
|
|
||||||
for(String page : bookMeta.getPages()) {
|
for(String page : bookMeta.getPages()) {
|
||||||
for (String command : page.split("\n")) {
|
for (String command : page.split("\n")) {
|
||||||
if (command.startsWith("#")) continue;
|
if (command.startsWith("#") || command.trim().isEmpty()) continue;
|
||||||
if (command.trim().isEmpty()) continue;
|
|
||||||
commands.add(command);
|
commands.add(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +126,7 @@ public class ScriptListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String[] generateArgumentArray(String command, String fullCommand) {
|
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) {
|
private static void sleepCommand(ScriptExecutor scriptExecutor, String[] args) {
|
||||||
@ -130,11 +135,11 @@ public class ScriptListener implements Listener {
|
|||||||
try {
|
try {
|
||||||
sleepTime = Integer.parseInt(args[0]);
|
sleepTime = Integer.parseInt(args[0]);
|
||||||
if (sleepTime <= 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;
|
sleepTime = 1;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} 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);
|
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), scriptExecutor::resume, sleepTime);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren