Arcturus-Community/src/main/java/com/eu/habbo/threading/runnables/RandomDiceNumber.java

48 lines
1.2 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.threading.runnables;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionColorWheel;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboItem;
public class RandomDiceNumber implements Runnable
{
private final HabboItem item;
private final Room room;
private final int maxNumber;
private int result;
public RandomDiceNumber(HabboItem item, Room room, int maxNumber)
{
this.item = item;
this.room = room;
this.maxNumber = maxNumber;
this.result = -1;
}
public RandomDiceNumber(Room room, HabboItem item, int result)
{
this.item = item;
this.room = room;
this.maxNumber = -1;
this.result = result;
}
@Override
public void run()
{
2019-03-18 02:22:00 +01:00
if(this.result <= 0)
this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1);
2018-07-06 15:30:00 +02:00
2019-03-18 02:22:00 +01:00
this.item.setExtradata(this.result + "");
2018-07-06 15:30:00 +02:00
this.item.needsUpdate(true);
Emulator.getThreading().run(this.item);
this.room.updateItem(this.item);
if(this.item instanceof InteractionColorWheel)
{
((InteractionColorWheel)this.item).clearRunnable();
}
}
}