minecraft-fakeplayer/src/main/java/io/github/hello09x/fakeplayer/Main.java
tanyaofei 61c0381326 1. 更改命令的实现方式,更符合 minecraft 的风格
2. 添加 `self-commands` 配置
3. 配置项新增是否拾取物品
2023-07-26 18:40:02 +08:00

58 lines
1.6 KiB
Java

package io.github.hello09x.fakeplayer;
import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig;
import io.github.hello09x.fakeplayer.command.Commands;
import io.github.hello09x.fakeplayer.listener.PlayerListeners;
import io.github.hello09x.fakeplayer.manager.FakeplayerManager;
import io.github.hello09x.fakeplayer.optional.BungeeCordServer;
import io.github.hello09x.fakeplayer.repository.UsedIdRepository;
import lombok.Getter;
import org.bukkit.plugin.java.JavaPlugin;
public final class Main extends JavaPlugin {
@Getter
private static Main instance;
@Override
public void onLoad() {
CommandAPI.onLoad(new CommandAPIBukkitConfig(this).silentLogs(true));
}
@Override
public void onEnable() {
// Plugin startup logic
instance = this;
Commands.register();
CommandAPI.onEnable();
{
getServer().getMessenger().registerIncomingPluginChannel(Main.getInstance(), "BungeeCord", BungeeCordServer.instance);
getServer().getMessenger().registerOutgoingPluginChannel(Main.getInstance(), "BungeeCord");
}
registerListeners();
}
@Override
public void onDisable() {
FakeplayerManager.instance.removeAll();
UsedIdRepository.instance.save();
{
getServer().getMessenger().unregisterIncomingPluginChannel(this);
getServer().getMessenger().unregisterOutgoingPluginChannel(this);
}
CommandAPI.onDisable();
}
private void registerListeners() {
var pm = getServer().getPluginManager();
pm.registerEvents(PlayerListeners.instance, this);
}
}