{
+ T map(ResultSet rs) throws SQLException;
+ }
+
+ @FunctionalInterface
+ public interface RowConsumer {
+ void accept(ResultSet rs) throws SQLException;
+ }
+
+ @FunctionalInterface
+ public interface ParameterBinder {
+ void bind(PreparedStatement ps, P value) throws SQLException;
+ }
+
+ public static class DataAccessException extends RuntimeException {
+ public DataAccessException(String message, Throwable cause) {
+ super(message, cause);
+ }
+ }
+
+ public static List query(String sql, RowMapper mapper, Object... params) {
+ try (Connection c = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement ps = c.prepareStatement(sql)) {
+ bindAll(ps, params);
+ try (ResultSet rs = ps.executeQuery()) {
+ List out = new ArrayList<>();
+ while (rs.next()) {
+ out.add(mapper.map(rs));
+ }
+ return out;
+ }
+ } catch (SQLException e) {
+ throw new DataAccessException("query failed: " + sql, e);
+ }
+ }
+
+ public static Optional queryOne(String sql, RowMapper mapper, Object... params) {
+ try (Connection c = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement ps = c.prepareStatement(sql)) {
+ bindAll(ps, params);
+ try (ResultSet rs = ps.executeQuery()) {
+ return rs.next() ? Optional.ofNullable(mapper.map(rs)) : Optional.empty();
+ }
+ } catch (SQLException e) {
+ throw new DataAccessException("queryOne failed: " + sql, e);
+ }
+ }
+
+ public static void forEach(String sql, RowConsumer consumer, Object... params) {
+ try (Connection c = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement ps = c.prepareStatement(sql)) {
+ bindAll(ps, params);
+ try (ResultSet rs = ps.executeQuery()) {
+ while (rs.next()) {
+ consumer.accept(rs);
+ }
+ }
+ } catch (SQLException e) {
+ throw new DataAccessException("forEach failed: " + sql, e);
+ }
+ }
+
+ public static int update(String sql, Object... params) {
+ try (Connection c = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement ps = c.prepareStatement(sql)) {
+ bindAll(ps, params);
+ return ps.executeUpdate();
+ } catch (SQLException e) {
+ throw new DataAccessException("update failed: " + sql, e);
+ }
+ }
+
+ public static int[] batchUpdate(String sql, Collection extends P> items, ParameterBinder
binder) {
+ try (Connection c = Emulator.getDatabase().getDataSource().getConnection();
+ PreparedStatement ps = c.prepareStatement(sql)) {
+ for (P item : items) {
+ binder.bind(ps, item);
+ ps.addBatch();
+ }
+ return ps.executeBatch();
+ } catch (SQLException e) {
+ throw new DataAccessException("batchUpdate failed: " + sql, e);
+ }
+ }
+
+ private static void bindAll(PreparedStatement ps, Object[] params) throws SQLException {
+ if (params == null) {
+ return;
+ }
+ for (int i = 0; i < params.length; i++) {
+ ps.setObject(i + 1, params[i]);
+ }
+ }
+}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
index ff3700c4..df51f0bb 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/achievements/AchievementManager.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.achievements;
import com.eu.habbo.Emulator;
+import com.eu.habbo.database.SqlQueries;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
@@ -49,16 +50,12 @@ public class AchievementManager {
if (habbo != null) {
progressAchievement(habbo, achievement, amount);
} else {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
- PreparedStatement statement = connection.prepareStatement("" +
- "INSERT INTO users_achievements_queue (user_id, achievement_id, amount) VALUES (?, ?, ?) " +
- "ON DUPLICATE KEY UPDATE amount = amount + ?")) {
- statement.setInt(1, habboId);
- statement.setInt(2, achievement.id);
- statement.setInt(3, amount);
- statement.setInt(4, amount);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "INSERT INTO users_achievements_queue (user_id, achievement_id, amount) VALUES (?, ?, ?) "
+ + "ON DUPLICATE KEY UPDATE amount = amount + ?",
+ habboId, achievement.id, amount, amount);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
@@ -203,44 +200,41 @@ public class AchievementManager {
}
public static void createUserEntry(Habbo habbo, Achievement achievement) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_achievements (user_id, achievement_name, progress) VALUES (?, ?, ?)")) {
- statement.setInt(1, habbo.getHabboInfo().getId());
- statement.setString(2, achievement.name);
- statement.setInt(3, 1);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "INSERT INTO users_achievements (user_id, achievement_name, progress) VALUES (?, ?, ?)",
+ habbo.getHabboInfo().getId(), achievement.name, 1);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
public static void saveAchievements(Habbo habbo) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_achievements SET progress = ? WHERE achievement_name = ? AND user_id = ? LIMIT 1")) {
- statement.setInt(3, habbo.getHabboInfo().getId());
- for (Map.Entry map : habbo.getHabboStats().getAchievementProgress().entrySet()) {
- statement.setInt(1, map.getValue());
- statement.setString(2, map.getKey().name);
- statement.addBatch();
- }
- statement.executeBatch();
- } catch (SQLException e) {
+ int userId = habbo.getHabboInfo().getId();
+ try {
+ SqlQueries.batchUpdate(
+ "UPDATE users_achievements SET progress = ? WHERE achievement_name = ? AND user_id = ? LIMIT 1",
+ habbo.getHabboStats().getAchievementProgress().entrySet(),
+ (ps, entry) -> {
+ ps.setInt(1, entry.getValue());
+ ps.setString(2, entry.getKey().name);
+ ps.setInt(3, userId);
+ });
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
public static int getAchievementProgressForHabbo(int userId, Achievement achievement) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1")) {
- statement.setInt(1, userId);
- statement.setString(2, achievement.name);
- try (ResultSet set = statement.executeQuery()) {
- if (set.next()) {
- return set.getInt("progress");
- }
- }
- } catch (SQLException e) {
+ try {
+ return SqlQueries.queryOne(
+ "SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1",
+ rs -> rs.getInt("progress"),
+ userId, achievement.name).orElse(0);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return 0;
}
-
- return 0;
}
public void reload() {
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java
index 1336f88f..99c238c3 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/campaign/calendar/CalendarManager.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.campaign.calendar;
import com.eu.habbo.Emulator;
+import com.eu.habbo.database.SqlQueries;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer;
import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent;
@@ -33,27 +34,27 @@ public class CalendarManager {
public boolean reload() {
this.dispose();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_campaigns WHERE enabled = 1")) {
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- calendarCampaigns.put(set.getInt("id"), new CalendarCampaign(set));
- }
- }
- } catch (SQLException e) {
+ try {
+ SqlQueries.query(
+ "SELECT * FROM calendar_campaigns WHERE enabled = 1",
+ CalendarCampaign::new)
+ .forEach(c -> calendarCampaigns.put(c.getId(), c));
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
return false;
}
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) {
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- CalendarCampaign campaign = calendarCampaigns.get(set.getInt("campaign_id"));
- if(campaign != null){
- campaign.addReward(new CalendarRewardObject(set));
- }
- }
- }
- } catch (SQLException e) {
+ try {
+ SqlQueries.query(
+ "SELECT * FROM calendar_rewards",
+ rs -> Map.entry(rs.getInt("campaign_id"), new CalendarRewardObject(rs)))
+ .forEach(entry -> {
+ CalendarCampaign campaign = calendarCampaigns.get(entry.getKey());
+ if (campaign != null) {
+ campaign.addReward(entry.getValue());
+ }
+ });
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
return false;
}
@@ -94,14 +95,12 @@ public class CalendarManager {
public boolean deleteCampaign(CalendarCampaign campaign) {
calendarCampaigns.remove(campaign.getId());
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM calendar_campaigns WHERE id = ? LIMIT 1")) {
- statement.setInt(1, campaign.getId());
- return statement.execute();
- } catch (SQLException e) {
+ try {
+ return SqlQueries.update("DELETE FROM calendar_campaigns WHERE id = ? LIMIT 1", campaign.getId()) > 0;
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return false;
}
-
- return false;
}
public CalendarCampaign getCalendarCampaign(String campaignName) {
@@ -136,14 +135,15 @@ public class CalendarManager {
habbo.getHabboStats().calendarRewardsClaimed.add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis())));
habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object, habbo));
object.give(habbo);
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, campaign_id, day, reward_id, timestamp) VALUES (?, ?, ?, ?, ?)")) {
- statement.setInt(1, habbo.getHabboInfo().getId());
- statement.setInt(2, campaign.getId());
- statement.setInt(3, day);
- statement.setInt(4, object.getId());
- statement.setInt(5, Emulator.getIntUnixTimestamp());
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "INSERT INTO calendar_rewards_claimed (user_id, campaign_id, day, reward_id, timestamp) VALUES (?, ?, ?, ?, ?)",
+ habbo.getHabboInfo().getId(),
+ campaign.getId(),
+ day,
+ object.getId(),
+ Emulator.getIntUnixTimestamp());
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
index b4a3ca78..c2a244cc 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/commands/UserInfoCommand.java
@@ -84,7 +84,7 @@ public class UserInfoCommand extends Command {
if (onlineHabbo != null) {
message.append("\r" + "Other accounts (");
- ArrayList users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10);
+ List users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10);
users.sort(new Comparator() {
@Override
public int compare(HabboInfo o1, HabboInfo o2) {
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
index 796f3f0c..d9a71c21 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
@@ -638,7 +638,7 @@ public class ItemManager {
statement.execute();
try (ResultSet set = statement.getGeneratedKeys()) {
- try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items_presents VALUES (?, ?)")) {
+ try (PreparedStatement preparedStatement = connection.prepareStatement("INSERT INTO items_presents (item_id, base_item_reward) VALUES (?, ?)")) {
while (set.next() && item == null) {
preparedStatement.setInt(1, set.getInt(1));
preparedStatement.setInt(2, Integer.parseInt(itemId));
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
index a081bfc5..727729b6 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/messenger/Message.java
@@ -1,15 +1,14 @@
package com.eu.habbo.habbohotel.messenger;
import com.eu.habbo.Emulator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import com.eu.habbo.core.DatabaseLoggable;
-import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
-public class Message implements Runnable {
- private static final Logger LOGGER = LoggerFactory.getLogger(Message.class);
+public class Message implements Runnable, DatabaseLoggable {
+
+ private static final String QUERY = "INSERT INTO chatlogs_private (user_from_id, user_to_id, message, timestamp) VALUES (?, ?, ?, ?)";
private final int fromId;
private final int toId;
@@ -26,20 +25,25 @@ public class Message implements Runnable {
@Override
public void run() {
- //TODO Turn into scheduler
if (Messenger.SAVE_PRIVATE_CHATS) {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO chatlogs_private (user_from_id, user_to_id, message, timestamp) VALUES (?, ?, ?, ?)")) {
- statement.setInt(1, this.fromId);
- statement.setInt(2, this.toId);
- statement.setString(3, this.message);
- statement.setInt(4, this.timestamp);
- statement.execute();
- } catch (SQLException e) {
- LOGGER.error("Caught SQL exception", e);
- }
+ Emulator.getDatabaseLogger().store(this);
}
}
+ @Override
+ public String getQuery() {
+ return QUERY;
+ }
+
+ @Override
+ public void log(PreparedStatement statement) throws SQLException {
+ statement.setInt(1, this.fromId);
+ statement.setInt(2, this.toId);
+ statement.setString(3, this.message);
+ statement.setInt(4, this.timestamp);
+ statement.addBatch();
+ }
+
public int getToId() {
return this.toId;
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
index c4d9e653..b361a1c3 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
@@ -2151,7 +2151,7 @@ public class Room implements Comparable, ISerialize, Runnable {
this.rightsManager.refreshRightsForHabbo(habbo);
}
- public THashMap getUsersWithRights() {
+ public Map getUsersWithRights() {
return this.rightsManager.getUsersWithRights();
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
index fff73a0b..40501c9a 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
@@ -496,7 +496,7 @@ public class RoomManager {
h.getClient().sendResponse(new RoomScoreComposer(room.getScore(), !this.hasVotedForRoom(h, room)));
}
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_votes VALUES (?, ?)")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_votes (user_id, room_id) VALUES (?, ?)")) {
statement.setInt(1, habbo.getHabboInfo().getId());
statement.setInt(2, room.getId());
statement.execute();
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java
index f21b5289..e1e2fe12 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomRightsManager.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
+import com.eu.habbo.database.SqlQueries;
import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -14,7 +15,6 @@ import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.plugin.events.users.UserRightsTakenEvent;
import gnu.trove.list.array.TIntArrayList;
-import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import org.slf4j.Logger;
@@ -24,6 +24,9 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Collections;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
* Manages room rights, bans, and mutes.
@@ -149,13 +152,11 @@ public class RoomRightsManager {
}
if (this.rights.add(userId)) {
- try (Connection connection = Emulator.getDatabase().getDataSource()
- .getConnection(); PreparedStatement statement = connection.prepareStatement(
- "INSERT INTO room_rights VALUES (?, ?)")) {
- statement.setInt(1, this.room.getId());
- statement.setInt(2, userId);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "INSERT INTO room_rights (room_id, user_id) VALUES (?, ?)",
+ this.room.getId(), userId);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
@@ -196,13 +197,11 @@ public class RoomRightsManager {
this.room.sendComposer(new RoomRemoveRightsListComposer(this.room, userId).compose());
if (this.rights.remove(userId)) {
- try (Connection connection = Emulator.getDatabase().getDataSource()
- .getConnection(); PreparedStatement statement = connection.prepareStatement(
- "DELETE FROM room_rights WHERE room_id = ? AND user_id = ?")) {
- statement.setInt(1, this.room.getId());
- statement.setInt(2, userId);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "DELETE FROM room_rights WHERE room_id = ? AND user_id = ?",
+ this.room.getId(), userId);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
@@ -225,12 +224,9 @@ public class RoomRightsManager {
this.rights.clear();
- try (Connection connection = Emulator.getDatabase().getDataSource()
- .getConnection(); PreparedStatement statement = connection.prepareStatement(
- "DELETE FROM room_rights WHERE room_id = ?")) {
- statement.setInt(1, this.room.getId());
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update("DELETE FROM room_rights WHERE room_id = ?", this.room.getId());
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
@@ -288,25 +284,22 @@ public class RoomRightsManager {
/**
* Gets all users with rights in the room.
*/
- public THashMap getUsersWithRights() {
- THashMap rightsMap = new THashMap<>();
-
- if (!this.rights.isEmpty()) {
- try (Connection connection = Emulator.getDatabase().getDataSource()
- .getConnection(); PreparedStatement statement = connection.prepareStatement(
- "SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?")) {
- statement.setInt(1, this.room.getId());
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- rightsMap.put(set.getInt("user_id"), set.getString("username"));
- }
- }
- } catch (SQLException e) {
- LOGGER.error("Caught SQL exception", e);
- }
+ public Map getUsersWithRights() {
+ if (this.rights.isEmpty()) {
+ return Collections.emptyMap();
}
- return rightsMap;
+ try {
+ return SqlQueries.query(
+ "SELECT users.username AS username, users.id as user_id FROM room_rights INNER JOIN users ON room_rights.user_id = users.id WHERE room_id = ?",
+ rs -> Map.entry(rs.getInt("user_id"), rs.getString("username")),
+ this.room.getId())
+ .stream()
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (a, b) -> b));
+ } catch (SqlQueries.DataAccessException e) {
+ LOGGER.error("Caught SQL exception", e);
+ return Collections.emptyMap();
+ }
}
/**
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
index 7f922ef4..61f8075e 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
@@ -273,7 +273,7 @@ public class Habbo implements Runnable {
return;
this.getHabboInfo().addPixels(event.points);
- if (this.client != null) this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
+ if (this.client != null) this.client.sendResponse(new UserCurrencyComposer(this));
}
@@ -292,7 +292,7 @@ public class Habbo implements Runnable {
this.getHabboInfo().addCurrencyAmount(event.type, event.points);
if (this.client != null)
- this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(type), event.points, event.type));
+ this.client.sendResponse(new UserPointsComposer(this.getHabboInfo().getCurrencyAmount(type), event.points, event.type));
}
@@ -303,7 +303,7 @@ public class Habbo implements Runnable {
public void whisper(String message, RoomChatMessageBubbles bubble) {
if (this.getRoomUnit().isInRoom()) {
- this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)));
+ this.client.sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(message, this.getRoomUnit(), bubble)));
}
}
@@ -315,7 +315,7 @@ public class Habbo implements Runnable {
public void talk(String message, RoomChatMessageBubbles bubble) {
if (this.getRoomUnit().isInRoom()) {
- this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTalkComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose());
+ this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTalkComposer(new RoomChatMessage(message, this.getRoomUnit(), bubble)).compose());
}
}
@@ -327,7 +327,7 @@ public class Habbo implements Runnable {
public void shout(String message, RoomChatMessageBubbles bubble) {
if (this.getRoomUnit().isInRoom()) {
- this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserShoutComposer(new RoomChatMessage(message, this.client.getHabbo().getRoomUnit(), bubble)).compose());
+ this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserShoutComposer(new RoomChatMessage(message, this.getRoomUnit(), bubble)).compose());
}
}
@@ -450,7 +450,7 @@ public class Habbo implements Runnable {
this.client.sendResponse(new FloodCounterComposer(remaining));
this.client.sendResponse(new MutedWhisperComposer(remaining));
- Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = this.getHabboInfo().getCurrentRoom();
if (room != null && !isFlood) {
room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.MUTED).compose());
}
@@ -460,7 +460,7 @@ public class Habbo implements Runnable {
public void unMute() {
this.habboStats.unMute();
this.client.sendResponse(new FloodCounterComposer(3));
- Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
+ Room room = this.getHabboInfo().getCurrentRoom();
if (room != null) {
room.sendComposer(new RoomUserIgnoredComposer(this, RoomUserIgnoredComposer.UNIGNORED).compose());
}
@@ -497,18 +497,18 @@ public class Habbo implements Runnable {
public void respect(Habbo target) {
- if (target != null && target != this.client.getHabbo()) {
+ if (target != null && target != this) {
target.getHabboStats().respectPointsReceived++;
- this.client.getHabbo().getHabboStats().respectPointsGiven++;
- this.client.getHabbo().getHabboStats().respectPointsToGive--;
- this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRespectComposer(target).compose());
- this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserActionComposer(this.client.getHabbo().getRoomUnit(), RoomUserAction.THUMB_UP).compose());
+ this.getHabboStats().respectPointsGiven++;
+ this.getHabboStats().respectPointsToGive--;
+ this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserRespectComposer(target).compose());
+ this.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserActionComposer(this.getRoomUnit(), RoomUserAction.THUMB_UP).compose());
- AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven"));
+ AchievementManager.progressAchievement(this, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectGiven"));
AchievementManager.progressAchievement(target, Emulator.getGameEnvironment().getAchievementManager().getAchievement("RespectEarned"));
- this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo());
- this.client.getHabbo().getHabboInfo().getCurrentRoom().dance(this.client.getHabbo().getRoomUnit(), DanceType.NONE);
+ this.getHabboInfo().getCurrentRoom().unIdle(this);
+ this.getHabboInfo().getCurrentRoom().dance(this.getRoomUnit(), DanceType.NONE);
}
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
index 5c21f4ca..e53aee11 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.users;
import com.eu.habbo.Emulator;
+import com.eu.habbo.database.SqlQueries;
import com.eu.habbo.habbohotel.catalog.CatalogItem;
import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.GamePlayer;
@@ -14,7 +15,6 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import gnu.trove.map.hash.TIntIntHashMap;
-import gnu.trove.procedure.TIntIntProcedure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -104,53 +104,47 @@ public class HabboInfo implements Runnable {
private void loadCurrencies() {
this.currencies = new TIntIntHashMap();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_currency WHERE user_id = ?")) {
- statement.setInt(1, this.id);
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- this.currencies.put(set.getInt("type"), set.getInt("amount"));
- }
- }
- } catch (SQLException e) {
+ try {
+ SqlQueries.forEach(
+ "SELECT * FROM users_currency WHERE user_id = ?",
+ rs -> this.currencies.put(rs.getInt("type"), rs.getInt("amount")),
+ this.id);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
private void saveCurrencies() {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO users_currency (user_id, type, amount) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = ?")) {
- this.currencies.forEachEntry(new TIntIntProcedure() {
- @Override
- public boolean execute(int a, int b) {
- try {
- statement.setInt(1, HabboInfo.this.getId());
- statement.setInt(2, a);
- statement.setInt(3, b);
- statement.setInt(4, b);
- statement.addBatch();
- } catch (SQLException e) {
- LOGGER.error("Caught SQL exception", e);
- }
- return true;
- }
- });
- statement.executeBatch();
- } catch (SQLException e) {
- LOGGER.error("Caught SQL exception", e);
+ List entries = new ArrayList<>(this.currencies.size());
+ this.currencies.forEachEntry((type, amount) -> {
+ entries.add(new int[]{type, amount});
+ return true;
+ });
+
+ try {
+ SqlQueries.batchUpdate(
+ "INSERT INTO users_currency (user_id, type, amount) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE amount = ?",
+ entries,
+ (ps, e) -> {
+ ps.setInt(1, this.id);
+ ps.setInt(2, e[0]);
+ ps.setInt(3, e[1]);
+ ps.setInt(4, e[1]);
+ });
+ } catch (SqlQueries.DataAccessException ex) {
+ LOGGER.error("Caught SQL exception", ex);
}
}
private void loadSavedSearches() {
- this.savedSearches = new ArrayList<>();
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_saved_searches WHERE user_id = ?")) {
- statement.setInt(1, this.id);
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- this.savedSearches.add(new NavigatorSavedSearch(set.getString("search_code"), set.getString("filter"), set.getInt("id")));
- }
- }
- } catch (SQLException e) {
+ try {
+ this.savedSearches = SqlQueries.query(
+ "SELECT * FROM users_saved_searches WHERE user_id = ?",
+ rs -> new NavigatorSavedSearch(rs.getString("search_code"), rs.getString("filter"), rs.getInt("id")),
+ this.id);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ this.savedSearches = new ArrayList<>();
}
}
@@ -182,26 +176,22 @@ public class HabboInfo implements Runnable {
public void deleteSavedSearch(NavigatorSavedSearch search) {
this.savedSearches.remove(search);
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM users_saved_searches WHERE id = ?")) {
- statement.setInt(1, search.getId());
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update("DELETE FROM users_saved_searches WHERE id = ?", search.getId());
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
private void loadMessengerCategories() {
- this.messengerCategories = new ArrayList<>();
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM messenger_categories WHERE user_id = ?")) {
- statement.setInt(1, this.id);
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- this.messengerCategories.add(new MessengerCategory(set.getString("name"), set.getInt("user_id"), set.getInt("id")));
- }
- }
- } catch (SQLException e) {
+ try {
+ this.messengerCategories = SqlQueries.query(
+ "SELECT * FROM messenger_categories WHERE user_id = ?",
+ rs -> new MessengerCategory(rs.getString("name"), rs.getInt("user_id"), rs.getInt("id")),
+ this.id);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ this.messengerCategories = new ArrayList<>();
}
}
@@ -232,10 +222,9 @@ public class HabboInfo implements Runnable {
public void deleteMessengerCategory(MessengerCategory category) {
this.messengerCategories.remove(category);
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM messenger_categories WHERE id = ?")) {
- statement.setInt(1, category.getId());
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update("DELETE FROM messenger_categories WHERE id = ?", category.getId());
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
@@ -389,12 +378,10 @@ public class HabboInfo implements Runnable {
public void setPixels(int pixels) {
this.setCurrencyAmount(0, pixels);
- this.run();
}
public void addPixels(int pixels) {
this.addCurrencyAmount(0, pixels);
- this.run();
}
public int getLastOnline() {
@@ -588,25 +575,26 @@ public class HabboInfo implements Runnable {
public void run() {
this.saveCurrencies();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ?, background_id = ?, background_stand_id = ?, background_overlay_id = ? WHERE id = ?")) {
- statement.setString(1, this.motto);
- statement.setString(2, this.online ? "1" : "0");
- statement.setString(3, this.look);
- statement.setString(4, this.gender.name());
- statement.setInt(5, this.credits);
- statement.setInt(7, this.lastOnline);
- statement.setInt(6, Emulator.getIntUnixTimestamp());
- statement.setInt(8, this.homeRoom);
- statement.setString(9, this.ipLogin);
- statement.setInt(10, this.rank != null ? this.rank.getId() : 1);
- statement.setString(11, this.machineID);
- statement.setString(12, this.username);
- statement.setInt(13, this.InfostandBg);
- statement.setInt(14, this.InfostandStand);
- statement.setInt(15, this.InfostandOverlay);
- statement.setInt(16, this.id);
- statement.executeUpdate();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update(
+ "UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ?, background_id = ?, background_stand_id = ?, background_overlay_id = ? WHERE id = ?",
+ this.motto,
+ this.online ? "1" : "0",
+ this.look,
+ this.gender.name(),
+ this.credits,
+ Emulator.getIntUnixTimestamp(),
+ this.lastOnline,
+ this.homeRoom,
+ this.ipLogin,
+ this.rank != null ? this.rank.getId() : 1,
+ this.machineID,
+ this.username,
+ this.InfostandBg,
+ this.InfostandStand,
+ this.InfostandOverlay,
+ this.id);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
index 8fc6aeb6..14fd99bf 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/HabboManager.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.users;
import com.eu.habbo.Emulator;
+import com.eu.habbo.database.SqlQueries;
import com.eu.habbo.habbohotel.modtool.ModToolBan;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.permissions.Rank;
@@ -22,6 +23,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.AbstractMap;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -47,37 +49,27 @@ public class HabboManager {
}
public static HabboInfo getOfflineHabboInfo(int id) {
- HabboInfo info = null;
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE id = ? LIMIT 1")) {
- statement.setInt(1, id);
- try (ResultSet set = statement.executeQuery()) {
- if (set.next()) {
- info = new HabboInfo(set);
- }
- }
- } catch (SQLException e) {
+ try {
+ return SqlQueries.queryOne(
+ "SELECT * FROM users WHERE id = ? LIMIT 1",
+ HabboInfo::new,
+ id).orElse(null);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return null;
}
-
- return info;
}
public static HabboInfo getOfflineHabboInfo(String username) {
- HabboInfo info = null;
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE username = ? LIMIT 1")) {
- statement.setString(1, username);
-
- try (ResultSet set = statement.executeQuery()) {
- if (set.next()) {
- info = new HabboInfo(set);
- }
- }
- } catch (SQLException e) {
+ try {
+ return SqlQueries.queryOne(
+ "SELECT * FROM users WHERE username = ? LIMIT 1",
+ HabboInfo::new,
+ username).orElse(null);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return null;
}
-
- return info;
}
public void addHabbo(Habbo habbo) {
@@ -195,43 +187,32 @@ public class HabboManager {
LOGGER.info("Habbo Manager -> Disposed!");
}
- public ArrayList getCloneAccounts(Habbo habbo, int limit) {
- ArrayList habboInfo = new ArrayList<>();
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users WHERE (ip_register = ? OR ip_current = ?) AND id != ? ORDER BY id DESC LIMIT ?")) {
- statement.setString(1, habbo.getHabboInfo().getIpRegister());
- statement.setString(2, habbo.getHabboInfo().getIpLogin());
- statement.setInt(3, habbo.getHabboInfo().getId());
- statement.setInt(4, limit);
-
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- habboInfo.add(new HabboInfo(set));
- }
- }
- } catch (SQLException e) {
+ public List getCloneAccounts(Habbo habbo, int limit) {
+ try {
+ return SqlQueries.query(
+ "SELECT * FROM users WHERE (ip_register = ? OR ip_current = ?) AND id != ? ORDER BY id DESC LIMIT ?",
+ HabboInfo::new,
+ habbo.getHabboInfo().getIpRegister(),
+ habbo.getHabboInfo().getIpLogin(),
+ habbo.getHabboInfo().getId(),
+ limit);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return new ArrayList<>();
}
-
- return habboInfo;
}
public List> getNameChanges(int userId, int limit) {
- List> nameChanges = new ArrayList<>();
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT timestamp, new_name FROM namechange_log WHERE user_id = ? ORDER by timestamp DESC LIMIT ?")) {
- statement.setInt(1, userId);
- statement.setInt(2, limit);
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- nameChanges.add(new AbstractMap.SimpleEntry<>(set.getInt("timestamp"), set.getString("new_name")));
- }
- }
- } catch (SQLException e) {
+ try {
+ return SqlQueries.query(
+ "SELECT timestamp, new_name FROM namechange_log WHERE user_id = ? ORDER by timestamp DESC LIMIT ?",
+ rs -> new AbstractMap.SimpleEntry<>(rs.getInt("timestamp"), rs.getString("new_name")),
+ userId,
+ limit);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
+ return Collections.emptyList();
}
-
- return nameChanges;
}
@@ -277,11 +258,9 @@ public class HabboManager {
habbo.getClient().sendResponse(new RecyclerLogicComposer());
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_give_rank.new_rank").replace("id", newRank.getName()));
} else {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET `rank` = ? WHERE id = ? LIMIT 1")) {
- statement.setInt(1, rankId);
- statement.setInt(2, userId);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update("UPDATE users SET `rank` = ? WHERE id = ? LIMIT 1", rankId, userId);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
@@ -294,11 +273,9 @@ public class HabboManager {
if (habbo != null) {
habbo.giveCredits(credits);
} else {
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1")) {
- statement.setInt(1, credits);
- statement.setInt(2, userId);
- statement.execute();
- } catch (SQLException e) {
+ try {
+ SqlQueries.update("UPDATE users SET credits = credits + ? WHERE id = ? LIMIT 1", credits, userId);
+ } catch (SqlQueries.DataAccessException e) {
LOGGER.error("Caught SQL exception", e);
}
}
diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java
index 5e1efddd..83716292 100644
--- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java
+++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/subscriptions/SubscriptionHabboClub.java
@@ -14,7 +14,6 @@ import com.eu.habbo.messages.outgoing.catalog.ClubCenterDataComposer;
import com.eu.habbo.messages.outgoing.generic.PickMonthlyClubGiftNotificationComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
import com.eu.habbo.messages.outgoing.users.*;
-import gnu.trove.map.hash.THashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -24,6 +23,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
@@ -215,7 +215,7 @@ public class SubscriptionHabboClub extends Subscription {
}
}
- THashMap queryParams = new THashMap<>();
+ Map queryParams = new HashMap<>();
queryParams.put("@user_id", habbo.getId());
queryParams.put("@timestamp_start", habbo.getHabboStats().lastHCPayday);
queryParams.put("@timestamp_end", HC_PAYDAY_NEXT_DATE);
diff --git a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java
index 42e2c571..f9626bc1 100644
--- a/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java
+++ b/Emulator/src/main/java/com/eu/habbo/messages/outgoing/rooms/RoomRightsListComposer.java
@@ -4,7 +4,6 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
-import gnu.trove.map.hash.THashMap;
import java.util.Map;
@@ -20,7 +19,7 @@ public class RoomRightsListComposer extends MessageComposer {
this.response.init(Outgoing.RoomRightsListComposer);
this.response.appendInt(this.room.getId());
- THashMap rightsMap = this.room.getUsersWithRights();
+ Map rightsMap = this.room.getUsersWithRights();
this.response.appendInt(rightsMap.size());
diff --git a/Emulator/src/main/resources/logback.xml b/Emulator/src/main/resources/logback.xml
index 7c9f1ce7..f4a62d3f 100644
--- a/Emulator/src/main/resources/logback.xml
+++ b/Emulator/src/main/resources/logback.xml
@@ -56,6 +56,8 @@
+
+
diff --git a/Latest_Compiled_Version/Habbo-4.1.0-jar-with-dependencies.jar b/Latest_Compiled_Version/Habbo-4.1.1-jar-with-dependencies.jar
similarity index 82%
rename from Latest_Compiled_Version/Habbo-4.1.0-jar-with-dependencies.jar
rename to Latest_Compiled_Version/Habbo-4.1.1-jar-with-dependencies.jar
index 60f89e8f..9fbfe2f2 100644
Binary files a/Latest_Compiled_Version/Habbo-4.1.0-jar-with-dependencies.jar and b/Latest_Compiled_Version/Habbo-4.1.1-jar-with-dependencies.jar differ
diff --git a/Latest_Compiled_Version/config.ini.example b/Latest_Compiled_Version/config.ini.example
index 1d05c91c..e1eee315 100644
--- a/Latest_Compiled_Version/config.ini.example
+++ b/Latest_Compiled_Version/config.ini.example
@@ -29,6 +29,14 @@ ws.whitelist=localhost
#Header name for real client IP when behind a proxy (e.g., X-Forwarded-For, CF-Connecting-IP). Leave empty if not using a proxy.
ws.ip.header=
+# Databse configuration
+db.pool.connection_timeout_ms = 10000
+db.pool.idle_timeout_ms = 600000
+db.pool.max_lifetime_ms = 1800000
+db.pool.validation_timeout_ms = 5000
+# set db.pool.leak_detection_ms to 0 to disable
+db.pool.leak_detection_ms = 20000 set to 0 to disable
+
enc.enabled=false
enc.e=3
enc.n=86851dd364d5c5cece3c883171cc6ddc5760779b992482bd1e20dd296888df91b33b936a7b93f06d29e8870f703a216257dec7c81de0058fea4cc5116f75e6efc4e9113513e45357dc3fd43d4efab5963ef178b78bd61e81a14c603b24c8bcce0a12230b320045498edc29282ff0603bc7b7dae8fc1b05b52b2f301a9dc783b7