41 lines
1.5 KiB
Java
41 lines
1.5 KiB
Java
package cn.hamster3.service.bukkit;
|
|
|
|
import cn.hamster3.mc.plugin.ball.common.api.BallAPI;
|
|
import cn.hamster3.service.bukkit.command.ServiceCommand;
|
|
import cn.hamster3.service.bukkit.hook.ServicePlaceholderHook;
|
|
import cn.hamster3.service.bukkit.listener.ServiceMainListener;
|
|
import cn.hamster3.service.bukkit.listener.BridgeListener;
|
|
import cn.hamster3.service.common.util.ServiceLogUtils;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
public class BallBridgePlugin extends JavaPlugin {
|
|
private static BallBridgePlugin instance;
|
|
|
|
public static BallBridgePlugin getInstance() {
|
|
return instance;
|
|
}
|
|
|
|
@Override
|
|
public void onLoad() {
|
|
instance = this;
|
|
ServiceLogUtils.setLogger(getLogger());
|
|
}
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
ServiceCommand.INSTANCE.register();
|
|
BallAPI.getInstance().getEventBus().register(BridgeListener.INSTANCE);
|
|
Bukkit.getPluginManager().registerEvents(ServiceMainListener.INSTANCE, this);
|
|
Bukkit.getScheduler().runTask(this, () -> {
|
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
|
ServicePlaceholderHook.INSTANCE.register();
|
|
getLogger().info("已注册 PlaceholderAPI 占位符.");
|
|
} else {
|
|
getLogger().warning("未找到 PlaceholderAPI 插件, 取消注册占位符.");
|
|
}
|
|
});
|
|
BallAPI.getInstance().subscribeIgnorePrefix("HamsterService");
|
|
}
|
|
}
|