Skip to content

Commit

Permalink
fix: Fix visual offhand dupe
Browse files Browse the repository at this point in the history
Closes #176
  • Loading branch information
osipxd committed Apr 19, 2022
1 parent 43bb381 commit d57910e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ X changes total

- Fixed `/rpginv reload` command
- Compatibility with Mimic 0.8+
- Visual dupe when press `F` on item

### Housekeeping

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,25 @@ public void run() {
}
}

@EventHandler(priority = EventPriority.MONITOR)
public void afterInventoryClick(@NotNull final InventoryClickEvent event) {
if (event.getClick() == ClickType.SWAP_OFFHAND && event.isCancelled()) {
syncOffhandSlot((Player) event.getWhoClicked());
}
}

// We should manually sync offhand slot after SWAP_OFFHAND event
// Issue: https://hub.spigotmc.org/jira/browse/SPIGOT-6145
private void syncOffhandSlot(Player player) {
final PlayerInventory inventory = player.getInventory();
new TrackedBukkitRunnable() {
@Override
public void run() {
inventory.setItemInOffHand(inventory.getItemInOffHand());
}
}.runTaskLater(RPGInventory.getInstance(), 1);
}

/**
* Check
*
Expand Down

0 comments on commit d57910e

Please sign in to comment.