mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Merge branch 'fix/gate' into 'dev'
Fix: Gates shouldn't close if a user stands on it when clicked or activated by wired See merge request morningstar/Arcturus-Community!297
This commit is contained in:
commit
5de8d0607c
@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
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.users.HabboItem;
|
||||
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||||
@ -38,17 +39,21 @@ public class InteractionGate extends HabboItem {
|
||||
|
||||
@Override
|
||||
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
|
||||
boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
|
||||
boolean executedByWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
|
||||
|
||||
if (client != null && !room.hasRights(client.getHabbo()) && !executedByWired)
|
||||
return;
|
||||
|
||||
if (!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty())
|
||||
// If a Habbo is standing on a tile occupied by the gate, the gate shouldn't open/close
|
||||
for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
|
||||
if (room.hasHabbosAt(tile.x, tile.y))
|
||||
return;
|
||||
|
||||
// Gate closed = 0, open = 1
|
||||
if (this.getExtradata().length() == 0)
|
||||
this.setExtradata("0");
|
||||
|
||||
this.setExtradata((Integer.valueOf(this.getExtradata()) + 1) % 2 + "");
|
||||
this.setExtradata((Integer.parseInt(this.getExtradata()) + 1) % 2 + "");
|
||||
room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
|
||||
this.needsUpdate(true);
|
||||
room.updateItemState(this);
|
||||
|
Loading…
Reference in New Issue
Block a user