Solved Kick player after set # of warnings

Discussion in 'Plugin Development' started by Icelaunche, Jan 28, 2014.

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

    Icelaunche

    How would I automatically log warnings per player (after they perform an action) into a config file then auto kick then after they reach a set number?


    Example Config:
    Code:
    warningstokick: 2
     
    warnings:
      Bob: 2
      Joe: 1
     
    
     
  2. Offline

    Desle

    Icelaunche

    Code:java
    1. limit = 3 //the max warnings before a player gets kicked.
    2. int curr = getConfig().getInt("warnings" + "." + p.getName()); //the current warnings of the player.
    3. getConfig().set("warnings" + "." p.getName(), curr + 1); //adds one to the player's warnings
    4. saveConfig(); //saves the warnings
    5.  
    6. if (curr >= limit) { //if the player's warnings are greater or equal to the limit defined above
    7. p.kickPlayer("You've reached the maximum amount of warnings!");
    //it will kick the player
     
  3. Offline

    Icelaunche

    Desle Thanks so much!
     
Thread Status:
Not open for further replies.

Share This Page