Compare commits

...

2 Commits

Author SHA1 Message Date
hyperdefined
cb5345bd14 1.9.2-hotfix-2 2025-02-15 13:10:39 -05:00
hyperdefined
eeb6038b66 1.9.2-hotfix 2025-02-11 15:57:49 -05:00
6 changed files with 49 additions and 18 deletions

View File

@@ -23,7 +23,7 @@
<groupId>lol.hyper</groupId>
<artifactId>toolstats</artifactId>
<version>1.9.2</version>
<version>1.9.2-hotfix-2</version>
<packaging>jar</packaging>
<name>ToolStats</name>

View File

@@ -19,6 +19,7 @@ package lol.hyper.toolstats.events;
import lol.hyper.toolstats.ToolStats;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -119,17 +120,32 @@ public class EntityDamage implements Listener {
return;
}
boolean isMain = shootingPlayerInventory.getItemInMainHand().getType() == Material.BOW || shootingPlayerInventory.getItemInMainHand().getType() == Material.CROSSBOW;
boolean isOffHand = shootingPlayerInventory.getItemInOffHand().getType() == Material.BOW || shootingPlayerInventory.getItemInOffHand().getType() == Material.CROSSBOW;
// player is shooting another player
if (mobBeingAttacked instanceof Player) {
ItemMeta newItem = toolStats.itemLore.updatePlayerKills(heldBow, 1);
if (newItem != null) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
ItemMeta newBow = toolStats.itemLore.updatePlayerKills(heldBow, 1);
if (newBow != null) {
if (isMain && isOffHand) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
}
}
} else {
// player is shooting a mob
ItemMeta newItem = toolStats.itemLore.updateMobKills(heldBow, 1);
if (newItem != null) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newItem);
ItemMeta newBow = toolStats.itemLore.updateMobKills(heldBow, 1);
if (newBow != null) {
if (isMain && isOffHand) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
shootingPlayerInventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
shootingPlayerInventory.getItemInOffHand().setItemMeta(newBow);
}
}
trackedMobs.add(mobBeingAttacked.getUniqueId());
}

View File

@@ -72,7 +72,9 @@ public class PlayerFish implements Listener {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.FISHING_ROD;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.FISHING_ROD;
if (isMain) {
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newFishingRod);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newFishingRod);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newFishingRod);

View File

@@ -65,15 +65,17 @@ public class SheepShear implements Listener {
}
// update the stats
ItemMeta newItem = toolStats.itemLore.updateSheepSheared(heldShears, 1);
if (newItem != null) {
ItemMeta newShears = toolStats.itemLore.updateSheepSheared(heldShears, 1);
if (newShears != null) {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.SHEARS;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.SHEARS;
if (isMain) {
inventory.getItemInMainHand().setItemMeta(newItem);
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newShears);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newShears);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newItem);
inventory.getItemInOffHand().setItemMeta(newShears);
}
}
}

View File

@@ -56,15 +56,17 @@ public class ShootBow implements Listener {
return;
}
ItemMeta newItem = toolStats.itemLore.updateArrowsShot(heldBow, 1);
if (newItem != null) {
ItemMeta newBow = toolStats.itemLore.updateArrowsShot(heldBow, 1);
if (newBow != null) {
PlayerInventory inventory = player.getInventory();
boolean isMain = inventory.getItemInMainHand().getType() == Material.BOW || inventory.getItemInMainHand().getType() == Material.CROSSBOW;
boolean isOffHand = inventory.getItemInOffHand().getType() == Material.BOW || inventory.getItemInOffHand().getType() == Material.CROSSBOW;
if (isMain) {
inventory.getItemInMainHand().setItemMeta(newItem);
if (isMain && isOffHand) {
inventory.getItemInMainHand().setItemMeta(newBow);
} else if (isMain) {
inventory.getItemInMainHand().setItemMeta(newBow);
} else if (isOffHand) {
inventory.getItemInOffHand().setItemMeta(newItem);
inventory.getItemInOffHand().setItemMeta(newBow);
}
}
}

View File

@@ -220,6 +220,9 @@ public class ItemChecker {
// if the player is holding a bow in their main hand, use that one
// if the bow is in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}
@@ -246,6 +249,9 @@ public class ItemChecker {
// if the player is holding shears in their main hand, use that one
// if the shears are in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}
@@ -272,6 +278,9 @@ public class ItemChecker {
// if the player is holding a fishing rod in their main hand, use that one
// if the fishing rod is in their offhand instead, use that one after checking main hand
// Minecraft prioritizes main hand if the player holds in both hands
if (isMain && isOffHand) {
return main;
}
if (isMain) {
return main;
}