Check if a fence has a leash around it?

Discussion in 'Plugin Development' started by Datdenkikniet, Oct 15, 2013.

Thread Status:
Not open for further replies.
  1. how would you check if the Fence f has a leash around it?
     
  2. Offline

    tommycake50

    Maybe check for entities in a 0 block radius?
     
  3. Datdenkikniet
    You could try something along the lines of this (untested):
    Code:java
    1. List<Entity> entities = ev.getPlayer().getWorld().getEntities();
    2. for(int x = 0; x < entities.size(); x++){
    3. if(entities.get(x).getLocation().getBlock().getType() == Material.FENCE && entities.get(x).getType().toString() == "lead"){
    4. //Do whatever you want
    5. }
    6. }


    You will probably have to change around entities.get(x).getType().toString() == "lead", not sure what the exact output of getType.getString() would be
     
  4. Offline

    tommycake50

    Or just test if entities.get(x).getType().equals(EntityType.LEASH_HITCH);
     
  5. Offline

    Garris0n

    To point it out, BlockFence has nothing to indicate whether there is a leash on it or not.
     
Thread Status:
Not open for further replies.

Share This Page