me.armar.plugins.autorank.warningmanager
Class WarningManager

java.lang.Object
  extended by me.armar.plugins.autorank.warningmanager.WarningManager

public class WarningManager
extends java.lang.Object

This class handles all warning message that are displayed when something is wrong with Autorank. Instead of disabling Autorank, it should display warnings when an admin joins.

Warnings will be stored in a list. Every warning will have its own priority. Whenever an player joins that has the permission 'autorank.warning.notice', the warning manager will grab the warning with the highest priority and show it to the player. This way the admin knows something is up and he has to fix it.

The highest priority warning will be saved as a message so it doesn't have to be recalculated every time someone joins. It will be determined when the first player that has the correct permission joins.

The priority level goes from 1 to 10, with 1 being the lowest priority and thus no need for attention, and 10 the highest, which represents critical failures.

The warning message is stored as a string including the priority level. The warnings list stores the strings in no particular order. The full string can be: "AdvancedConfig.yml contains incorrect groups!>10". The '>' identifier splits the real warning message and the priority. If this identifier is not found, the priority will be set to 1.

NOTE:
Warnings cannot be unregistered. The only way to remove the warnings is to fix them so they don't ever get registered.

Author:
Staartvin

Field Summary
private  java.lang.String highestPriorityWarn
           
private  java.util.List<java.lang.String> warnings
           
 
Constructor Summary
WarningManager()
           
 
Method Summary
private  java.lang.String findHighestPriorityWarning()
           
private  java.lang.String findMessage(java.lang.String warning)
           
private  int findPriority(java.lang.String warning)
           
 java.lang.String getHighestWarning()
          Returns warning with the highest priority level.
 void registerWarning(java.lang.String message, int priority)
          Register a new warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

highestPriorityWarn

private java.lang.String highestPriorityWarn

warnings

private java.util.List<java.lang.String> warnings
Constructor Detail

WarningManager

public WarningManager()
Method Detail

registerWarning

public void registerWarning(java.lang.String message,
                            int priority)
Register a new warning. Priority level will be capped if this number is too high or too low.

Parameters:
message - Warning message description
priority - Priority level (1 - 10).

getHighestWarning

public java.lang.String getHighestWarning()
Returns warning with the highest priority level.

Returns:
highest priority warning message; returns null if no warning was found

findHighestPriorityWarning

private java.lang.String findHighestPriorityWarning()

findPriority

private int findPriority(java.lang.String warning)

findMessage

private java.lang.String findMessage(java.lang.String warning)