Search in sources :

Example 26 with Projectile

use of org.bukkit.entity.Projectile in project AuthMeReloaded by AuthMe.

the class EntityListenerTest method shouldRejectProjectileLaunchFromUnauthed.

@Test
public void shouldRejectProjectileLaunchFromUnauthed() {
    // given
    Projectile projectile = mock(Projectile.class);
    Player player = mock(Player.class);
    given(projectile.getShooter()).willReturn(player);
    ProjectileLaunchEvent event = mock(ProjectileLaunchEvent.class);
    given(event.getEntity()).willReturn(projectile);
    given(listenerService.shouldCancelEvent(player)).willReturn(true);
    // when
    listener.onProjectileLaunch(event);
    // then
    verify(listenerService).shouldCancelEvent(player);
    verify(event).setCancelled(true);
}
Also used : Player(org.bukkit.entity.Player) ProjectileLaunchEvent(org.bukkit.event.entity.ProjectileLaunchEvent) Projectile(org.bukkit.entity.Projectile) Test(org.junit.Test)

Aggregations

Projectile (org.bukkit.entity.Projectile)26 EventHandler (org.bukkit.event.EventHandler)19 Entity (org.bukkit.entity.Entity)18 Player (org.bukkit.entity.Player)14 LivingEntity (org.bukkit.entity.LivingEntity)9 PotionEffect (org.bukkit.potion.PotionEffect)6 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)4 ProjectileLaunchEvent (org.bukkit.event.entity.ProjectileLaunchEvent)4 Test (org.junit.Test)4 TownyWorld (com.palmergames.bukkit.towny.object.TownyWorld)3 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)3 PlayerCache (com.palmergames.bukkit.towny.object.PlayerCache)2 net.aufdemrand.denizen.objects.dEntity (net.aufdemrand.denizen.objects.dEntity)2 net.aufdemrand.denizen.objects.dPlayer (net.aufdemrand.denizen.objects.dPlayer)2 Material (org.bukkit.Material)2 Block (org.bukkit.block.Block)2 ProjectileSource (org.bukkit.projectiles.ProjectileSource)2 Vector (org.bukkit.util.Vector)2 EntityActionInfo (com.gamingmesh.jobs.actions.EntityActionInfo)1 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)1