Allow bulk buy/sell when sneaking. Resolves #65

This commit is contained in:
Ali Moghnieh 2016-07-22 23:56:26 +01:00
parent 3245ce10ac
commit 87adbb477d
No known key found for this signature in database
GPG key ID: F09D3A1BAF2E6D70
3 changed files with 62 additions and 4 deletions

View file

@ -19,6 +19,8 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -787,4 +789,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
this.afkMessage = message;
}
}
/**
* Returns the {@link ItemStack} in the main hand or off-hand. If the main hand is empty then the offhand item is returned - also nullable.
*/
public ItemStack getItemInHand() {
if (ReflUtil.getNmsVersionObject().isLowerThan(ReflUtil.V1_9_R1)) {
return getBase().getInventory().getItemInHand();
} else {
PlayerInventory inventory = getBase().getInventory();
return inventory.getItemInMainHand() != null ? inventory.getItemInMainHand() : inventory.getItemInOffHand();
}
}
}