mirror of
https://github.com/hyperdefined/ToolStats.git
synced 2025-12-08 13:44:59 +00:00
misc cleanup
This commit is contained in:
@@ -29,7 +29,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class SheepShear implements Listener {
|
||||
|
||||
@@ -53,7 +52,7 @@ public class SheepShear implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack heldShears = getShears(player.getInventory());
|
||||
ItemStack heldShears = toolStats.itemChecker.getShears(player.getInventory());
|
||||
// player swapped or we can't get the shears
|
||||
if (heldShears == null) {
|
||||
return;
|
||||
@@ -78,30 +77,4 @@ public class SheepShear implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's shears.
|
||||
*
|
||||
* @param inventory Their inventory.
|
||||
* @return Their shears, either main or offhand.
|
||||
*/
|
||||
private static @Nullable ItemStack getShears(PlayerInventory inventory) {
|
||||
ItemStack main = inventory.getItemInMainHand();
|
||||
ItemStack offHand = inventory.getItemInOffHand();
|
||||
|
||||
boolean isMain = main.getType() == Material.SHEARS;
|
||||
boolean isOffHand = offHand.getType() == Material.SHEARS;
|
||||
|
||||
// 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) {
|
||||
return main;
|
||||
}
|
||||
if (isOffHand) {
|
||||
return offHand;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user