Solved InventoryOpenEvent get HumanEntity chat input

Discussion in 'Spigot Plugin Development' started by JustBrainless, Mar 27, 2020.

  1. Hey Spigot users,
    i plan to use a player's last chat input for an event verification. So far I have failed miserably. Maybe you can help me rock that thing. In principle, "LastString" (source code below ->) should give me the last chat input from the player. However, this should not be visible to other players. PS: (The event can only give me a HumanEntity, no player.)

    Code (Java):

    @EventHandler(priority = EventPriority.HIGHEST)
     public void onInteract(InventoryOpenEvent event) {
            HumanEntity player = event.getPlayer();
            if(LastString.equals("....")) {

                 //Do something....


            else {



  2. You can cast HumanEntity to player if I remember correcly.
    You can get LastString by making a hashmap, and storing the players message in it when they chat.
  3. Ok that works.
    I have to implement a way in which the thread waits for the input and executes the following code in real time as soon as the input is there.
    Does anyone have a suggestion? Preferably with source code :unsure:
    #3 JustBrainless, Mar 27, 2020
    Last edited: Mar 27, 2020