2021-08-13 20:49:36 +00:00
|
|
|
package net.tylermurphy.hideAndSeek;
|
|
|
|
|
2021-08-27 21:20:07 +00:00
|
|
|
import java.io.File;
|
2021-08-23 17:57:50 +00:00
|
|
|
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-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;
|
2021-09-01 01:55:27 +00:00
|
|
|
private BukkitTask 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();
|
|
|
|
}
|
|
|
|
},0,1);
|
2021-08-13 20:49:36 +00:00
|
|
|
}
|
|
|
|
|
2021-09-01 01:55:27 +00:00
|
|
|
public void onDisable() {
|
2021-12-20 21:51:44 +00:00
|
|
|
if(onTickTask != null)
|
|
|
|
onTickTask.cancel();
|
2021-12-26 04:46:22 +00:00
|
|
|
UUIDFetcher.cleanup();
|
2021-09-01 01:55:27 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 14:29:31 +00:00
|
|
|
public boolean onCommand(CommandSender sender, Command cmd,String label, String[] args) {
|
2021-12-26 22:58:18 +00:00
|
|
|
return CommandHandler.handleCommand(sender, args);
|
2021-08-23 17:57:50 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 14:29:31 +00:00
|
|
|
public List<String> onTabComplete(CommandSender sender, Command command, 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
|
|
|
}
|
|
|
|
|
|
|
|
}
|