Kicking a player after a certain amount of warnings

Discussion in 'Plugin Development' started by JOPHESTUS, Jul 21, 2012.

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


    Hey dere,

    I am adding more features into my warning plugin, and one that it'd like to add is when a user's warning count gets to a defined int (in config) it will kick them and then reset the amount of warnings.

    How would I go about coding that?
    amountofwarnsbeforekick: 3
        warnamount: 2
    - Swearing
    - Stealing
        warnamount: 1
    - X-Raying
    If you need any more info just ask
    (I hope the explanation is understandable)


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: May 27, 2016
  2. Offline


    There's no need to tag spam people.

    Learn the Configuration API and it will become apparent. At this rate, we'd have coded your plugin for you...
    ZeusAllMighty11 likes this.
  3. Offline


    Easy math.

    if warnings < 3 {
    if warnings == 3{
    send message( "Your warning level is high!");
    if warnings > 3 {
    bukkit dispatch command console sender (ban + args[0])
  4. Offline


    I am learning it, I don't learn very well by reading a big wiki page. I tagged them because they are nice people who take the time to help someone instead of posting comments that in no way help with what I need.
    It's kinda sad that I forgot how to do that :p Thanks :)
  5. Offline


    Just looking over what you have, and I've got a few suggestions. Rather than using a separate value for the number of warnings, you should instead use the length of the list of warnings.
    ArrayList<String> warnings = getConfig().getStringList("md_5");
    int warningCount = warnings.size();
    This is also just a bit easier to do, as the player's would no longer be a ConfigurationSection, just a simple list. It's also makes less work later if you decide that you want to add in functionality for removing warnings, as you don't have to sync the value with the number of warnings.
    JOPHESTUS likes this.
  6. Offline


    :D It works :D
    But a concern I have is, the amount of times they can be warned before getting kicked is defined in the config, at the moment my code is like this
    if (warningCount == maxwarnings){
    Doing it like this will only kick them when they reach the amount defined, so if they get kicked, they can keep being warned over and over again.

    I was thinking adding in another warningslog.yml so they all get logged to there and the warnings.yml and when they get kicked it will erase it from the warnings.yml. What do you think?
  7. Offline


    If that's the goal of your plugin(kicking them), then you should go ahead. I personally would ban them. An alternative to banning them is executing a customizable console command for X warnings. Although, SimpleWarnings does this, as well as a plugin similar to it that I've made.
  8. Offline


    Next weekend I might add in bans & some other stuff, but for now kicks.
    Thanks so much for your help :D
  9. Offline


    In this case just use
    if (warningCount >= maxwarnings)
    which basically means 'if warning count is more than or is maxwarnings, do whatever.
    WarmakerT likes this.
  10. Offline


    You could add a check into your command where they get warned and check if they already have the max number of warnings, and if they do, then just leave their warning count alone.
  11. Offline


    ..or do what I stated above.
Thread Status:
Not open for further replies.

Share This Page