Skip to content

Commit cb5345b

Browse files
committed
1.9.2-hotfix-2
1 parent eeb6038 commit cb5345b

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
<groupId>lol.hyper</groupId>
2525
<artifactId>toolstats</artifactId>
26-
<version>1.9.2-hotfix</version>
26+
<version>1.9.2-hotfix-2</version>
2727
<packaging>jar</packaging>
2828

2929
<name>ToolStats</name>

src/main/java/lol/hyper/toolstats/events/EntityDamage.java

+22-6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import lol.hyper.toolstats.ToolStats;
2121
import org.bukkit.GameMode;
22+
import org.bukkit.Material;
2223
import org.bukkit.entity.Arrow;
2324
import org.bukkit.entity.LivingEntity;
2425
import org.bukkit.entity.Player;
@@ -119,17 +120,32 @@ public void onDamage(EntityDamageByEntityEvent event) {
119120
return;
120121
}
121122

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+
122126
// player is shooting another player
123127
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+
}
127137
}
128138
} else {
129139
// 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+
}
133149
}
134150
trackedMobs.add(mobBeingAttacked.getUniqueId());
135151
}

0 commit comments

Comments
 (0)