Arcturus-Community/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java

112 lines
4.2 KiB
Java
Raw Normal View History

2018-07-06 15:30:00 +02:00
package com.eu.habbo.habbohotel.modtool;
import com.eu.habbo.Emulator;
2019-07-21 19:16:27 +02:00
import com.eu.habbo.habbohotel.users.HabboItem;
2018-07-06 15:30:00 +02:00
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.UpdateModToolIssue;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
2019-05-26 20:14:53 +02:00
public class ModToolIssue implements ISerialize {
2018-07-06 15:30:00 +02:00
public int id;
public volatile ModToolTicketState state;
2019-03-18 02:22:00 +01:00
public volatile ModToolTicketType type;
2018-07-06 15:30:00 +02:00
public int category;
public int timestamp;
public volatile int priority;
public int reportedId;
2019-03-18 02:22:00 +01:00
public String reportedUsername;
2018-07-06 15:30:00 +02:00
public int roomId;
public int senderId;
2019-03-18 02:22:00 +01:00
public String senderUsername;
2018-07-06 15:30:00 +02:00
public volatile int modId = -1;
public volatile String modName = "";
2019-03-18 02:22:00 +01:00
public String message;
2018-07-06 15:30:00 +02:00
public ArrayList<ModToolChatLog> chatLogs = null;
2019-05-30 20:05:25 +02:00
public int groupId = -1;
public int threadId = -1;
public int commentId = -1;
2019-07-21 19:16:27 +02:00
public HabboItem photoItem = null;
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
public ModToolIssue(ResultSet set) throws SQLException {
2018-07-06 15:30:00 +02:00
this.id = set.getInt("id");
this.state = ModToolTicketState.getState(set.getInt("state"));
this.timestamp = set.getInt("timestamp");
this.priority = set.getInt("score");
this.senderId = set.getInt("sender_id");
this.senderUsername = set.getString("sender_username");
this.reportedId = set.getInt("reported_id");
this.reportedUsername = set.getString("reported_username");
this.message = set.getString("issue");
this.modId = set.getInt("mod_id");
this.modName = set.getString("mod_username");
this.type = ModToolTicketType.values()[set.getInt("type") - 1];
this.category = set.getInt("category");
2020-01-28 00:36:01 +01:00
this.groupId = set.getInt("group_id");
this.threadId = set.getInt("thread_id");
this.commentId = set.getInt("comment_id");
int photoItemId = set.getInt("photo_item_id");
if (photoItemId != -1) {
this.photoItem = Emulator.getGameEnvironment().getItemManager().loadHabboItem(photoItemId);
2020-01-28 00:36:01 +01:00
}
2018-07-06 15:30:00 +02:00
2019-05-26 20:14:53 +02:00
if (this.modId <= 0) {
2018-07-06 15:30:00 +02:00
this.modName = "";
this.state = ModToolTicketState.OPEN;
}
}
2019-05-26 20:14:53 +02:00
public ModToolIssue(int senderId, String senderUserName, int reportedId, String reportedUsername, int reportedRoomId, String message, ModToolTicketType type) {
2018-07-06 15:30:00 +02:00
this.state = ModToolTicketState.OPEN;
this.timestamp = Emulator.getIntUnixTimestamp();
this.priority = 0;
this.senderId = senderId;
this.senderUsername = senderUserName;
this.reportedUsername = reportedUsername;
this.reportedId = reportedId;
this.roomId = reportedRoomId;
this.message = message;
this.type = type;
this.category = 1;
}
@Override
2019-05-26 20:14:53 +02:00
public void serialize(ServerMessage message) {
2018-07-06 15:30:00 +02:00
message.appendInt(this.id); //ID
message.appendInt(this.state.getState()); //STATE
message.appendInt(this.type.getType()); //TYPE
message.appendInt(this.category); //CATEGORY ID
message.appendInt(((Emulator.getIntUnixTimestamp() - this.timestamp))); //TIME IN MS AGO
message.appendInt(this.priority); //PRIORITY
2018-09-28 21:25:00 +02:00
message.appendInt(1);
2018-07-06 15:30:00 +02:00
message.appendInt(this.senderId); //Reporter user ID
message.appendString(this.senderUsername); //Reporter user name.
message.appendInt(this.reportedId); //Reported user ID.
message.appendString(this.reportedUsername); //Reported user name.
2020-01-27 18:17:11 +01:00
message.appendInt(this.modId); //ADMIN User ID?
message.appendString(this.modName); //ADMIN User name?
2018-07-06 15:30:00 +02:00
message.appendString(this.message);
message.appendInt(0);
2019-05-26 20:14:53 +02:00
if (this.chatLogs != null) {
2018-07-06 15:30:00 +02:00
message.appendInt(this.chatLogs.size());
2019-05-26 20:14:53 +02:00
for (ModToolChatLog chatLog : this.chatLogs) {
2018-07-06 15:30:00 +02:00
message.appendString(chatLog.message);
message.appendInt(0);
message.appendInt(chatLog.message.length());
}
2019-05-26 20:14:53 +02:00
} else {
2018-07-06 15:30:00 +02:00
message.appendInt(0);
}
}
2019-05-26 20:14:53 +02:00
public void updateInDatabase() {
2018-07-06 15:30:00 +02:00
Emulator.getThreading().run(new UpdateModToolIssue(this));
}
}