If statement error

Discussion in 'Plugin Development' started by Coopah, Feb 6, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Coopah

    @Rocoty
    [world/-2/16]
    It prints the world, x and y of the chunk.
     
  2. Offline

    Rocoty

    I just ran your code on my server. This part seems to function exactly as predicted. Are you sure you're looking for fault in the correct place?
     
  3. Offline

    Coopah

    @Rocoty
    Did you make more then one clan?
     
  4. Offline

    Rocoty

    @Coopah I used your exact configuration.
     
  5. Offline

    Coopah

    @Rocoty
    Hmm, I have no clue. There isn't anywhere else in the code that should be affecting this. So I've removed the else statement and I tried adding it further on in the code. Everything works fine now, however, the "wilderness" is never being shown.
    Code:
    Code:
    @EventHandler
        public void onPlayerMove(PlayerMoveEvent e) {
    
            Player p = e.getPlayer();
    
            Chunk chunk = p.getLocation().getChunk();
            String chunk2 = chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ();
            String cName = plugin.getConfig().getString(p.getName() + ".Clan");
    
            if (plugin.getConfig().contains("Claims")) {
    
                for(String string : plugin.getConfig().getConfigurationSection("Claims").getKeys(true)) {
    
                    List<String> list = plugin.getConfig().getStringList("Claims." + string);
                  
                    if (e.getFrom().getChunk().equals(e.getTo().getChunk())) {
    
                        if (list.contains(chunk2)) {
    
                            if (plugin.getConfig().contains(p.getName())) {                  
    
                                if (plugin.getConfig().getString(p.getName() + ".Clan") == null) {
    
                                    if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + string);
    
                                    }
    
                                } else if (plugin.getConfig().getString(p.getName() + ".Clan").contains(string)) {
    
                                    if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + ChatColor.AQUA + string);
    
                                    }
    
                                    plugin.saveConfig();
    
                                } else if (plugin.getConfig().getStringList(cName + ".Allies").contains(string)) {
    
                                    if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + ChatColor.LIGHT_PURPLE + string);
    
                                    }
    
                                    plugin.saveConfig();
    
                                } else if (plugin.getConfig().getStringList(cName + ".Enemies").contains(string)) {
    
                                    if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + ChatColor.RED + string);
    
                                    }
    
                                    plugin.saveConfig();
    
                                } else if (!plugin.getConfig().getString(p.getName() + ".Clan").contains(string)) {
    
                                    if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + string);
    
                                    }
    
                                    plugin.saveConfig();
                                  
                                } else {
    
                                    if (!plugin.getConfig().contains(p.getName())) {
    
                                        plugin.getConfig().set(p.getName(), "");
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", p.getLocation().getWorld().getName() + "/" + p.getLocation().getBlockX() + "/" + p.getLocation().getBlockY());
                                        p.sendMessage(StringList.pref() + "Territory: " + ChatColor.DARK_GREEN + "Wilderness");
    
                                    } else if (plugin.getConfig().getString(p.getName() + ".PrevChunk") == null) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", "");
    
    
                                    } else if (!plugin.getConfig().getString(p.getName() + ".PrevChunk").contains(chunk2)) {
    
                                        plugin.getConfig().set(p.getName() + ".PrevChunk", chunk.getWorld().getName() + "/" + chunk.getX() + "/" + chunk.getZ());
                                        p.sendMessage(StringList.pref() + "Territory: " + ChatColor.DARK_GREEN + "Wilderness");
    
                                    }
    
                                    plugin.saveConfig();
    
                                }
                            }
                        }
    
                    }
                }
            }
    
    
        }
     
  6. Offline

    Coopah

  7. Offline

    Zombie_Striker

    Add a Iterator that goes through and prints a line of all of the strings in list, and then compare those lines to the chunk you're trying to get. It says that list does not contain chunk2, so see what it does contain.
     
Thread Status:
Not open for further replies.

Share This Page