Adding to an Int from Config

Discussion in 'Plugin Development' started by AwesomeMarioFan, Sep 16, 2013.

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

    AwesomeMarioFan

    Hello,
    I am trying to implement a hitcounter function to my plugin, where when a player joins it adds one to the config, and announces it.
    Here is the code:
    Code:
    @EventHandler
        public void onPlayerJoin(PlayerJoinEvent evt) {
    getConfig().getInt("internal.hitCounter");
    getConfig().set("internal.hitCounter", getConfig().getInt("internal.hitCounter") + 1);
            saveConfig();
    getConfig().getBoolean("config.enablehitCounter");
    if(getConfig().getBoolean("config.enablehitCounter") == true) {
    this.getServer().broadcastMessage("[AMFGaming] The server has " + getConfig().getInt("internal.hitCounter") + " hits!");
    }
    }
    Edit: Hit Counter part of Config.yml:
    Code:
    internal:
      hitCounter: 0
    I was wondering if I was doing something wrong?
    Thanks!,
     
  2. Offline

    chasechocolate

    What doesn't work? Does it announce the message?
     
  3. Offline

    PimpDuck

    Yeah, I don't see anything wrong :I
     
  4. Offline

    AwesomeMarioFan

    When I rejoin on a test server a bunch of times the message doesn't seem to display and the hit counter stays at 0 in the config.yml.
    I even tried adding @Override to my onEnable, but still nothing.

    Ah,

    Seems to work if I implement it into another plugin I'm working on.
    Maybe I had messy code or something.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
Thread Status:
Not open for further replies.

Share This Page