Advertisement
Guest User

MapManager Class

a guest
Jun 22nd, 2015
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.66 KB | None | 0 0
  1. package com.pixelyeti.goldsiege.GameMechs;
  2.  
  3. import com.pixelyeti.goldsiege.Main;
  4. import com.pixelyeti.goldsiege.Util.FileManager;
  5. import org.bukkit.configuration.ConfigurationSection;
  6. import org.bukkit.configuration.file.FileConfiguration;
  7.  
  8. import javax.security.auth.login.Configuration;
  9. import java.util.Random;
  10.  
  11. /**
  12.  * Created by Callum on 11/06/2015.
  13.  */
  14. public class MapManager {
  15.  
  16.     private static Main plugin;
  17.  
  18.     public MapManager(Main plugin) {
  19.         this.plugin = plugin;
  20.     }
  21.  
  22.     public static final Map[] maps = null;
  23.     public static int count = 0;
  24.  
  25.     public static final void initiateMaps() {
  26.         FileConfiguration config = plugin.getConfigFile(); // <----------- ERRORING FOR NO REASON D:
  27.         ConfigurationSection configSection = config.getConfigurationSection("Maps");
  28.         for (String s : configSection.getKeys(false)) {
  29.             String name = plugin.getConfigFile().getString("Maps." + s + ".Name");
  30.             int numTeams = plugin.getConfigFile().getInt("Maps." + s + ".NumTeams");
  31.             String worldFileName = plugin.getConfigFile().getString("Maps." + s + ".WorldFileName");
  32.             boolean saving = plugin.getConfigFile().getBoolean("Maps." + s + ".Saving");
  33.  
  34.             maps[count] = new Map(name, numTeams, worldFileName, saving, Map.loadSpawns(name));
  35.  
  36.             count++;
  37.         }
  38.     }
  39.  
  40.     public static int selectMap() {
  41.         Map map = null;
  42.         Random rand = new Random();
  43.  
  44.         int randNum = rand.nextInt(((maps.length - 1) - 0) +1);
  45.         map = maps[randNum];
  46.  
  47.         return randNum;
  48.     }
  49.  
  50.     public static Map[] getMaps() {
  51.         return maps;
  52.     }
  53.  
  54.  
  55.  
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement