Package org.kikikan.deadbymoonlight
Class Configurable
- java.lang.Object
-
- org.kikikan.deadbymoonlight.Configurable
-
- All Implemented Interfaces:
java.lang.Comparable<Configurable>
- Direct Known Subclasses:
GameComponent
,Item
,Perk
public abstract class Configurable extends java.lang.Object implements java.lang.Comparable<Configurable>
Represents an Object that must have a config file in your plugin's folder.
-
-
Constructor Summary
Constructors Constructor Description Configurable(org.bukkit.plugin.java.JavaPlugin plugin)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Configurable o)
boolean
equals(java.lang.Object obj)
protected java.util.Map<java.lang.String,java.lang.Object>
getAllValuesFromConfig()
protected boolean
getDefaultEnabled()
If this function returns true this Configurable will be enabled by default in the config file.abstract java.lang.String
getDescription()
The description of the Configurable, which will appear when the player hovers their cursor on the chat.abstract java.lang.String
getDisplayName()
The name that will be shown to playersprotected abstract java.lang.String
getFileName()
Gets the name of the config file.java.lang.String
getFormattedName()
Removes every whitespace in the name.abstract java.lang.String
getName()
The name of each Configurable has to be unique.org.bukkit.plugin.java.JavaPlugin
getPlugin()
protected java.lang.String
getRequirements()
Used for displaying the Configurable's requirements in the console ifgetDefaultEnabled()
returnsfalse
.protected java.lang.Object
getValueFromConfig(java.lang.String id, java.lang.Object defaultValue)
Gets the value with the specified id from the config file.int
hashCode()
boolean
isEnabled()
Gets the enabled state of the Configurable.net.md_5.bungee.api.chat.TextComponent
toTextComponent()
Generates Text that will have the description in its hoverevent.
-
-
-
Method Detail
-
getName
public abstract java.lang.String getName()
The name of each Configurable has to be unique.- Returns:
- The unique name of the Configurable Object
-
getDisplayName
public abstract java.lang.String getDisplayName()
The name that will be shown to players- Returns:
- The (translated) name that will be shown to players
-
getDescription
public abstract java.lang.String getDescription()
The description of the Configurable, which will appear when the player hovers their cursor on the chat.- Returns:
- An informative description
-
getFileName
protected abstract java.lang.String getFileName()
Gets the name of the config file.- Returns:
- The name of the config file.
-
getDefaultEnabled
protected boolean getDefaultEnabled()
If this function returns true this Configurable will be enabled by default in the config file.- Returns:
- The condition telling whether the environment met the requirements of this perk.
-
getRequirements
protected java.lang.String getRequirements()
Used for displaying the Configurable's requirements in the console ifgetDefaultEnabled()
returnsfalse
.;- Returns:
- The requirements in String form.
-
getFormattedName
public final java.lang.String getFormattedName()
Removes every whitespace in the name. This is what will be used for identification, so it must be unique.- Returns:
- The name without any whitespace.
-
isEnabled
public final boolean isEnabled()
Gets the enabled state of the Configurable. Only reads the file when you add the Configurable using the API, so you can use it as many times as you want during runtime without worrying about performance.- Returns:
- True, if the Configurable is enabled.
-
getValueFromConfig
protected final java.lang.Object getValueFromConfig(java.lang.String id, java.lang.Object defaultValue)
Gets the value with the specified id from the config file. As this method opens the file every time you call it, it's recommended that you only call this once for every value and save the values intostatic
fields of your class.- Parameters:
id
- The ID of the value you're looking for.defaultValue
- If the value is not found in the config file this value will get returned and written into the file.- Returns:
- The value found in the config file or the default value if nothing was found
- Throws:
java.lang.IllegalArgumentException
- If id is equal to"enabled"
as that is handled usingisEnabled()
andsetEnabled()
-
getAllValuesFromConfig
protected final java.util.Map<java.lang.String,java.lang.Object> getAllValuesFromConfig()
-
getPlugin
public final org.bukkit.plugin.java.JavaPlugin getPlugin()
-
toTextComponent
public final net.md_5.bungee.api.chat.TextComponent toTextComponent()
Generates Text that will have the description in its hoverevent.- Returns:
- The TextComponent of the Configurable
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public final int compareTo(Configurable o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Configurable>
-
-