kenshinshideandseek/src/main/java/net/tylermurphy/hideAndSeek/Main.java

89 lines
2.7 KiB
Java
Raw Normal View History

/*
* This file is part of Kenshins Hide and Seek
*
* Copyright (c) 2021 Tyler Murphy.
*
* Kenshins Hide and Seek free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
2021-12-27 19:14:32 +00:00
* he Free Software Foundation version 3.
*
* Kenshins Hide and Seek is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
2021-08-13 20:49:36 +00:00
package net.tylermurphy.hideAndSeek;
2021-08-27 21:20:07 +00:00
import java.io.File;
import java.util.List;
2021-12-26 04:46:22 +00:00
import net.tylermurphy.hideAndSeek.database.Database;
import net.tylermurphy.hideAndSeek.util.UUIDFetcher;
2021-08-13 20:49:36 +00:00
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
2021-09-01 01:55:27 +00:00
import org.bukkit.scheduler.BukkitTask;
2021-08-13 20:49:36 +00:00
2021-12-26 22:58:18 +00:00
import net.tylermurphy.hideAndSeek.game.CommandHandler;
2021-12-25 14:16:03 +00:00
import net.tylermurphy.hideAndSeek.game.EventListener;
import net.tylermurphy.hideAndSeek.util.TabCompleter;
import net.tylermurphy.hideAndSeek.game.Game;
2021-10-23 00:03:15 +00:00
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Localization;
2021-10-31 15:25:27 +00:00
import net.tylermurphy.hideAndSeek.configuration.Items;
2021-12-26 22:58:18 +00:00
import net.tylermurphy.hideAndSeek.game.Board;
2021-12-28 16:53:55 +00:00
import org.jetbrains.annotations.NotNull;
2021-08-13 20:49:36 +00:00
public class Main extends JavaPlugin implements Listener {
public static Main plugin;
2021-10-23 00:03:15 +00:00
public static File root, data;
2022-04-13 17:47:59 +00:00
private int onTickTask;
2021-12-25 14:16:03 +00:00
2021-08-13 20:49:36 +00:00
public void onEnable() {
plugin = this;
2021-10-23 00:03:15 +00:00
root = this.getServer().getWorldContainer();
data = this.getDataFolder();
2021-12-26 22:58:18 +00:00
getServer().getPluginManager().registerEvents(new EventListener(), this);
2021-10-21 00:14:01 +00:00
Config.loadConfig();
2021-10-29 03:09:28 +00:00
Localization.loadLocalization();
2021-10-31 15:25:27 +00:00
Items.loadItems();
2021-12-26 04:46:22 +00:00
2021-12-26 22:58:18 +00:00
CommandHandler.registerCommands();
Board.reload();
Database.init();
2021-12-26 04:46:22 +00:00
UUIDFetcher.init();
2021-11-08 20:53:13 +00:00
onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, () -> {
try{
2021-12-26 22:58:18 +00:00
Game.onTick();
2021-11-08 20:53:13 +00:00
} catch (Exception e) {
e.printStackTrace();
}
2022-04-13 17:47:59 +00:00
},0,1).getTaskId();
2021-08-13 20:49:36 +00:00
}
2021-09-01 01:55:27 +00:00
public void onDisable() {
2022-04-13 17:47:59 +00:00
Main.plugin.getServer().getScheduler().cancelTask(onTickTask);
2021-12-26 04:46:22 +00:00
UUIDFetcher.cleanup();
2022-04-13 17:47:59 +00:00
Board.cleanup();
2021-09-01 01:55:27 +00:00
}
2021-12-28 16:53:55 +00:00
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
2021-12-26 22:58:18 +00:00
return CommandHandler.handleCommand(sender, args);
}
2021-12-28 16:53:55 +00:00
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) {
2021-12-26 22:58:18 +00:00
return TabCompleter.handleTabComplete(sender, args);
2021-08-13 20:49:36 +00:00
}
2021-12-28 16:53:55 +00:00
}