Add reporting photos

This commit is contained in:
Alejandro 2019-07-21 20:16:27 +03:00
parent f2d1329883
commit 06d8300886
7 changed files with 83 additions and 2 deletions

View File

@ -7,7 +7,8 @@ public enum ModToolChatRecordDataContext {
ROOM_ID("roomId", 1), ROOM_ID("roomId", 1),
GROUP_ID("groupId", 1), GROUP_ID("groupId", 1),
THREAD_ID("threadId", 1), THREAD_ID("threadId", 1),
MESSAGE_ID("messageId", 1); MESSAGE_ID("messageId", 1),
PHOTO_ID("extraDataId", 2);
public final String key; public final String key;
public final int type; public final int type;

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.modtool; package com.eu.habbo.habbohotel.modtool;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ISerialize; import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.UpdateModToolIssue; import com.eu.habbo.threading.runnables.UpdateModToolIssue;
@ -28,6 +29,7 @@ public class ModToolIssue implements ISerialize {
public int groupId = -1; public int groupId = -1;
public int threadId = -1; public int threadId = -1;
public int commentId = -1; public int commentId = -1;
public HabboItem photoItem = null;
public ModToolIssue(ResultSet set) throws SQLException { public ModToolIssue(ResultSet set) throws SQLException {
this.id = set.getInt("id"); this.id = set.getInt("id");

View File

@ -468,6 +468,7 @@ public class PacketManager {
this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class);
this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class); this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class);
this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class); this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class);
this.registerHandler(Incoming.ReportPhotoEvent, ReportPhotoEvent.class);
} }
void registerTrading() throws Exception { void registerTrading() throws Exception {

View File

@ -292,6 +292,7 @@ public class Incoming {
public static final int UpdateUIFlagsEvent = 2313; public static final int UpdateUIFlagsEvent = 2313;
public static final int ReportThreadEvent = 534; public static final int ReportThreadEvent = 534;
public static final int ReportCommentEvent = 1412; public static final int ReportCommentEvent = 1412;
public static final int ReportPhotoEvent = 2492;
public static final int RequestCraftingRecipesEvent = 1173; public static final int RequestCraftingRecipesEvent = 1173;
public static final int RequestCraftingRecipesAvailableEvent = 3086; public static final int RequestCraftingRecipesAvailableEvent = 3086;

View File

@ -43,6 +43,12 @@ public class ModToolRequestIssueChatlogEvent extends MessageHandler {
chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage(), c.getCommentId() == issue.commentId)).collect(Collectors.toList()); chatlog = thread.getComments().stream().map(c -> new ModToolChatLog(c.getCreatedAt(), c.getHabbo().getHabboInfo().getId(), c.getHabbo().getHabboInfo().getUsername(), c.getMessage(), c.getCommentId() == issue.commentId)).collect(Collectors.toList());
} }
} }
} else if (issue.type == ModToolTicketType.PHOTO) {
if (issue.photoItem != null) {
chatlogType = ModToolIssueChatlogType.PHOTO;
chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId);
}
} else { } else {
chatlogType = ModToolIssueChatlogType.CHAT; chatlogType = ModToolIssueChatlogType.CHAT;

View File

@ -0,0 +1,63 @@
package com.eu.habbo.messages.incoming.modtool;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionExternalImage;
import com.eu.habbo.habbohotel.modtool.CfhTopic;
import com.eu.habbo.habbohotel.modtool.ModToolIssue;
import com.eu.habbo.habbohotel.modtool.ModToolTicketType;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.modtool.ModToolReportReceivedAlertComposer;
import com.eu.habbo.threading.runnables.InsertModToolIssue;
import com.google.gson.JsonParser;
public class ReportPhotoEvent extends MessageHandler {
@Override
public void handle() throws Exception {
boolean hasExtradataId = this.packet.readShort() != 0;
this.packet.getBuffer().resetReaderIndex();
if (hasExtradataId) {
String extradataId = this.packet.readString();
}
int roomId = this.packet.readInt();
int reportedUserId = this.packet.readInt();
int topicId = this.packet.readInt();
int itemId = this.packet.readInt();
CfhTopic topic = Emulator.getGameEnvironment().getModToolManager().getCfhTopic(topicId);
if (topic == null) return;
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
if (room == null) return;
HabboItem item = room.getHabboItem(itemId);
if (item == null || !(item instanceof InteractionExternalImage)) return;
InteractionExternalImage photoItem = (InteractionExternalImage) item;
String photoCreatorId = new JsonParser().parse(photoItem.getExtradata()).getAsJsonObject().get("u").getAsString();
if (photoCreatorId == null) return;
HabboInfo photoCreator = Emulator.getGameEnvironment().getHabboManager().getHabboInfo(Integer.valueOf(photoCreatorId));
if (photoCreator == null) return;
ModToolIssue issue = new ModToolIssue(this.client.getHabbo().getHabboInfo().getId(), this.client.getHabbo().getHabboInfo().getUsername(), photoCreator.getId(), photoCreator.getUsername(), roomId, "", ModToolTicketType.PHOTO);
issue.photoItem = photoItem;
new InsertModToolIssue(issue).run();
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, ""));
Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
}
}

View File

@ -8,7 +8,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -65,6 +64,14 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
ModToolChatRecordDataContext.GROUP_ID.append(this.response); ModToolChatRecordDataContext.GROUP_ID.append(this.response);
this.response.appendInt(this.issue.commentId); this.response.appendInt(this.issue.commentId);
} }
} else if (this.issue.type == ModToolTicketType.PHOTO) {
this.response.appendShort(2);
ModToolChatRecordDataContext.ROOM_NAME.append(this.response);
this.response.appendString(this.roomName);
ModToolChatRecordDataContext.PHOTO_ID.append(this.response);
this.response.appendString(this.issue.photoItem.getId() + "");
} else { } else {
this.response.appendShort(3); //Context Count this.response.appendShort(3); //Context Count