mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Dependency enchantment registering now use the api.
This commit is contained in:
parent
6f1e53f68e
commit
365d0ea847
6 changed files with 25 additions and 33 deletions
|
|
@ -5,7 +5,6 @@ import org.bukkit.NamespacedKey;
|
|||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager;
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.CAVanillaEnchantment;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -38,13 +37,6 @@ public class CAEnchantmentRegistry {
|
|||
register(new CAVanillaEnchantment(enchantment));
|
||||
}
|
||||
|
||||
if(DependencyManager.INSTANCE.getEnchantmentSquaredCompatibility() != null){
|
||||
DependencyManager.INSTANCE.getEnchantmentSquaredCompatibility().registerEnchantments();
|
||||
}
|
||||
if(DependencyManager.INSTANCE.getEcoEnchantCompatibility() != null){
|
||||
DependencyManager.INSTANCE.getEcoEnchantCompatibility().registerEnchantments();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
|
|||
new IncludeGroup("new_group"),
|
||||
0);
|
||||
|
||||
ConfigHolder.CONFLICT_HOLDER.getConflictManager().getConflictList().add(conflict);
|
||||
ConfigHolder.CONFLICT_HOLDER.getConflictManager().addConflict(conflict);
|
||||
|
||||
// save empty conflict in config
|
||||
String[] emptyStringArray = new String[0];
|
||||
|
|
|
|||
|
|
@ -80,8 +80,6 @@ class CustomAnvil : JavaPlugin() {
|
|||
override fun onEnable() {
|
||||
instance = this
|
||||
|
||||
val pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
// Disable old plugin name if exist
|
||||
val potentialPlugin = Bukkit.getPluginManager().getPlugin("UnsafeEnchantsPlus")
|
||||
if (potentialPlugin != null) {
|
||||
|
|
@ -93,13 +91,9 @@ class CustomAnvil : JavaPlugin() {
|
|||
// Load dependency
|
||||
DependencyManager.loadDependency()
|
||||
|
||||
// Register enchantments
|
||||
// Register vanilla enchantments
|
||||
CAEnchantmentRegistry.getInstance().registerStartupEnchantments()
|
||||
|
||||
// Load chat listener
|
||||
chatListener = ChatEventListener()
|
||||
pluginManager.registerEvents(chatListener, this)
|
||||
|
||||
// Load config
|
||||
val success = ConfigHolder.loadConfig()
|
||||
if (!success) return
|
||||
|
|
@ -107,23 +101,26 @@ class CustomAnvil : JavaPlugin() {
|
|||
// temporary: handle 1.21 update
|
||||
Update_1_21.handleUpdate()
|
||||
|
||||
// Handle custom enchant config
|
||||
DependencyManager.handleConfigChanges(this)
|
||||
|
||||
// Load gui constants //TODO maybe something better later
|
||||
MainConfigGui.getInstance().init(DependencyManager.packetManager)
|
||||
GuiSharedConstant.loadConstants()
|
||||
|
||||
// Load metrics
|
||||
Metrics(this, bstatsPluginId)
|
||||
// Register enchantment of compatible plugin and load configuration change.
|
||||
DependencyManager.registerEnchantments()
|
||||
DependencyManager.handleCompatibilityConfig(this)
|
||||
|
||||
// Add commands to reload the plugin
|
||||
prepareCommand()
|
||||
|
||||
server.pluginManager.registerEvents(
|
||||
AnvilEventListener(DependencyManager.packetManager),
|
||||
this
|
||||
)
|
||||
// Load chat listener
|
||||
chatListener = ChatEventListener()
|
||||
server.pluginManager.registerEvents(chatListener, this)
|
||||
|
||||
// Register anvil events
|
||||
server.pluginManager.registerEvents(AnvilEventListener(DependencyManager.packetManager), this)
|
||||
|
||||
// Load metrics
|
||||
Metrics(this, bstatsPluginId)
|
||||
}
|
||||
|
||||
fun reloadResource(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ object DependencyManager {
|
|||
|
||||
}
|
||||
|
||||
fun handleConfigChanges(plugin: Plugin) {
|
||||
fun handleCompatibilityConfig(plugin: Plugin) {
|
||||
val folder = File(plugin.dataFolder, "compatibility")
|
||||
|
||||
enchantmentSquaredCompatibility?.registerPluginConfiguration()
|
||||
|
|
@ -53,4 +53,10 @@ object DependencyManager {
|
|||
defaultConfig["enchant_values.${enchantment.key.key}.book"] = rarity.bookValue
|
||||
}
|
||||
|
||||
fun registerEnchantments() {
|
||||
enchantmentSquaredCompatibility?.registerEnchantments()
|
||||
ecoEnchantCompatibility?.registerEnchantments()
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class EcoEnchantDependency(private val ecoEnchantPlugin: Plugin) {
|
|||
doSave = true
|
||||
config[testPath] = true
|
||||
|
||||
DependencyManager.writeDefaultConfig(defaultConfig, enchantment)
|
||||
DependencyManager.writeDefaultConfig(defaultConfig, enchantment) //TODO move to api register
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import org.bukkit.event.inventory.PrepareAnvilEvent
|
|||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.plugin.Plugin
|
||||
import xyz.alexcrea.cuanvil.api.ConflictBuilder
|
||||
import xyz.alexcrea.cuanvil.api.EnchantmentApi
|
||||
import xyz.alexcrea.cuanvil.api.MaterialGroupApi
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment
|
||||
|
|
@ -36,11 +37,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
|||
|
||||
fun registerEnchantments(){
|
||||
for (enchant in CustomEnchantManager.getInstance().allEnchants.values) {
|
||||
CAEnchantmentRegistry.getInstance().register(
|
||||
CAEnchantSquaredEnchantment(
|
||||
enchant
|
||||
)
|
||||
)
|
||||
EnchantmentApi.registerEnchantment(CAEnchantSquaredEnchantment(enchant))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -81,7 +78,7 @@ class EnchantmentSquaredDependency(private val enchantmentSquaredPlugin: Plugin)
|
|||
}
|
||||
|
||||
// Write default level limit and xp cost
|
||||
for (enchantment in esEnchantments) {
|
||||
for (enchantment in esEnchantments) { //TODO move to api register
|
||||
DependencyManager.writeDefaultConfig(defaultConfig, enchantment)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue