Check and set Config

Discussion in 'Plugin Development' started by Charona, May 6, 2014.

Thread Status:
Not open for further replies.
  1. Hello, I have some problems with configs, i've made a inventory GUI here's the code:
    Code:
    @EventHandler
        public void onInterractGui(InventoryClickEvent event) {
            Player player = (Player) event.getWhoClicked();
            if (!main.choix.contains(player.getName()))
                return;
            switch (event.getCurrentItem().getType()) {
            case IRON_SWORD:
                chevalier(player);
                player.closeInventory();
                break;
    default:
                break;
            }
        }
    And this is the second part

    Code:
    public void chevalier(Player player) {
     
            String Classe = "Classe." + player.getName();
            String CurrentClasse = "CurrentClasse." + player.getName();
     
            if (getConfig().contains(Classe + "chevalier")) {
     
                player.sendMessage(ChatColor.GOLD + "Votre nouvelle classe est"
                        + ChatColor.DARK_BLUE + "Chevalier");
                getConfig().set(CurrentClasse, Integer.valueOf("chevalier"));
                saveConfig();
     
                player.closeInventory();
                main.choix.remove(player.getName());
            }
        }
    Sorry but i'm a beginner and i don't know how to make this works :/
    Thanks for help ;)
     
  2. Offline

    Deleted user

    What's the problem?
     
  3. Offline

    jdjack

    In the bit of code below, i think you may have missed out a . in the 6th line. I have posted a possible correction below.

    Code:java
    1. public void chevalier(Player player) {
    2.  
    3. String Classe = "Classe." + player.getName();
    4. String CurrentClasse = "CurrentClasse." + player.getName();
    5.  
    6. if (getConfig().contains(Classe + "chevalier")) {
    7.  
    8. player.sendMessage(ChatColor.GOLD + "Votre nouvelle classe est"
    9. + ChatColor.DARK_BLUE + "Chevalier");
    10. getConfig().set(CurrentClasse, Integer.valueOf("chevalier"));
    11. saveConfig();
    12.  
    13. player.closeInventory();
    14. main.choix.remove(player.getName());
    15. }
    16. }


    Code:java
    1. if (getConfig().contains(Classe + ".chevalier")) {
     
  4. The problem is when i click on the iron sword the inventory is close but nothing after
     
Thread Status:
Not open for further replies.

Share This Page