mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 07:20:50 +01:00
Validate room name and description when creating room & save trade mode
This commit is contained in:
parent
db14789d6b
commit
ed2ec3e6f3
@ -327,10 +327,10 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
|
||||
public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId) {
|
||||
public Room createRoom(int ownerId, String ownerName, String name, String description, String modelName, int usersMax, int categoryId, int tradeType) {
|
||||
Room room = null;
|
||||
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category) VALUES (?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO rooms (owner_id, owner_name, name, description, model, users_max, category, trade_mode) VALUES (?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS)) {
|
||||
statement.setInt(1, ownerId);
|
||||
statement.setString(2, ownerName);
|
||||
statement.setString(3, name);
|
||||
@ -338,6 +338,7 @@ public class RoomManager {
|
||||
statement.setString(5, modelName);
|
||||
statement.setInt(6, usersMax);
|
||||
statement.setInt(7, categoryId);
|
||||
statement.setInt(8, tradeType);
|
||||
statement.execute();
|
||||
try (ResultSet set = statement.getGeneratedKeys()) {
|
||||
if (set.next())
|
||||
@ -351,8 +352,8 @@ public class RoomManager {
|
||||
}
|
||||
|
||||
|
||||
public Room createRoomForHabbo(Habbo habbo, String name, String description, String modelName, int usersMax, int categoryId) {
|
||||
Room room = this.createRoom(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), name, description, modelName, usersMax, categoryId);
|
||||
public Room createRoomForHabbo(Habbo habbo, String name, String description, String modelName, int usersMax, int categoryId, int tradeType) {
|
||||
Room room = this.createRoom(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), name, description, modelName, usersMax, categoryId, tradeType);
|
||||
|
||||
Emulator.getPluginManager().fireEvent(new NavigatorRoomCreatedEvent(habbo, room));
|
||||
|
||||
|
@ -41,6 +41,12 @@ public class RequestCreateRoomEvent extends MessageHandler {
|
||||
if (tradeType > 2)
|
||||
return;
|
||||
|
||||
if (name.length() < 3 || name.length() > 25 || !Emulator.getGameEnvironment().getWordFilter().filter(name, this.client.getHabbo()).equals(name))
|
||||
return;
|
||||
|
||||
if (description.length() > 128 || !Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description))
|
||||
return;
|
||||
|
||||
int count = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(this.client.getHabbo()).size();
|
||||
int max = this.client.getHabbo().getHabboStats().hasActiveClub() ? RoomManager.MAXIMUM_ROOMS_VIP : RoomManager.MAXIMUM_ROOMS_USER;
|
||||
|
||||
@ -49,13 +55,9 @@ public class RequestCreateRoomEvent extends MessageHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final Room room = Emulator.getGameEnvironment().getRoomManager().createRoomForHabbo(this.client.getHabbo(), name, description, modelName, maxUsers, categoryId);
|
||||
final Room room = Emulator.getGameEnvironment().getRoomManager().createRoomForHabbo(this.client.getHabbo(), name, description, modelName, maxUsers, categoryId, tradeType);
|
||||
|
||||
if (room != null) {
|
||||
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
|
||||
//Emulator.getGameEnvironment().getRoomManager().leaveRoom(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getCurrentRoom());
|
||||
}
|
||||
|
||||
this.client.sendResponse(new RoomCreatedComposer(room));
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class RoomSettingsSaveEvent extends MessageHandler {
|
||||
if (room.isOwner(this.client.getHabbo())) {
|
||||
String name = this.packet.readString();
|
||||
|
||||
if (name.isEmpty()) {
|
||||
if (name.trim().isEmpty() || name.length() > 60) {
|
||||
this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_NAME_MISSING, ""));
|
||||
return;
|
||||
}
|
||||
@ -34,6 +34,11 @@ public class RoomSettingsSaveEvent extends MessageHandler {
|
||||
}
|
||||
|
||||
String description = this.packet.readString();
|
||||
|
||||
if (description.length() > 255) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Emulator.getGameEnvironment().getWordFilter().filter(description, this.client.getHabbo()).equals(description)) {
|
||||
this.client.sendResponse(new RoomEditSettingsErrorComposer(room.getId(), RoomEditSettingsErrorComposer.ROOM_DESCRIPTION_BADWORDS, ""));
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user