mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
alpha version up & cleanup code.
This commit is contained in:
parent
1b83c8db81
commit
00fba2f4b0
40 changed files with 893 additions and 718 deletions
|
|
@ -24,17 +24,22 @@ class CustomAnvil : JavaPlugin() {
|
|||
|
||||
// Permission string required to use the plugin's features
|
||||
const val affectedByPluginPermission = "ca.affected"
|
||||
|
||||
// Permission string required to bypass enchantment conflicts test
|
||||
const val bypassFusePermission = "ca.bypass.fuse"
|
||||
|
||||
// Permission string required to bypass enchantment conflicts test
|
||||
const val bypassLevelPermission = "ca.bypass.level"
|
||||
|
||||
// Permission string required to reload the config
|
||||
const val commandReloadPermission = "ca.command.reload"
|
||||
|
||||
// Permission string required to edit the plugin's config
|
||||
const val editConfigPermission = "ca.config.edit"
|
||||
|
||||
// Command Name to reload the config
|
||||
const val commandReloadName = "anvilconfigreload"
|
||||
|
||||
// Test command name
|
||||
const val commandTestName = "customanvilconfig"
|
||||
|
||||
|
|
@ -71,7 +76,7 @@ class CustomAnvil : JavaPlugin() {
|
|||
|
||||
// Disable old plugin name if exist
|
||||
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
|
||||
if(potentialPlugin != null){
|
||||
if (potentialPlugin != null) {
|
||||
Bukkit.getPluginManager().disablePlugin(potentialPlugin)
|
||||
logger.warning("An old version of this plugin was detected")
|
||||
logger.warning("Please note CustomAnvil is a more recent version of UnsafeEnchantsPlus")
|
||||
|
|
@ -83,7 +88,7 @@ class CustomAnvil : JavaPlugin() {
|
|||
|
||||
// Load config
|
||||
val success = ConfigHolder.loadConfig()
|
||||
if(!success) return
|
||||
if (!success) return
|
||||
|
||||
// Load metrics
|
||||
val metric = Metrics(this, bstatsPluginId)
|
||||
|
|
@ -98,26 +103,28 @@ class CustomAnvil : JavaPlugin() {
|
|||
)
|
||||
}
|
||||
|
||||
fun reloadResource(resourceName: String,
|
||||
hardFailSafe:Boolean = true): YamlConfiguration?{
|
||||
fun reloadResource(
|
||||
resourceName: String,
|
||||
hardFailSafe: Boolean = true
|
||||
): YamlConfiguration? {
|
||||
// Save default resource
|
||||
val file = File(dataFolder,resourceName)
|
||||
if(!file.exists()){
|
||||
saveResource(resourceName,false)
|
||||
val file = File(dataFolder, resourceName)
|
||||
if (!file.exists()) {
|
||||
saveResource(resourceName, false)
|
||||
}
|
||||
// Load resource
|
||||
val yamlConfig = YamlConfiguration()
|
||||
try {
|
||||
val configReader = FileReader(file)
|
||||
yamlConfig.load(configReader)
|
||||
} catch (test: Exception){
|
||||
if(hardFailSafe){
|
||||
} catch (test: Exception) {
|
||||
if (hardFailSafe) {
|
||||
// This is important and may impact gameplay if it does not load.
|
||||
// Failsafe is to stop the plugin
|
||||
logger.severe("Resource $resourceName Could not be load or reload.")
|
||||
logger.severe("Disabling plugin.")
|
||||
Bukkit.getPluginManager().disablePlugin(this)
|
||||
}else{
|
||||
} else {
|
||||
logger.warning("Resource $resourceName Could not be load or reload.")
|
||||
}
|
||||
return null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue