tweaks724/src/main/java/eu/m724/tweaks/TweaksPlugin.java

115 lines
3.6 KiB
Java
Raw Normal View History

2024-11-27 20:46:13 +01:00
/*
* Copyright (C) 2024 Minecon724
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
* in the project root for the full license text.
*/
2024-11-16 12:37:12 +01:00
package eu.m724.tweaks;
2024-12-08 13:31:06 +01:00
import eu.m724.mstats.MStatsPlugin;
2024-12-06 17:13:33 +01:00
import eu.m724.tweaks.auth.AuthManager;
2024-11-16 12:37:12 +01:00
import eu.m724.tweaks.chat.ChatCommands;
import eu.m724.tweaks.chat.ChatManager;
2024-11-23 17:51:03 +01:00
import eu.m724.tweaks.door.DoorManager;
2024-12-11 15:51:43 +01:00
import eu.m724.tweaks.full.FullListener;
2024-11-28 18:43:37 +01:00
import eu.m724.tweaks.hardcore.HardcoreManager;
import eu.m724.tweaks.motd.MotdManager;
2024-11-17 09:48:38 +01:00
import eu.m724.tweaks.ping.F3NameListener;
import eu.m724.tweaks.ping.PingChecker;
import eu.m724.tweaks.ping.PingCommands;
2024-11-24 20:05:52 +01:00
import eu.m724.tweaks.pomodoro.PomodoroCommands;
import eu.m724.tweaks.pomodoro.PomodoroManager;
2024-11-30 11:30:15 +01:00
import eu.m724.tweaks.sleep.SleepManager;
import eu.m724.tweaks.updater.UpdaterCommands;
2024-11-26 20:25:13 +01:00
import eu.m724.tweaks.updater.UpdaterManager;
2024-11-20 20:17:26 +01:00
import eu.m724.tweaks.worldborder.WorldBorderManager;
2024-11-16 12:37:12 +01:00
2024-11-19 17:40:03 +01:00
import java.io.IOException;
2024-11-29 17:19:10 +01:00
import java.util.Locale;
2024-11-16 12:37:12 +01:00
import java.util.Objects;
2024-12-08 13:31:06 +01:00
public class TweaksPlugin extends MStatsPlugin {
2024-11-16 12:37:12 +01:00
@Override
public void onEnable() {
2024-11-29 17:19:10 +01:00
long start = System.nanoTime();
2024-11-23 17:51:03 +01:00
TweaksConfig config = TweaksConfig.load(this);
2024-11-29 17:19:10 +01:00
new Language(Locale.US); // TODO
2024-11-16 12:37:12 +01:00
// whether enabled is handled inside
new WorldBorderManager().init(this);
2024-11-23 17:51:03 +01:00
if (config.chatEnabled()) {
ChatManager chatManager = new ChatManager(this);
chatManager.init();
ChatCommands chatCommands = new ChatCommands(chatManager);
Objects.requireNonNull(getCommand("chat")).setExecutor(chatCommands);
Objects.requireNonNull(getCommand("chatmanage")).setExecutor(chatCommands);
}
if (config.doorEnabled()) {
new DoorManager().init(this);
}
if (config.brandEnabled()) {
new F3NameListener(this).init();
}
2024-11-17 09:48:38 +01:00
new PingChecker(this).init();
Objects.requireNonNull(getCommand("ping")).setExecutor(new PingCommands());
2024-11-19 17:40:03 +01:00
2024-11-23 17:51:03 +01:00
/*if (getServer().getPluginManager().getPlugin("voicechat") != null) {
2024-11-19 17:40:03 +01:00
new MusicPlayer(this).init();
} else {
getLogger().warning("To use voice extensions, install \"Simple Voice Chat\"");
2024-11-23 17:51:03 +01:00
}*/
2024-11-19 17:40:03 +01:00
2024-11-23 17:51:03 +01:00
if (config.motdEnabled()) {
try {
2024-11-28 18:43:37 +01:00
new MotdManager(this).init();
2024-11-23 17:51:03 +01:00
} catch (IOException e) {
getLogger().severe("Failed to initialize MOTD extension");
throw new RuntimeException(e);
}
2024-11-19 17:40:03 +01:00
}
2024-11-20 20:17:26 +01:00
2024-11-24 20:05:52 +01:00
if (config.pomodoroEnabled()) {
new PomodoroManager(this).init();
getCommand("pomodoro").setExecutor(new PomodoroCommands());
}
2024-11-26 20:25:13 +01:00
if (config.updaterEnabled()) {
try {
new UpdaterManager(this).init();
getCommand("updates").setExecutor(new UpdaterCommands());
2024-11-26 20:25:13 +01:00
} catch (IOException e) {
throw new RuntimeException(e);
}
}
2024-11-28 18:43:37 +01:00
2024-11-29 17:19:10 +01:00
if (config.hardcoreEnabled()) {
new HardcoreManager().init(this);
}
2024-11-30 11:30:15 +01:00
if (config.sleepEnabled()) {
new SleepManager().init(this);
}
2024-11-29 17:19:10 +01:00
2024-12-06 17:13:33 +01:00
if (config.authEnabled()) {
new AuthManager(this).init(getCommand("tauth"));
}
2024-12-11 15:51:43 +01:00
this.getServer().getPluginManager().registerEvents(new FullListener(), this);
2024-12-08 13:49:54 +01:00
if (config.metrics())
mStats(1);
2024-12-08 13:31:06 +01:00
2024-11-29 17:19:10 +01:00
getLogger().info("Took %.3f milliseconds".formatted((System.nanoTime() - start) / 1000000.0));
2024-11-16 12:37:12 +01:00
}
2024-12-02 17:55:15 +01:00
public boolean hasResource(String resource) {
return this.getClassLoader().getResource(resource) != null;
}
2024-11-16 12:37:12 +01:00
}