I have 2 pieces of code Code: if(args[0].equalsIgnoreCase("newregion")){ if(p.hasPermission("sc.regions")){ if(selectone.get(p.getName()) != null){ if(selecttwo.get(p.getName()) != null){ if(args.length == 2){ if(plugin.getConfig().isSet("regions." + args[1])){ p.sendMessage(ChatColor.GREEN + "Replaced old region " + args[1] + " with new one"); } plugin.getConfig().set("regions." + args[1] + ".select1", locationToString(selectone.get(p.getName()))); plugin.getConfig().set("regions." + args[1] + ".select2", locationToString(selecttwo.get(p.getName()))); plugin.saveDefaultConfig(); p.sendMessage(ChatColor.GREEN + "Region " + args[1] + " added"); } }else{ p.sendMessage(ChatColor.RED + "Selection 2 with /sc wand must be set before using this command."); } }else{ p.sendMessage(ChatColor.RED + "Selection 1 with /sc wand must be set before using this command."); } } } and Code: @EventHandler public void onPlayerInteract(PlayerInteractEvent event){ if(event.getPlayer().getItemInHand() != null){ if(event.getPlayer().getItemInHand().getItemMeta() != null){ if(event.getPlayer().getItemInHand().getItemMeta().getDisplayName() != null){ if(event.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Grey Territory Wand")){ if(event.getAction() == Action.RIGHT_CLICK_BLOCK){ this.selecttwo.put(event.getPlayer().getName(), event.getClickedBlock().getLocation()); event.getPlayer().sendMessage(ChatColor.GREEN + "Selection 2 selected at " + locationToString(selecttwo.get(event.getPlayer().getName()))); }else if(event.getAction() == Action.LEFT_CLICK_BLOCK){ this.selectone.put(event.getPlayer().getName(), event.getClickedBlock().getLocation()); event.getPlayer().sendMessage(ChatColor.GREEN + "Selection 1 selected at " + locationToString(selectone.get(event.getPlayer().getName()))); } } } } } } This second code will send me the selection messages, but the command /sc newregion tells me that select1.get(p.getName()) is null. I did this all using the same player.
@Zombie_Striker At later parts, I checked both selects. Both are null. It won't help. It just points to select1 or 2 .get(p.getUniqueId); being null
@Hex_27 I can't really find your issue, but I did notice something else. You called saveDefaultConfig() when setting the paths, that has to be saveConfig() or else your data won't get saved
@megamichiel But my comments... Besides that, the program doesn't really reach that part. The error just decides to come out
@megamichiel Sorry if I'm reluctant to, but this is a paid plugin, so I'm not ready to release large parts of the code publicly. Besides, what does onEnable have to do with this? The plugin can enable itself fine, and the other listeners in the problematic class work fine. (Except the selections being null.) @CodePlaysMinecraft In instantiated hashmaps. <UUID, Location>
@Hex_27 You charge a person to develop a plugin for someone and you can't handle to finish that task. Now these people here are trying to help you as best as they possibly can. If you don't want to show some code or at least post a stacktrace, then I guess you've come to the wrong place.
Print out the Map when a player uses the command. I.e. After: if(p.hasPermission("sc.regions")){ Type: Code: System.out.println(selectone.toString()); System.out.println(selecttwo.toString()); If it's empty, it means something is clearing the Map or removing it. By the way, I'd recommend using a custom made class, e.g. called Selection, that contains two int arrays and the string (world name). The int arrays having a size of 3, and the xyz coords are put in there. It's easier to manage one Map than two.
@megamichiel Yes I have, and the other listeners work fine. That listener works too, but select1 and 2 just become null
@Hex_27, let's start here. First of all, stop using player names. I don't know how many times we will have to say this. Names break plugins. Tons of servers advocate not changing names for this exact reason- tons of devs refuse to switch to UUID. Please don't contribute. I know those hashmaps aren't set with the generic type of UUID. If they are, you need a better IDE that will warn you to unchecked cast errors. Denying us the stack trace is going to make this hard, but what I think is happening is that you have several instances of the same class. Each listener is registered differently, (The amount of people who don't understand Java's memory practices drive me insane). This is a temp fix, but set the hashmaps as final and static. DON'T LEAVE THEM THIS WAY. If it suddenly works, come back and post your listener declarations. If you get a syntax error, you screwed up bad somewhere.
@Tecno_Wizard It was UUID, I changed it to names cos I wanted to see if it worked. I'll try the static thing.