Multiply trade GUIs from one villager

Discussion in 'Plugin Development' started by Pr07o7yp3, Aug 18, 2014.

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

    Pr07o7yp3

    Ok, I'm working on RPG server. Everything is OK, I made city with villagers and set them custom offers. But when someone trade with a villager noone else can trade with it in the sametime.
    So, I'm still not officially run the server but I'm sure there will be trolls who will stay AFK with open villager trade GUI. So, I want to prevent this. Any ideas?
    I'm searching for code for multiply trade GUIs from one villager but I found that there is no way with bukkit API.
    I know that I have to cancel the event in EntityInteract event and then open the trade GUI manualy but didn't find example codes for this.
    So I'll be grateful for some help. :D
     
  2. Problem solving: Why not just put a 30 second timer or something they can be in the villager for?
     
  3. Offline

    Pr07o7yp3

    Yea, I thought about that but its a little noobish. :D
     
  4. Offline

    Lactem

    This is what I would do:
    1. Make a list of UUIDs.
    2. Listen for EntityInteractEvent (like you said).
    3. Make sure the entity is a villager.
    4. Check if the player's UUID is in your UUID list.
    - If it is, remove it and don't cancel the event.
    - If it isn't, add the player's UUID to the list, cancel this event, and call a new EntityInteractEvent with a Entity#clone().

    Keep in mind that this is only an idea. I have no idea if it will work or if cloning entities is even supported.
     
  5. Offline

    fireblast709

    Lactem Pr07o7yp3 PlayerInteractEntityEvent iirc. EntityInteractEvent is the Entity version of PlayerInteractEvent.
     
  6. Offline

    Lactem

  7. Offline

    Pr07o7yp3

    Yea, I my code is something like your first 4 points.
    I have to try this clone() but how to call this event?
     
  8. Offline

    Lactem

  9. Offline

    Pr07o7yp3

    Ok, can a simple code? I just don't know how to use this entity clone.
     
Thread Status:
Not open for further replies.

Share This Page