mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Rewriten how dependency is handled
This commit is contained in:
parent
b512d8f732
commit
aad9974baf
10 changed files with 56 additions and 19 deletions
|
|
@ -27,7 +27,7 @@ import org.bukkit.inventory.ItemStack
|
|||
import org.bukkit.inventory.meta.Repairable
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.group.ConflictType
|
||||
import xyz.alexcrea.cuanvil.packet.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager
|
||||
import xyz.alexcrea.cuanvil.recipe.AnvilCustomRecipe
|
||||
import xyz.alexcrea.cuanvil.util.UnitRepairUtil.getRepair
|
||||
import kotlin.math.min
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ import org.bukkit.plugin.java.JavaPlugin
|
|||
import xyz.alexcrea.cuanvil.command.EditConfigExecutor
|
||||
import xyz.alexcrea.cuanvil.command.ReloadExecutor
|
||||
import xyz.alexcrea.cuanvil.config.ConfigHolder
|
||||
import xyz.alexcrea.cuanvil.dependency.DependencyManager
|
||||
import xyz.alexcrea.cuanvil.enchant.WrappedEnchantment
|
||||
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui
|
||||
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant
|
||||
import xyz.alexcrea.cuanvil.listener.ChatEventListener
|
||||
import xyz.alexcrea.cuanvil.packet.NoProtocoLib
|
||||
import xyz.alexcrea.cuanvil.packet.PacketManager
|
||||
import xyz.alexcrea.cuanvil.packet.ProtocoLibWrapper
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager
|
||||
import xyz.alexcrea.cuanvil.update.Update_1_21
|
||||
import xyz.alexcrea.cuanvil.util.Metrics
|
||||
import java.io.File
|
||||
|
|
@ -76,8 +75,6 @@ class CustomAnvil : JavaPlugin() {
|
|||
|
||||
}
|
||||
|
||||
lateinit var packetManager: PacketManager
|
||||
|
||||
/**
|
||||
* Setup plugin for use
|
||||
*/
|
||||
|
|
@ -97,11 +94,8 @@ class CustomAnvil : JavaPlugin() {
|
|||
// Register enchantments
|
||||
WrappedEnchantment.registerEnchantments()
|
||||
|
||||
// Load ProtocolLib dependency if exist
|
||||
packetManager = if(pluginManager.isPluginEnabled("ProtocolLib"))
|
||||
{ ProtocoLibWrapper(); }
|
||||
else
|
||||
{ NoProtocoLib(); }
|
||||
// Load dependency
|
||||
DependencyManager.loadDependency()
|
||||
|
||||
// Load chat listener
|
||||
chatListener = ChatEventListener()
|
||||
|
|
@ -115,7 +109,7 @@ class CustomAnvil : JavaPlugin() {
|
|||
Update_1_21.handleUpdate()
|
||||
|
||||
// Load gui constants //TODO maybe something better later
|
||||
MainConfigGui.getInstance().init(this.packetManager)
|
||||
MainConfigGui.getInstance().init(DependencyManager.packetManager)
|
||||
GuiSharedConstant.loadConstants()
|
||||
|
||||
// Load metrics
|
||||
|
|
@ -125,7 +119,7 @@ class CustomAnvil : JavaPlugin() {
|
|||
prepareCommand()
|
||||
|
||||
server.pluginManager.registerEvents(
|
||||
AnvilEventListener(packetManager),
|
||||
AnvilEventListener(DependencyManager.packetManager),
|
||||
this
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
import org.bukkit.Bukkit
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.NoProtocoLib
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.PacketManager
|
||||
import xyz.alexcrea.cuanvil.dependency.protocolib.ProtocoLibWrapper
|
||||
|
||||
object DependencyManager {
|
||||
|
||||
lateinit var packetManager: PacketManager
|
||||
var enchantmentSquaredCompatibility: EnchantmentSquaredDependency? = null;
|
||||
|
||||
fun loadDependency(){
|
||||
val pluginManager = Bukkit.getPluginManager();
|
||||
|
||||
// ProtocolLib dependency
|
||||
packetManager =
|
||||
if(pluginManager.isPluginEnabled("ProtocolLib")) ProtocoLibWrapper();
|
||||
else NoProtocoLib();
|
||||
|
||||
// Enchantment Squared dependency
|
||||
enchantmentSquaredCompatibility =
|
||||
if(pluginManager.isPluginEnabled("EnchantsSquared")) EnchantmentSquaredDependency()
|
||||
else null
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package xyz.alexcrea.cuanvil.dependency
|
||||
|
||||
class EnchantmentSquaredDependency {
|
||||
|
||||
fun registerEnchantements(){
|
||||
//TODO
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.alexcrea.cuanvil.packet
|
||||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.alexcrea.cuanvil.packet
|
||||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.alexcrea.cuanvil.packet
|
||||
package xyz.alexcrea.cuanvil.dependency.protocolib
|
||||
|
||||
import com.comphenix.protocol.PacketType
|
||||
import com.comphenix.protocol.ProtocolLibrary
|
||||
Loading…
Add table
Add a link
Reference in a new issue