Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

Commit

Permalink
Update PRESENTOPEN.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Quackster committed Oct 27, 2019
1 parent c6868ba commit ee7a9d1
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
import org.alexdev.kepler.dao.mysql.ItemDao;
import org.alexdev.kepler.game.catalogue.CatalogueItem;
import org.alexdev.kepler.game.catalogue.CatalogueManager;
import org.alexdev.kepler.game.fuserights.Fuseright;
import org.alexdev.kepler.game.item.Item;
import org.alexdev.kepler.game.item.base.ItemBehaviour;
import org.alexdev.kepler.game.fuserights.Fuseright;
import org.alexdev.kepler.game.player.Player;
import org.alexdev.kepler.game.room.Room;
import org.alexdev.kepler.messages.incoming.catalogue.GRPC;
import org.alexdev.kepler.messages.outgoing.catalogue.DELIVER_PRESENT;
import org.alexdev.kepler.messages.types.MessageEvent;
import org.alexdev.kepler.server.netty.streams.NettyRequest;
import org.alexdev.kepler.util.DateUtil;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -48,7 +47,13 @@ public void handle(Player player, NettyRequest reader) throws Exception {
//System.out.println("Custom data: " + item.getCustomData());
//System.out.println(receivedFrom);

CatalogueItem catalogueItem = CatalogueManager.getInstance().getCatalogueItem(saleCode);
CatalogueItem catalogueItem = null;

if (StringUtils.isNumeric(saleCode)) {
catalogueItem = CatalogueManager.getInstance().getCatalogueItems().stream().filter(shopItem -> shopItem.getId() == Integer.parseInt(saleCode)).findFirst().orElse(null);
} else {
catalogueItem = CatalogueManager.getInstance().getCatalogueItem(saleCode);
}

// Don't create a new item instance, reuse if the item isn't a trophy or teleporter, etc
if (!catalogueItem.isPackage() && !catalogueItem.getDefinition().hasBehaviour(ItemBehaviour.PRIZE_TROPHY) &&
Expand Down

0 comments on commit ee7a9d1

Please sign in to comment.