mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-26 16:30:52 +01:00
Fixed overcomplicated implementation
This commit is contained in:
parent
13e882021b
commit
88c4e0b288
@ -5,8 +5,4 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
|
||||
public interface IWiredPeriodical {
|
||||
int getInterval();
|
||||
void setInterval(int value);
|
||||
boolean isTriggerTileUpdated();
|
||||
void setTriggerTileUpdated(boolean value);
|
||||
RoomTile getOldTile();
|
||||
void setOldTile(RoomTile value);
|
||||
}
|
||||
|
@ -22,12 +22,6 @@ import java.sql.SQLException;
|
||||
public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset {
|
||||
public final int PARAM_REPEAT_TIME = 0;
|
||||
protected int counter = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean triggerTileUpdated;
|
||||
@Getter
|
||||
@Setter
|
||||
private RoomTile oldTile;
|
||||
@Setter
|
||||
private int interval;
|
||||
|
||||
@ -53,15 +47,25 @@ public class WiredTriggerRepeater extends InteractionWiredTrigger implements IWi
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
this.triggerTileUpdated = true;
|
||||
this.oldTile = oldLocation;
|
||||
if(room.getTriggersOnRoom().containsKey(oldLocation)) {
|
||||
if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) {
|
||||
room.getTriggersOnRoom().remove(oldLocation);
|
||||
}
|
||||
}
|
||||
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
this.triggerTileUpdated = true;
|
||||
this.oldTile = room.getLayout().getTile(this.getX(), this.getY());
|
||||
RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||
|
||||
if(room.getTriggersOnRoom().containsKey(oldLocation)) {
|
||||
if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) {
|
||||
room.getTriggersOnRoom().remove(oldLocation);
|
||||
}
|
||||
}
|
||||
|
||||
super.onPickUp(room);
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,6 @@ import java.sql.SQLException;
|
||||
public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements IWiredPeriodical, WiredTriggerReset {
|
||||
public final int PARAM_REPEAT_TIME = 0;
|
||||
protected int counter = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean triggerTileUpdated;
|
||||
@Getter
|
||||
@Setter
|
||||
private RoomTile oldTile;
|
||||
@Setter
|
||||
private int interval;
|
||||
public WiredTriggerRepeaterLong(ResultSet set, Item baseItem) throws SQLException {
|
||||
@ -50,20 +44,30 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
|
||||
|
||||
@Override
|
||||
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
|
||||
this.triggerTileUpdated = true;
|
||||
this.oldTile = oldLocation;
|
||||
if(room.getTriggersOnRoom().containsKey(oldLocation)) {
|
||||
if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) {
|
||||
room.getTriggersOnRoom().remove(oldLocation);
|
||||
}
|
||||
}
|
||||
|
||||
super.onMove(room, oldLocation, newLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickUp(Room room) {
|
||||
this.triggerTileUpdated = true;
|
||||
this.oldTile = room.getLayout().getTile(this.getX(), this.getY());
|
||||
RoomTile oldLocation = room.getLayout().getTile(this.getX(), this.getY());
|
||||
|
||||
if(room.getTriggersOnRoom().containsKey(oldLocation)) {
|
||||
if(room.getTriggersOnRoom().get(oldLocation).getId() == this.getId()) {
|
||||
room.getTriggersOnRoom().remove(oldLocation);
|
||||
}
|
||||
}
|
||||
|
||||
super.onPickUp(room);
|
||||
}
|
||||
|
||||
public int getInterval() {
|
||||
return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 500;
|
||||
return this.getWiredSettings().getIntegerParams().get(PARAM_REPEAT_TIME) * 5000;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4399,23 +4399,15 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
if(((IWiredPeriodical) trigger).isTriggerTileUpdated()) {
|
||||
if(this.triggersOnRoom.containsKey(((IWiredPeriodical) trigger).getOldTile())) {
|
||||
if(this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()).getId() == trigger.getId() || this.triggersOnRoom.get(((IWiredPeriodical) trigger).getOldTile()) == null) {
|
||||
this.triggersOnRoom.remove(((IWiredPeriodical) trigger).getOldTile());
|
||||
}
|
||||
}
|
||||
((IWiredPeriodical) trigger).setTriggerTileUpdated(false);
|
||||
((IWiredPeriodical) trigger).setOldTile(null);
|
||||
}
|
||||
|
||||
RoomTile triggerTile = this.layout.getTile(trigger.getX(), trigger.getY());
|
||||
|
||||
if (this.triggersOnRoom.containsKey(triggerTile)) {
|
||||
if (this.triggersOnRoom.get(triggerTile) == null || (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) trigger).getInterval() <= ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval())) {
|
||||
this.triggersOnRoom.put(triggerTile, trigger);
|
||||
} else if (this.triggersOnRoom.get(triggerTile).getId() != trigger.getId() && ((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) {
|
||||
return;
|
||||
if(this.triggersOnRoom.get(triggerTile).getId() != trigger.getId()) {
|
||||
if(((IWiredPeriodical) this.triggersOnRoom.get(triggerTile)).getInterval() <= ((IWiredPeriodical) trigger).getInterval()) {
|
||||
return;
|
||||
} else {
|
||||
this.triggersOnRoom.put(triggerTile, trigger);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.triggersOnRoom.put(triggerTile, trigger);
|
||||
|
Loading…
Reference in New Issue
Block a user