コード例 #1
0
  @Test
  public void testWhenVehicleIsAttackedByNonPlayerEventIsPassed() {
    VehicleDamageEvent event = new VehicleDamageEvent(mockVehicle, mock(Creeper.class), 10.0);

    systemUnderTest.onVehicleDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #2
0
  @Test
  public void testWhenCreaturesIsAttackedByNonPlayerEventIsPassed() {
    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mock(Creeper.class), mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #3
0
  @Test
  public void testTrustedPlayerCanDamageVehiclesWhenInChunk() {
    playerIsTrusted();

    VehicleDamageEvent event = new VehicleDamageEvent(mockVehicle, mockPlayer, 10.0);

    systemUnderTest.onVehicleDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #4
0
  @Test
  public void testWhenMonstersAreAttackedByUntrustedPlayersTheyStillGetHurt() {
    playerIsUntrusted();

    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mockPlayer, mock(Monster.class), null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #5
0
  @Test
  public void testAdminCanDamageCreaturesWhenInChunk() {
    playerIsAdmin();

    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mockPlayer, mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #6
0
  @Test
  public void testAdminCanDamageVehiclesWithProjectilesWhenInChunk() {
    playerIsAdmin();
    playerThrewProjectile();

    VehicleDamageEvent event = new VehicleDamageEvent(mockVehicle, mockProjectile, 10.0);

    systemUnderTest.onVehicleDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #7
0
  @Test
  public void testUntrustedPlayerCannotDamageVehiclesWhenInChunk() {
    playerIsUntrusted();

    VehicleDamageEvent event = new VehicleDamageEvent(mockVehicle, mockPlayer, 10.0);

    systemUnderTest.onVehicleDamage(event);
    Assert.assertTrue(event.isCancelled());
    verify(mockPlayer)
        .sendMessage("§eYou do not have APlayer's permission to break vehicles here.");
  }
コード例 #8
0
  @Test
  public void testTrustedPlayerCanDamageCreaturesWithProjectilesWhenInChunk() {
    playerIsTrusted();
    playerThrewProjectile();

    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mockProjectile, mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #9
0
  @Test
  public void testWhenVehicleIsAttackedByNonPlayerWithProjectileEventIsPassed() {
    Skeleton mockSkeleton = mock(Skeleton.class);
    Projectile mockAttacker = mock(Projectile.class);
    when(mockAttacker.getShooter()).thenReturn(mockSkeleton);

    VehicleDamageEvent event = new VehicleDamageEvent(mockVehicle, mockAttacker, 10.0);

    systemUnderTest.onVehicleDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #10
0
  @Test
  public void testWhenCreaturesIsAttackedByNonPlayerWithProjectileEventIsPassed() {
    Skeleton mockSkeleton = mock(Skeleton.class);
    Projectile mockAttacker = mock(Projectile.class);
    when(mockAttacker.getShooter()).thenReturn(mockSkeleton);

    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mockAttacker, mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertFalse(event.isCancelled());
  }
コード例 #11
0
  @Test
  public void testUntrustedPlayerCannotDamageCreaturesWhenInChunk() {
    playerIsUntrusted();

    EntityDamageByEntityEvent event =
        new EntityDamageByEntityEvent(mockPlayer, mockCreature, null, 10.0);

    systemUnderTest.onEntityDamage(event);
    Assert.assertTrue(event.isCancelled());
    verify(mockPlayer)
        .sendMessage("§eYou do not have APlayer's permission to hurt creatures here.");
  }