diff --git a/src/de/warking/bungeecore/BungeeCore.java b/src/de/warking/bungeecore/BungeeCore.java index abc3920..195af76 100644 --- a/src/de/warking/bungeecore/BungeeCore.java +++ b/src/de/warking/bungeecore/BungeeCore.java @@ -15,6 +15,7 @@ import java.io.IOException; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; +import java.util.concurrent.TimeUnit; import java.util.logging.Level; public class BungeeCore extends Plugin { @@ -25,6 +26,8 @@ public class BungeeCore extends Plugin { public static final String TeamchatPrefix = "§4T§7c§r §e"; public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy"); public static String LobbyServer; + public static String [] BroadCastMsgs; + public static int LastBroadCast = 0; public static final HashMap serverPermissions = new HashMap<>(); public static final HashMap commands = new HashMap<>(); @@ -45,8 +48,10 @@ public class BungeeCore extends Plugin { config.set("db.weburl", "jdbc:mysql://127.0.0.1:3306/Website"); config.set("db.username", "root"); config.set("db.password", "$password"); - String [] cmds = {"l", "hub", "lobby"}; - config.set("servers.HunjyLobby.commands", cmds); + String [] cmd = {"l", "hub", "lobby"}; + config.set("servers.HunjyLobby.commands", cmd); + String [] bcs = {"Standardmitteilung!"}; + config.set("broadcasts", bcs); config.set("servers.HunjyLobby.permission", "bungeecore.server.user"); ConfigurationProvider.getProvider(YamlConfiguration.class).save(config, configFile); } @@ -92,9 +97,18 @@ public class BungeeCore extends Plugin { addCmd(new AlertCommand()); addCmd(new KickCommand()); addCmd(new JoinmeCommand()); - //addCmd(new FightCommand()); + addCmd(new FightCommand()); addCmd(new HelpCommand()); addCmd(new BanCommand()); + + BroadCastMsgs = config.getStringList("broadcasts").toArray(new String[1]); + getProxy().getScheduler().schedule(this, () -> { + getProxy().broadcast(ChatPrefix + BroadCastMsgs[LastBroadCast]); + LastBroadCast++; + if(LastBroadCast == BroadCastMsgs.length){ + LastBroadCast = 0; + } + }, 5, 5, TimeUnit.MINUTES); } @Override diff --git a/src/de/warking/bungeecore/commands/BanCommand.java b/src/de/warking/bungeecore/commands/BanCommand.java index 5a6bdc3..bc27c8b 100644 --- a/src/de/warking/bungeecore/commands/BanCommand.java +++ b/src/de/warking/bungeecore/commands/BanCommand.java @@ -57,7 +57,11 @@ public class BanCommand extends Command { msgBuilder.append(msg); sender.sendMessage(BungeeCore.ChatPrefix + "Du hast " + target.UserName + " gebannt. Grund: §c" + msg); ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(target.UUID); - target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg); - targetPlayer.disconnect(msgBuilder.toString()); + if(targetPlayer != null){ + target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg); + targetPlayer.disconnect(msgBuilder.toString()); + }else{ + target.banPlayer(null, banTime, msg); + } } } diff --git a/src/de/warking/bungeecore/commands/FightCommand.java b/src/de/warking/bungeecore/commands/FightCommand.java index bbed93e..26b6d17 100644 --- a/src/de/warking/bungeecore/commands/FightCommand.java +++ b/src/de/warking/bungeecore/commands/FightCommand.java @@ -18,7 +18,7 @@ import java.util.List; public class FightCommand extends Command { public FightCommand() { - super("fight", ""); + super("fight", "bungeecore.joinme"); } @Override diff --git a/src/de/warking/bungeecore/sql/WarkingUser.java b/src/de/warking/bungeecore/sql/WarkingUser.java index 3a9ca80..fe5748c 100644 --- a/src/de/warking/bungeecore/sql/WarkingUser.java +++ b/src/de/warking/bungeecore/sql/WarkingUser.java @@ -114,6 +114,7 @@ public class WarkingUser { public void banPlayer(String ip, Timestamp time, String banReason){ sql.update("UPDATE UserData SET BanTime = '" + time.toString() + "', BanReason = '" + banReason + "' WHERE UUID = '" + UUID.toString() + "'"); - updateBanIP(ip); + if(ip != null) + updateBanIP(ip); } }