From eecb8ba8faef60a26f256989e73b574eddb45e5b Mon Sep 17 00:00:00 2001 From: Harmonic Date: Tue, 12 Apr 2022 17:06:00 -0700 Subject: [PATCH] Normal group members can no longer view hidden posts & admins can now hide & unhide posts. --- .../guilds/forums/ForumThreadState.java | 4 ++-- .../GuildForumModerateMessageEvent.java | 8 +++---- .../forums/GuildForumModerateThreadEvent.java | 22 +++++++------------ .../GuildForumThreadsMessagesEvent.java | 22 ++++++++++++++----- .../generic/alerts/BubbleAlertKeys.java | 1 + 5 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java index 4e044b98..2e57039e 100644 --- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java +++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java @@ -3,8 +3,8 @@ package com.eu.habbo.habbohotel.guilds.forums; public enum ForumThreadState { OPEN(0), CLOSED(1), - HIDDEN_BY_ADMIN(10), - HIDDEN_BY_STAFF(20); + HIDDEN_BY_STAFF_MEMBER(10), + HIDDEN_BY_GUILD_ADMIN(20); private int stateId; diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java index f7211d14..6febac46 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateMessageEvent.java @@ -37,7 +37,7 @@ public class GuildForumModerateMessageEvent extends MessageHandler { return; } - boolean isStaff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); + boolean hasStaffPermissions = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); if (member == null) { @@ -45,14 +45,14 @@ public class GuildForumModerateMessageEvent extends MessageHandler { return; } - boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().type < GuildRank.MEMBER.type); + boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)); - if (!isAdmin && !isStaff) { + if (!isGuildAdministrator && !hasStaffPermissions) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } - if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { + if (state == ForumThreadState.HIDDEN_BY_GUILD_ADMIN.getStateId() && !hasStaffPermissions) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java index dfd1d31d..5a83d413 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumModerateThreadEvent.java @@ -21,6 +21,8 @@ public class GuildForumModerateThreadEvent extends MessageHandler { int guildId = packet.readInt(); int threadId = packet.readInt(); int state = packet.readInt(); + // STATE 20 - HIDDEN_BY_GUILD_ADMIN = HIDDEN BY GUILD ADMINS/ HOTEL MODERATORS + // STATE 1 = VISIBLE THREAD Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); @@ -30,29 +32,21 @@ public class GuildForumModerateThreadEvent extends MessageHandler { return; } - boolean isStaff = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); - GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); + boolean hasStaffPerms = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); // check for if they have staff perm + boolean isGuildAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)); + + if (member == null) { this.client.sendResponse(new ConnectionErrorComposer(401)); return; } - - boolean isAdmin = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().type < GuildRank.MEMBER.type); - - if (!isAdmin && !isStaff) { + if (!isGuildAdmin && !hasStaffPerms) { this.client.sendResponse(new ConnectionErrorComposer(403)); return; } - if (state == ForumThreadState.HIDDEN_BY_STAFF.getStateId() && !isStaff) { - this.client.sendResponse(new ConnectionErrorComposer(403)); - return; - } - - thread.setState(ForumThreadState.fromValue(state)); - thread.setAdminId(this.client.getHabbo().getHabboInfo().getId()); - + thread.setState(ForumThreadState.fromValue(state)); // sets state as defined in the packet thread.run(); switch (state) { diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java index c315fb1a..7841b0bf 100644 --- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java +++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GuildForumThreadsMessagesEvent.java @@ -2,14 +2,21 @@ package com.eu.habbo.messages.incoming.guilds.forums; import com.eu.habbo.Emulator; import com.eu.habbo.habbohotel.guilds.Guild; +import com.eu.habbo.habbohotel.guilds.GuildMember; +import com.eu.habbo.habbohotel.guilds.GuildRank; +import com.eu.habbo.habbohotel.guilds.GuildState; import com.eu.habbo.habbohotel.guilds.forums.ForumThread; import com.eu.habbo.habbohotel.guilds.forums.ForumThreadState; +import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; +import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumCommentsComposer; import com.eu.habbo.messages.outgoing.guilds.forums.GuildForumDataComposer; import com.eu.habbo.messages.outgoing.handshake.ConnectionErrorComposer; + + public class GuildForumThreadsMessagesEvent extends MessageHandler { @Override public void handle() throws Exception { @@ -18,20 +25,23 @@ public class GuildForumThreadsMessagesEvent extends MessageHandler { int index = packet.readInt(); // 40 int limit = packet.readInt(); // 20 + Guild guild = Emulator.getGameEnvironment().getGuildManager().getGuild(guildId); ForumThread thread = ForumThread.getById(threadId); - + boolean hasStaffPermissions = this.client.getHabbo().hasPermission(Permission.ACC_MODTOOL_TICKET_Q); if (guild == null || thread == null) { this.client.sendResponse(new ConnectionErrorComposer(404)); return; } + GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, this.client.getHabbo().getHabboInfo().getId()); + boolean isGuildAdministrator = (guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || member.getRank().equals(GuildRank.ADMIN)); - if ((thread.getState() == ForumThreadState.HIDDEN_BY_ADMIN || thread.getState() == ForumThreadState.HIDDEN_BY_STAFF) && guild.getOwnerId() != this.client.getHabbo().getHabboInfo().getId()) { - this.client.sendResponse(new BubbleAlertComposer("oldforums.error.access_denied")); - } else { + if (thread.getState().getStateId() != 20 || hasStaffPermissions || isGuildAdministrator) { this.client.sendResponse(new GuildForumCommentsComposer(guildId, threadId, index, thread.getComments(limit, index))); + this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo())); + } + else { + this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FORUMS_ACCESS_DENIED.key).compose()); } - - this.client.sendResponse(new GuildForumDataComposer(guild, this.client.getHabbo())); } } \ No newline at end of file diff --git a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java index d3f30596..36ed0441 100644 --- a/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java +++ b/src/main/java/com/eu/habbo/messages/outgoing/generic/alerts/BubbleAlertKeys.java @@ -20,6 +20,7 @@ public enum BubbleAlertKeys { FORUMS_MESSAGE_HIDDEN("forums.message.hidden"), FORUMS_MESSAGE_RESTORED("forums.message.restored"), FORUMS_THREAD_HIDDEN("forums.thread.hidden"), + FORUMS_ACCESS_DENIED("forums.error.access_denied"), FORUMS_THREAD_LOCKED("forums.thread.locked"), FORUMS_THREAD_PINNED("forums.thread.pinned"), FORUMS_THREAD_RESTORED("forums.thread.restored"),