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;
|
2024-02-17 08:53:12 +00:00
|
|
|
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;
|
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-06-30 18:28:18 +00:00
|
|
|
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();
|
2024-06-30 18:28:18 +00:00
|
|
|
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() {
|
2024-02-17 08:53:12 +00:00
|
|
|
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();
|
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));
|
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
|
|
|
}
|