PlayerUtils/src/main/java/com/alttd/playerutils/PlayerUtils.java

68 lines
2.2 KiB
Java
Raw Normal View History

2023-07-06 03:24:06 +00:00
package com.alttd.playerutils;
import com.alttd.playerutils.commands.PlayerUtilsCommand;
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;
import com.alttd.playerutils.config.Messages;
2023-07-08 04:26:01 +00:00
import com.alttd.playerutils.event_listeners.RotateBlockEvent;
import com.alttd.playerutils.event_listeners.TeleportEvent;
2023-07-06 03:24:06 +00:00
import com.alttd.playerutils.event_listeners.XpBottleEvent;
import com.alttd.playerutils.util.Logger;
import org.bukkit.plugin.PluginManager;
2023-07-06 03:24:06 +00:00
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
2023-07-06 03:24:06 +00:00
public final class PlayerUtils extends JavaPlugin {
private Logger logger;
2023-07-08 04:26:01 +00:00
private PlayerUtilsCommand playerUtilsCommand;
2023-07-06 03:24:06 +00:00
@Override
public void onEnable() {
this.logger = new Logger(getLogger());
registerCommands();
registerEvents();
2023-07-08 22:24:58 +00:00
reloadConfigs();
printVersion();
}
private void printVersion() {
Properties gitProps = new Properties();
try (InputStream inputStream = getClass().getClassLoader().getResourceAsStream("git.properties")) {
gitProps.load(inputStream);
} catch (IOException e) {
logger.severe("Unable to load git.properties, unknown version");
return;
}
logger.info("Git commit ID: %s".formatted(gitProps.getProperty("git.commit.id")));
logger.info("Git commit time: %s".formatted(gitProps.getProperty("git.commit.time")));
2023-07-06 03:24:06 +00:00
}
@Override
public void onDisable() {
}
private void registerCommands() {
2023-07-08 04:26:01 +00:00
playerUtilsCommand = new PlayerUtilsCommand(this, logger);
2023-07-06 03:24:06 +00:00
}
private void registerEvents() {
PluginManager pluginManager = getServer().getPluginManager();
pluginManager.registerEvents(new XpBottleEvent(this, logger), this);
pluginManager.registerEvents(new TeleportEvent(), this);
2023-07-08 04:26:01 +00:00
RotateBlockEvent rotateBlockEvent = new RotateBlockEvent();
pluginManager.registerEvents(rotateBlockEvent, this);
2023-07-08 04:26:01 +00:00
playerUtilsCommand.addSubCommand(new RotateBlock(rotateBlockEvent));
2023-07-06 03:24:06 +00:00
}
2023-07-07 21:49:34 +00:00
public void reloadConfigs() {
Config.reload(logger);
Messages.reload(logger);
}
2023-07-06 03:24:06 +00:00
}