111 lines
3.5 KiB
Java
111 lines
3.5 KiB
Java
/*
|
|
* 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.
|
|
*/
|
|
|
|
package eu.m724.tweaks;
|
|
|
|
import eu.m724.mstats.MStatsPlugin;
|
|
import eu.m724.tweaks.auth.AuthManager;
|
|
import eu.m724.tweaks.chat.ChatCommands;
|
|
import eu.m724.tweaks.chat.ChatManager;
|
|
import eu.m724.tweaks.door.DoorManager;
|
|
import eu.m724.tweaks.hardcore.HardcoreManager;
|
|
import eu.m724.tweaks.motd.MotdManager;
|
|
import eu.m724.tweaks.ping.F3NameListener;
|
|
import eu.m724.tweaks.ping.PingChecker;
|
|
import eu.m724.tweaks.ping.PingCommands;
|
|
import eu.m724.tweaks.pomodoro.PomodoroCommands;
|
|
import eu.m724.tweaks.pomodoro.PomodoroManager;
|
|
import eu.m724.tweaks.sleep.SleepManager;
|
|
import eu.m724.tweaks.updater.UpdaterCommands;
|
|
import eu.m724.tweaks.updater.UpdaterManager;
|
|
import eu.m724.tweaks.worldborder.WorldBorderManager;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Locale;
|
|
import java.util.Objects;
|
|
|
|
public class TweaksPlugin extends MStatsPlugin {
|
|
@Override
|
|
public void onEnable() {
|
|
long start = System.nanoTime();
|
|
|
|
TweaksConfig config = TweaksConfig.load(this);
|
|
new Language(Locale.US); // TODO
|
|
|
|
// whether enabled is handled inside
|
|
new WorldBorderManager().init(this);
|
|
|
|
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();
|
|
}
|
|
|
|
new PingChecker(this).init();
|
|
Objects.requireNonNull(getCommand("ping")).setExecutor(new PingCommands());
|
|
|
|
/*if (getServer().getPluginManager().getPlugin("voicechat") != null) {
|
|
new MusicPlayer(this).init();
|
|
} else {
|
|
getLogger().warning("To use voice extensions, install \"Simple Voice Chat\"");
|
|
}*/
|
|
|
|
if (config.motdEnabled()) {
|
|
try {
|
|
new MotdManager(this).init();
|
|
} catch (IOException e) {
|
|
getLogger().severe("Failed to initialize MOTD extension");
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
if (config.pomodoroEnabled()) {
|
|
new PomodoroManager(this).init();
|
|
getCommand("pomodoro").setExecutor(new PomodoroCommands());
|
|
}
|
|
|
|
if (config.updaterEnabled()) {
|
|
try {
|
|
new UpdaterManager(this).init();
|
|
getCommand("updates").setExecutor(new UpdaterCommands());
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
if (config.hardcoreEnabled()) {
|
|
new HardcoreManager().init(this);
|
|
}
|
|
|
|
if (config.sleepEnabled()) {
|
|
new SleepManager().init(this);
|
|
}
|
|
|
|
if (config.authEnabled()) {
|
|
new AuthManager(this).init(getCommand("tauth"));
|
|
}
|
|
|
|
if (config.metrics())
|
|
mStats(1);
|
|
|
|
getLogger().info("Took %.3f milliseconds".formatted((System.nanoTime() - start) / 1000000.0));
|
|
}
|
|
|
|
public boolean hasResource(String resource) {
|
|
return this.getClassLoader().getResource(resource) != null;
|
|
}
|
|
}
|