mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Clear item in offhand slot in /clearinventory
GitHub fancy things: Fixes #950. Fixes #1426. Fixes #1834.
This commit is contained in:
parent
37dfd81cc9
commit
983f3a7935
2 changed files with 15 additions and 0 deletions
|
@ -113,12 +113,14 @@ public class Commandclearinventory extends EssentialsCommand {
|
||||||
sender.sendMessage(tl("inventoryClearingAllItems", player.getDisplayName()));
|
sender.sendMessage(tl("inventoryClearingAllItems", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
|
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
|
||||||
|
InventoryWorkaround.setItemInOffHand(player, null);
|
||||||
} else if (type == -2) // type -2 represents double wildcard or all items and armor
|
} else if (type == -2) // type -2 represents double wildcard or all items and armor
|
||||||
{
|
{
|
||||||
if (showExtended) {
|
if (showExtended) {
|
||||||
sender.sendMessage(tl("inventoryClearingAllArmor", player.getDisplayName()));
|
sender.sendMessage(tl("inventoryClearingAllArmor", player.getDisplayName()));
|
||||||
}
|
}
|
||||||
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
|
InventoryWorkaround.clearInventoryNoArmor(player.getInventory());
|
||||||
|
InventoryWorkaround.setItemInOffHand(player, null);
|
||||||
player.getInventory().setArmorContents(null);
|
player.getInventory().setArmorContents(null);
|
||||||
} else {
|
} else {
|
||||||
if (data == -1) // data -1 means that all subtypes will be cleared
|
if (data == -1) // data -1 means that all subtypes will be cleared
|
||||||
|
|
|
@ -239,4 +239,17 @@ public final class InventoryWorkaround {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void setItemInOffHand(Player p, ItemStack item) {
|
||||||
|
// This assumes that all builds that support a main hand also support an off hand.
|
||||||
|
if (hasMainHandSupport == null || hasMainHandSupport) {
|
||||||
|
try {
|
||||||
|
p.getInventory().setItemInOffHand(item);
|
||||||
|
hasMainHandSupport = true;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
hasMainHandSupport = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue