🔹 small updates

This commit is contained in:
duckietm 2025-02-05 14:36:19 +01:00
parent 65069510e7
commit 57aa3c14cd
3 changed files with 29 additions and 41 deletions

View File

@ -366,15 +366,13 @@ public final class MarketPlace {
THashSet<MarketPlaceOffer> offers = new THashSet<>(); THashSet<MarketPlaceOffer> offers = new THashSet<>();
offers.addAll(client.getHabbo().getInventory().getMarketplaceItems()); offers.addAll(client.getHabbo().getInventory().getMarketplaceItems());
synchronized (client.getHabbo().getInventory()) { for (MarketPlaceOffer offer : offers) {
for (MarketPlaceOffer offer : offers) { if (offer.getState().equals(MarketPlaceState.SOLD)) {
if (offer.getState().equals(MarketPlaceState.SOLD)) { client.getHabbo().getInventory().removeMarketplaceOffer(offer);
client.getHabbo().getInventory().removeMarketplaceOffer(offer); credits += offer.getPrice();
credits += offer.getPrice(); removeUser(offer);
removeUser(offer); offer.needsUpdate(true);
offer.needsUpdate(true); Emulator.getThreading().run(offer);
Emulator.getThreading().run(offer);
}
} }
} }

View File

@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
@ -13,7 +12,6 @@ import com.eu.habbo.threading.runnables.CannonResetCooldownAction;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
public class InteractionCannon extends HabboItem { public class InteractionCannon extends HabboItem {
public boolean cooldown = false; public boolean cooldown = false;
@ -46,41 +44,33 @@ public class InteractionCannon extends HabboItem {
return false; return false;
} }
@Override @Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception { public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects); if (room == null)
return;
if (room == null) return; if (client != null) {
RoomUnit roomUnit = client.getHabbo().getRoomUnit();
RoomTile tile = room.getLayout().getTile(this.getX(), this.getY()); int rotation = this.getRotation();
RoomTile fuseTile = room.getLayout().getTileInFront(tile, this.getRotation()); int dx = (rotation == 4) ? -1 : (rotation == 0) ? 2 : 0;
List<RoomTile> tiles = room.getLayout().getTilesAround(fuseTile); int dy = (rotation == 2) ? 2 : (rotation == 6) ? -1 : 0;
int x = this.getX() + dx;
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + 7) % 8)); int y = this.getY() + dy;
tiles.remove(room.getLayout().getTileInFront(tile, (this.getRotation() + 5) % 8)); if (roomUnit.getX() == x && roomUnit.getY() == y) {
this.shoot(room, client);
boolean conditionClient = (client != null); }
boolean conditionTile = (tiles.contains(client != null ? client.getHabbo().getRoomUnit().getCurrentLocation() : null)); } else {
boolean conditionWalk = (client != null && client.getHabbo().getRoomUnit().canWalk()); this.shoot(room, null);
if (!this.cooldown && conditionClient && conditionTile && conditionWalk) {
client.getHabbo().getRoomUnit().setCanWalk(false);
client.getHabbo().getRoomUnit().setGoalLocation(client.getHabbo().getRoomUnit().getCurrentLocation());
client.getHabbo().getRoomUnit().lookAtPoint(fuseTile);
client.getHabbo().getRoomUnit().statusUpdate(true);
this.cooldown = true;
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
room.updateItemState(this);
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
} }
} }
private void shoot(Room room, GameClient client) {
this.cooldown = true;
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
room.updateItemState(this);
Emulator.getThreading().run(new CannonKickAction(this, room, client), 750);
Emulator.getThreading().run(new CannonResetCooldownAction(this), 2000);
}
@Override @Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {

View File

@ -330,7 +330,7 @@ public class RoomUnit {
zHeight += room.getLayout().getHeightAtSquare(next.x, next.y); zHeight += room.getLayout().getHeightAtSquare(next.x, next.y);
} }
Optional<HabboItem> stackHelper = this.room.getItemsAt(next).stream().filter(i -> i instanceof InteractionTileWalkMagic).findAny(); Optional<HabboItem> stackHelper = room.getItemsAt(next).stream().filter(i -> i instanceof InteractionTileWalkMagic).findAny();
if (stackHelper.isPresent()) { if (stackHelper.isPresent()) {
zHeight = stackHelper.get().getZ(); zHeight = stackHelper.get().getZ();
} }