mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-07-05 14:35:33 +02:00
135 lines
3.7 KiB
Java
135 lines
3.7 KiB
Java
![]() |
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
|
||
|
|
||
|
import com.eu.habbo.Emulator;
|
||
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||
|
import com.eu.habbo.habbohotel.items.Item;
|
||
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
|
||
|
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
|
||
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||
|
import com.eu.habbo.habbohotel.rooms.RoomUnit;
|
||
|
import com.eu.habbo.habbohotel.wired.WiredEffectType;
|
||
|
import com.eu.habbo.messages.ClientMessage;
|
||
|
import com.eu.habbo.messages.ServerMessage;
|
||
|
import com.eu.habbo.threading.runnables.WiredResetTimers;
|
||
|
import gnu.trove.procedure.TObjectProcedure;
|
||
|
|
||
|
import java.sql.ResultSet;
|
||
|
import java.sql.SQLException;
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
|
||
|
public class WiredEffectResetTimers extends InteractionWiredEffect
|
||
|
{
|
||
|
public static final WiredEffectType type = WiredEffectType.RESET_TIMERS;
|
||
|
|
||
|
private int delay = 0;
|
||
|
|
||
|
public WiredEffectResetTimers(ResultSet set, Item baseItem) throws SQLException
|
||
|
{
|
||
|
super(set, baseItem);
|
||
|
}
|
||
|
|
||
|
public WiredEffectResetTimers(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
|
||
|
{
|
||
|
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void serializeWiredData(ServerMessage message, Room room)
|
||
|
{
|
||
|
message.appendBoolean(false);
|
||
|
message.appendInt(5);
|
||
|
message.appendInt(0);
|
||
|
message.appendInt(this.getBaseItem().getSpriteId());
|
||
|
message.appendInt(this.getId());
|
||
|
message.appendString("");
|
||
|
message.appendInt(1);
|
||
|
message.appendInt(this.getDelay());
|
||
|
message.appendInt(0);
|
||
|
message.appendInt(this.getType().code);
|
||
|
message.appendInt(this.getDelay());
|
||
|
|
||
|
if (this.requiresTriggeringUser())
|
||
|
{
|
||
|
List<Integer> invalidTriggers = new ArrayList<>();
|
||
|
room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure<InteractionWiredTrigger>()
|
||
|
{
|
||
|
@Override
|
||
|
public boolean execute(InteractionWiredTrigger object)
|
||
|
{
|
||
|
if (!object.isTriggeredByRoomUnit())
|
||
|
{
|
||
|
invalidTriggers.add(object.getBaseItem().getSpriteId());
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
});
|
||
|
message.appendInt(invalidTriggers.size());
|
||
|
for (Integer i : invalidTriggers)
|
||
|
{
|
||
|
message.appendInt(i);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
message.appendInt(0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean saveData(ClientMessage packet, GameClient gameClient)
|
||
|
{
|
||
|
packet.readInt();
|
||
|
packet.readString();
|
||
|
packet.readInt();
|
||
|
this.delay = packet.readInt();
|
||
|
this.setDelay(this.delay);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
|
||
|
{
|
||
|
Emulator.getThreading().run(new WiredResetTimers(room), this.delay);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public String getWiredData()
|
||
|
{
|
||
|
return this.delay + "";
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void loadWiredData(ResultSet set, Room room) throws SQLException
|
||
|
{
|
||
|
String data = set.getString("wired_data");
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (!data.equals(""))
|
||
|
this.delay = Integer.valueOf(data);
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
this.setDelay(this.delay);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onPickUp()
|
||
|
{
|
||
|
this.delay = 0;
|
||
|
this.setDelay(0);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public WiredEffectType getType()
|
||
|
{
|
||
|
return type;
|
||
|
}
|
||
|
}
|