Fixed Some Wireds with new structure, patched bug with repeaters, loadWired moved to Items

This commit is contained in:
Stankman 2023-06-20 22:01:21 -05:00
parent a6c6e8222f
commit 9ed3bfc37a
8 changed files with 82 additions and 24 deletions

View File

@ -685,7 +685,13 @@ public class ItemManager {
Constructor<? extends HabboItem> c = itemClass.getConstructor(ResultSet.class, Item.class); Constructor<? extends HabboItem> c = itemClass.getConstructor(ResultSet.class, Item.class);
c.setAccessible(true); c.setAccessible(true);
return (HabboItem) c.newInstance(set, baseItem); HabboItem item = (HabboItem) c.newInstance(set, baseItem);
if (item instanceof InteractionWired interactionWired) {
interactionWired.loadWiredSettings(set);
}
return item;
} catch (Exception e) { } catch (Exception e) {
log.error("Caught exception", e); log.error("Caught exception", e);
} }

View File

@ -76,16 +76,9 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
} }
for(HabboItem item : this.getWiredSettings().getItems(room)) { for(HabboItem item : this.getWiredSettings().getItems(room)) {
WiredChangeDirectionSetting setting = null; WiredChangeDirectionSetting setting = this.itemsSettings.computeIfAbsent(item, k ->
if(!this.itemsSettings.containsKey(item)) { new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection)
this.itemsSettings.put(item, new WiredChangeDirectionSetting(item.getId(), item.getRotation(), startDirection)); );
} else {
setting = this.itemsSettings.get(item);
}
if(setting == null) {
continue;
}
RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue()); RoomTile targetTile = room.getLayout().getTileInFront(room.getLayout().getTile(item.getX(), item.getY()), setting.getDirection().getValue());
int count = 1; int count = 1;

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset;
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.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -38,8 +39,37 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements ICy
} }
} }
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
if(room.getTriggersOnRoom().containsValue(this)) {
room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY());
}
super.onMove(room, oldLocation, newLocation);
}
@Override
public void onPickUp(Room room) {
if(room.getTriggersOnRoom().containsValue(this)) {
room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY());
}
super.onPickUp(room);
}
@Override @Override
public void cycle(Room room) { public void cycle(Room room) {
String key = this.getX() + ";" + this.getY();
if(room.getTriggersOnRoom().containsKey(key)) {
if(room.getTriggersOnRoom().get(key).getId() != this.getId()) {
if(!(room.getTriggersOnRoom().get(key) instanceof WiredTriggerRepeaterLong) && room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) {
return;
}
}
}
room.getTriggersOnRoom().put(key, this);
this.counter += 500; this.counter += 500;
if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) { if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500) {
this.counter = 0; this.counter = 0;

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset; import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.WiredTriggerReset;
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.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -37,10 +38,39 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
} }
} }
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
if(room.getTriggersOnRoom().containsValue(this)) {
room.getTriggersOnRoom().remove(oldLocation.getX() + ";" + oldLocation.getY());
}
super.onMove(room, oldLocation, newLocation);
}
@Override
public void onPickUp(Room room) {
if(room.getTriggersOnRoom().containsValue(this)) {
room.getTriggersOnRoom().remove(this.getX() + ";" + this.getY());
}
super.onPickUp(room);
}
@Override @Override
public void cycle(Room room) { public void cycle(Room room) {
String key = this.getX() + ";" + this.getY();
if(room.getTriggersOnRoom().containsKey(key)) {
if(room.getTriggersOnRoom().get(key).getId() != this.getId()) {
if(room.getTriggersOnRoom().get(key).getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) <= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) {
return;
}
}
}
room.getTriggersOnRoom().put(key, this);
this.counter += 500; this.counter += 500;
if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME)) { if (this.counter >= this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 5000) {
this.counter = 0; this.counter = 0;
if (this.getRoomId() != 0) { if (this.getRoomId() != 0) {
if (room.isLoaded()) { if (room.isLoaded()) {

View File

@ -292,6 +292,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private RoomSpecialTypes roomSpecialTypes; private RoomSpecialTypes roomSpecialTypes;
@Getter @Getter
private TraxManager traxManager; private TraxManager traxManager;
@Getter
private HashMap<String, InteractionWiredTrigger> triggersOnRoom;
private boolean cycleOdd; private boolean cycleOdd;
@Getter @Getter
private long cycleTimestamp; private long cycleTimestamp;
@ -381,6 +383,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.activeTrades = new THashSet<>(0); this.activeTrades = new THashSet<>(0);
this.rights = new TIntArrayList(); this.rights = new TIntArrayList();
this.userVotes = new ArrayList<>(); this.userVotes = new ArrayList<>();
this.triggersOnRoom = new HashMap<>();
} }
public synchronized void loadData() { public synchronized void loadData() {
@ -407,7 +410,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.loadBots(connection); this.loadBots(connection);
this.loadPets(connection); this.loadPets(connection);
this.loadWordFilter(connection); this.loadWordFilter(connection);
this.loadWiredData(connection); // this.loadWiredData(connection);
this.idleCycles = 0; this.idleCycles = 0;
this.loaded = true; this.loaded = true;
@ -1027,7 +1030,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
message.appendInt(this.ownerId); message.appendInt(this.ownerId);
message.appendString(this.ownerName); message.appendString(this.ownerName);
} }
message.appendInt(this.state.getState()); message.appendInt(this.state.ordinal());
message.appendInt(this.getUserCount()); message.appendInt(this.getUserCount());
message.appendInt(this.usersMax); message.appendInt(this.usersMax);
message.appendString(this.description); message.appendString(this.description);

View File

@ -6,12 +6,8 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum RoomState { public enum RoomState {
OPEN(0), OPEN,
LOCKED(1), LOCKED,
PASSWORD(2), PASSWORD,
INVISIBLE(3); INVISIBLE
private final int state;
} }

View File

@ -29,7 +29,7 @@ public class GetGuestRoomResultComposer extends MessageComposer {
this.response.appendInt(this.room.getOwnerId()); this.response.appendInt(this.room.getOwnerId());
this.response.appendString(this.room.getOwnerName()); this.response.appendString(this.room.getOwnerName());
} }
this.response.appendInt(this.room.getState().getState()); this.response.appendInt(this.room.getState().ordinal());
this.response.appendInt(this.room.getUserCount()); this.response.appendInt(this.room.getUserCount());
this.response.appendInt(this.room.getUsersMax()); this.response.appendInt(this.room.getUsersMax());
this.response.appendString(this.room.getDescription()); this.response.appendString(this.room.getDescription());

View File

@ -15,7 +15,7 @@ public class RoomSettingsDataComposer extends MessageComposer {
this.response.appendInt(this.room.getId()); this.response.appendInt(this.room.getId());
this.response.appendString(this.room.getName()); this.response.appendString(this.room.getName());
this.response.appendString(this.room.getDescription()); this.response.appendString(this.room.getDescription());
this.response.appendInt(this.room.getState().getState()); this.response.appendInt(this.room.getState().ordinal());
this.response.appendInt(this.room.getCategory()); this.response.appendInt(this.room.getCategory());
this.response.appendInt(this.room.getUsersMax()); this.response.appendInt(this.room.getUsersMax());
this.response.appendInt(this.room.getUsersMax()); this.response.appendInt(this.room.getUsersMax());