Exemplo n.º 1
0
 @Override
 public void run() {
   for (Pet cosmetic : this.module.getParent().getApi().getAllCosmetics(Pet.class)) {
     Creature entity = cosmetic.getEntity();
     Player p = cosmetic.getPlayer();
     if (!entity.getWorld().getName().equalsIgnoreCase(p.getWorld().getName())
         || entity.getLocation().distance(p.getLocation())
             >= this.module.getConfig().getTeleportDistance()) {
       entity.teleport(p);
       entity.setTarget(p);
     }
   }
 }
  @Before
  public void setupTestCase() {
    mockVehicle = mock(Vehicle.class);
    mockCreature = mock(Creature.class);
    DataManager mockDataManager = mock(DataManager.class);
    Location mockLocation = mock(Location.class);
    mockChunk = mock(ChunkData.class);
    systemUnderTest = new EntityEventHandler(mockDataManager);

    when(mockVehicle.getLocation()).thenReturn(mockLocation);
    when(mockCreature.getLocation()).thenReturn(mockLocation);
    when(mockDataManager.getChunkAt(mockLocation)).thenReturn(mockChunk);
    when(mockChunk.getOwnerName()).thenReturn("APlayer");
  }