|
19 | 19 |
|
20 | 20 | import lol.hyper.toolstats.ToolStats; |
21 | 21 | import org.bukkit.GameMode; |
| 22 | +import org.bukkit.Material; |
22 | 23 | import org.bukkit.entity.Arrow; |
23 | 24 | import org.bukkit.entity.LivingEntity; |
24 | 25 | import org.bukkit.entity.Player; |
@@ -119,17 +120,32 @@ public void onDamage(EntityDamageByEntityEvent event) { |
119 | 120 | return; |
120 | 121 | } |
121 | 122 |
|
| 123 | + boolean isMain = shootingPlayerInventory.getItemInMainHand().getType() == Material.BOW || shootingPlayerInventory.getItemInMainHand().getType() == Material.CROSSBOW; |
| 124 | + boolean isOffHand = shootingPlayerInventory.getItemInOffHand().getType() == Material.BOW || shootingPlayerInventory.getItemInOffHand().getType() == Material.CROSSBOW; |
| 125 | + |
122 | 126 | // player is shooting another player |
123 | 127 | if (mobBeingAttacked instanceof Player) { |
124 | | - ItemMeta newItem = toolStats.itemLore.updatePlayerKills(heldBow, 1); |
125 | | - if (newItem != null) { |
126 | | - shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem); |
| 128 | + ItemMeta newBow = toolStats.itemLore.updatePlayerKills(heldBow, 1); |
| 129 | + if (newBow != null) { |
| 130 | + if (isMain && isOffHand) { |
| 131 | + shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow); |
| 132 | + } else if (isMain) { |
| 133 | + shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow); |
| 134 | + } else if (isOffHand) { |
| 135 | + shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow); |
| 136 | + } |
127 | 137 | } |
128 | 138 | } else { |
129 | 139 | // player is shooting a mob |
130 | | - ItemMeta newItem = toolStats.itemLore.updateMobKills(heldBow, 1); |
131 | | - if (newItem != null) { |
132 | | - shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem); |
| 140 | + ItemMeta newBow = toolStats.itemLore.updateMobKills(heldBow, 1); |
| 141 | + if (newBow != null) { |
| 142 | + if (isMain && isOffHand) { |
| 143 | + shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow); |
| 144 | + } else if (isMain) { |
| 145 | + shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow); |
| 146 | + } else if (isOffHand) { |
| 147 | + shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow); |
| 148 | + } |
133 | 149 | } |
134 | 150 | trackedMobs.add(mobBeingAttacked.getUniqueId()); |
135 | 151 | } |
|
0 commit comments