mirror of
https://github.com/CarmJos/MineSQL.git
synced 2026-06-05 00:48:16 +08:00
添加插件禁用监听器
This commit is contained in:
+10
-2
@@ -6,7 +6,11 @@ import cc.carm.plugin.easysql.api.EasySQLAPI;
|
|||||||
import cc.carm.plugin.easysql.api.EasySQLPluginPlatform;
|
import cc.carm.plugin.easysql.api.EasySQLPluginPlatform;
|
||||||
import cn.beecp.BeeDataSource;
|
import cn.beecp.BeeDataSource;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -53,6 +57,10 @@ public class EasySQLBukkit extends JavaPlugin implements EasySQLPluginPlatform,
|
|||||||
apiImpl.getSQLManagers().keySet().forEach(apiImpl::unregisterSQLManager);
|
apiImpl.getSQLManagers().keySet().forEach(apiImpl::unregisterSQLManager);
|
||||||
super.onDisable();
|
super.onDisable();
|
||||||
}
|
}
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPluginDisable(PluginDisableEvent event){
|
||||||
|
this.unregister(event.getPlugin());
|
||||||
|
}
|
||||||
// =========== 平台注册方法 ===========
|
// =========== 平台注册方法 ===========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,7 +69,7 @@ public class EasySQLBukkit extends JavaPlugin implements EasySQLPluginPlatform,
|
|||||||
* @param name SQLManager 映射名称
|
* @param name SQLManager 映射名称
|
||||||
* @param sqlManager SQLManager 实例
|
* @param sqlManager SQLManager 实例
|
||||||
*/
|
*/
|
||||||
public void register(@NotNull JavaPlugin plugin, @NotNull String name, @NotNull SQLManager sqlManager){
|
public void register(@NotNull Plugin plugin, @NotNull String name, @NotNull SQLManager sqlManager){
|
||||||
if(this.apiImpl.getSQLManagers().containsKey(name)){
|
if(this.apiImpl.getSQLManagers().containsKey(name)){
|
||||||
// 名称冲突处理
|
// 名称冲突处理
|
||||||
throw new IllegalArgumentException("Instance name conflict: " + name+", Already registered by "+this.apiImpl.getNameSpace(name));
|
throw new IllegalArgumentException("Instance name conflict: " + name+", Already registered by "+this.apiImpl.getNameSpace(name));
|
||||||
@@ -92,7 +100,7 @@ public class EasySQLBukkit extends JavaPlugin implements EasySQLPluginPlatform,
|
|||||||
* 注销指定插件注册的所有 SQLManager 实例
|
* 注销指定插件注册的所有 SQLManager 实例
|
||||||
* @param plugin 插件
|
* @param plugin 插件
|
||||||
*/
|
*/
|
||||||
public void unregister(@NotNull JavaPlugin plugin){
|
public void unregister(@NotNull Plugin plugin){
|
||||||
this.apiImpl.unregisterSQLManagerAll(plugin.getName());
|
this.apiImpl.unregisterSQLManagerAll(plugin.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user