diff --git a/.classpath b/.classpath index 7cda3b6..f7666f0 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,7 @@ - + diff --git a/bin/.gitignore b/bin/.gitignore deleted file mode 100644 index d57ae51..0000000 --- a/bin/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/hjw/ diff --git a/bin/hjw/maintenanceannouncer/Listener.class b/bin/hjw/maintenanceannouncer/Listener.class index 691f70c..876afef 100644 Binary files a/bin/hjw/maintenanceannouncer/Listener.class and b/bin/hjw/maintenanceannouncer/Listener.class differ diff --git a/bin/hjw/maintenanceannouncer/Main.class b/bin/hjw/maintenanceannouncer/Main.class index 410cf41..140f292 100644 Binary files a/bin/hjw/maintenanceannouncer/Main.class and b/bin/hjw/maintenanceannouncer/Main.class differ diff --git a/config.yml b/config.yml index 797a1b1..97440b3 100644 --- a/config.yml +++ b/config.yml @@ -10,19 +10,22 @@ Allow reloads to Maintenance Announcer: true # Tell players about server maintenance when they join the server. (default: true) Tell players about server maintenance on join: true +# Tell admins about server maintenance when they join the server. (default: true) +Tell admins about server maintenance on join: true + # ----Message Customization------------------------------------------------------------------ # Here's where you can customize every message. Maintenance has started: '&f Maintenance to the server has started. Please excuse any lag.' Maintenance has ended: '&f Maintenance to the server has ended. Thanks for your patience.' Invalid argument message: '&a Invalid Argument! Args: start, begin, stop, end, admin start, admin begin, admin stop, admin end, reload.' -Maintenance ongoing message: '&f The server is currently undergoing maintenance. Please excuse any lag.' -Maintenance not ongoing message: '&f The server is not currently undergoing maintenance.' +Maintenance ongoing message: '&f The server is currently under maintenance. Please excuse any lag.' +Maintenance not ongoing message: '&f The server is not currently under any maintenance.' Prefix: '&c[Maintenance Announcer]' Admin only prefix: '&c[Maintenance Announcer (ADMIN ONLY)]' Sent to all admins message: '&a Sent to ALL admins!' Too many arguments message: '&a Too many arguments were entered!' # Made with love in Tennessee. -# Copyright 2016 - 2021 Hayden Watson. +# Copyright 2016 - 2022 Hayden Watson. # Maintenance Announcer is available under the MIT license. \ No newline at end of file diff --git a/plugin.yml b/plugin.yml index 67cb6a9..357e41d 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: MaintenanceAnnouncer author: Hayden Watson -version: 6.0 +version: 6.0.1 website: https://haydenwatson.co/maintenance-announcer prefix: Maintenance Announcer main: hjw.maintenanceannouncer.Main @@ -9,7 +9,7 @@ database: false commands: maintenance: - description: Check if the server is undergoing maintenance. + description: Check if the server is under maintenance. permission: hjw.maintenanceannouncer.see maintenance start: description: Broadcast to players that maintenance has started. @@ -23,11 +23,11 @@ commands: description: Check if the server is undergoing maintenance (admin only). permission: hjw.maintenanceannouncer.adminsee maintenance admin start: - description: Broadcast to only admins that maintenance has started. + description: Broadcast to admins only that maintenance has started. permission: hjw.maintenanceannouncer.adminstart aliases: [admin begin] maintenance admin end: - description: Broadcast to only admins that maintenance has ended. + description: Broadcast to admins only that maintenance has ended. permission: hjw.maintenanceannouncer.adminend aliases: [admin stop] maintenance reload: @@ -46,7 +46,7 @@ permissions: hjw.maintenanceannouncer.adminend: true hjw.maintenanceannouncer.reload: true hjw.maintenanceannouncer.see: - description: Allows you to see there is server maintenance going on. + description: Allows you to see if server maintenance is going on. default: true hjw.maintenanceannouncer.start: description: Allows broadcasting that maintenance has started. @@ -55,13 +55,13 @@ permissions: description: Allows broadcasting that maintenance has ended. default: op hjw.maintenanceannouncer.adminsee: - description: Allows you to see there is admin only server maintenance going on. + description: Allows you to see if admin only server maintenance is going on. default: op hjw.maintenanceannouncer.adminstart: - description: Allows broadcasting that maintenance has started to only admins. + description: Allows broadcasting that maintenance has started to admins only. default: op hjw.maintenanceannouncer.adminend: - description: Allows broadcasting that maintenance has ended to only admins. + description: Allows broadcasting that maintenance has ended to admins only. default: op hjw.maintenanceannouncer.reload: description: Reloads the plugin. diff --git a/src/hjw/maintenanceannouncer/Listener.java b/src/hjw/maintenanceannouncer/Listener.java index 29fa3d9..2d8caba 100644 --- a/src/hjw/maintenanceannouncer/Listener.java +++ b/src/hjw/maintenanceannouncer/Listener.java @@ -15,14 +15,20 @@ public Listener(Main plugin) { @EventHandler private void onPlayerJoin(PlayerJoinEvent event) { - // This feature automatically notifies players when they join on whether or not maintenance is ongoing to the server at the current moment. - if(event.getPlayer().hasPermission("hjw.maintenanceannouncer.see") && plugin.started == true) { - event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Prefix") + plugin.getConfig().getString("Maintenance ongoing message"))); + // Check config file for if Maintenance Announcer should tell players about server maintenance on join. + if (plugin.getConfig().getBoolean("Tell players about server maintenance on join") == true) { + // This feature automatically notifies players when they join on whether or not maintenance is ongoing to the server at the current moment. + if(event.getPlayer().hasPermission("hjw.maintenanceannouncer.see") && plugin.started == true) { + event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Prefix") + plugin.getConfig().getString("Maintenance ongoing message"))); + } } - - // Check if user can see if admin only maintenance has started. - if(event.getPlayer().hasPermission("hjw.maintenanceannouncer.adminsee") && plugin.adminOnlyStarted == true) { - event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Admin only prefix") + plugin.getConfig().getString("Maintenance ongoing message"))); + + // Check config file for if Maintenance Announcer should tell admins about server maintenance on join. + if(plugin.getConfig().getBoolean("Tell admins about server maintenance on join") == true) { + // Check if user can see if admin only maintenance has started. + if(event.getPlayer().hasPermission("hjw.maintenanceannouncer.adminsee") && plugin.adminOnlyStarted == true) { + event.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Admin only prefix") + plugin.getConfig().getString("Maintenance ongoing message"))); + } } } } \ No newline at end of file diff --git a/src/hjw/maintenanceannouncer/Main.java b/src/hjw/maintenanceannouncer/Main.java index 8f37c2b..bd4314b 100755 --- a/src/hjw/maintenanceannouncer/Main.java +++ b/src/hjw/maintenanceannouncer/Main.java @@ -12,8 +12,8 @@ public class Main extends JavaPlugin { - public boolean started = false; // Var for if the maintenance to the server is active. - public boolean adminOnlyStarted = false; // Var for if the admin only maintenance to the server is active. + public boolean started = false; // Bool for if the maintenance to the server is active. + public boolean adminOnlyStarted = false; // Bool for if the admin only maintenance to the server is active. private String prefix = "[Maintenance Announcer]"; private String adminOnlyPrefix = "[Maintenance Announcer (ADMIN ONLY)]"; @@ -33,8 +33,8 @@ public void onEnable() { adminOnlyStarted = true; } - if (getConfig().getBoolean("Tell players about server maintenance on join") == true) { - startEvent(); + if ((getConfig().getBoolean("Tell players about server maintenance on join") == true) || (getConfig().getBoolean("Tell admins about server maintenance on join") == true)) { + startEvent(); // Start the listener for telling player or admins that the server is under maintenance. } // Load customized prefixes from the config file. @@ -192,8 +192,8 @@ private void startMaintenance() { started = true; // Save that maintenance to the server has started to the config file. - getConfig().set("Maintenance", true); - saveConfig(); + getConfig().set("Maintenance", true); // Set "Maintenance" Bool as true. + saveConfig(); // Saves changes to the config file. // Broadcast that maintenance has started to all the players. for (Player player : Bukkit.getServer().getOnlinePlayers()) { @@ -202,7 +202,7 @@ private void startMaintenance() { } } - getLogger().info("A maintenance started announcement to the server was made!"); + getLogger().info("A maintenance start announcement to the server was made!"); } @@ -220,7 +220,7 @@ private void endMaintenance() { } } - getLogger().info("A maintenance ended announcement to the server was made!"); + getLogger().info("A maintenance end announcement to the server was made!"); } @@ -237,7 +237,7 @@ private void startAdminMaintenance() { } } - getLogger().info("An admin only maintenance started announcement to the server was made!"); + getLogger().info("An *admin only* maintenance start announcement to the server was made!"); } @@ -256,7 +256,7 @@ private void stopAdminMaintenance() { } } - getLogger().info("An admin only maintenance ended announcement to the server was made!"); + getLogger().info("An *admin only* maintenance end announcement to the server was made!"); } private void createConfig() {