Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Enable */
- @SuppressWarnings("deprecation")
- public void onEnable() {
- //WORDLEDIT LADEN
- if(getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
- }
- //CONFIG LADEN
- this.cU = new ConfigUtil();
- // LANGUAGE LADEN
- langManager = new LanguageManager();
- this.saveResource("nicks.txt", true);
- System.out.println("[SurvivalGames " + getDescription().getVersion() + "] Lizenzschlüssel erkannt! Plugin wird ausgeführt!");
- System.out.println("[SurvivalGames] Version: " + version);
- Updater updater = new Updater();
- //SQLMANAGER LADEN
- this.sqlManager = new SQLManager();
- //DATEN LADEN
- this.prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix")) + " §r";
- this.refill = getConfig().getBoolean("refill.active");
- if(getConfig().getBoolean("stats.enabled")) {
- String host = getConfig().getString("stats.sql.host");
- String user = getConfig().getString("stats.sql.user");
- String pw = getConfig().getString("stats.sql.pw");
- String db = getConfig().getString("stats.sql.db");
- try {
- this.c = DriverManager.getConnection("jdbc:mysql://" + host + "/" + db, user, pw);
- this.stats = true;
- Statement stmt = c.createStatement();
- 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)");
- } catch(Exception e) {
- e.printStackTrace();
- System.err.println("[SurvivalGames " + getDescription().getVersion() + "] Verbindung zur SQL-Datenbank konnte nicht hergestellt werden!");
- }
- }
- //GAMEPLAY
- this.gamePlay = getConfig().getBoolean("gameplay");
- if(gamePlay && !getConfig().contains("map")) {
- gamePlay = false;
- System.err.println("[SurvivalGames " + getDescription().getVersion() + "] GamePlay wurde deaktiviert, da keine Map installiert wurde!");
- }
- new SurvivalGamesCommand();
- if(gamePlay) {
- if(!getConfig().getString("forceMap").equals("none") && getConfig().contains("map." + getConfig().getString("forceMap"))) {
- voting = false;
- currentMap = new me.nicedev.sg.utils.Map(getConfig().getString("forceMap"));
- forceMapScoreboard = new ConfigurableScoreboard(ChatColor.translateAlternateColorCodes('&', getConfig().getString("forceMapScoreboard.title")), false);
- int lineNumber = 0;
- for(String line : getConfig().getStringList("forceMapScoreboard.lines")) {
- forceMapScoreboard.setLine(lineNumber, ChatColor.translateAlternateColorCodes('&', line).replace("%map%", currentMap.getDisplayName()), 0);
- lineNumber++;
- }
- }
- items.put("voting", getItem("voting", ""));
- items.put("backtolobby", getItem("backtolobby", ""));
- items.put("nickOff", getItem("nick", "Off"));
- items.put("nickOn", getItem("nick", "On"));
- if(!getConfig().getString("fallbackserver").equals("none") || !getConfig().getString("items.backtolobby.server").equals("none")) {
- this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
- }
- this.voteSB = Bukkit.getScoreboardManager().getNewScoreboard();
- Objective voteObj = voteSB.registerNewObjective("votes", "dummy");
- voteObj.setDisplayName("§a§lVotes");
- voteObj.setDisplaySlot(DisplaySlot.SIDEBAR);
- //PEX/VAULT LADEN
- PluginManager pm = Bukkit.getPluginManager();
- Bukkit.createWorld(new WorldCreator(getConfig().getString("lobbyspawn").split(";")[5]));
- toLoc(getConfig().getString("lobbyspawn")).getWorld().setAnimalSpawnLimit(0);
- toLoc(getConfig().getString("lobbyspawn")).getWorld().setMonsterSpawnLimit(0);
- List<String> maps = new ArrayList<String>();
- for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
- maps.add(key);
- }
- if(maps.size() > 5) {
- while(maps.size() > 5) {
- maps.remove(new Random().nextInt(maps.size()));
- }
- }
- int i = 1;
- for(String key : maps) {
- me.nicedev.sg.utils.Map map = new me.nicedev.sg.utils.Map(key);
- WorldCreator wc = new WorldCreator(key);
- Bukkit.createWorld(wc);
- Bukkit.getWorld(key).setMonsterSpawnLimit(0);
- voteMaps.put(i, new VoteMap(map));
- voteObj.getScore(Bukkit.getOfflinePlayer("§a" + splitName(map.getDisplayName(), 14))).setScore(0);
- this.maps.add(map);
- i++;
- }
- this.loadVoteInv();
- new SurvivalGamesCountdown().runTaskTimer(this, 0L, 20L);
- new BlockListener();
- new DamageListener();
- new DeathListener();
- new InteractListener();
- new JoinQuitListener();
- new MoveListener();
- new OtherListener();
- for(World world : Bukkit.getWorlds()) {
- world.setAutoSave(false);
- }
- if(getConfig().getBoolean("notallchests.active")) {
- for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
- String[] split = getConfig().getString("notallchests.amount").split("/");
- int zaehler = Integer.parseInt(split[0]);
- int nenner = Integer.parseInt(split[1]);
- int maxChests =
- (getConfig().getStringList("map." + key + ".notallchests.chests").size() / nenner) * zaehler;
- List<Location> moeglich = new ArrayList<Location>();
- List<Location> newLocs = new ArrayList<Location>();
- for(String string : getConfig().getStringList("map." + key + ".notallchests.chests")) {
- moeglich.add(toLoc(string));
- }
- while(newLocs.size() != maxChests) {
- if(moeglich.size() == 0) {
- break;
- }
- Location loc = moeglich.get(new Random().nextInt(moeglich.size()));
- moeglich.remove(loc);
- newLocs.add(loc);
- }
- for(Location loc : newLocs) {
- setChest(loc.getBlock());
- }
- for(Location loc : moeglich) {
- if(getConfig().getStringList("map." + key + ".hardchests")
- .contains(loc.getBlockX() + ";" + loc.getBlockY() + ";" +
- loc.getBlockZ() + ";" + loc.getWorld().getName())) {
- setChest(loc.getBlock());
- continue;
- }
- loc.getBlock().setType(Material.AIR);
- }
- }
- }
- } else {
- new SetupListener();
- if(getConfig().contains("map")) {
- Bukkit.createWorld(new WorldCreator(getConfig().getString("lobbyspawn").split(";")[5]));
- for(String key : getConfig().getConfigurationSection("map").getKeys(false)) {
- Bukkit.createWorld(new WorldCreator(key));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement