66 lines
2.3 KiB
Java
66 lines
2.3 KiB
Java
package com.alttd.playerutils;
|
|
|
|
import com.alttd.playerutils.commands.PlayerUtilsCommand;
|
|
import com.alttd.playerutils.commands.playerutils_subcommands.GhastSpeed;
|
|
import com.alttd.playerutils.commands.playerutils_subcommands.RotateBlock;
|
|
import com.alttd.playerutils.config.Config;
|
|
import com.alttd.playerutils.config.KeyStorage;
|
|
import com.alttd.playerutils.config.Messages;
|
|
import com.alttd.playerutils.event_listeners.*;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.plugin.PluginManager;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
public final class PlayerUtils extends JavaPlugin {
|
|
|
|
private PlayerUtilsCommand playerUtilsCommand;
|
|
|
|
@Override
|
|
public void onEnable() {
|
|
registerCommands();
|
|
registerEvents();
|
|
reloadConfigs();
|
|
registerSchedulers();
|
|
}
|
|
|
|
@Override
|
|
public void onDisable() {
|
|
KeyStorage.STORAGE.save();
|
|
}
|
|
|
|
private void registerCommands() {
|
|
playerUtilsCommand = new PlayerUtilsCommand(this);
|
|
}
|
|
|
|
private void registerEvents() {
|
|
PluginManager pluginManager = getServer().getPluginManager();
|
|
pluginManager.registerEvents(new XpBottleEvent(this), this);
|
|
pluginManager.registerEvents(new TeleportEvent(), this);
|
|
pluginManager.registerEvents(new GoatHornEvent(), this);
|
|
pluginManager.registerEvents(new LimitArmorStands(this), this);
|
|
pluginManager.registerEvents(new BlockBlockUseEvent(), this);
|
|
pluginManager.registerEvents(new PlayerJoin(this), this);
|
|
|
|
RotateBlockEvent rotateBlockEvent = new RotateBlockEvent();
|
|
pluginManager.registerEvents(rotateBlockEvent, this);
|
|
playerUtilsCommand.addSubCommand(new RotateBlock(rotateBlockEvent));
|
|
|
|
GhastSpeedEvent ghastSpeedEvent = new GhastSpeedEvent();
|
|
pluginManager.registerEvents(ghastSpeedEvent, this);
|
|
playerUtilsCommand.addSubCommand(new GhastSpeed(ghastSpeedEvent));
|
|
}
|
|
|
|
public void reloadConfigs() {
|
|
Config.reload();
|
|
Messages.reload();
|
|
KeyStorage.reload();
|
|
}
|
|
|
|
private void registerSchedulers() {
|
|
Bukkit.getScheduler().runTaskTimerAsynchronously(this, KeyStorage.STORAGE::save,
|
|
TimeUnit.MINUTES.toSeconds(5) * 20, TimeUnit.MINUTES.toSeconds(5) * 20);
|
|
}
|
|
}
|