From 0bf852befb2bc5575b6be17ca78359a43ea0c7e0 Mon Sep 17 00:00:00 2001 From: Fabrizio La Rosa Date: Sat, 13 Jun 2020 22:39:29 +0200 Subject: [PATCH] Replaced Runnable with lambda --- .../command/commands/island/ChatCommand.java | 34 ++++++++----------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java b/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java index bb90a16d..19a8cbc9 100644 --- a/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java +++ b/src/main/java/com/songoda/skyblock/command/commands/island/ChatCommand.java @@ -85,27 +85,23 @@ public class ChatCommand extends SubCommand { Island finalIsland = island; String finalIslandRole = islandRole; - Bukkit.getScheduler().runTaskAsynchronously(skyblock, new Runnable(){ + Bukkit.getScheduler().runTaskAsynchronously(skyblock, () -> { + PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), + String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); + Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); - @Override - public void run() { - PlayerIslandChatEvent islandChatEvent = new PlayerIslandChatEvent(player, finalIsland.getAPIWrapper(), - String.join(" ", args), configLoad.getString("Island.Chat.Format.Message")); - Bukkit.getServer().getPluginManager().callEvent(islandChatEvent); + if (!islandChatEvent.isCancelled()) { + for (UUID islandMembersOnlineList : islandManager.getMembersOnline(finalIsland)) { + Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); + String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, + islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()))) + .replace("%message", islandChatEvent.getMessage()); + targetPlayer.sendMessage(message); + } - if (!islandChatEvent.isCancelled()) { - for (UUID islandMembersOnlineList : islandManager.getMembersOnline(finalIsland)) { - Player targetPlayer = Bukkit.getServer().getPlayer(islandMembersOnlineList); - String message = ChatColor.translateAlternateColorCodes('&', messageManager.replaceMessage(targetPlayer, - islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()))) - .replace("%message", islandChatEvent.getMessage()); - targetPlayer.sendMessage(message); - } - - if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { - messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()) - .replace("%message", islandChatEvent.getMessage())); - } + if (fileManager.getConfig(new File(skyblock.getDataFolder(), "config.yml")).getFileConfiguration().getBoolean("Island.Chat.OutputToConsole")) { + messageManager.sendMessage(Bukkit.getConsoleSender(), islandChatEvent.getFormat().replace("%role", finalIslandRole).replace("%player", player.getName()) + .replace("%message", islandChatEvent.getMessage())); } } });