[GELÖST] MapManager - ERROR beim Laden

Wenn ihr bei eurem Plugin nicht weiter kommt, könnt ihr hier euer Problem beschreiben und um Hilfe bitten.

[GELÖST] MapManager - ERROR beim Laden

Beitragvon IcySkill » So 18. Okt 2015, 15:22

Hey,

ich habe mal wieder ein Problem: Ich programmiere im Moment ein Map-Management System, welches mit einem Voting-System zusammen hängt. Die Map, die das Voting gewonnen hat, wird geladen und somit auch die Locations der Map, die in einer Datei abgespeichert sind, die wie die Map heißt. Jedoch erhalte ich beim Laden der Locations folgenden Error:

Error:
Code: Alles auswählen
  1. [16:04:20 WARN]: [BedWars] Task #12 for BedWars v1.8.7 generated an exception
  2. java.lang.NullPointerException
  3.         at de.icyskill.bed.manager.MapManager.loadMapSpawners(MapManager.java:102) ~[?:?]
  4.         at de.icyskill.bed.manager.GameManager.prepareStart(GameManager.java:21) ~[?:?]
  5.         at de.icyskill.bed.scheduler.LobbyScheduler.run(LobbyScheduler.java:58) ~[?:?]
  6.         at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot_server.jar:git-Spigot-5818108-5e91446]
  7.         at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot_server.jar:git-Spigot-5818108-5e91446]
  8.         at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:726) [spigot_server.jar:git-Spigot-5818108-5e91446]
  9.         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:368) [spigot_server.jar:git-Spigot-5818108-5e91446]
  10.         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:657) [spigot_server.jar:git-Spigot-5818108-5e91446]
  11.         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:560) [spigot_server.jar:git-Spigot-5818108-5e91446]
  12.         at java.lang.Thread.run(Unknown Source) [?:1.8.0_20]


