Fix: Cancel item interactions while interacting with a shopkeeper.
When a player interacts with a shopkeeper entity while holding an item in hand, we may first receive the entity interaction event, which starts an UI session, and then the interaction event for the item. To not start any item actions for the held item (such as trident charging, food consumption, etc.), we cancel any interaction events while an UI session is already active.master
parent
1d6ede58bc
commit
1935fe0c7e
|
@ -12,7 +12,7 @@ Date format: (YYYY-MM-DD)
|
|||
* Fixed: The 'active shopkeepers' would not get properly cleaned up in some occasions (even on shopkeeper removal) if the shopkeeper mob got deleted or the shop object was no longer considered 'active' for some other reason. A side effect of this was that the shopkeeper entity would get respawned, even though it was not supposed to get spawned or even after the shopkeeper was already deleted.
|
||||
* Fixed: The DerivedSettings use the default value for the name-regex setting during initialization now to properly catch user errors during the subsequent setup after the config has already been loaded.
|
||||
* Fixed: The selling and book shops attempted to convert currency items into high currency items even if the high currency got disabled.
|
||||
* Fixed: Trading via shift-clicking while the player is charging a trident would allow the player to duplicate the trident.
|
||||
* Fixed: Trading via shift-clicking while the player is charging a trident would allow the player to duplicate the trident. We now prevent any item actions to even start when interacting with a shopkeeper.
|
||||
|
||||
Internal changes:
|
||||
* Added AbstractShopkeeper#tick which gets invoked roughly once per second for all shopkeepers in currently active chunks.
|
||||
|
|
|
@ -14,10 +14,12 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryInteractEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
import com.nisovin.shopkeepers.api.ShopkeepersPlugin;
|
||||
import com.nisovin.shopkeepers.util.Log;
|
||||
import com.nisovin.shopkeepers.util.TestPlayerInteractEvent;
|
||||
|
||||
class UIListener implements Listener {
|
||||
|
||||
|
@ -190,4 +192,20 @@ class UIListener implements Listener {
|
|||
Player player = (Player) event.getWhoClicked();
|
||||
uiHandler.onInventoryDragLate(event, player);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
void onPlayerInteract(PlayerInteractEvent event) {
|
||||
// ignore our own fake interact event:
|
||||
if (event instanceof TestPlayerInteractEvent) return;
|
||||
|
||||
// When a player interacts with a shopkeeper entity while holding an item in hand, we may first receive the
|
||||
// entity interaction event, which starts an UI session, and then the interaction event for the item.
|
||||
// To not start any item actions for the held item, we cancel any interaction events while an UI session is
|
||||
// active.
|
||||
Player player = event.getPlayer();
|
||||
SKUISession session = this.getUISession(player);
|
||||
if (session != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue