From 112e1ff3777bf766b3c346a7d4af8e38ded7d5d6 Mon Sep 17 00:00:00 2001 From: Oliver Date: Sun, 12 May 2024 20:33:32 +0000 Subject: [PATCH] Fix non-random speech.java --- .../com/eu/habbo/habbohotel/bots/Bot.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index b1149aa9..995a7af1 100644 --- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -43,11 +43,11 @@ public class Bot implements Runnable { private short chatDelay; private int chatTimeOut; private int chatTimestamp; - private short lastChatIndex; + private int lastChatIndex; private int bubble; - private String type; + private final String type; private int effect; @@ -187,9 +187,7 @@ public class Bot implements Runnable { if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) { if (this.room != null) { - this.lastChatIndex = (this.chatRandom ? (short) Emulator.getRandom().nextInt(this.chatLines.size()) : (this.lastChatIndex == (this.chatLines.size() - 1) ? 0 : this.lastChatIndex++)); - - if (this.lastChatIndex >= this.chatLines.size()) { + if (this.lastChatIndex < 0 || this.lastChatIndex >= this.chatLines.size()) { this.lastChatIndex = 0; } @@ -204,9 +202,19 @@ public class Bot implements Runnable { this.talk(message); } + if (this.chatRandom) { + this.lastChatIndex = (short) Emulator.getRandom().nextInt(this.chatLines.size()); + } else { + this.lastChatIndex++; + if (this.lastChatIndex >= this.chatLines.size()) { + this.lastChatIndex = 0; // start from scratch :-3 + } + } + this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; } } + } } @@ -420,6 +428,11 @@ public class Bot implements Runnable { return this.effect; } + public void setBubble(int bubble) { + this.bubble = bubble; + this.needsUpdate = true; + } + public void setEffect(int effect, int duration) { this.effect = effect; this.needsUpdate = true;