Skip to content

Commit

Permalink
6.0.1 Changes RC1
Browse files Browse the repository at this point in the history
Updated comments and added new features!
  • Loading branch information
Mrweatherman208 committed Aug 4, 2022
1 parent 90ea9fa commit 8e51f13
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="C:/Users/hjw07/Documents/Eclipse Projects/spigot-1.17.1.jar">
<classpathentry exported="true" kind="lib" path="/Users/haydenwatson/Eclipse Projects/spigot-api-1.19-R0.1-SNAPSHOT.jar">
<attributes>
<attribute name="module" value="true"/>
</attributes>
Expand Down
1 change: 0 additions & 1 deletion bin/.gitignore

This file was deleted.

Binary file modified bin/hjw/maintenanceannouncer/Listener.class
Binary file not shown.
Binary file modified bin/hjw/maintenanceannouncer/Main.class
Binary file not shown.
9 changes: 6 additions & 3 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
16 changes: 8 additions & 8 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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:
Expand All @@ -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.
Expand All @@ -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.
Expand Down
20 changes: 13 additions & 7 deletions src/hjw/maintenanceannouncer/Listener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
}
}
}
20 changes: 10 additions & 10 deletions src/hjw/maintenanceannouncer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)]";
Expand All @@ -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.
Expand Down Expand Up @@ -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()) {
Expand All @@ -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!");

}

Expand All @@ -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!");

}

Expand All @@ -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!");

}

Expand All @@ -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() {
Expand Down

0 comments on commit 8e51f13

Please sign in to comment.