{CLOSED AND OPENED NEW THREAD}Ticket message

Discussion in 'Plugin Development' started by GalaxyBeatzz, Mar 9, 2014.

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

    GalaxyBeatzz

    Hello I'm busy with a sort of ticket system. When players use the command /problem {here their problem} this will send a message to everyone of the staff... And I'm kinda stuck. So I have a config where you can set wich players recieve this messages. I have the command and an answer that says: Your message have been sended to the staff. But how do I actually send a message to the staff and how do I set the argument that is placed behind /problem to be send to the staff...
    Thanks if someone helps...
     
  2. Offline

    electro4fun

    Code:java
    1. if(args.length == 1){
    2. for(Player online : Bukkit.getOnlinePlayers()){
    3. if(staffList.contains(online.getName()){
    4. online.sendMessage("Ticket Message: " + args[0]);
    5. }
    6. }
    7. }
     
  3. Offline

    GalaxyBeatzz

    Thank you ;)
     
  4. Offline

    GameplayJDK

    GalaxyBeatzz
    If the problem is solved, mark the thread as solved :)
     
  5. Offline

    GalaxyBeatzz

    Sorry I need some more help. My config:
    Code:
    staff:
    - Notch
    - Herobrine
    That is what my config looks like. Now I want all the playernames listed there to recieve the message people put after /problem.

    electro4fun Please help ? :3

    staffList gets underlined in RED.

    GameplayJDK do you have any idea? I need this really...

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

    GameplayJDK

    GalaxyBeatzz
    As far as I understand, you need to get every subitem of the staff property in your config.
    Code:java
    1.  
    2. for(String key : config.getConfigurationSection("derp").getKeys(false)){
    3. System.out.println(config.getString("derp."+ key));
    4. }
    5.  
     
  7. Offline

    GalaxyBeatzz

    I could probably give up java due to the fact I don't understand this. I'm just a very new coder and I coded some "fun" plugins and I know how basic stuff works but please give me an explanaintion. GameplayJDK
     
  8. Offline

    GameplayJDK

    GalaxyBeatzz
    Ok. Sorry. I got these information from here.

    Code:java
    1.  
    2. for(String key : config.getConfigurationSection("staff").getKeys(false)){ // Here you get the "staff" sections subitems
    3. System.out.println(config.getString("staff: "+ key)); // The variable key is the name of the staff, that is looped over at the moment.
    4. }
    5.  


    The whole code would be:
    Code:java
    1.  
    2. // Put this in front of the onEnable() method:
    3. public List<String> staffList = new ArrayList<String>(); // The staff list (empty)
    4.  
    5. // This goes into the onEnable() method:
    6. // config = the yaml config file
    7. for (String key : config.getConfigurationSection("staff").getKeys(false)) { // Filling the staff list:
    8. staffList.add(key);
    9. }
    10.  
    11. // And this you put into the onCommand(...) method:
    12. if (sender instanceof Player) {
    13. if (cmd.getName().equalIgnoreCase("ticket")) {
    14. if (args.length >= 1) {
    15. String msg = "";
    16. for (int argn = 0; argm < args.length; argn++) {
    17. msg += args[argn] + " ";
    18. }
    19. for(Player online : Bukkit.getOnlinePlayers()) {
    20. if (staffList.contains(online.getName()) {
    21. online.sendMessage("Ticket Message: " + msg);
    22. }
    23. }
    24. }
    25. return true;
    26. }
    27. }
    28. return false;
    29.  
     
    GalaxyBeatzz likes this.
  9. Offline

    GalaxyBeatzz

    GameplayJDK Thnx ;) Really needed this
    EDIT: Well you really helped my out but:
    Code:java
    1. for (int argn = 0; argm < args.length; argn++) {

    The ARGM part is underlined, what to do! :eek:
    EDIT: Nvm I fixed it but now it says: config cannot be resolved...

    Wait maybe you don't really get it. The config only has one section you could select the whole config.

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

    GameplayJDK

    GalaxyBeatzz
    You're welcome :)
    You have to create a ymlconfig called config. But you will find tutorials tutorials on this through Google.
     
  11. Offline

    GalaxyBeatzz

    I already have the config fike :p i dont suck that much hehe

    GameplayJDK sorry forgot to tag you :p

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

    GameplayJDK

  13. Offline

    GalaxyBeatzz

    No... He doesn't get the config part alltough I do have a config made already... GameplayJDK
     
  14. Offline

    GameplayJDK

    Then change the "config" that is underlined in red to whatever your premade config is named. GalaxyBeatzz
     
  15. Offline

    GalaxyBeatzz

  16. Offline

    GameplayJDK

    You haven't closed the for loop, didn't you? GalaxyBeatzz
    The test I will Review as soon as I'm on my computer again
     
  17. Offline

    GalaxyBeatzz

    GameplayJDK yeah let's continue this later, I'm not on my computer, and you're not. ;P
     
Thread Status:
Not open for further replies.

Share This Page