What's the problem?

Discussion in 'Plugin Development' started by bigflori, Aug 19, 2017.

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

    bigflori

    Hi, i don't know what is the problem with the code!
    Please help me out.

    Code:
    public class PlayerKill implements Listener {
        private core cfg;
        public PlayerKill(core pl)
        {
            pl = cfg;
        }
        @EventHandler
        public void onPlayerKill(PlayerDeathEvent event)
        {
            if(event.getEntity().getKiller() instanceof Player)
            {
                Player killer = event.getEntity().getKiller();
                Player victim = event.getEntity();
                String uuidKiller = killer.getUniqueId().toString();
                String uuidVictim = victim.getUniqueId().toString();
                int pointsKiller = cfg.getConfig().getInt(uuidKiller + ".pontok");
                int pointsVictim = cfg.getConfig().getInt(uuidVictim + ".pontok");
               
                cfg.getConfig().set(uuidKiller + ".pontok", pointsKiller + 3);
                cfg.getConfig().set(uuidVictim + ".pontok", pointsVictim - 3);
                cfg.saveConfig();
            }
        }
    }
    
     
  2. Offline

    Horsey

    You need to use cfg = pl, not the other way around.

    Edit: also, your core should be in UpperCamelCase (like: Core or My MainClass)
     
    bigflori likes this.
  3. Offline

    bigflori

    Thank you so much! I swapped but not directly the "cfg = pl"
    Now that's work. :)
     
  4. Offline

    Reflxction

    Please mark the thread as solved if the issue is solved
     
Thread Status:
Not open for further replies.

Share This Page