🆙 Make Dice more Random and same roll time as habbo

This commit is contained in:
DuckieTM 2024-05-26 15:33:56 +02:00
parent c10431c50d
commit 2d528aaaac
3 changed files with 8 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.security.MessageDigest;
import java.security.SecureRandom;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
@ -71,6 +72,7 @@ public final class Emulator {
private static GameEnvironment gameEnvironment;
private static PluginManager pluginManager;
private static BadgeImager badgeImager;
private static final SecureRandom secureRandom = new SecureRandom();
static {
Thread hook = new Thread(new Runnable() {
@ -360,7 +362,9 @@ public final class Emulator {
public static Random getRandom() {
return ThreadLocalRandom.current();
}
public static SecureRandom getRandomDice() {
return secureRandom;
}
public static BadgeImager getBadgeImager() {
return badgeImager;
}

View File

@ -58,9 +58,9 @@ public class InteractionDice extends HabboItem {
Emulator.getThreading().run(this);
if (event.result > 0) {
Emulator.getThreading().run(new RandomDiceNumber(room, this, event.result), 1500);
Emulator.getThreading().run(new RandomDiceNumber(room, this, event.result), 2000);
} else {
Emulator.getThreading().run(new RandomDiceNumber(this, room, this.getBaseItem().getStateCount()), 1500);
Emulator.getThreading().run(new RandomDiceNumber(this, room, this.getBaseItem().getStateCount()), 2000);
}
}
}

View File

@ -28,7 +28,7 @@ public class RandomDiceNumber implements Runnable {
@Override
public void run() {
if (this.result <= 0)
this.result = (Emulator.getRandom().nextInt(this.maxNumber) + 1);
this.result = (Emulator.getRandomDice().nextInt(this.maxNumber) + 1);
this.item.setExtradata(this.result + "");
this.item.needsUpdate(true);