Not working

Discussion in 'Plugin Development' started by Plugers11, Apr 21, 2014.

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

    Plugers11

    public class Kill implements Listener{

    @EventHandler
    public void on(PlayerDeathEvent e){
    Player za = e.getEntity().getKiller();

    int kill = Main.getKills();
    Main.cfg.getInt("Kills." + za.getName(), kill+1);
    try {
    Main.cfg.save(Main.file);
    } catch (IOException e1) {
    e1.printStackTrace();
    }
    }
     
  2. Offline

    ButterSquidz

    There is so much wrong with this code... I don't know where to begin. Please show us the code of the main class, your config and your stack trace.
     
  3. Offline

    Plugers11

    Main


    public static File file = new File("plugins/Dead", "deads.yml");
    public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);

    public void onEnable(){

    this.getServer().getPluginManager().registerEvents(new Dead(), this);
    this.getServer().getPluginManager().registerEvents(new Kill(), this);
    try {
    cfg.load(file);
    } catch (FileNotFoundException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    } catch (InvalidConfigurationException e) {
    e.printStackTrace();
    }

    try {
    cfg.save(file);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public void onDisable(){
    try {
    cfg.save(file);
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    public static int getDeaths() {
    return cfg.getInt("Deads", 0);
    }
    public static int getKills(){
    return cfg.getInt("Kills", 0);
    }
    }

    And ?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    ZodiacTheories

    Plugers11 -------------------------------------------------^ (code button)

    Could you use the code button to show your code please.
     
  5. Offline

    Plugers11

  6. Offline

    ZodiacTheories

  7. Offline

    MrInterBugs

    @Plugers11 You do have a Plugin.yml dont you
     
  8. Offline

    Plugers11

    I fixed the problem
    I create new project and new ideas :d
    And working
    Thx for help guys
     
Thread Status:
Not open for further replies.

Share This Page