Initialization :
Code (Java):
[INDENT
]
private
final MinecraftAPI minecraftAPI
;
[
/INDENT
]
private
boolean initializeKaraAPI
(
)
{
return
(minecraftAPI
!=
null
)
?
(
new
Object
(
)
{
boolean status
(
)
{
return
true
;
}
}
).
status
(
)
:
(
new
Object
(
)
{
boolean status
(
)
{
getLogger
(
).
severe
(
"No KaraAPI"
)
;
return
false
;
}
}
).
status
(
)
;
}
[INDENT
]@Override
public
void onEnable
(
)
{
[INDENT
]
this.
minecraftAPI
= MinecraftAPI.
getINSTANCE
(
)
;
if
(initializeKaraAPI
(
)
{
[INDENT
]
// Code using the API goes here[/INDENT]
}
[
/INDENT
]
}
[
/INDENT
]
Methods:
- Creating a debug message :
Code (Java):
private DebugMessageAPI debugMessage
;
@Override
public
void onEnable
(
)
{
// Other Code goes here
if
(minecraftAPI
!=
null
)
debugMessage
= minecraftAPI.
getDebugMessageAPI
(
)
;
else debugMessage
=
new DebugMessageAPI
(
)
;
if
(initializeKaraAPI
(
)
)
{
if
(debugMessage
!=
null
)
{
debugMessage.
StatutPlugin
(StatutMessageList.
ENABLE, getDescription
(
), getLogger
(
)
)
;
}
}
}
Creating a Configuration File:
To streamline the creation and management of configuration files for your plugin, utilize the YourConfig class provided below. This class extends ConfigManager, offering comprehensive support for configuration file operations.
Code (Java):
public
class YourConfig
extends ConfigManager
{
public YourConfig
(
)
{
super
(MainInstance, filepath, filename, commonkey
)
;
}
@Override
public
void initBaseConfig
(
)
{
// Base Configuration Initialization goes here
}
}
Methods:
- initBaseConfig(): Override this method to initialize base configurations for your plugin.
Additional Information:
- If filepath is provided and not empty, the configuration file will be located in the plugins folder rather than the plugin's base folder.
- Although commonkey can be left blank, assigning a value is recommended (though untested).
Note:
-
- If filepath is provided and not empty, the configuration file will be located in the plugins folder rather than the plugin's base folder.
- Although commonkey can be left blank, assigning a value is recommended (though untested).
These are the essential methods provided by the
ConfigManager class:
- initBaseConfig()
- createFile()
- getYml()
- getNameFile()
- getFile()
- getKey()
- getFileExists()
- getYamlSection()
- getYamlSection(String path)
- getYamlSectionInt(String index)
- getYamlSectionDouble(String index)
- getYamlSectionString(String index)
- getYamlSectionList(String index)
- getYamlConfigurationSectionList(String index)
- setYamlConfig(String index, int value)
- setYamlConfig(String index, double value)
- setYamlConfig(String index, String value)
- saveConfig()
- loadConfig()