mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-12-03 11:16:26 +01:00
Custom configs added for wired (multiple users teleporting at the same time)
Custom place/rotate under user setting Custom walk on furni if placed/rotated under user setting
This commit is contained in:
parent
be3207eca0
commit
40793258b6
@ -4,9 +4,9 @@ import com.eu.habbo.Emulator;
|
|||||||
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.RoomUnit;
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
|
||||||
import com.eu.habbo.messages.ServerMessage;
|
import com.eu.habbo.messages.ServerMessage;
|
||||||
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
|
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
|
||||||
|
import gnu.trove.map.hash.TLongLongHashMap;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -18,6 +18,7 @@ import java.sql.SQLException;
|
|||||||
public abstract class InteractionWired extends InteractionDefault {
|
public abstract class InteractionWired extends InteractionDefault {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
|
||||||
private long cooldown;
|
private long cooldown;
|
||||||
|
private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3);
|
||||||
|
|
||||||
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
|
||||||
super(set, baseItem);
|
super(set, baseItem);
|
||||||
@ -69,10 +70,16 @@ public abstract class InteractionWired extends InteractionDefault {
|
|||||||
public abstract void onPickUp();
|
public abstract void onPickUp();
|
||||||
|
|
||||||
public void activateBox(Room room) {
|
public void activateBox(Room room) {
|
||||||
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
this.activateBox(room, (RoomUnit)null, 0L);
|
||||||
room.sendComposer(new ItemStateComposer(this).compose());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void activateBox(Room room, RoomUnit roomUnit, long millis) {
|
||||||
|
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
|
||||||
|
room.sendComposer(new ItemStateComposer(this).compose());
|
||||||
|
if (roomUnit != null) {
|
||||||
|
this.addUserExecutionCache(roomUnit.getId(), millis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected long requiredCooldown() {
|
protected long requiredCooldown() {
|
||||||
return 50L;
|
return 50L;
|
||||||
@ -96,4 +103,27 @@ public abstract class InteractionWired extends InteractionDefault {
|
|||||||
public boolean isUsable() {
|
public boolean isUsable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean userCanExecute(int roomUnitId, long timestamp) {
|
||||||
|
if (roomUnitId == -1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
if (this.userExecutionCache.containsKey((long)roomUnitId)) {
|
||||||
|
long lastTimestamp = this.userExecutionCache.get((long)roomUnitId);
|
||||||
|
if (timestamp - lastTimestamp < 100L) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearUserExecutionCache() {
|
||||||
|
this.userExecutionCache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addUserExecutionCache(int roomUnitId, long timestamp) {
|
||||||
|
this.userExecutionCache.put((long)roomUnitId, timestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4501,10 +4501,12 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
if(t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
|
if(t.state == RoomTileState.INVALID) return FurnitureMovementError.INVALID_MOVE;
|
||||||
|
if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) {
|
||||||
if (checkForUnits && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
if (checkForUnits && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||||
if (checkForUnits && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
if (checkForUnits && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
||||||
if (checkForUnits && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
|
if (checkForUnits && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
@ -4610,10 +4612,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) {
|
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor) {
|
||||||
return moveFurniTo(item, tile, rotation, actor, true);
|
return moveFurniTo(item, tile, rotation, actor, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) {
|
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates) {
|
||||||
|
return moveFurniTo(item, tile, rotation, actor, sendUpdates, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FurnitureMovementError moveFurniTo(HabboItem item, RoomTile tile, int rotation, Habbo actor, boolean sendUpdates, boolean checkForUnits) {
|
||||||
RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY());
|
RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY());
|
||||||
|
|
||||||
boolean pluginHelper = false;
|
boolean pluginHelper = false;
|
||||||
@ -4631,6 +4637,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
|
|
||||||
//Check if can be placed at new position
|
//Check if can be placed at new position
|
||||||
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||||
|
THashSet<RoomTile> newOccupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
|
||||||
|
|
||||||
HabboItem topItem = this.getTopItemAt(occupiedTiles, null);
|
HabboItem topItem = this.getTopItemAt(occupiedTiles, null);
|
||||||
|
|
||||||
@ -4640,11 +4647,16 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
|
HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
|
||||||
if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
|
if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
|
||||||
return FurnitureMovementError.CANT_STACK;
|
return FurnitureMovementError.CANT_STACK;
|
||||||
|
|
||||||
|
if(!Emulator.getConfig().getBoolean("wired.place.under", false) || (Emulator.getConfig().getBoolean("wired.place.under", false) && !item.isWalkable() && !item.getBaseItem().allowSit())) {
|
||||||
|
if (checkForUnits) {
|
||||||
if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
if (!magicTile && this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
|
||||||
if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
if (!magicTile && this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
|
||||||
if (!magicTile && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
|
if (!magicTile && this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
|
||||||
for (RoomTile t : occupiedTiles) {
|
for (RoomTile t : occupiedTiles) {
|
||||||
@ -4746,6 +4758,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
|
|||||||
);
|
);
|
||||||
this.updateBotsAt(t.x, t.y);
|
this.updateBotsAt(t.x, t.y);
|
||||||
}
|
}
|
||||||
|
if(Emulator.getConfig().getBoolean("wired.place.under", false)) {
|
||||||
|
for(RoomTile t : newOccupiedTiles) {
|
||||||
|
for(Habbo h : this.getHabbosAt(t.x, t.y)) {
|
||||||
|
try {
|
||||||
|
item.onWalkOn(h.getRoomUnit(), this, null);
|
||||||
|
}
|
||||||
|
catch(Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return FurnitureMovementError.NONE;
|
return FurnitureMovementError.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,8 +160,9 @@ public class WiredHandler {
|
|||||||
|
|
||||||
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff, final THashSet<InteractionWiredEffect> effectsToExecute) {
|
public static boolean handle(InteractionWiredTrigger trigger, final RoomUnit roomUnit, final Room room, final Object[] stuff, final THashSet<InteractionWiredEffect> effectsToExecute) {
|
||||||
long millis = System.currentTimeMillis();
|
long millis = System.currentTimeMillis();
|
||||||
if (Emulator.isReady && trigger.canExecute(millis) && trigger.execute(roomUnit, room, stuff)) {
|
int roomUnitId = roomUnit != null ? roomUnit.getId() : -1;
|
||||||
trigger.activateBox(room);
|
if (Emulator.isReady && ((Emulator.getConfig().getBoolean("wired.custom.enabled", false) && (trigger.canExecute(millis) || roomUnitId > -1) && trigger.userCanExecute(roomUnitId, millis)) || (!Emulator.getConfig().getBoolean("wired.custom.enabled", false) && trigger.canExecute(millis))) && trigger.execute(roomUnit, room, stuff)) {
|
||||||
|
trigger.activateBox(room, roomUnit, millis);
|
||||||
|
|
||||||
THashSet<InteractionWiredCondition> conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY());
|
THashSet<InteractionWiredCondition> conditions = room.getRoomSpecialTypes().getConditions(trigger.getX(), trigger.getY());
|
||||||
THashSet<InteractionWiredEffect> effects = room.getRoomSpecialTypes().getEffects(trigger.getX(), trigger.getY());
|
THashSet<InteractionWiredEffect> effects = room.getRoomSpecialTypes().getEffects(trigger.getX(), trigger.getY());
|
||||||
@ -193,7 +194,7 @@ public class WiredHandler {
|
|||||||
THashSet<InteractionWiredExtra> extras = room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY());
|
THashSet<InteractionWiredExtra> extras = room.getRoomSpecialTypes().getExtras(trigger.getX(), trigger.getY());
|
||||||
|
|
||||||
for (InteractionWiredExtra extra : extras) {
|
for (InteractionWiredExtra extra : extras) {
|
||||||
extra.activateBox(room);
|
extra.activateBox(room, roomUnit, millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<InteractionWiredEffect> effectList = new ArrayList<>(effects);
|
List<InteractionWiredEffect> effectList = new ArrayList<>(effects);
|
||||||
@ -241,7 +242,7 @@ public class WiredHandler {
|
|||||||
LOGGER.error("Caught exception", e);
|
LOGGER.error("Caught exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
effect.activateBox(room);
|
effect.activateBox(room, roomUnit, millis);
|
||||||
}
|
}
|
||||||
}, effect.getDelay() * 500);
|
}, effect.getDelay() * 500);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user