Skip to content

Commit

Permalink
Allow wandering trader interaction at any time #2484
Browse files Browse the repository at this point in the history
  • Loading branch information
bengibbs committed Aug 28, 2024
1 parent c2737f0 commit 86eb9f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public void onPlayerInteractAtEntity(final PlayerInteractAtEntityEvent e) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteractEntity(PlayerInteractEntityEvent e)
{
System.out.println(e.getEventName());
System.out.println(e.getRightClicked());
Player p = e.getPlayer();
Location l = e.getRightClicked().getLocation();

Expand Down Expand Up @@ -80,8 +82,9 @@ else if (e.getRightClicked() instanceof 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
// Check naming and check trading
this.checkIsland(e, p, l, Flags.TRADING);
Expand All @@ -104,6 +107,7 @@ else if (e.getRightClicked() instanceof Allay)
}
else if (e.getPlayer().getInventory().getItemInMainHand().getType().equals(Material.NAME_TAG))
{
System.out.println("name tag");
// Name tags
this.checkIsland(e, p, l, Flags.NAME_TAG);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,11 @@ public void testOnPlayerInteractEntityWanderingTraderNoInteraction() {
clickedEntity = mock(WanderingTrader.class);
when(clickedEntity.getLocation()).thenReturn(location);
when(clickedEntity.getType()).thenReturn(EntityType.WANDERING_TRADER);
when(inv.getItemInMainHand()).thenReturn(new ItemStack(Material.STONE));
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
eil.onPlayerInteractEntity(e);
verify(notifier, times(2)).notify(any(), eq("protection.protected"));
assertTrue(e.isCancelled());
verify(notifier, never()).notify(any(), eq("protection.protected"));
assertFalse(e.isCancelled());
}

/**
Expand Down Expand Up @@ -286,8 +287,8 @@ public void testOnPlayerInteractEntityNamingWanderingTraderAllowedNoTrading() {
when(clickedEntity.getLocation()).thenReturn(location);
PlayerInteractEntityEvent e = new PlayerInteractEntityEvent(mockPlayer, clickedEntity, hand);
eil.onPlayerInteractEntity(e);
verify(notifier).notify(any(), eq("protection.protected"));
assertTrue(e.isCancelled());
verify(notifier, never()).notify(any(), eq("protection.protected"));
assertFalse(e.isCancelled());
}

/**
Expand Down

0 comments on commit 86eb9f5

Please sign in to comment.