From c3faa9163f089bccaf8b65b4fef3be1a6b35a758 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 1 May 2020 11:46:22 +0200 Subject: [PATCH] Implement broadcasting Signed-off-by: Lixfel --- .../bungeecore/commands/CheckCommand.java | 18 +++++++++++++++--- .../commands/ServerTeamchatCommand.java | 14 +++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/CheckCommand.java b/src/de/steamwar/bungeecore/commands/CheckCommand.java index eb0eea73..cfd2a8d6 100644 --- a/src/de/steamwar/bungeecore/commands/CheckCommand.java +++ b/src/de/steamwar/bungeecore/commands/CheckCommand.java @@ -17,6 +17,7 @@ import net.md_5.bungee.config.Configuration; import java.sql.Timestamp; import java.time.Instant; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; public class CheckCommand extends BasicCommand { @@ -37,6 +38,12 @@ public class CheckCommand extends BasicCommand { public CheckCommand() { super("check", ConnectionListener.CHECK_PERMISSION); + + ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> { + List schematics = getSchemsToCheck(); + if(schematics.size() > 0) + ServerTeamchatCommand.sendToTeam("§7Es sind §e" + schematics.size() + " §7Schematics zu prüfen§8!"); + }, 10, 10, TimeUnit.MINUTES); } @Override @@ -72,13 +79,18 @@ public class CheckCommand extends BasicCommand { } } - private void list(ProxiedPlayer player) { + private static List getSchemsToCheck(){ List schematicList = new LinkedList<>(); for (SchematicType type : SchematicType.values()) { if (type.check()) schematicList.addAll(Schematic.getAllSchemsOfType(type)); } + return schematicList; + } + + private void list(ProxiedPlayer player) { + List schematicList = getSchemsToCheck(); BungeeCore.send(player, "§e§lZu prüfen sind " + schematicList.size() + " Schematics"); @@ -223,7 +235,7 @@ public class CheckCommand extends BasicCommand { ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid()); if(player != null) BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§aDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §ewurde freigegeben§8!"); - BungeeCore.send(checker, "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!"); + ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!"); abort(); } @@ -233,7 +245,7 @@ public class CheckCommand extends BasicCommand { ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid()); if(player != null) BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDein §e" + schematic.getSchemType().name() + " " + schematic.getSchemName() + " §cwurde abgelehnt§8: §c" + reason); - BungeeCore.send(checker, "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §awurde aufgrund von §e" + reason + " §aabgelehnt!"); + ServerTeamchatCommand.sendToTeam("§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §awurde aufgrund von §e" + reason + " §aabgelehnt!"); abort(); } diff --git a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java index 91612b69..bda31c43 100644 --- a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java @@ -30,11 +30,15 @@ public class ServerTeamchatCommand extends BasicCommand { String msg = msgBuilder.toString(); msg = ChatColor.translateAlternateColorCodes('&', msg); - for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ - if ((target.hasPermission("bungeecore.teamchat")) - && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ - target.sendMessage(msg); - } + sendToTeam(msg); + } + } + + public static void sendToTeam(String message){ + for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ + if ((target.hasPermission("bungeecore.teamchat")) + && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ + BungeeCore.send(target, message); } } }