diff --git a/core/src/main/java/top/iseason/bukkittemplate/runtime/loader/IsolatedClassLoader.java b/core/src/main/java/top/iseason/bukkittemplate/runtime/loader/IsolatedClassLoader.java index c9e0a3bf..c2e6c888 100644 --- a/core/src/main/java/top/iseason/bukkittemplate/runtime/loader/IsolatedClassLoader.java +++ b/core/src/main/java/top/iseason/bukkittemplate/runtime/loader/IsolatedClassLoader.java @@ -1,7 +1,7 @@ package top.iseason.bukkittemplate.runtime.loader; +import javax.management.loading.MLet; import java.net.URL; -import java.net.URLClassLoader; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -12,7 +12,7 @@ *
插件自定义的加载器,用于隔离依赖
*本ClassLoader将优先加载urls中有的class,而不是双亲委托
*/ -public class IsolatedClassLoader extends URLClassLoader { +public class IsolatedClassLoader extends MLet { /** * 自由添加黑名单 */ @@ -26,6 +26,10 @@ public IsolatedClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); } + public IsolatedClassLoader() { + super(); + } + @Override protected Class> loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { diff --git a/core/src/main/kotlin/top/iseason/bukkittemplate/config/DatabaseConfig.kt b/core/src/main/kotlin/top/iseason/bukkittemplate/config/DatabaseConfig.kt index 9eb922d1..4cb55cd3 100644 --- a/core/src/main/kotlin/top/iseason/bukkittemplate/config/DatabaseConfig.kt +++ b/core/src/main/kotlin/top/iseason/bukkittemplate/config/DatabaseConfig.kt @@ -29,7 +29,11 @@ object DatabaseConfig : SimpleYAMLConfig() { @Comment("", "修改完配置保存时是否自动重连数据库") var autoReload = true - @Comment("", "数据库类型: 支持 MySQL、MariaDB、SQLite、Oracle、PostgreSQL、SQLServer") + @Comment( + "", + "数据库驱动类型: 支持 MySQL、MariaDB、SQLite、Oracle、PostgreSQL、SQLServer", + "如果你的 MySQL 总是连不上请将驱动类型改为 MariaDB,它支持连接到mysql" + ) @Key var database_type = "SQLite" @@ -41,7 +45,11 @@ object DatabaseConfig : SimpleYAMLConfig() { @Key var database_name = "database_${BukkitTemplate.getPlugin().name}" - @Comment("", "jdbcUrl 最后面的参数, 紧跟在database-name后面,请注意添加分隔符", "") + @Comment( + "", + "jdbcUrl 最后面的参数, 紧跟在database-name后面,请注意添加分隔符", + "如果你的mysql提示 ssl 有关的信息请添加: '?useSSL=false'" + ) @Key var params = "" @@ -168,20 +176,20 @@ object DatabaseConfig : SimpleYAMLConfig() { } val config = when (database_type) { "MySQL" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("mysql:mysql-connector-java:8.0.32") + runtimeManager.downloadADependency("mysql:mysql-connector-java:8.0.30") jdbcUrl = "jdbc:mysql://$address/$database_name$params" //可能兼容旧的mysql驱动 driverClassName = "com.mysql.jdbc.Driver" } "MariaDB" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("org.mariadb.jdbc:mariadb-java-client:3.1.2") + runtimeManager.downloadADependency("org.mariadb.jdbc:mariadb-java-client:3.1.3") jdbcUrl = "jdbc:mariadb://$address/$database_name$params" driverClassName = "org.mariadb.jdbc.Driver" } "SQLite" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("org.xerial:sqlite-jdbc:3.41.0.0") + runtimeManager.downloadADependencyAssembly("org.xerial:sqlite-jdbc:3.41.2.0") jdbcUrl = "jdbc:sqlite:$address$params" driverClassName = "org.sqlite.JDBC" } @@ -193,19 +201,19 @@ object DatabaseConfig : SimpleYAMLConfig() { // } "PostgreSQL" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9") + runtimeManager.downloadADependency("com.impossibl.pgjdbc-ng:pgjdbc-ng:0.8.9") jdbcUrl = "jdbc:pgsql://$address/$database_name$params" driverClassName = "com.impossibl.postgres.jdbc.PGDriver" } "Oracle" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("com.oracle.database.jdbc:ojdbc8:21.9.0.0") + runtimeManager.downloadADependency("com.oracle.database.jdbc:ojdbc8:21.9.0.0") jdbcUrl = "dbc:oracle:thin:@//$address/$database_name$params" driverClassName = "oracle.jdbc.OracleDriver" } "SQLServer" -> HikariConfig(props).apply { - runtimeManager.downloadADependencyAssembly("com.microsoft.sqlserver:mssql-jdbc:11.2.3.jre8") + runtimeManager.downloadADependency("com.microsoft.sqlserver:mssql-jdbc:11.2.3.jre8") jdbcUrl = "jdbc:sqlserver://$address;DatabaseName=$database_name$params" driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver" } diff --git a/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/SakuraBindAPI.kt b/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/SakuraBindAPI.kt index 1f338cfa..8fed1f43 100644 --- a/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/SakuraBindAPI.kt +++ b/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/SakuraBindAPI.kt @@ -2,6 +2,7 @@ package top.iseason.bukkit.sakurabind import io.github.bananapuncher714.nbteditor.NBTEditor import org.bukkit.Bukkit +import org.bukkit.OfflinePlayer import org.bukkit.block.Block import org.bukkit.entity.Entity import org.bukkit.entity.HumanEntity @@ -315,8 +316,10 @@ object SakuraBindAPI { */ @JvmStatic fun getOwnerName(uuid: UUID): String? { - val player = Bukkit.getPlayer(uuid) ?: Bukkit.getOfflinePlayer(uuid) - return if (player.hasPlayedBefore()) player.name else null + var player: OfflinePlayer? = Bukkit.getPlayer(uuid) + if (player != null) return player.name + else player = Bukkit.getOfflinePlayer(uuid) + return if (player.hasPlayedBefore()) player.name else uuid.toString() } /** diff --git a/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/config/GlobalSettings.kt b/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/config/GlobalSettings.kt index 743cd44b..c19618d1 100644 --- a/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/config/GlobalSettings.kt +++ b/plugin/src/main/kotlin/top/iseason/bukkit/sakurabind/config/GlobalSettings.kt @@ -61,19 +61,19 @@ object GlobalSettings : SimpleYAMLConfig() { @Key("item-deny.interact-left@") @Comment("", "手上拿着绑定物品时禁止左键交互") - var item_deny__interact_left = false + var item_deny__interact_left = true @Key("item-deny.interact-right@") @Comment("", "手上拿着绑定物品时禁止右键交互") - var item_deny__interact_right = false + var item_deny__interact_right = true @Key("item-deny.interact-entity@") @Comment("", "禁止实体交互(攻击或右键)") - var item_deny__interact_entity = false + var item_deny__interact_entity = true @Key("item-deny.armor-stand@") @Comment("", "禁止盔甲架交互") - var item_deny__armor_stand = false + var item_deny__armor_stand = true @Key @Comment("", "禁止丢弃") @@ -83,11 +83,11 @@ object GlobalSettings : SimpleYAMLConfig() { @Comment("", "禁止含有绑定物品的容器被玩家破坏") var item_deny__container_break = false - @Key("item-deny.pickup@") + @Key() @Comment("", "禁止捡起") var item_deny__pickup = false - @Key("item-deny.click@") + @Key() @Comment("", "禁止拿走绑定物品") var item_deny__click = false @@ -156,15 +156,15 @@ object GlobalSettings : SimpleYAMLConfig() { @Key("block-deny.break@") @Comment("", "禁止方块物品被破坏") - var block_deny__break = false + var block_deny__break = true @Key("block-deny.place@") @Comment("", "禁止方块物品被放置") - var block_deny__place = false + var block_deny__place = true @Key("block-deny.interact@") @Comment("", "禁止方块物品被互动(左右键)") - var block_deny__interact = false + var block_deny__interact = true @Key @Comment("", "禁止方块物品被爆炸损坏") @@ -190,23 +190,23 @@ object GlobalSettings : SimpleYAMLConfig() { @Comment("", "绑定的生物的名字, {0} 为玩家名 {1} 为实体名") var entity__bind_name = "&a{0} &f的 &7{1}" - @Key("entity.bind-drops") + @Key() @Comment("", "绑定实体死亡掉落物也绑定") var entity__bind_drops = false @Key("entity.hostility@") @Comment("", "是否对敌对目标") - var entity__hostility = false + var entity__hostility = true - @Key("entity.defend") + @Key() @Comment("", "是否守护非敌对目标(吸引仇恨)") var entity__defend = false - @Key("entity.defend-distance") + @Key() @Comment("", "绑定的实体对友好目标的守护距离") var entity__defend_distance = 10.0 - @Key("entity.spawn-egg-check") + @Key() @Comment("", "是否启用刷怪蛋检测, 启用之后绑定的刷怪蛋生成的生物会绑定") var entity__spawn_egg_check = false @@ -214,31 +214,31 @@ object GlobalSettings : SimpleYAMLConfig() { @Comment("", "", "由绑定物品生成的实体的监听器", "一般指刷怪蛋") var entity_deny: MemorySection? = null - @Key("entity-deny.damage-by-entity") + @Key() @Comment("", "是否禁止该实体被除了玩家之外的实体攻击掉血") var entity_deny_damage_by_entity = false @Key("entity-deny.damage-by-player@") @Comment("", "是否禁止该实体被玩家攻击掉血") - var entity_deny_damage_by_player = false + var entity_deny_damage_by_player = true - @Key("entity-deny.damage") + @Key() @Comment("", "是否禁止该实体受到任何伤害") var entity_deny_damage = false @Key("entity-deny.interact@") @Comment("", "是否禁止与该实体交互(右键)") - var entity_deny_interact = false + var entity_deny_interact = true - @Key("entity-deny.ai") + @Key() @Comment("", "是否禁用实体AI (1.9+)") var entity_deny_ai = false - @Key("entity-deny.gravity") + @Key() @Comment("", "是否禁用实体重力 (1.10+)") var entity_deny_gravity = false - @Key("entity-deny.drops") + @Key() @Comment("", "禁止绑定实体死亡掉落物") var entity_deny_drops = false