How to get chat as value

Discussion in 'Plugin Development' started by FiesteroCraft, Aug 5, 2016.

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

    FiesteroCraft

    Hi, i want to get a message of chat as value. I have a Inventory GUI called "Ban a player", and i want when a player click an item, the gui will close, and the chat for this player will block, then if player type a player name in chat, this player will ban and the chat unlock. How do i do that?
     
  2. Offline

    Marti201

  3. Offline

    FiesteroCraft

    Yes, i use this. But, i dont know the rest. You can write an example please?
     
  4. Offline

    XxTimexX

    @FiesteroCraft
    An example code would mean spoonfeeding. I will show you how you could do it, but nothing more then that:
    1. Check if player did what he had to do in the GUI
    2. Check what message did the player send using #getMessage() method
    3. If the message didn't equal the name of that player then cancell the event.
    4. If the message was equal to the name of player then ban that player
     
  5. Offline

    FiesteroCraft

    So, when player click the item on the Inventory GUI, it will block chat for this player, and in AsyncPlayerChatEvent check if the message contains player name and if it true, will ban this player?
     
  6. Offline

    XxTimexX

    @FiesteroCraft
    Basically, as soon as player clicks on the item in GUI block the chat for player (using AsyncPlayerChatEvent) and then listen for the messages using #getMessage() method. If the message contains player's name then ban the player, else, leave the chat blocked untill the message contains the player's name.
     
  7. Offline

    FiesteroCraft

    And how to detect if message contains a player name?
     
  8. Offline

    XxTimexX

    @FiesteroCraft
    #getMessage().equalsIgnoreCase(put method for player detection here)
     
  9. @FiesteroCraft Loop all online players, check if the message contains their name
     
  10. Online

    timtower Administrator Administrator Moderator

    @FiesteroCraft Conversation API might also be an option for this.
     
  11. Offline

    Irantwomiles

    When you click the item in your GUI you put the player in a map<string, string>. Then on AsyncChat you check if the map contains the players name and if so check what they typed. Think8by about this again you could probably do it with a list as well.
     
Thread Status:
Not open for further replies.

Share This Page