Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java

162 lines
4.6 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.users;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlace;
import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceOffer;
import com.eu.habbo.habbohotel.catalog.marketplace.MarketPlaceState;
import com.eu.habbo.habbohotel.users.inventory.*;
import gnu.trove.set.hash.THashSet;
2019-05-26 20:14:53 +02:00
public class HabboInventory {
2018-07-06 15:30:00 +02:00
//Configuration. Loaded from database & updated accordingly.
public static int MAXIMUM_ITEMS = 10000;
2019-05-26 20:14:53 +02:00
private final THashSet<MarketPlaceOffer> items;
private final Habbo habbo;
2018-07-06 15:30:00 +02:00
private WardrobeComponent wardrobeComponent;
private BadgesComponent badgesComponent;
private BotsComponent botsComponent;
private EffectsComponent effectsComponent;
private ItemsComponent itemsComponent;
private PetsComponent petsComponent;
2019-05-26 20:14:53 +02:00
public HabboInventory(Habbo habbo) {
2018-07-06 15:30:00 +02:00
this.habbo = habbo;
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.badgesComponent = new BadgesComponent(this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.botsComponent = new BotsComponent(this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.effectsComponent = new EffectsComponent(this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.itemsComponent = new ItemsComponent(this, this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.petsComponent = new PetsComponent(this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
2019-05-26 20:14:53 +02:00
try {
2018-07-06 15:30:00 +02:00
this.wardrobeComponent = new WardrobeComponent(this.habbo);
2019-05-26 20:14:53 +02:00
} catch (Exception e) {
2018-07-06 15:30:00 +02:00
Emulator.getLogging().logErrorLine(e);
}
this.items = MarketPlace.getOwnOffers(this.habbo);
}
2019-05-26 20:14:53 +02:00
public WardrobeComponent getWardrobeComponent() {
2018-07-06 15:30:00 +02:00
return this.wardrobeComponent;
}
2019-05-26 20:14:53 +02:00
public void setWardrobeComponent(WardrobeComponent wardrobeComponent) {
2018-07-06 15:30:00 +02:00
this.wardrobeComponent = wardrobeComponent;
}
2019-05-26 20:14:53 +02:00
public BadgesComponent getBadgesComponent() {
2018-07-06 15:30:00 +02:00
return this.badgesComponent;
}
2019-05-26 20:14:53 +02:00
public void setBadgesComponent(BadgesComponent badgesComponent) {
2018-07-06 15:30:00 +02:00
this.badgesComponent = badgesComponent;
}
2019-05-26 20:14:53 +02:00
public BotsComponent getBotsComponent() {
2018-07-06 15:30:00 +02:00
return this.botsComponent;
}
2019-05-26 20:14:53 +02:00
public void setBotsComponent(BotsComponent botsComponent) {
2018-07-06 15:30:00 +02:00
this.botsComponent = botsComponent;
}
2019-05-26 20:14:53 +02:00
public EffectsComponent getEffectsComponent() {
2018-07-06 15:30:00 +02:00
return this.effectsComponent;
}
2019-05-26 20:14:53 +02:00
public void setEffectsComponent(EffectsComponent effectsComponent) {
2018-07-06 15:30:00 +02:00
this.effectsComponent = effectsComponent;
}
2019-05-26 20:14:53 +02:00
public ItemsComponent getItemsComponent() {
2018-07-06 15:30:00 +02:00
return this.itemsComponent;
}
2019-05-26 20:14:53 +02:00
public void setItemsComponent(ItemsComponent itemsComponent) {
2018-07-06 15:30:00 +02:00
this.itemsComponent = itemsComponent;
}
2019-05-26 20:14:53 +02:00
public PetsComponent getPetsComponent() {
2018-07-06 15:30:00 +02:00
return this.petsComponent;
}
2019-05-26 20:14:53 +02:00
public void setPetsComponent(PetsComponent petsComponent) {
2018-07-06 15:30:00 +02:00
this.petsComponent = petsComponent;
}
2019-05-26 20:14:53 +02:00
public void dispose() {
2018-07-06 15:30:00 +02:00
this.badgesComponent.dispose();
this.botsComponent.dispose();
this.effectsComponent.dispose();
this.itemsComponent.dispose();
this.petsComponent.dispose();
this.wardrobeComponent.dispose();
this.badgesComponent = null;
this.botsComponent = null;
this.effectsComponent = null;
this.itemsComponent = null;
this.petsComponent = null;
this.wardrobeComponent = null;
}
2019-05-26 20:14:53 +02:00
public void addMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) {
2018-07-06 15:30:00 +02:00
this.items.add(marketPlaceOffer);
}
2019-05-26 20:14:53 +02:00
public void removeMarketplaceOffer(MarketPlaceOffer marketPlaceOffer) {
2018-07-06 15:30:00 +02:00
this.items.remove(marketPlaceOffer);
}
2019-05-26 20:14:53 +02:00
public THashSet<MarketPlaceOffer> getMarketplaceItems() {
2018-07-06 15:30:00 +02:00
return this.items;
}
2019-05-26 20:14:53 +02:00
public int getSoldPriceTotal() {
2018-07-06 15:30:00 +02:00
int i = 0;
2019-05-26 20:14:53 +02:00
for (MarketPlaceOffer offer : this.items) {
if (offer.getState().equals(MarketPlaceState.SOLD)) {
i += offer.getPrice();
2018-07-06 15:30:00 +02:00
}
}
return i;
}
2019-05-26 20:14:53 +02:00
public MarketPlaceOffer getOffer(int id) {
for (MarketPlaceOffer offer : this.items) {
if (offer.getOfferId() == id)
2018-07-06 15:30:00 +02:00
return offer;
}
return null;
}
2019-05-26 20:14:53 +02:00
public Habbo getHabbo() {
2018-07-06 15:30:00 +02:00
return this.habbo;
}
}