MapManager:
Code: Alles auswählen
  1. public class MapManager {
  2.     private final BedWars plugin;
  3.     public static File file;
  4.     public static FileConfiguration cfg;
  5.     private static Map<String, Location> locations;
  6.     private static String mapName;
  7.    
  8.     public MapManager(BedWars plugin) {
  9.         this.plugin = plugin;
  10.         locations = new HashMap<>();
  11.         if(BedWars.getMapName() != null) {
  12.             mapName = BedWars.getMapName();
  13.         } else mapName = "world";
  14.         file = new File(plugin.getDataFolder() + "/MapData", mapName + ".yml");
  15.         cfg = YamlConfiguration.loadConfiguration(file);
  16.     }
  17.    
  18.     public static void setRespawnBlocks() {
  19.         switch(BedWars.getTeamCount()) {
  20.             case TWO:
  21.                 Location twored = getMapDataLocation("RedRespawnBlock");
  22.                 Location twoblue = getMapDataLocation("BlueRespawnBlock");
  23.                 twored.getBlock().setType(Material.EMERALD_BLOCK);
  24.                 twoblue.getBlock().setType(Material.EMERALD_BLOCK);
  25.                 break;
  26.             case FOUR:
  27.                 Location fourred = getMapDataLocation("RedRespawnBlock");
  28.                 Location fourblue = getMapDataLocation("BlueRespawnBlock");
  29.                 Location fourgreen = getMapDataLocation("GreenRespawnBlock");
  30.                 Location fouryellow = getMapDataLocation("YellowRespawnBlock");
  31.                 fourred.getBlock().setType(Material.EMERALD_BLOCK);
  32.                 fourblue.getBlock().setType(Material.EMERALD_BLOCK);
  33.                 fourgreen.getBlock().setType(Material.EMERALD_BLOCK);
  34.                 fouryellow.getBlock().setType(Material.EMERALD_BLOCK);
  35.                 break;
  36.             case EIGHT:
  37.                 Location eightred = getMapDataLocation("RedRespawnBlock");
  38.                 Location eightblue = getMapDataLocation("BlueRespawnBlock");
  39.                 Location eightgreen = getMapDataLocation("GreenRespawnBlock");
  40.                 Location eightyellow = getMapDataLocation("YellowRespawnBlock");
  41.                 Location eightgold = getMapDataLocation("GoldRespawnBlock");
  42.                 Location eightwhite = getMapDataLocation("WhiteRespawnBlock");
  43.                 Location eightpurple = getMapDataLocation("PurpleRespawnBlock");
  44.                 Location eightaqua = getMapDataLocation("AquaRespawnBlock");
  45.                 eightred.getBlock().setType(Material.EMERALD_BLOCK);
  46.                 eightblue.getBlock().setType(Material.EMERALD_BLOCK);
  47.                 eightgreen.getBlock().setType(Material.EMERALD_BLOCK);
  48.                 eightyellow.getBlock().setType(Material.EMERALD_BLOCK);
  49.                 eightgold.getBlock().setType(Material.EMERALD_BLOCK);
  50.                 eightwhite.getBlock().setType(Material.EMERALD_BLOCK);
  51.                 eightpurple.getBlock().setType(Material.EMERALD_BLOCK);
  52.                 eightaqua.getBlock().setType(Material.EMERALD_BLOCK);
  53.                 break;
  54.         }
  55.     }
  56.    
  57.     public static void loadMap() {
  58.         if(mapName != null) {
  59.             mapName = BedWars.getMapName();
  60.             Bukkit.getServer().createWorld(new WorldCreator(mapName));
  61.             World map = Bukkit.getServer().getWorld(mapName);
  62.             map.setMonsterSpawnLimit(0);
  63.             map.setAnimalSpawnLimit(0);
  64.             map.setDifficulty(Difficulty.EASY);
  65.             map.setPVP(true);
  66.         }
  67.     }
  68.    
  69.     public static void loadMapSpawners() {
  70.         if(cfg.getConfigurationSection("Spawners").getKeys(false) != null) {
  71.             for(String name : cfg.getConfigurationSection("Spawners").getKeys(false)) {
  72.                 Location loc = new Location(
  73.                         Bukkit.getServer().getWorld(cfg.getString("Spawners." + name + ".Location.World")),
  74.                         cfg.getDouble("Spawners." + name + ".Location.X"),
  75.                         cfg.getDouble("Spawners." + name + ".Location.Y"),
  76.                         cfg.getDouble("Spawners." + name + ".Location.Z"));
  77.                 switch(cfg.getString("Spawners." + name + ".Type")) {
  78.                     case "bronze":
  79.                         BronzeSpawner.locations.add(loc);
  80.                         break;
  81.                     case "silver":
  82.                         SilverSpawner.locations.add(loc);
  83.                         break;
  84.                     case "gold":
  85.                         GoldSpawner.locations.add(loc);
  86.                         break;
  87.                 }
  88.             }
  89.         }  else System.out.println("ERROR: Can not loadMapSpawners()!");
  90.     }
  91.    
  92.     public static void loadMapDataLocations() {
  93.         if(cfg.getConfigurationSection("Locations").getKeys(false) != null) {
  94.             for(String name : cfg.getConfigurationSection("Locations").getKeys(false)) {
  95.                 Location loc = new Location(
  96.                         Bukkit.getServer().getWorld(cfg.getString("Locations." + name + ".Location.World")),
  97.                         cfg.getDouble("Locations." + name + ".Location.X"),
  98.                         cfg.getDouble("Locations." + name + ".Location.Y"),
  99.                         cfg.getDouble("Locations." + name + ".Location.Z"));
  100.                 loc.setYaw((float) cfg.getDouble("Locations." + name + ".Location.Yaw"));
  101.                 loc.setPitch((float) cfg.getDouble("Locations." + name + ".Location.Pitch"));
  102.                 locations.put(name, loc);
  103.             }
  104.         } else System.out.println("ERROR: Can not loadMapDataLocations()!");
  105.     }
  106.    
  107.     public static Location getMapDataLocation(String data) {
  108.         if(locations.containsKey(data)) {
  109.             return locations.get(data);
  110.         }
  111.         return null;
  112.     }
  113. }


