Skip to content

Commit

Permalink
6.0 RC2!
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrweatherman208 committed Oct 21, 2021
1 parent 4505df5 commit fc46be0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
Binary file modified bin/hjw/maintenanceannouncer/Main.class
Binary file not shown.
4 changes: 3 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Maintenance not ongoing message: '&f The server is not currently undergoing main
Prefix: '&c[Maintenance Announcer]'
Admin only prefix: '&c[Maintenance Announcer (ADMIN ONLY)]'
Sent to all admins message: '&a Sent to ALL admins!'
Two arguments are needed message: '&a2 arguments are needed!'
Two arguments are needed message: '&a 2 arguments are needed!'

# Made with love in Tennessee.
# Copyright 2016 - 2021 Hayden Watson.
# Maintenance Announcer is available under the MIT license.
31 changes: 19 additions & 12 deletions src/hjw/maintenanceannouncer/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,8 @@ public boolean onCommand (CommandSender sender, Command cmd, String label, Strin
switch (args.length) {
case 0: // User just used "/maintenance"

// Check if user can see if admin only maintenance has started.
if(sender.hasPermission("hjw.maintenanceannouncer.adminsee")) {
if (getConfig().getBoolean("adminOnlyMaintenance") == true) {
// Tell commandSender that admin only maintenance to the server is going.
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', adminOnlyPrefix + getConfig().getString("Maintenance ongoing message")));
}
}

// Check if user can see if maintenance has started.
if(sender.hasPermission("hjw.maintenanceannouncer.see")) {

if (getConfig().getBoolean("Maintenance") == true) {
// Tell commandSender that maintenance to the server is ongoing.
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + getConfig().getString("Maintenance ongoing message")));
Expand All @@ -81,6 +72,14 @@ public boolean onCommand (CommandSender sender, Command cmd, String label, Strin
}
}

// Check if user can see if admin only maintenance has started.
if(sender.hasPermission("hjw.maintenanceannouncer.adminsee")) {
if (getConfig().getBoolean("adminOnlyMaintenance") == true) {
// Tell commandSender that admin only maintenance to the server is going.
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', adminOnlyPrefix + getConfig().getString("Maintenance ongoing message")));
}
}

return true;
case 1: // User just used one argument in their command.

Expand Down Expand Up @@ -138,6 +137,7 @@ public boolean onCommand (CommandSender sender, Command cmd, String label, Strin
// Invalid Argument
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', adminOnlyPrefix + getConfig().getString("Invalid argument message")));
case 2: // User used 2 arguments in their command.

// Check for "admin" being the first argument.
if (args[0].equalsIgnoreCase("admin")) {
if (args[1].equalsIgnoreCase("start") || (args[1].equalsIgnoreCase("begin"))) {
Expand All @@ -155,11 +155,18 @@ public boolean onCommand (CommandSender sender, Command cmd, String label, Strin
}
return true;
}
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', adminOnlyPrefix + getConfig().getString("Invalid argument message")));

// Give user message that their argument was wrong.
if (sender.hasPermission("hjw.maintenanceannouncer.see")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + getConfig().getString("Invalid argument message")));
}
}
return true;
default: sender.sendMessage(ChatColor.translateAlternateColorCodes('&', adminOnlyPrefix + getConfig().getString("Two arguments are needed message")));

default:
// Runs if the user puts a bunch of different arguments.
if (sender.hasPermission("hjw.maintenanceannouncer.see")) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + getConfig().getString("Two arguments are needed message")));
}
}
}
return false;
Expand Down

0 comments on commit fc46be0

Please sign in to comment.