Guest User

Untitled

a guest
Nov 19th, 2019
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Main extends JavaPlugin {
  2. private static Main plugin;
  3. private ArrayList<Arena> arenaList;
  4. private ArrayList<UUID> playersInGame;
  5.  
  6. public void onEnable() {
  7. plugin = this;
  8. loadConfig();
  9. loadArenas();
  10. loadCommands();
  11. loadEvents();
  12.  
  13. getLogger().info("Plugin has been enabled!");
  14. }
  15.  
  16.  
  17.  
  18. public void loadConfig() {
  19. getConfig().addDefault("prefix", "&2&lUltraSpleef &7» ");
  20. getConfig().options().copyDefaults(true);
  21. saveConfig();
  22. }
  23.  
  24. }
  25.  
  26. public void loadArenas() {
  27. int count = 0;
  28. ConfigurationSection arenas = Main.getPlugin().getConfig().getConfigurationSection("arenas");
  29. for (String key : arenas.getKeys(false)) {
  30. World world = Bukkit.getServer().getWorld(getConfig().getString("arenas." + key + ".spawn.world"));
  31. if (world == null) {
  32. Bukkit.getLogger()
  33. .info(getPrefix() + ChatColor.RED + "Error! cannot find a world named " + world.getName());
  34. getServer().getPluginManager().disablePlugin(this);
  35. return;
  36. }
  37. if (getConfig().getString("arenas." + key + ".spawn.x") == null
  38. || getConfig().getString("arenas." + key + ".spawn.y") == null
  39. || getConfig().getString("arenas." + key + ".spawn.z") == null
  40. || getConfig().getString("arenas." + key + ".spawn.yaw") == null
  41. || getConfig().getString("arenas." + key + ".spawn.pitch") == null) {
  42. Bukkit.getLogger().info(getPrefix() + ChatColor.RED + "Error! Please enter valid coordinates");
  43. getServer().getPluginManager().disablePlugin(this);
  44. return;
  45.  
  46. }
  47. Location spawn = new Location(world, Double.valueOf(getConfig().getString("arenas." + key + ".spawn.x")),
  48. Double.valueOf(getConfig().getString("arenas." + key + ".spawn.y")),
  49. Double.valueOf(getConfig().getString("arenas." + key + ".spawn.z")),
  50. Float.valueOf(getConfig().getString("arenas." + key + ".spawn.yaw")),
  51. Float.valueOf(getConfig().getString("arenas." + key + ".spawn.pitch")));
  52. arenaList.add(new Arena(world, spawn, key));
  53. count++;
  54.  
  55. }
  56.  
  57. }
  58.  
  59. public String getPrefix() {
  60. return ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix"));
  61. }
  62.  
  63. public static Main getPlugin() {
  64. return plugin; // Access other classes
  65. }
  66. }
RAW Paste Data