Skip to content

Commit

Permalink
修复 ArcLight 和 数据库问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Iseason2000 authored and Iseason2000 committed Apr 30, 2023
1 parent 5804a27 commit 7b3986e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,7 +12,7 @@
* <p>插件自定义的加载器,用于隔离依赖</p>
* <p>本ClassLoader将优先加载urls中有的class,而不是双亲委托</p>
*/
public class IsolatedClassLoader extends URLClassLoader {
public class IsolatedClassLoader extends MLet {
/**
* 自由添加黑名单
*/
Expand All @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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 = ""

Expand Down Expand Up @@ -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"
}
Expand All @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("", "禁止丢弃")
Expand All @@ -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

Expand Down Expand Up @@ -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("", "禁止方块物品被爆炸损坏")
Expand All @@ -190,55 +190,55 @@ 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

@Key
@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

Expand Down

0 comments on commit 7b3986e

Please sign in to comment.