Dateien nach "src/main/java/com/alttd/playerutils" hochladen
This commit is contained in:
parent
4cff7bb407
commit
a38cd61c31
76
src/main/java/com/alttd/playerutils/PlayerUtils.java
Normal file
76
src/main/java/com/alttd/playerutils/PlayerUtils.java
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
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.RandomPlotPort;
|
||||
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 lombok.extern.slf4j.Slf4j;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public final class PlayerUtils extends JavaPlugin {
|
||||
|
||||
private PlayerUtilsCommand playerUtilsCommand;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
registerCommands();
|
||||
reloadConfigs();
|
||||
registerEvents();
|
||||
registerSchedulers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
KeyStorage.STORAGE.save();
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
playerUtilsCommand = new PlayerUtilsCommand(this);
|
||||
if (getServer().getPluginManager().isPluginEnabled("PlotSquared")) {
|
||||
playerUtilsCommand.addSubCommand(new RandomPlotPort(this));
|
||||
} else {
|
||||
log.warn("PlotSquared not found — rpp subcommand will not be registered.");
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
pluginManager.registerEvents(new BookWriteEvent(), this);
|
||||
pluginManager.registerEvents(new BookByteLimitListener(), this);
|
||||
pluginManager.registerEvents(new VillagerWorkstationEvent(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);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user