Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 KB | None | 0 0
  1. /* Enable */
  2. @SuppressWarnings("deprecation")
  3. public void onEnable() {
  4. //WORDLEDIT LADEN
  5. if(getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
  6. }
  7.  
  8. //CONFIG LADEN
  9. this.cU = new ConfigUtil();
  10.  
  11. // LANGUAGE LADEN
  12. langManager = new LanguageManager();
  13.  
  14. this.saveResource("nicks.txt", true);
  15. System.out.println("[SurvivalGames " + getDescription().getVersion() + "] Lizenzschlüssel erkannt! Plugin wird ausgeführt!");
  16. System.out.println("[SurvivalGames] Version: " + version);
  17. Updater updater = new Updater();
  18.  
  19. //SQLMANAGER LADEN
  20. this.sqlManager = new SQLManager();
  21.  
  22. //DATEN LADEN
  23. this.prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix")) + " §r";
  24. this.refill = getConfig().getBoolean("refill.active");
  25.  
  26. if(getConfig().getBoolean("stats.enabled")) {
  27. String host = getConfig().getString("stats.sql.host");
  28. String user = getConfig().getString("stats.sql.user");
  29. String pw = getConfig().getString("stats.sql.pw");
  30. String db = getConfig().getString("stats.sql.db");
  31.  
  32. try {
  33. this.c = DriverManager.getConnection("jdbc:mysql://" + host + "/" + db, user, pw);
  34. this.stats = true;
  35.  
  36. Statement stmt = c.createStatement();
  37.  
  38. stmt.executeUpdate("CREATE TABLE IF NOT EXISTS sg_stats (id int primary key NOT NULL AUTO_INCREMENT, uuid varchar(50), points int, kills int, deaths int, wins int, minutes int)");
  39.  
  40. } catch(Exception e) {
  41. e.printStackTrace();
  42. System.err.println("[SurvivalGames " + getDescription().getVersion() + "] Verbindung zur SQL-Datenbank konnte nicht hergestellt werden!");
  43. }
  44. }
  45.  
  46. //GAMEPLAY
  47. this.gamePlay = getConfig().getBoolean("gameplay");
  48.  
  49. if(gamePlay && !getConfig().contains("map")) {
  50. gamePlay = false;
  51. System.err.println("[SurvivalGames " + getDescription().getVersion() + "] GamePlay wurde deaktiviert, da keine Map installiert wurde!");
  52. }
  53.  
  54. new SurvivalGamesCommand();
  55.  
  56. if(gamePlay) {
  57. if(!getConfig().getString("forceMap").equals("none") && getConfig().contains("map." + getConfig().getString("forceMap"))) {
  58. voting = false;
  59. currentMap = new me.nicedev.sg.utils.Map(getConfig().getString("forceMap"));
  60.  
  61. forceMapScoreboard = new ConfigurableScoreboard(ChatColor.translateAlternateColorCodes('&', getConfig().getString("forceMapScoreboard.title")), false);
  62.  
  63. int lineNumber = 0;
  64. for(String line : getConfig().getStringList("forceMapScoreboard.lines")) {
  65. forceMapScoreboard.setLine(lineNumber, ChatColor.translateAlternateColorCodes('&', line).replace("%map%", currentMap.getDisplayName()), 0);
  66. lineNumber++;
  67. }
  68. }
  69.  
  70. items.put("voting", getItem("voting", ""));
  71. items.put("backtolobby", getItem("backtolobby", ""));
  72. items.put("nickOff", getItem("nick", "Off"));
  73. items.put("nickOn", getItem("nick", "On"));
  74.  
  75. if(!getConfig().getString("fallbackserver").equals("none") || !getConfig().getString("items.backtolobby.server").equals("none")) {
  76. this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
  77. }
  78.  
  79. this.voteSB = Bukkit.getScoreboardManager().getNewScoreboard();
  80. Objective voteObj = voteSB.registerNewObjective("votes", "dummy");
  81. voteObj.setDisplayName("§a§lVotes");
  82. voteObj.setDisplaySlot(DisplaySlot.SIDEBAR);
  83.  
  84. //PEX/VAULT LADEN
  85. PluginManager pm = Bukkit.getPluginManager();
  86.  
  87. Bukkit.createWorld(new WorldCreator(getConfig().getString("lobbyspawn").split(";")[5]));
  88. toLoc(getConfig().getString("lobbyspawn")).getWorld().setAnimalSpawnLimit(0);
  89. toLoc(getConfig().getString("lobbyspawn")).getWorld().setMonsterSpawnLimit(0);
  90.  
  91. List<String> maps = new ArrayList<String>();
  92.  
  93. for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
  94. maps.add(key);
  95. }
  96.  
  97. if(maps.size() > 5) {
  98. while(maps.size() > 5) {
  99. maps.remove(new Random().nextInt(maps.size()));
  100. }
  101. }
  102.  
  103. int i = 1;
  104. for(String key : maps) {
  105. me.nicedev.sg.utils.Map map = new me.nicedev.sg.utils.Map(key);
  106. WorldCreator wc = new WorldCreator(key);
  107. Bukkit.createWorld(wc);
  108. Bukkit.getWorld(key).setMonsterSpawnLimit(0);
  109. voteMaps.put(i, new VoteMap(map));
  110.  
  111. voteObj.getScore(Bukkit.getOfflinePlayer("§a" + splitName(map.getDisplayName(), 14))).setScore(0);
  112. this.maps.add(map);
  113. i++;
  114. }
  115.  
  116. this.loadVoteInv();
  117. new SurvivalGamesCountdown().runTaskTimer(this, 0L, 20L);
  118.  
  119. new BlockListener();
  120. new DamageListener();
  121. new DeathListener();
  122. new InteractListener();
  123. new JoinQuitListener();
  124. new MoveListener();
  125. new OtherListener();
  126.  
  127. for(World world : Bukkit.getWorlds()) {
  128. world.setAutoSave(false);
  129. }
  130.  
  131. if(getConfig().getBoolean("notallchests.active")) {
  132.  
  133. for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
  134. String[] split = getConfig().getString("notallchests.amount").split("/");
  135. int zaehler = Integer.parseInt(split[0]);
  136. int nenner = Integer.parseInt(split[1]);
  137.  
  138. int maxChests =
  139. (getConfig().getStringList("map." + key + ".notallchests.chests").size() / nenner) * zaehler;
  140. List<Location> moeglich = new ArrayList<Location>();
  141. List<Location> newLocs = new ArrayList<Location>();
  142.  
  143. for(String string : getConfig().getStringList("map." + key + ".notallchests.chests")) {
  144. moeglich.add(toLoc(string));
  145. }
  146.  
  147. while(newLocs.size() != maxChests) {
  148. if(moeglich.size() == 0) {
  149. break;
  150. }
  151.  
  152. Location loc = moeglich.get(new Random().nextInt(moeglich.size()));
  153.  
  154. moeglich.remove(loc);
  155. newLocs.add(loc);
  156. }
  157.  
  158. for(Location loc : newLocs) {
  159. setChest(loc.getBlock());
  160. }
  161.  
  162. for(Location loc : moeglich) {
  163. if(getConfig().getStringList("map." + key + ".hardchests")
  164. .contains(loc.getBlockX() + ";" + loc.getBlockY() + ";" +
  165. loc.getBlockZ() + ";" + loc.getWorld().getName())) {
  166. setChest(loc.getBlock());
  167. continue;
  168. }
  169.  
  170. loc.getBlock().setType(Material.AIR);
  171. }
  172.  
  173. }
  174.  
  175. }
  176. } else {
  177. new SetupListener();
  178. if(getConfig().contains("map")) {
  179. Bukkit.createWorld(new WorldCreator(getConfig().getString("lobbyspawn").split(";")[5]));
  180.  
  181. for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
  182. Bukkit.createWorld(new WorldCreator(key));
  183. }
  184. }
  185. }
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement