Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMonsterCrackable.java

69 lines
1.9 KiB
Java
Raw Normal View History

2018-12-22 11:39:00 +01:00
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import java.sql.ResultSet;
import java.sql.SQLException;
2019-05-26 20:14:53 +02:00
public class InteractionMonsterCrackable extends InteractionCrackable implements ICycleable {
2018-12-22 11:39:00 +01:00
private int lastHealthChange = 0;
private boolean respawn = false;
2019-05-26 20:14:53 +02:00
public InteractionMonsterCrackable(ResultSet set, Item baseItem) throws SQLException {
2018-12-22 11:39:00 +01:00
super(set, baseItem);
}
2019-05-26 20:14:53 +02:00
public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
2018-12-22 11:39:00 +01:00
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
2019-05-26 20:14:53 +02:00
public void cycle(Room room) {
if (this.ticks > 0 && Emulator.getIntUnixTimestamp() - this.lastHealthChange > 30) {
2019-03-18 02:22:00 +01:00
this.lastHealthChange = Emulator.getIntUnixTimestamp();
2018-12-22 11:39:00 +01:00
this.ticks--;
room.updateItem(this);
}
}
@Override
2019-05-26 20:14:53 +02:00
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
2019-03-18 02:22:00 +01:00
if (room.isPublicRoom()) this.respawn = true;
2018-12-22 11:39:00 +01:00
super.onClick(client, room, objects);
}
@Override
2019-05-26 20:14:53 +02:00
public boolean resetable() {
2018-12-22 11:39:00 +01:00
return this.respawn;
}
@Override
2019-05-26 20:14:53 +02:00
public void reset(Room room) {
2018-12-22 11:39:00 +01:00
RoomTile tile = room.getRandomWalkableTile();
this.setX(tile.x);
this.setY(tile.y);
this.setZ(room.getStackHeight(tile.x, tile.y, false));
super.reset(room);
}
@Override
2019-05-26 20:14:53 +02:00
public boolean allowAnyone() {
2018-12-22 11:39:00 +01:00
return this.respawn;
}
@Override
2019-05-26 20:14:53 +02:00
public boolean isUsable() {
2018-12-22 11:39:00 +01:00
return true;
}
@Override
2019-05-26 20:14:53 +02:00
protected boolean placeInRoom() {
2018-12-22 11:39:00 +01:00
return this.respawn;
}
}