Get custom name from villager?

Discussion in 'Plugin Development' started by jusjus112, May 13, 2014.

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

    jusjus112

    Im trying to get the name of my custom villager, bit with no succes! How can i get it?
    it says only, Event worked and Villager worked! Not Villager name worked!
    Im trying it an an PlayerInteractEntityEvent:
    Code:java
    1. @SuppressWarnings("deprecation")
    2. @EventHandler
    3. public void onVillagerInterAct(PlayerInteractEntityEvent e) {
    4. Bukkit.broadcastMessage("DEBUG>> Event WORKED!");
    5. if (e.getRightClicked() instanceof Villager) {
    6. Bukkit.broadcastMessage("DEBUG>> VILLAGER WORKED!");
    7. if (e.getRightClicked().getType().getName().equals("Hotel Medewerker")) {
    8. e.setCancelled(true);
    9. Bukkit.broadcastMessage("DEBUG>> VILLAGER NAME WORKED!");
    10. }
    11. }
    12. }
     
  2. Offline

    TGRHavoc

    jusjus112
    getCustomName().equals("Hotel Medewerker");
     
  3. Offline

    jusjus112

    TGRHavoc
    i cant get the custom name!
    When i do getRightClicked(). does noet work!
     
  4. Offline

    Epixpenguin

    jusjus112
    You set the custom name to the villager, not the right click event
    e.getCustomName.equals("Villager #7");
     
  5. Offline

    jusjus112

    Epixpenguin
    oke thnaks, but is there an way to stop the villager from moving?
    Like cancel the EntityMoveEvent! I cant find it
     
  6. Offline

    stuntguy3000

    Sadly, No such event exists. The easiest way to prevent a Villager from "moving" is to teleport the villager back to the same location every tick. This can be achieved by a Scheduler.
     
  7. Offline

    Epixpenguin

    Or maybe you could set the villagers walk speed but I don't think the method exist in the villager class
     
Thread Status:
Not open for further replies.

Share This Page