Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-392

getRabbitType() returns null for BROWN rabbits

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None

      Rabbit.getRabbitType() returns null when getting the Rabbit.Type for a brown rabbit

      Tested with:

      BunnyType.java
      public class BunnyType extends JavaPlugin implements Listener {
      
          @Override
          public void onEnable() {
              getServer().getPluginManager().registerEvents(this, this);
          }
      
          @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
          public void onInteract(PlayerInteractEntityEvent event) {
              Entity entity = event.getRightClicked();
              if (entity.getType().equals(EntityType.RABBIT)) {
                  Rabbit rabbit = (Rabbit) entity;
                  Rabbit.Type rabbitType = rabbit.getRabbitType();
                  String type;
                  if (rabbitType == null) {
                      type = "type was NULL";
                  } else {
                      type = rabbitType.toString();
                  }
                  event.getPlayer().sendMessage("Rabbit Type: " + type);
              }
          }
      }
      

      Spawn in a brown rabbit and right click it.

            md_5 md_5
            eccentric Eccentric Devotion
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: