fix(modtool): guard ticket lifecycle inputs

This commit is contained in:
simoleo89
2026-06-15 20:07:24 +02:00
parent 044d1141cd
commit 916ef7af3a
11 changed files with 172 additions and 10 deletions
@@ -15,9 +15,13 @@ public class ModToolCloseTicketEvent extends MessageHandler {
this.packet.readInt();
int ticketId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(ticketId) || state < 1 || state > 3) {
return;
}
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId);
if (issue == null || issue.modId != this.client.getHabbo().getHabboInfo().getId())
if (!ModToolTicketGuard.isOwnedBy(issue, this.client.getHabbo()))
return;
Habbo sender = Emulator.getGameEnvironment().getHabboManager().getHabbo(issue.senderId);
@@ -14,9 +14,17 @@ public class ModToolIssueChangeTopicEvent extends MessageHandler {
this.packet.readInt();
int categoryId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(ticketId) || !ModToolTicketGuard.isPositiveId(categoryId)) {
return;
}
if (Emulator.getGameEnvironment().getModToolManager().getCfhTopic(categoryId) == null) {
return;
}
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId);
if (issue != null) {
if (ModToolTicketGuard.isOwnedBy(issue, this.client.getHabbo())) {
issue.category = categoryId;
new UpdateModToolIssue(issue).run();
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
@@ -15,10 +15,17 @@ public class ModToolPickTicketEvent extends MessageHandler {
public void handle() throws Exception {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
this.packet.readInt();
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt());
int ticketId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(ticketId)) {
this.client.getHabbo().alert(Emulator.getTexts().getValue("support.ticket.picked.failed"));
return;
}
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId);
if (issue != null) {
if (issue.state == ModToolTicketState.PICKED) {
if (!ModToolTicketGuard.canPick(issue)) {
this.client.sendResponse(new ModToolIssueInfoComposer(issue));
this.client.getHabbo().alert(Emulator.getTexts().getValue("support.ticket.picked.failed"));
@@ -13,17 +13,22 @@ public class ModToolReleaseTicketEvent extends MessageHandler {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
int count = this.packet.readInt();
if (!ModToolTicketGuard.isValidReleaseBatch(count)) {
return;
}
while (count != 0) {
count--;
int ticketId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(ticketId)) {
continue;
}
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId);
if (issue == null)
continue;
if (issue.modId != this.client.getHabbo().getHabboInfo().getId())
if (!ModToolTicketGuard.isOwnedBy(issue, this.client.getHabbo()))
continue;
issue.modId = 0;
@@ -16,7 +16,13 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler {
@Override
public void handle() throws Exception {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt());
int ticketId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(ticketId)) {
return;
}
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(ticketId);
if (issue != null) {
List<ModToolChatLog> chatlog = new ArrayList<>();
@@ -12,7 +12,13 @@ public class ModToolRequestRoomChatlogEvent extends MessageHandler {
public void handle() throws Exception {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
this.packet.readInt();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.packet.readInt());
int roomId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(roomId)) {
return;
}
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
if (room != null)
this.client.sendResponse(new ModToolRoomChatlogComposer(room, Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(room.getId())));
@@ -14,6 +14,10 @@ public class ModToolRequestRoomUserChatlogEvent extends MessageHandler {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
int userId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(userId)) {
return;
}
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
if (habbo != null) {
@@ -13,6 +13,11 @@ public class ModToolRequestUserChatlogEvent extends MessageHandler {
public void handle() throws Exception {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
int userId = this.packet.readInt();
if (!ModToolTicketGuard.isPositiveId(userId)) {
return;
}
HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(userId);
if (habboInfo == null) {
return;
@@ -0,0 +1,28 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketState;
import com.eu.habbo.habbohotel.users.Habbo;
final class ModToolTicketGuard {
static final int MAX_RELEASE_BATCH = 50;
private ModToolTicketGuard() {
}
static boolean isPositiveId(int id) {
return id > 0;
}
static boolean isValidReleaseBatch(int count) {
return count > 0 && count <= MAX_RELEASE_BATCH;
}
static boolean isOwnedBy(ModToolIssue issue, Habbo moderator) {
return issue != null && moderator != null && issue.modId == moderator.getHabboInfo().getId();
}
static boolean canPick(ModToolIssue issue) {
return issue != null && issue.state != ModToolTicketState.PICKED;
}
}