GameManager:
Code: Alles auswählen
  1. public class GameManager {
  2.     private BedWars plugin;
  3.    
  4.     public static void start() {
  5.         TeamManager.autoAddToTeam();
  6.        
  7.         System.out.println("Game started!");
  8.     }
  9.    
  10.     public static void prepareStart() {
  11.         BedWars.getInstance().loadMapManager();
  12.         MapManager.loadMap();
  13.         MapManager.loadMapSpawners();
  14.         MapManager.loadMapDataLocations();
  15.         MapManager.setRespawnBlocks();
  16.         BedWars.getInstance().setupWorld();
  17.         BedWars.getInstance().startSpawners();
  18.     }
  19. }


Hauptklasse:
Code: Alles auswählen
  1. public class BedWars extends JavaPlugin {
  2.     public enum GameState {
  3.         LOBBY,
  4.         INGAME,
  5.         RESTART;
  6.     }
  7.    
  8.     public static enum TeamCount {
  9.         TWO,
  10.         FOUR,
  11.         EIGHT;
  12.     }
  13.    
  14.     private final String prefix = "§f§l« §b§lBW §f§l» §r";
  15.     public String gameType;
  16.     private static TeamCount teamCount;
  17.     private static BedWars instance;
  18.     private static String mapName;
  19.     private GameState state;
  20.     public static List<Player> red, blue, green, yellow, gold, white, purple, aqua, spectators;
  21.     public static List<List> lists;
  22.     public Scoreboard scoreboard;
  23.    
  24.     ConfigManager configManager;
  25.     ListenerManager listenerManager;
  26.     TeamManager teamManager;
  27.     BoardManager boardManager;
  28.     VoteManager voteManager;
  29.     MapManager mapManager;
  30.    
  31.     WaitingScheduler waitingScheduler;
  32.     LobbyScheduler lobbyScheduler;
  33.     RestartScheduler restartScheduler;
  34.    
  35.     BronzeSpawner bronzeSpawner;
  36.     SilverSpawner silverSpawner;
  37.     GoldSpawner goldSpawner;
  38.     @Override
  39.     public void onEnable() {
  40.         instance = this;
  41.         state = GameState.LOBBY;
  42.         initManager();
  43.         initClasses();
  44.         initCommands();
  45.         conMySQL();
  46.         ((CraftServer) Bukkit.getServer()).getServer().setMotd("LOBBY:" + getGameType());
  47.         Bukkit.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
  48.     }
  49.     @Override
  50.     public void onDisable() {
  51.         MySQLGames.disconnect();
  52.         MySQLLobby.disconnect();
  53.         super.onDisable();
  54.     }
  55.    
  56.     private void initClasses() {
  57.         ListenerBundle bundle = new ListenerBundle();
  58.         if(finishedSetup()) {
  59.             bundle.addListener(new LobbyListener(this));
  60.             listenerManager.register("Lobby", bundle);
  61.             startWaitingScheduler();
  62.         } else {
  63.             bundle.addListener(new SetupListener(this));
  64.             listenerManager.register("Setup", bundle);
  65.         }
  66.     }
  67.    
  68.     private void initCommands() {
  69.         CommandManager cm = new CommandManager();
  70.         cm.setup();
  71.         getCommand("bw").setExecutor(cm);
  72.     }
  73.    
  74.     private void initManager() {
  75.         configManager = new ConfigManager(this);
  76.         ConfigManager.loadConfig();
  77.         scoreboard = Bukkit.getScoreboardManager().getMainScoreboard();
  78.         setupTeams();
  79.         listenerManager = new ListenerManager(this);
  80.         gameType = getTeamsPerRound() + " x " + getPlayersPerTeam();
  81.         if(finishedSetup()) {
  82.             initGameManager();
  83.         }
  84.     }
  85.    
  86.     private void initGameManager() {
  87.         boardManager = new BoardManager(this);
  88.         voteManager = new VoteManager(this);
  89.         teamManager = new TeamManager(this);
  90.         teamManager.loadTeams();
  91.     }
  92.    
  93.     private void conMySQL() {
  94.         MySQLFile file = new MySQLFile();
  95.         file.setStandard();
  96.         file.readData();
  97.         MySQLGames.connect();
  98.         MySQLLobby.connect();
  99.        
  100.         try {
  101.             PreparedStatement ps = MySQLGames.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS bedwars(playeruuid text, playername text, points int, kills int, beds int, deaths int, wins int, played int)");
  102.             ps.executeUpdate();
  103.             ps.close();
  104.         } catch(SQLException ex) {
  105.             ex.printStackTrace();
  106.         }
  107.     }
  108.    
  109.     public void setupTeams() {
  110.         spectators = new ArrayList<>();
  111.         lists = new ArrayList<>();
  112.         if((ConfigManager.getInt("BedWars.Teams") == 2) | (ConfigManager.getInt("BedWars.Teams") == 4) | (ConfigManager.getInt("BedWars.Teams") == 8)) {
  113.             int count = getTeamsPerRound();
  114.             switch(count) {
  115.                 case 2:
  116.                     teamCount = TeamCount.TWO;
  117.                     red = new ArrayList<>();
  118.                     blue = new ArrayList<>();
  119.                     lists.add(red);
  120.                     lists.add(blue);
  121.                     break;
  122.                 case 4:
  123.                     teamCount = TeamCount.FOUR;
  124.                     red = new ArrayList<>();
  125.                     blue = new ArrayList<>();
  126.                     green = new ArrayList<>();
  127.                     yellow = new ArrayList<>();
  128.                     lists.add(red);
  129.                     lists.add(blue);
  130.                     lists.add(green);
  131.                     lists.add(yellow);
  132.                     break;
  133.                 case 8:
  134.                     teamCount = TeamCount.EIGHT;
  135.                     red = new ArrayList<>();
  136.                     blue = new ArrayList<>();
  137.                     green = new ArrayList<>();
  138.                     yellow = new ArrayList<>();
  139.                     gold = new ArrayList<>();
  140.                     white = new ArrayList<>();
  141.                     purple = new ArrayList<>();
  142.                     aqua = new ArrayList<>();
  143.                     lists.add(red);
  144.                     lists.add(blue);
  145.                     lists.add(green);
  146.                     lists.add(yellow);
  147.                     lists.add(gold);
  148.                     lists.add(white);
  149.                     lists.add(purple);
  150.                     lists.add(aqua);
  151.                     break;
  152.             }
  153.         }
  154.     }
  155.    
  156.     public void setupWorld() {
  157.         if(finishedSetup()) {
  158.             Bukkit.getWorld(mapName).setAutoSave(false);
  159.             System.out.println("WARNING: World Autosave disabled!");
  160.         }
  161.     }
  162.    
  163.     public static BedWars getInstance() {
  164.         return instance;
  165.     }
  166.    
  167.     public String getPrefix() {
  168.         return prefix;
  169.     }
  170.    
  171.     public String getGameType() {
  172.         return gameType;
  173.     }
  174.    
  175.     public static TeamCount getTeamCount() {
  176.         return teamCount;
  177.     }
  178.    
  179.     public GameState getState() {
  180.         return state;
  181.     }
  182.    
  183.     public Scoreboard getScoreboard() {
  184.         return scoreboard;
  185.     }
  186.    
  187.     public ConfigManager getConfigManager() {
  188.         return configManager;
  189.     }
  190.    
  191.     public ListenerManager getListenerManager() {
  192.         return listenerManager;
  193.     }
  194.    
  195.     public TeamManager getTeamManager() {
  196.         return teamManager;
  197.     }
  198.    
  199.     public BoardManager getBoardManager() {
  200.         return boardManager;
  201.     }
  202.    
  203.     public void loadMapManager() {
  204.         mapManager = new MapManager(this);
  205.     }
  206.    
  207.     public static String getMapName() {
  208.         return mapName;
  209.     }
  210.    
  211.     public static void setMapName(String name) {
  212.         mapName = name;
  213.     }
  214.    
  215.     public boolean finishedSetup() {
  216.         return configManager.getBoolean("BedWars.Finished-Setup");
  217.     }
  218.    
  219.     public void setFinishedSetup(boolean finished) {
  220.         configManager.set("BedWars.Finished-Setup", finished);
  221.     }
  222.    
  223.     public static int getPlayersPerTeam() {
  224.         return ConfigManager.getInt("BedWars.PlayersPerTeam");
  225.     }
  226.    
  227.     public int getTeamsPerRound() {
  228.         return ConfigManager.getInt("BedWars.Teams");
  229.     }
  230.    
  231.     public void startWaitingScheduler() {
  232.         waitingScheduler = new WaitingScheduler(this);
  233.     }
  234.    
  235.     public void startLobbyScheduler() {
  236.         lobbyScheduler = new LobbyScheduler(this);
  237.     }
  238.    
  239.     public void startRestartScheduler() {
  240.         restartScheduler = new RestartScheduler();
  241.     }
  242.    
  243.     public void startSpawners() {
  244.         bronzeSpawner = new BronzeSpawner(this);
  245.         silverSpawner = new SilverSpawner(this);
  246.         goldSpawner = new GoldSpawner(this);
  247.     }
  248. }


