2023-07-06 03:24:06 +00:00
|
|
|
package com.alttd.playerutils;
|
|
|
|
|
|
|
|
|
|
import com.alttd.playerutils.commands.PlayerUtilsCommand;
|
2025-07-20 02:36:02 +00:00
|
|
|
import com.alttd.playerutils.commands.playerutils_subcommands.GhastSpeed;
|
2023-07-08 04:26:01 +00:00
|
|
|
import com.alttd.playerutils.commands.playerutils_subcommands.RotateBlock;
|
2023-07-07 21:49:34 +00:00
|
|
|
import com.alttd.playerutils.config.Config;
|
2024-10-04 18:53:54 +00:00
|
|
|
import com.alttd.playerutils.config.KeyStorage;
|
2023-07-07 21:49:34 +00:00
|
|
|
import com.alttd.playerutils.config.Messages;
|
2025-03-22 19:33:31 +00:00
|
|
|
import com.alttd.playerutils.event_listeners.*;
|
2024-10-04 18:53:54 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2024-02-17 08:53:12 +00:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
2023-07-06 03:24:06 +00:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
2024-10-04 18:53:54 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
2024-06-30 18:28:18 +00:00
|
|
|
|
2023-07-06 03:24:06 +00:00
|
|
|
public final class PlayerUtils extends JavaPlugin {
|
|
|
|
|
|
2023-07-08 04:26:01 +00:00
|
|
|
private PlayerUtilsCommand playerUtilsCommand;
|
2023-07-06 03:24:06 +00:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEnable() {
|
|
|
|
|
registerCommands();
|
|
|
|
|
registerEvents();
|
2023-07-08 22:24:58 +00:00
|
|
|
reloadConfigs();
|
2024-10-04 18:53:54 +00:00
|
|
|
registerSchedulers();
|
2023-07-06 03:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDisable() {
|
2024-10-04 19:27:06 +00:00
|
|
|
KeyStorage.STORAGE.save();
|
2023-07-06 03:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerCommands() {
|
2025-07-24 21:04:52 +00:00
|
|
|
playerUtilsCommand = new PlayerUtilsCommand(this);
|
2023-07-06 03:24:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerEvents() {
|
2024-02-17 08:53:12 +00:00
|
|
|
PluginManager pluginManager = getServer().getPluginManager();
|
2025-07-24 21:04:52 +00:00
|
|
|
pluginManager.registerEvents(new XpBottleEvent(this), this);
|
2024-02-17 08:53:12 +00:00
|
|
|
pluginManager.registerEvents(new TeleportEvent(), this);
|
2025-07-24 21:04:52 +00:00
|
|
|
pluginManager.registerEvents(new GoatHornEvent(), this);
|
|
|
|
|
pluginManager.registerEvents(new LimitArmorStands(this), this);
|
|
|
|
|
pluginManager.registerEvents(new BlockBlockUseEvent(), this);
|
2025-10-31 00:45:54 +00:00
|
|
|
pluginManager.registerEvents(new PlayerJoin(), this);
|
2023-07-08 04:26:01 +00:00
|
|
|
|
2025-07-24 21:04:52 +00:00
|
|
|
RotateBlockEvent rotateBlockEvent = new RotateBlockEvent();
|
2024-02-17 08:53:12 +00:00
|
|
|
pluginManager.registerEvents(rotateBlockEvent, this);
|
2023-07-08 04:26:01 +00:00
|
|
|
playerUtilsCommand.addSubCommand(new RotateBlock(rotateBlockEvent));
|
2025-07-20 02:36:02 +00:00
|
|
|
|
2025-07-24 21:04:52 +00:00
|
|
|
GhastSpeedEvent ghastSpeedEvent = new GhastSpeedEvent();
|
2025-07-20 02:36:02 +00:00
|
|
|
pluginManager.registerEvents(ghastSpeedEvent, this);
|
2025-07-24 21:04:52 +00:00
|
|
|
playerUtilsCommand.addSubCommand(new GhastSpeed(ghastSpeedEvent));
|
2023-07-06 03:24:06 +00:00
|
|
|
}
|
2023-07-07 21:49:34 +00:00
|
|
|
|
|
|
|
|
public void reloadConfigs() {
|
2025-07-24 21:04:52 +00:00
|
|
|
Config.reload();
|
|
|
|
|
Messages.reload();
|
|
|
|
|
KeyStorage.reload();
|
2024-10-04 18:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void registerSchedulers() {
|
|
|
|
|
Bukkit.getScheduler().runTaskTimerAsynchronously(this, KeyStorage.STORAGE::save,
|
|
|
|
|
TimeUnit.MINUTES.toSeconds(5) * 20, TimeUnit.MINUTES.toSeconds(5) * 20);
|
2023-07-07 21:49:34 +00:00
|
|
|
}
|
2023-07-06 03:24:06 +00:00
|
|
|
}
|