me.armar.plugins.autorank.playerchecker.requirement
Class Requirement

java.lang.Object
  extended by me.armar.plugins.autorank.playerchecker.requirement.Requirement
Direct Known Subclasses:
BlocksBrokenRequirement, BlocksPlacedRequirement, DamageTakenRequirement, ExpRequirement, FactionPowerRequirement, GamemodeRequirement, HasItemRequirement, LocationRequirement, MobKillsRequirement, MoneyRequirement, PlayerKillsRequirement, TimeRequirement, TotalVotesRequirement, WorldRequirement

public abstract class Requirement
extends java.lang.Object

Whenever you want to create a new requirement, you'll have to extend this class. Every requirement needs the following:

- Option to check if the requirement is optional.

- Results that will be performed when the requirement is completed. These results have to be one of the results registered in Autorank.

- Option to check if the requirement will auto complete.

Author:
Staartvin

Field Summary
private  Autorank autorank
           
 
Constructor Summary
Requirement()
           
 
Method Summary
 Autorank getAutorank()
           
abstract  java.lang.String getDescription()
          Gets the description of the requirement Make sure this is always a translatable message.
abstract  java.lang.String getProgress(org.bukkit.entity.Player player)
          Gets the current progress of a player on a certain requirement.
abstract  int getReqId()
          Get the id of this requirement.
abstract  java.util.List<Result> getResults()
          Gets the results when this requirement is finished
 boolean isCompleted(int reqID, java.lang.String playerName)
          Check if the requirement is completed already.
abstract  boolean isOptional()
          Is this an optional requirement?
abstract  boolean meetsRequirement(org.bukkit.entity.Player player)
          Does it meet the requirements?
 void setAutorank(Autorank autorank)
           
abstract  boolean setOptions(java.lang.String[] options, boolean optional, java.util.List<Result> results, boolean autoComplete, int reqId)
          Setup requirement specific objects.
 java.lang.String toString()
           
abstract  boolean useAutoCompletion()
          Use auto completion for this?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

autorank

private Autorank autorank
Constructor Detail

Requirement

public Requirement()
Method Detail

setAutorank

public final void setAutorank(Autorank autorank)

getAutorank

public final Autorank getAutorank()

setOptions

public abstract boolean setOptions(java.lang.String[] options,
                                   boolean optional,
                                   java.util.List<Result> results,
                                   boolean autoComplete,
                                   int reqId)
Setup requirement specific objects. This method is called when Autorank sets up its config. The requirement id, auto completion and optional values are assigned automatically.

Parameters:
options - String[] containing values of the config
optional - Is this an optional requirement?
results - List containing results
autoComplete - Will this auto complete?
reqId - id of the requirement
Returns:

meetsRequirement

public abstract boolean meetsRequirement(org.bukkit.entity.Player player)
Does it meet the requirements? This method gets called when someone does /ar check or /ar complete. It should always contain the following line:

if (isCompleted(getReqId(), player.getName())) { return true; }

Parameters:
player - Player to check for
Returns:
true if it meets the requirements; false otherwise

getDescription

public abstract java.lang.String getDescription()
Gets the description of the requirement Make sure this is always a translatable message.

Returns:
string containing description (in locale language)

isOptional

public abstract boolean isOptional()
Is this an optional requirement? (Not a main requirement)

Returns:
true when optional; false otherwise.

getResults

public abstract java.util.List<Result> getResults()
Gets the results when this requirement is finished

Returns:
A list of results that has to be done.

useAutoCompletion

public abstract boolean useAutoCompletion()
Use auto completion for this?

Returns:
true when auto complete; false otherwise

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isCompleted

public final boolean isCompleted(int reqID,
                                 java.lang.String playerName)
Check if the requirement is completed already.

Parameters:
reqID - Requirement id.
playerName - Player to check for
Returns:
true if completed, false otherwise.

getProgress

public abstract java.lang.String getProgress(org.bukkit.entity.Player player)
Gets the current progress of a player on a certain requirement.

Parameters:
player - Player to check for
Returns:
String containing the progress

getReqId

public abstract int getReqId()
Get the id of this requirement. This should get assigned automatically at setOptions(). The id should always be dynamic.

Returns:
id