LobbyScheduler:
Code: Alles auswählen
  1. public class LobbyScheduler implements Runnable {
  2.     private BedWars plugin;
  3.     private int time;
  4.     private int waiting;
  5.     private int run;
  6.    
  7.     public LobbyScheduler(BedWars plugin) {
  8.         this.plugin = plugin;
  9.         time = 31;
  10.         waiting = 21;
  11.         run = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this, 20L, 20L);
  12.     }
  13.     @Override
  14.     public void run() {
  15.         if(Bukkit.getOnlinePlayers().isEmpty()) {
  16.             time = 31;
  17.             return;
  18.         }
  19.        
  20.         if(Bukkit.getOnlinePlayers().size() <= 1) {
  21.             Bukkit.getScheduler().cancelTask(run);
  22.             plugin.startWaitingScheduler();
  23.         }
  24.        
  25.         time --;
  26.        
  27.         for(Player players : Bukkit.getOnlinePlayers()) {
  28.             TitleManager.sendActionBar(players, Messages.msg(players, "lobby_countdown_actionbar").replace("%t", time + "").replace("%s", (time == 1 ? Messages.msg(players, "second") : Messages.msg(players, "seconds"))));
  29.         }
  30.        
  31.         if((time == 30) | (time == 20) | (time == 10) | (time == 3) | (time == 2) | (time == 1)) {
  32.             for(Player players : Bukkit.getOnlinePlayers()) {
  33.                 players.sendMessage(BedWars.getInstance().getPrefix() + Messages.msg(players, "lobby_countdown_chat").replace("%t", time + "").replace("%s", (time == 1 ? Messages.msg(players, "second") : Messages.msg(players, "seconds"))));
  34.                 players.playSound(players.getLocation(), Sound.NOTE_PLING, 2.0F, 2.0F);
  35.             }
  36.         }
  37.        
  38.         if(time == 15) {
  39.             VoteManager.getVoteResult();
  40.         }
  41.         if(time == 10) {
  42.             GameManager.prepareStart();
  43.         }
  44.        
  45.         if(time == 0) {
  46.             Bukkit.getScheduler().cancelTask(run);
  47.             for(Player players : Bukkit.getOnlinePlayers()) {
  48.                 players.sendMessage(BedWars.getInstance().getPrefix() + Messages.msg(players, "lobby_countdown_gamestart"));
  49.                 players.playSound(players.getLocation(), Sound.ENDERDRAGON_GROWL, 2.0F, 2.0F);
  50.             }
  51.             GameManager.start();
  52.         }
  53.     }
  54. }


Ich hoffe, ihr könnt mir mal wieder helfen. Vielen Dank im Voraus!
Mit freundlichen Grüßen

- IcySkill
Benutzeravatar
IcySkill
 
Beiträge: 153
Registriert: Do 12. Feb 2015, 15:23
Wohnort: Baden-Württemberg

Zurück zu Hilfe und Support

Wer ist online?

Mitglieder in diesem Forum: Google [Bot] und 20 Gäste

cron