From 9705b3e42a0d26045f1f5dbc750db39d458391e4 Mon Sep 17 00:00:00 2001 From: duckietm Date: Thu, 28 May 2026 13:00:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20Added=20the=20option=20turn=20in?= =?UTF-8?q?=20menu=20for=20BOT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/eu/habbo/habbohotel/bots/Bot.java | 32 +++++++++++++------ .../eu/habbo/habbohotel/bots/FrankBot.java | 10 ++++-- .../rooms/bots/BotSaveSettingsEvent.java | 28 ++++++++++++---- 3 files changed, 52 insertions(+), 18 deletions(-) diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index 9123c338..d373cfa5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -189,11 +189,7 @@ public class Bot implements Runnable { int timeOut = Emulator.getRandom().nextInt(20) * 2; this.roomUnit.setWalkTimeOut((timeOut < 10 ? 5 : timeOut) + Emulator.getIntUnixTimestamp()); } - }/* else { - for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) { - WiredManager.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray()); - } - }*/ + } } if (!this.chatLines.isEmpty() && this.chatTimeOut <= Emulator.getIntUnixTimestamp() && this.chatAuto) { @@ -218,7 +214,7 @@ public class Bot implements Runnable { } else { this.lastChatIndex++; if (this.lastChatIndex >= this.chatLines.size()) { - this.lastChatIndex = 0; // start from scratch :-3 + this.lastChatIndex = 0; } } @@ -310,9 +306,6 @@ public class Bot implements Runnable { public void setName(String name) { this.name = name; this.needsUpdate = true; - - //if(this.room != null) - //this.room.sendComposer(new ChangeNameUpdatedComposer(this.getRoomUnit(), this.getName()).compose()); } public String getMotto() { @@ -539,9 +532,28 @@ public class Bot implements Runnable { } } - private static final short[] DEFAULT_OWNER_ACTION_IDS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + private static final short[] DEFAULT_OWNER_ACTION_IDS = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11}; + + public static final int ACTION_ROTATE = 11; + + private static final long MIN_OWNER_ACTION_INTERVAL_MS = 200L; + + private volatile long lastOwnerActionAt; public short[] getOwnerActionIds() { return DEFAULT_OWNER_ACTION_IDS; } + + public synchronized boolean tryAcquireOwnerActionSlot() { + long now = System.currentTimeMillis(); + if (now - this.lastOwnerActionAt < MIN_OWNER_ACTION_INTERVAL_MS) { + return false; + } + this.lastOwnerActionAt = now; + return true; + } + + public void onPostOwnerAction(int actionId) { + // no-op default + } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/FrankBot.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/FrankBot.java index a373f0fc..2a844cb9 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/FrankBot.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/FrankBot.java @@ -23,7 +23,6 @@ import java.util.regex.Pattern; public class FrankBot extends ButlerBot { private static final Logger LOGGER = LoggerFactory.getLogger(FrankBot.class); - public static final String BOT_TYPE = "frank"; public static final String PERMISSION_USE = "acc_bot_frank"; private static final String KEY_DOOR_LINES = "__door_lines"; @@ -75,13 +74,20 @@ public class FrankBot extends ButlerBot { } } - private static final short[] FRANK_OWNER_ACTIONS = new short[0]; + private static final short[] FRANK_OWNER_ACTIONS = { (short) Bot.ACTION_ROTATE }; @Override public short[] getOwnerActionIds() { return FRANK_OWNER_ACTIONS; } + @Override + public void onPostOwnerAction(int actionId) { + if (actionId == ACTION_ROTATE && this.getRoomUnit() != null) { + this.homeRotation = this.getRoomUnit().getBodyRotation(); + } + } + public static void initialise() { chatResponses.clear(); doorLines = DEFAULT_DOOR_LINES; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java index 6d7c8d21..23a99af3 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/bots/BotSaveSettingsEvent.java @@ -5,11 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.BotManager; import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.rooms.Room; +import com.eu.habbo.habbohotel.rooms.RoomUserRotation; import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserNameChangedComposer; +import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer; import com.eu.habbo.plugin.events.bots.BotSavedChatEvent; import com.eu.habbo.plugin.events.bots.BotSavedLookEvent; @@ -28,16 +30,20 @@ public class BotSaveSettingsEvent extends MessageHandler { if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { int botId = this.packet.readInt(); - Bot bot = room.getBot(Math.abs(botId)); - if (bot == null) return; - - if (bot.getOwnerActionIds().length == 0) - return; - int settingId = this.packet.readInt(); + boolean allowed = false; + for (short a : bot.getOwnerActionIds()) { + if (a == settingId) { + allowed = true; + break; + } + } + if (!allowed) return; + + if (!bot.tryAcquireOwnerActionSlot()) return; switch (settingId) { case 1: @@ -163,8 +169,18 @@ public class BotSaveSettingsEvent extends MessageHandler { bot.needsUpdate(true); room.sendComposer(new RoomUsersComposer(bot).compose()); break; + case Bot.ACTION_ROTATE: + if (bot.getRoomUnit() == null) break; + int next = (bot.getRoomUnit().getBodyRotation().getValue() + 2) % 8; + RoomUserRotation rotation = RoomUserRotation.fromValue(next); + bot.getRoomUnit().setRotation(rotation); + bot.needsUpdate(true); + room.sendComposer(new RoomUserStatusComposer(bot.getRoomUnit()).compose()); + break; } + bot.onPostOwnerAction(settingId); + if (bot.needsUpdate()) { Emulator.getThreading().run(bot); }