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

97 lines
2.5 KiB
Java
Raw Normal View History

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-10-21 00:14:01 +00:00
import java.util.HashMap;
import java.util.List;
2021-10-21 00:14:01 +00:00
import java.util.Map;
2021-08-13 20:49:36 +00:00
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
2021-10-21 00:14:01 +00:00
import org.bukkit.entity.Player;
2021-08-13 20:49:36 +00:00
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-09-01 01:55:27 +00:00
import net.tylermurphy.hideAndSeek.bukkit.CommandHandler;
import net.tylermurphy.hideAndSeek.bukkit.EventListener;
import net.tylermurphy.hideAndSeek.bukkit.TabCompleter;
import net.tylermurphy.hideAndSeek.bukkit.Tick;
2021-10-23 00:03:15 +00:00
import net.tylermurphy.hideAndSeek.configuration.Config;
import net.tylermurphy.hideAndSeek.configuration.Localization;
2021-09-01 01:55:27 +00:00
import net.tylermurphy.hideAndSeek.events.Glow;
import net.tylermurphy.hideAndSeek.events.Taunt;
import net.tylermurphy.hideAndSeek.events.Worldborder;
2021-10-21 00:14:01 +00:00
import net.tylermurphy.hideAndSeek.util.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-08-13 20:49:36 +00:00
2021-10-21 00:14:01 +00:00
public Taunt taunt;
public Glow glow;
public Worldborder worldborder;
public Board board;
public Map<String,Player> playerList = new HashMap<String,Player>();
public String status = "Standby";
public int timeLeft = 0, gameId = 0;;
2021-09-01 01:55:27 +00:00
private BukkitTask onTickTask;
2021-08-13 20:49:36 +00:00
public void onEnable() {
plugin = this;
// Setup Initial Player Count
getServer().getPluginManager().registerEvents(new EventListener(), this);
2021-08-13 20:49:36 +00:00
2021-10-23 00:03:15 +00:00
// Get Data Folder
root = this.getServer().getWorldContainer();
data = this.getDataFolder();
2021-08-13 20:49:36 +00:00
// Init Configuration
2021-10-23 00:03:15 +00:00
Main.plugin.saveResource("localization.yml", false);
Main.plugin.saveResource("config.yml", false);
2021-10-21 00:14:01 +00:00
Config.loadConfig();
2021-10-23 00:03:15 +00:00
Localization.init();
2021-08-13 20:49:36 +00:00
// Register Commands
CommandHandler.registerCommands();
2021-08-13 20:49:36 +00:00
2021-10-21 00:14:01 +00:00
//Board
board = new Board();
2021-10-21 01:37:38 +00:00
board.reload();
2021-08-27 21:20:07 +00:00
2021-08-13 20:49:36 +00:00
// Start Tick Timer
2021-09-01 01:55:27 +00:00
onTickTask = Bukkit.getServer().getScheduler().runTaskTimer(this, new Runnable(){
2021-08-13 20:49:36 +00:00
public void run(){
2021-08-18 23:21:59 +00:00
try{
2021-09-01 01:55:27 +00:00
Tick.onTick();
2021-08-18 23:21:59 +00:00
} catch (Exception e) {
e.printStackTrace();
}
2021-08-13 20:49:36 +00:00
}
2021-08-18 23:21:59 +00:00
},0,1);
2021-08-13 20:49:36 +00:00
}
2021-09-01 01:55:27 +00:00
public void onDisable() {
onTickTask.cancel();
}
2021-08-13 20:49:36 +00:00
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
return CommandHandler.handleCommand(sender, cmd, label, args);
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
2021-09-01 01:55:27 +00:00
return TabCompleter.handleTabComplete(sender, command, label, args);
2021-08-13 20:49:36 +00:00
}
}