How do I add to a config list from a command?

Discussion in 'Plugin Development' started by ObviousEmeralds, Mar 21, 2016.

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

    ObviousEmeralds

    Hello, I am currently trying to make a punishment plugin and one of the feature I want to add is to be able to check a players punishment history. I am trying to do this by whenever someone bans/kicks/mutes/warns a player it adds it to a list in the config. Here's an example of the config.yml about what I mean

    Code:
    #Config
    
    {Player UUID}:
       history:
          - {bans/kicks/mutes/warnings here}
          - Examples:
          - Warned by ObviousEmeralds for spamming
          - Muted by ObviousEmeralds for spamming
          - Banned by ObviousEmeralds for Fly hacking
    If that won't work out, is there any easier ways to do it?
     
  2. Offline

    Zombie_Striker

    @ObviousEmeralds
    Store all the violations as an arraylist, and save them using the following line.
    getConfig().set(UUID+".history", Arraylist of all the violations);
     
    Last edited: Mar 22, 2016
    Gonmarte likes this.
  3. Offline

    ObviousEmeralds

    The ban command would be /ban <player> <reason>... Not /ban <Player> <Violation>
     
  4. Offline

    Zombie_Striker

    @ObviousEmeralds
    But still, that is how you would store all the violations for a player.
     
  5. Offline

    ObviousEmeralds

    What if someone were to do "/ban <player> Flight Hacking - Moving smoothly through the air"
     
  6. Offline

    ericejs123

    You can check if the second arg is a player, if it is, then add that to an arraylist. then cycle through the rest of the args with a for loop, adding it to the arraylist. then cycle through the arraylist to form the reason why the player got kicked/banned/muted/etc. then add it the the config by Zombie_Striker's method. That's how I would go about it; not sure if there is any other way too
     
Thread Status:
Not open for further replies.

Share This Page