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;
|
|
|
|
|
|
|
|
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-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;
|
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
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
public class TweaksPlugin extends JavaPlugin {
|
|
|
|
@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
|
|
|
|
2024-12-01 10:49:42 +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();
|
|
|
|
} 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
|
|
|
|
|
|
|
getLogger().info("Took %.3f milliseconds".formatted((System.nanoTime() - start) / 1000000.0));
|
2024-11-16 12:37:12 +01:00
|
|
|
}
|
|
|
|
}
|