mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Fix placing furni from gifts to a room. Closes #55
This commit is contained in:
parent
a413bfb0c6
commit
b408d59b05
@ -414,11 +414,14 @@ public class MarketPlace
|
||||
RequestOffersEvent.cachedResults.clear();
|
||||
try
|
||||
{
|
||||
client.sendResponse(new RemoveHabboItemComposer(event.item.getGiftAdjustedId()));
|
||||
client.sendResponse(new InventoryRefreshComposer());
|
||||
|
||||
event.item.setFromGift(false);
|
||||
|
||||
MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo());
|
||||
client.getHabbo().getInventory().addMarketplaceOffer(offer);
|
||||
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item);
|
||||
client.sendResponse(new RemoveHabboItemComposer(event.item.getId()));
|
||||
client.sendResponse(new InventoryRefreshComposer());
|
||||
item.setUserId(-1);
|
||||
item.needsUpdate(true);
|
||||
Emulator.getThreading().run(item);
|
||||
|
@ -43,6 +43,7 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
||||
private int limitedSells;
|
||||
private boolean needsUpdate = false;
|
||||
private boolean needsDelete = false;
|
||||
private boolean isFromGift = false;
|
||||
|
||||
public HabboItem(ResultSet set, Item baseItem) throws SQLException
|
||||
{
|
||||
@ -131,6 +132,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getGiftAdjustedId() {
|
||||
if (this.isFromGift) return -this.id;
|
||||
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getUserId()
|
||||
{
|
||||
return this.userId;
|
||||
@ -508,4 +515,12 @@ public abstract class HabboItem implements Runnable, IEventTriggers
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isFromGift() {
|
||||
return isFromGift;
|
||||
}
|
||||
|
||||
public void setFromGift(boolean fromGift) {
|
||||
isFromGift = fromGift;
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class ItemsComponent
|
||||
|
||||
public HabboItem getHabboItem(int itemId)
|
||||
{
|
||||
return this.items.get(itemId);
|
||||
return this.items.get(Math.abs(itemId));
|
||||
}
|
||||
|
||||
public HabboItem getAndRemoveHabboItem(final Item item)
|
||||
|
@ -50,7 +50,7 @@ public class RecycleEvent extends MessageHandler
|
||||
for (HabboItem item : items)
|
||||
{
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getId()));
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId()));
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class CraftingCraftItemEvent extends MessageHandler
|
||||
@Override
|
||||
public boolean execute(HabboItem object)
|
||||
{
|
||||
CraftingCraftItemEvent.this.client.sendResponse(new RemoveHabboItemComposer(object.getId()));
|
||||
CraftingCraftItemEvent.this.client.sendResponse(new RemoveHabboItemComposer(object.getGiftAdjustedId()));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -93,7 +93,7 @@ public class CraftingCraftSecretEvent extends MessageHandler
|
||||
for (HabboItem item : habboItems)
|
||||
{
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getId()));
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId()));
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(item.getId()));
|
||||
}
|
||||
this.client.sendResponse(new InventoryRefreshComposer());
|
||||
|
@ -36,7 +36,8 @@ public class PostItPlaceEvent extends MessageHandler
|
||||
item.needsUpdate(true);
|
||||
room.sendComposer(new AddWallItemComposer(item, this.client.getHabbo().getHabboInfo().getUsername()).compose());
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item);
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getId()));
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId()));
|
||||
item.setFromGift(false);
|
||||
Emulator.getThreading().run(item);
|
||||
|
||||
if (room.getOwnerId() != this.client.getHabbo().getHabboInfo().getId())
|
||||
|
@ -23,11 +23,6 @@ public class RoomPlaceItemEvent extends MessageHandler
|
||||
int itemId = -1;
|
||||
|
||||
if (values.length != 0) itemId = Integer.valueOf(values[0]);
|
||||
if(itemId < 0)
|
||||
{
|
||||
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.INVALID_MOVE.errorCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if(!this.client.getHabbo().getRoomUnit().isInRoom())
|
||||
{
|
||||
@ -122,7 +117,8 @@ public class RoomPlaceItemEvent extends MessageHandler
|
||||
}
|
||||
}
|
||||
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getId()));
|
||||
this.client.sendResponse(new RemoveHabboItemComposer(item.getGiftAdjustedId()));
|
||||
this.client.getHabbo().getInventory().getItemsComponent().removeHabboItem(item.getId());
|
||||
item.setFromGift(false);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
|
||||
@Override
|
||||
public boolean execute(int a, HabboItem habboItem)
|
||||
{
|
||||
this.response.appendInt(habboItem.getId());
|
||||
this.response.appendInt(habboItem.getGiftAdjustedId());
|
||||
this.response.appendString(habboItem.getBaseItem().getType().code);
|
||||
this.response.appendInt(habboItem.getId());
|
||||
this.response.appendInt(habboItem.getBaseItem().getSpriteId());
|
||||
|
@ -19,8 +19,7 @@ public class InventoryUpdateItemComposer extends MessageComposer
|
||||
public ServerMessage compose()
|
||||
{
|
||||
this.response.init(Outgoing.InventoryItemUpdateComposer);
|
||||
this.response.appendInt(2);
|
||||
this.response.appendInt(this.habboItem.getId());
|
||||
this.response.appendInt(this.habboItem.getGiftAdjustedId());
|
||||
this.response.appendString(this.habboItem.getBaseItem().getType().code);
|
||||
this.response.appendInt(this.habboItem.getId());
|
||||
this.response.appendInt(this.habboItem.getBaseItem().getSpriteId());
|
||||
@ -55,7 +54,7 @@ public class InventoryUpdateItemComposer extends MessageComposer
|
||||
this.response.appendBoolean(false);
|
||||
this.response.appendInt(-1);
|
||||
|
||||
if (this.habboItem.getBaseItem().getType() != FurnitureType.WALL) {
|
||||
if (this.habboItem.getBaseItem().getType() == FurnitureType.FLOOR) {
|
||||
this.response.appendString(""); //slotId
|
||||
this.response.appendInt(0);
|
||||
}
|
||||
|
@ -22,11 +22,11 @@ public class PresentItemOpenedComposer extends MessageComposer
|
||||
public ServerMessage compose()
|
||||
{
|
||||
this.response.init(Outgoing.PresentItemOpenedComposer);
|
||||
this.response.appendString(this.item.getBaseItem().getType().code);
|
||||
this.response.appendString(this.item.getBaseItem().getType().code.toLowerCase());
|
||||
this.response.appendInt(this.item.getBaseItem().getSpriteId());
|
||||
this.response.appendString(this.item.getBaseItem().getName());
|
||||
this.response.appendInt(this.item.getId());
|
||||
this.response.appendString(this.item.getBaseItem().getType().code);
|
||||
this.response.appendString(this.item.getBaseItem().getType().code.toLowerCase());
|
||||
this.response.appendBoolean(this.unknown);
|
||||
this.response.appendString(this.text);
|
||||
return this.response;
|
||||
|
@ -1,16 +1,25 @@
|
||||
package com.eu.habbo.threading.runnables;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.items.FurnitureType;
|
||||
import com.eu.habbo.habbohotel.items.interactions.InteractionGift;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryItemsComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
||||
import com.eu.habbo.messages.outgoing.inventory.InventoryUpdateItemComposer;
|
||||
import com.eu.habbo.messages.outgoing.rooms.items.PresentItemOpenedComposer;
|
||||
import gnu.trove.set.hash.THashSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class OpenGift implements Runnable
|
||||
{
|
||||
private final HabboItem item;
|
||||
@ -42,6 +51,8 @@ public class OpenGift implements Runnable
|
||||
i.run();
|
||||
}
|
||||
|
||||
if (inside != null) inside.setFromGift(true);
|
||||
|
||||
this.habbo.getInventory().getItemsComponent().addItems(items);
|
||||
|
||||
RoomTile tile = this.room.getLayout().getTile(this.item.getX(), this.item.getY());
|
||||
@ -49,15 +60,49 @@ public class OpenGift implements Runnable
|
||||
{
|
||||
this.room.updateTile(tile);
|
||||
}
|
||||
this.habbo.getClient().sendResponse(new AddHabboItemComposer(items));
|
||||
this.habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
|
||||
|
||||
Emulator.getThreading().run(new QueryDeleteHabboItem(this.item.getId()));
|
||||
Emulator.getThreading().run(new RemoveFloorItemTask(this.room, this.item), this.item.getBaseItem().getName().contains("present_wrap") ? 5000 : 0);
|
||||
|
||||
this.habbo.getClient().sendResponse(new InventoryRefreshComposer());
|
||||
|
||||
Map<AddHabboItemComposer.AddHabboItemCategory, List<Integer>> unseenItems = new HashMap<>();
|
||||
|
||||
for (HabboItem item : items) {
|
||||
switch (item.getBaseItem().getType()) {
|
||||
case WALL:
|
||||
case FLOOR:
|
||||
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI, new ArrayList<>());
|
||||
|
||||
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.OWNED_FURNI).add(item.getGiftAdjustedId());
|
||||
|
||||
break;
|
||||
|
||||
case BADGE:
|
||||
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BADGE)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BADGE, new ArrayList<>());
|
||||
|
||||
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BADGE).add(item.getId()); // badges cannot be placed so no need for gift adjusted ID
|
||||
break;
|
||||
|
||||
case PET:
|
||||
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.PET)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.PET, new ArrayList<>());
|
||||
|
||||
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.PET).add(item.getGiftAdjustedId());
|
||||
break;
|
||||
|
||||
case ROBOT:
|
||||
if (!unseenItems.containsKey(AddHabboItemComposer.AddHabboItemCategory.BOT)) unseenItems.put(AddHabboItemComposer.AddHabboItemCategory.BOT, new ArrayList<>());
|
||||
|
||||
unseenItems.get(AddHabboItemComposer.AddHabboItemCategory.BOT).add(item.getGiftAdjustedId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
this.habbo.getClient().sendResponse(new AddHabboItemComposer(unseenItems));
|
||||
|
||||
if (inside != null)
|
||||
{
|
||||
this.habbo.getClient().sendResponse(new InventoryUpdateItemComposer(inside));
|
||||
this.habbo.getClient().sendResponse(new PresentItemOpenedComposer(inside, "", false));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user