Advertisement
Guest User

getOfferedOverlapItem

a guest
Oct 24th, 2014
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. /**
  2. * Returns a GameItem object if any of the items offered by the player exist in the
  3. * recipients inventory, and if the combined total amount is greater than the maximum
  4. * value of an Integer type.
  5. * @param player the player with the offered items were checking
  6. * @return a GameItem object if the pre-explained conditions are met
  7. */
  8. private GameItem getOfferOverlapItem(Client player) {
  9. Client recipient = getOther(player);
  10. for (GameItem playerItem : items.get(player)) {
  11. if (!playerItem.isStackable()) {
  12. continue;
  13. }
  14. if (!recipient.getItems().playerHasItem(playerItem.getId())) {
  15. continue;
  16. }
  17. long amount = ((long) playerItem.getAmount()
  18. + (long) recipient.getItems().getItemAmount(playerItem.getId()));
  19. if (amount > Integer.MAX_VALUE) {
  20. return new GameItem(playerItem.getId(), recipient.getItems().getItemAmount(playerItem.getId()));
  21. }
  22. }
  23. return null;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement