Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Returns a GameItem object if any of the items offered by the player exist in the
- * recipients inventory, and if the combined total amount is greater than the maximum
- * value of an Integer type.
- * @param player the player with the offered items were checking
- * @return a GameItem object if the pre-explained conditions are met
- */
- private GameItem getOfferOverlapItem(Client player) {
- Client recipient = getOther(player);
- for (GameItem playerItem : items.get(player)) {
- if (!playerItem.isStackable()) {
- continue;
- }
- if (!recipient.getItems().playerHasItem(playerItem.getId())) {
- continue;
- }
- long amount = ((long) playerItem.getAmount()
- + (long) recipient.getItems().getItemAmount(playerItem.getId()));
- if (amount > Integer.MAX_VALUE) {
- return new GameItem(playerItem.getId(), recipient.getItems().getItemAmount(playerItem.getId()));
- }
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement