Problem with hashmap

Discussion in 'Spigot Plugin Development' started by 225wre, May 21, 2019.

Thread Status:
Not open for further replies.
  1. I fix it, the private in hashmap has the problem :)
     
    #1 225wre, May 21, 2019
    Last edited: May 23, 2019
  2. Hello,

    Everything depends on how you fill this map, and how you get it.
    This little part of code, without errors, doesn't help us, to help you.
     
  3. You're never checking if the arena is null before adding it, what the error is telling you is that the arena you're trying to add to the list is null aka nothing.
     
  4. Code (Text):

    if(!gm.exists(name)){
        p.sendMessage(Utils.chat(mes.getString("DoesNotExist")));
    }
                     
    Arena arena = gm.getArena(name);
     
    i imagine you want to skip the rest of the block once you determine "!gm.exists(name)" is true.
     
  5. I assume the code in your initial post is from your GameManager class.
    Your second post shows that you never use gm.registerArenas() before trying to add a player to an arena. Your hashmap with arenas is therefore empty and gm.getArena() always returns null.
     
  6. I have tried adding a message at the end of when the sands are loaded so that it tells me the size of the hashmap and is different from 0
     
  7. check if the values inside the config is null
     
  8. Yup, hashmaps support null values unless you specify otherwise.
     
  9. How can I verify if it is null? do you have any idea? some example?
     
  10. Don't add a null value to the map, aka. you should have a null check before adding a value to a map, or specify @NotNull
     
  11. I added messages in each quantity and data to verify that it was wrong, and this happened

    Code (Text):
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Minplayers 0 for Arena null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Maxplayers 0 for Arena null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading World for Arena null World: null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Prefix for Arena null Prefix: null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Waitimer 0 for Arena null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Minutes the Game 0 Arena: null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Seconds the Game 0 Arena: null[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Assassains for Arena null Assassains: 0[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Detectives for Arena null Detectives: 0[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Accomplices for Arena null Accomplices: 0[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Assistants for Arena null Assistants: 0[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Minplayers 1 for Arena portal[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Maxplayers 4 for Arena portal[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading World for Arena portal World: end[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Prefix for Arena portal Prefix: end[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Waitimer 45 for Arena portal[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Minutes the Game 10 Arena: portal[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Seconds the Game 5 Arena: portal[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Assassains for Arena portal Assassains: 1[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Detectives for Arena portal Detectives: 1[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Accomplices for Arena portal Accomplices: 1[m
    [17:42:50] [Server thread/INFO]: [0;36;1mLoading Quantity the Assistants for Arena portal Assistants: 1[m
    [17:42:50] [Server thread/INFO]: [0;35;1mLoading WorldMap for Arena portal[m
    [17:42:51] [Server thread/INFO]: -------- World Settings For [end] --------
    [17:42:51] [Server thread/INFO]: Item Despawn Rate: 6000
    [17:42:51] [Server thread/INFO]: Item Merge Radius: 2.5
    [17:42:51] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
    [17:42:51] [Server thread/INFO]: Arrow Despawn Rate: 1200
    [17:42:51] [Server thread/INFO]: View Distance: 10
    [17:42:51] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
    [17:42:51] [Server thread/INFO]: Experience Merge Radius: 3.0
    [17:42:51] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
    [17:42:51] [Server thread/INFO]: Mob Spawn Range: 4
    [17:42:51] [Server thread/INFO]: Cactus Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Cane Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Melon Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Mushroom Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Sapling Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Wheat Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: NetherWart Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Vine Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Cocoa Growth Modifier: 100%
    [17:42:51] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
    [17:42:51] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
    [17:42:51] [Server thread/INFO]: Random Lighting Updates: false
    [17:42:51] [Server thread/INFO]: Structure Info Saving: true
    [17:42:51] [Server thread/INFO]: Max TNT Explosions: 100
    [17:42:51] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
    [17:42:51] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
    [17:42:51] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617 Monument: 10387313 Slime: 987234911
    [17:42:52] [Server thread/INFO]: Preparing start region for level 1 (Seed: 0)
    [17:42:54] [Server thread/INFO]: Preparing spawn area for end, 40%
    [17:42:55] [Server thread/INFO]: Preparing spawn area for end, 93%
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading Spawns Locations for portal[m
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading Gold Drop Locations for portal[m
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading Lobby Location for Arena portal[m
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading MainLobby Location for Arena portal[m
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading Spectator Location for Arena portal[m
    [17:42:55] [Server thread/INFO]: [0;36;1mLoading Spectator Location for Arena portal[m
    [17:42:55] [Server thread/INFO]: [0;33;1mArena Succefully Loaded By Name portal[m
    [17:42:55] [Server thread/INFO]: [0;35;1mBlock not Sign Found end Skiped This Sign[m
    [17:42:55] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
    [17:42:55] [Server thread/INFO]: Done (12,582s)! For help, type "help" or "?"
    after that I fixed it and now if you send me the values look

    Code (Text):
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Minplayers 1 for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Maxplayers 4 for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Prefix for Arena hoyo Prefix: end[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Waitimer 45 for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Minutes the Game 10 Arena: hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Seconds the Game 5 Arena: hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Quantity the Assassains for Arena hoyo Assassains: 1[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Quantity the Detectives for Arena hoyo Detectives: 1[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Quantity the Accomplices for Arena hoyo Accomplices: 1[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Quantity the Assistants for Arena hoyo Assistants: 1[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Spawns Locations for hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Gold Drop Locations for hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Lobby Location for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading MainLobby Location for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Spectator Location for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;36;1mLoading Spectator Location for Arena hoyo[m
    [18:06:34] [Server thread/INFO]: [0;33;1mArena Succefully Loaded By Name hoyo[m
    but still the hashamp system when I want to enter an arena says that it does not exist, it does not give me errors, it just says that it does not exist
     
  12. I have no idea how your Arena system is setup, it may be an issue with your Arena class/interface...
     
  13. Code (Java):

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label,
                String[] args) {
                ...
                GameManager gm = new GameManager();
                ...
                            if(!gm.exists(name)){
                                p.sendMessage(Utils.chat(mes.getString("DoesNotExist")));
                            }
                   
                            Arena arena = gm.getArena(name);
                            ...            
       
    These are the 2 times I see you doing something with you GameManager after initializing it.
    Can you explain where exactly this new GameManager gets it's arenas from?
    For me this looks like you never register any arenas here at all.
     
    #13 MightyOne, May 22, 2019
    Last edited: May 22, 2019
    • Agree Agree x 1
  14. When the console is printing out null that usually means its very easy to fix the error. I recommend using Bukkit.Broadcast() for each each variable on the line and tracing it back to what ever is null.
     
  15. Look there
    Code (Java):
    public class GameManager {
     
        private HashMap<String, Arena> arenas = new HashMap<>();
        private NumberFormat nf = NumberFormat.getInstance();
     
     
        public void registerArenas(String name, String prefix, int minplayers, int maxplayers, int assassains, int detectives, int accomplices, int assistants, int waitimer, List<Location> spawn , List<Location> gold,
                Location lobby, Location mainlobby, Location spectator, Location corpse, int minutes, int seconds){
            arenas.put(name, new Arena(name, prefix, minplayers, maxplayers, minutes, seconds, waitimer, assassains, detectives, accomplices, assistants, lobby, mainlobby, spectator, corpse, gold, spawn));
        }
     
        public Arena getArena(String name){
            return arenas.get(name);
        }
     
        public Arena remove(String name){
            return arenas.remove(name);
        }
     
        public boolean exists(String name){
            return arenas.containsKey(name);
        }
     
        public HashMap<String, Arena> getArenas(){
            return this.arenas;
        }
     
        public Arena getContentOf(String cont){
            for(String ar : arenas.keySet()){
                Arena arena = getArena(ar);
                if(arena.getPrefix().equals(ChatColor.stripColor(cont))){
                    return arena;
                }
            }
            return null;
        }
     
     
        public Arena getByEntity(Entity ent){
            Player p = (Player) ent;
            for(Arena arena : getArenas().values()){
                List<UUID> players = arena.getPlayers();
                if(players.contains(p.getUniqueId())){
                    return arena;
                }
            }
            return null;
        }
        public boolean getByPlayer(Player p){
            for(Arena arena : getArenas().values()){
                List<UUID> players = arena.getPlayersInGame();
                if(players.contains(p.getUniqueId())){
                    return true;
                }
            }
            return false;
        }
        public Arena getArenaByPlayer(Player p){
          for(Arena arena : getArenas().values()){
              List<UUID> players = arena.getPlayers();
              if(players.contains(p.getUniqueId())){
                  return arena;
              }
          }
          return null;
        }
        public void loadArenas() throws IOException{
            arenas.clear();
            if(ConfigManager.getInstance().getArenasFile().exists()){
                try{
                    FileConfiguration base = ConfigManager.getInstance().getArenas();
                    if(base.getConfigurationSection("arenas") != null){
                        for(String key : base.getConfigurationSection("arenas").getKeys(false)){
                       
                            String name = base.getString("arenas." + key + ".name");
                            String world = base.getString("arenas." + key + ".world");
                            if(world != null ){
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading World for Arena " + name + " World: " + world);
                            WorldManager wm = new WorldManager();
                            Environment type = Environment.valueOf(base.getString("arenas." + key  + ".worldtype").toUpperCase());
                            Bukkit.getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"Loading WorldMap for Arena " + name);
                            wm.loadWorld(world, type);
                       
                            int minplayers = base.getInt("arenas." + key + ".minplayers");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Minplayers "+ nf.format(minplayers)+" for Arena "+name);

                            int maxplayers = base.getInt("arenas." + key + ".maxplayers");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Maxplayers "+ nf.format(maxplayers)+" for Arena "+name);

                            String prefix = base.getString("arenas." + key + ".prefix");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Prefix for Arena "+ name + " Prefix: "+ prefix);

                            int waitimer = base.getInt("arenas." + key + ".waitimer");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Waitimer " + nf.format(waitimer)+" for Arena "+name);

                            int minutes = base.getInt("arenas." + key + ".minutes");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Minutes the Game " + nf.format(minutes)+" Arena: "+name);

                            int seconds = base.getInt("arenas."  + key + ".seconds");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Seconds the Game " + nf.format(seconds)+" Arena: "+name);

                            int assassains = base.getInt("arenas." + key + ".assassains");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Quantity the Assassains for Arena " + name + " Assassains: " + nf.format(assassains));

                            int detectives = base.getInt("arenas." + key + ".detectives");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Quantity the Detectives for Arena " + name + " Detectives: " + nf.format(detectives));
                       
                            int accomplices = base.getInt("arenas." + key + ".accomplices");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Quantity the Accomplices for Arena " + name + " Accomplices: " + nf.format(accomplices));
                       
                            int assistants = base.getInt("arenas." + key + ".assistants");
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Quantity the Assistants for Arena " + name + " Assistants: " + nf.format(assistants));
                       
                            List<String> loc = base.getStringList("arenas." + key + ".spawn");
                            List<Location> spawns = new ArrayList<>();
                       
                            List<String> gold = base.getStringList("arenas." + key + ".gold");
                            List<Location> golds = new ArrayList<>();
                       
                            for(String s : loc){
                                String[] get = s.split(":");
                           
                           
                                double x = Double.valueOf(get[0]);
                                double y = Double.valueOf(get[1]);
                                double z = Double.valueOf(get[2]);
                                float pitch = Float.valueOf(get[3]);
                                float yaw = Float.valueOf(get[4]);
                                if(get.length == 5){
                                Location spawn = new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
                                spawns.add(spawn);
                                Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Spawns Locations for " + name);
                                }else{
                                    Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Missing Args for Spawn location");
                                }
                            }
                       
                            for(String s : gold){
                                String[] get = s.split(":");
                           
                                double x = Double.valueOf(get[0]);
                                double y = Double.valueOf(get[1]);
                                double z = Double.valueOf(get[2]);
                                float pitch = Float.valueOf(get[3]);
                                float yaw = Float.valueOf(get[4]);
                           
                                if(get.length == 5){
                                Location god = new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
                                golds.add(god);
                                Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Gold Drop Locations for " + name);
                                }else{
                                    Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Missing Args for Gold drop location");
                                }
                            }
                       
                       
                            double lobbyx = base.getDouble("arenas." + key + ".lobby.x");
                            double lobbyy = base.getDouble("arenas." + key + ".lobby.y");
                            double lobbyz = base.getDouble("arenas." + key + ".lobby.z");
                            float  lobbyp = (float) base.getDouble("arenas." + key + ".lobby.pitch");
                            float lobbyyaw = (float) base.getDouble("arenas." + key + ".lobby.yaw");
                            String wlobby = base.getString("arenas." + key + ".lobby.world");
                            Location lobby = new Location(Bukkit.getWorld(wlobby), lobbyx, lobbyy, lobbyz, lobbyyaw, lobbyp);
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Lobby Location for Arena "+ name);
                       
                       
                            double mlobbyx = base.getDouble("arenas." + key + ".mainlobby.x");
                            double mlobbyy = base.getDouble("arenas." + key + ".mainlobby.y");
                            double mlobbyz = base.getDouble("arenas." + key + ".mainlobby.z");
                            float  mlobbyp = (float) base.getDouble("arenas." + key + ".mainlobby.pitch");
                            float mlobbyyaw = (float) base.getDouble("arenas." + key + ".mainlobby.yaw");
                            String wmain = base.getString("arenas." + key + ".mainlobby.world");
                            Location mainlobby = new Location(Bukkit.getWorld(wmain), mlobbyx, mlobbyy, mlobbyz, mlobbyyaw, mlobbyp);
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading MainLobby Location for Arena "+ name);
                       
                       
                            double cx = base.getDouble("arenas." + key + ".corpse.x");
                            double cy = base.getDouble("arenas." + key + ".corpse.y");
                            double cz = base.getDouble("arenas." + key + ".corpse.z");
                            float  cp = (float) base.getDouble("arenas." + key + ".corpse.pitch");
                            float cyaw = (float) base.getDouble("arenas." + key + ".corpse.yaw");
                            Location corpse = new Location(Bukkit.getWorld(world), cx, cy, cz, cyaw, cp);
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Spectator Location for Arena "+ name);
                       
                       
                            double sx = base.getDouble("arenas." + key + ".spectator.x");
                            double sy = base.getDouble("arenas." + key + ".spectator.y");
                            double sz = base.getDouble("arenas." + key + ".spectator.z");
                            float  sp = (float) base.getDouble("arenas." + key + ".spectator.pitch");
                            float syaw = (float) base.getDouble("arenas." + key + ".spectator.yaw");
                            Location spectator = new Location(Bukkit.getWorld(world), sx, sy, sz, syaw, sp);
                            Bukkit.getConsoleSender().sendMessage(ChatColor.AQUA+"Loading Spectator Location for Arena "+ name);
                       
                       
                            if(loc != null && gold != null && name !=  null && world != null && type != null && minutes >= 0 && seconds >= 0 && waitimer >= 0 && prefix != null
                                    && maxplayers >= 0 && minplayers >= 0 && assassains >= 0 && detectives >= 0 && accomplices >= 0 && assistants >= 0 && lobby != null && mainlobby != null && spectator != null && corpse != null){
                                arenas.put(name, new Arena(name, prefix, minplayers, maxplayers, minutes, seconds, waitimer, assassains, detectives, accomplices, assistants, lobby, mainlobby, spectator, corpse, golds, spawns));
                                getArena(name).setStates(ArenaStates.WAITING);
                                Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW+"Arena Succefully Loaded By Name "+ name);
                                if(arenas.isEmpty()){
                                    Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW+"Arenas is Empty");
                                }
                            }else{
                                Bukkit.getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"Could not be Load the Arena "+ name);
                            }
                       
                            }else{
                           
                            }
                        }
                    }
                }catch(YAMLException e){
                    Bukkit.getConsoleSender().sendMessage(ChatColor.RED+"Exception in: ");
                    e.printStackTrace();
                }
            }else{
                Bukkit.getConsoleSender().sendMessage(ChatColor.RED+"Section could not be null");
            }
        }
    and it this how i can load the arenas

    Code (Java):
    public class MurderMistery extends JavaPlugin{

     
     
        public PluginDescriptionFile pdf = getDescription();
        public String RConfig;
        public String Name = ChatColor.DARK_RED+"--["+ChatColor.RED+pdf.getName()+ChatColor.DARK_RED+"]--";
        public String Vers = ChatColor.AQUA+"["+ChatColor.RED+pdf.getVersion()+ChatColor.AQUA+"]";
        private ConfigManager cg;
        private static MurderMistery instance;
        private GameManager gm;
        private SignManager sg;
        Utils util = new Utils();
     
        public void onEnable(){
            instance = this;
            Bukkit.getConsoleSender().sendMessage(Name);
            Bukkit.getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"-----------------------");
            Bukkit.getConsoleSender().sendMessage(Utils.chat("&bVersion:")+Vers);
            Bukkit.getConsoleSender().sendMessage(Utils.chat("&cEnabling Plugin and Data"));
            Bukkit.getConsoleSender().sendMessage(ChatColor.LIGHT_PURPLE+"-----------------------");

            registerFiles();
            RegisterConfig();
            registerEvents();
            registerCommands();
            Countdown.setupCooldown();
            this.gm = new GameManager();
            this.sg = new SignManager();
            try{
            gm.loadArenas();
            sg.loadSing();
            }catch(IOException e){
                e.printStackTrace();
            }
        }
    and the arenas into yml, nobody exist

    Code (Text):
    arenas:
      example: hello
      end:
        name: hoyo
        prefix: end
        minplayers: 1
        maxplayers: 4
        world: end
        worldtype: NORMAL
        waitimer: 45
        minutes: 10
        seconds: 5
        assassains: 1
        detectives: 1
        accomplices: 1
        assistants: 1
        spawn:
        - -38.06607117034351:67.0:-3.9928373477381696:20.483337:28.155725
        gold:
        - -38.06607117034351:67.0:-3.9928373477381696:20.483337:28.155725
        lobby:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
          world: end
        mainlobby:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
          world: end
        corpse:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
        spectator:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
        sign:
          x: 48.0
          y: 109.0
          z: 149.0
          world: spawn
      portal:
        name: portal
        prefix: portal
        minplayers: 2
        maxplayers: 4
        world: portal
        worldtype: NORMAL
        waitimer: 45
        minutes: 10
        seconds: 5
        assassains: 1
        detectives: 1
        accomplices: 1
        assistants: 1
        spawn: []
        gold: []
        lobby:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
          world: portal
        mainlobby:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
          world: portal
        corpse:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
        spectator:
          x: 0
          y: 0
          z: 0
          pitch: 0
          yaw: 0
        sign:
          x: 48.0
          y: 109.0
          z: 149.0
          world: spawn
     
     
  16. Then delete GameManager gm = new GameManager(); in your method onCommand(). This local variable has the same name as the global one, which is confusing, it is a completely new instance and has no arenas loaded and it is the reason why you are receiving NPEs
     
  17. You never add any arenas. You should make a global variable in your main class ex.

    Code (Java):
    public class MyPluginMainClass extends JavaPlugin {
       
       private GameManager gm;
       // other stuff
       ...
       
      @Override
      public void onEnable() {
         gm = new GameManager();
         gm.registerArenas(// whatever you should put here);
         // other code
      }
     
      public GameManager getGameManager() {
          return gm;
      }
    }
    Then in your command to get a instance of the game manager you do this:
    Code (Java):
    ...
    GameManager gm = mainClassInstance.getGameManager();
    ...
     
  18. Strahan

    Benefactor

    Also just FYI it's mystery not mistery ;)
     
Thread Status:
Not open for further replies.

Share This Page