mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 10:45:22 +01:00
Merge pull request #2485 from BentoBoxWorld/2484_wandering_trader
Allow wandering trader interaction at any time #2484
This commit is contained in:
commit
bd028aa5f2
@ -42,6 +42,8 @@ public class EntityInteractListener extends FlagListener {
|
|||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent e)
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent e)
|
||||||
{
|
{
|
||||||
|
System.out.println(e.getEventName());
|
||||||
|
System.out.println(e.getRightClicked());
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
Location l = e.getRightClicked().getLocation();
|
Location l = e.getRightClicked().getLocation();
|
||||||
|
|
||||||
@ -80,8 +82,9 @@ public class EntityInteractListener extends FlagListener {
|
|||||||
this.checkIsland(e, p, l, Flags.BOAT);
|
this.checkIsland(e, p, l, Flags.BOAT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.getRightClicked() instanceof Villager || e.getRightClicked() instanceof WanderingTrader)
|
else if (e.getRightClicked() instanceof Villager && !(e.getRightClicked() instanceof WanderingTrader))
|
||||||
{
|
{
|
||||||
|
System.out.println("Villager trading");
|
||||||
// Villager trading
|
// Villager trading
|
||||||
// Check naming and check trading
|
// Check naming and check trading
|
||||||
this.checkIsland(e, p, l, Flags.TRADING);
|
this.checkIsland(e, p, l, Flags.TRADING);
|
||||||
@ -104,6 +107,7 @@ public class EntityInteractListener extends FlagListener {
|
|||||||
}
|
}
|
||||||
else if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG))
|
else if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG))
|
||||||
{
|
{
|
||||||
|
System.out.println("name tag");
|
||||||
// Name tags
|
// Name tags
|
||||||
this.checkIsland(e, p, l, Flags.NAME_TAG);
|
this.checkIsland(e, p, l, Flags.NAME_TAG);
|
||||||
}
|
}
|
||||||
|
@ -250,10 +250,11 @@ public class EntityInteractListenerTest extends AbstractCommonSetup {
|
|||||||
clickedEntity = mock(WanderingTrader.class);
|
clickedEntity = mock(WanderingTrader.class);
|
||||||
when(clickedEntity.getLocation()).thenReturn(location);
|
when(clickedEntity.getLocation()).thenReturn(location);
|
||||||
when(clickedEntity.getType()).thenReturn(EntityType.WANDERING_TRADER);
|
when(clickedEntity.getType()).thenReturn(EntityType.WANDERING_TRADER);
|
||||||
|
when(inv.getItemInMainHand()).thenReturn(new ItemStack(Material.STONE));
|
||||||
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
|
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
|
||||||
eil.onPlayerInteractEntity(e);
|
eil.onPlayerInteractEntity(e);
|
||||||
verify(notifier, times(2)).notify(any(), eq("protection.protected"));
|
verify(notifier, never()).notify(any(), eq("protection.protected"));
|
||||||
assertTrue(e.isCancelled());
|
assertFalse(e.isCancelled());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -286,8 +287,8 @@ public class EntityInteractListenerTest extends AbstractCommonSetup {
|
|||||||
when(clickedEntity.getLocation()).thenReturn(location);
|
when(clickedEntity.getLocation()).thenReturn(location);
|
||||||
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
|
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
|
||||||
eil.onPlayerInteractEntity(e);
|
eil.onPlayerInteractEntity(e);
|
||||||
verify(notifier).notify(any(), eq("protection.protected"));
|
verify(notifier, never()).notify(any(), eq("protection.protected"));
|
||||||
assertTrue(e.isCancelled());
|
assertFalse(e.isCancelled());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user