diff --git a/README.md b/README.md
index 34a13cda..cdb52090 100644
--- a/README.md
+++ b/README.md
@@ -11,8 +11,8 @@ TheGeneral's own words were "dont like it then dont use it". We did not like wha
Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
## Versions ##
-![image](https://img.shields.io/badge/VERSION-2.1.1-success.svg?style=for-the-badge&logo=appveyor)
-![image](https://img.shields.io/badge/STATUS-STABLE-blue.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/VERSION-2.2.0-success.svg?style=for-the-badge&logo=appveyor)
+![image](https://img.shields.io/badge/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor)
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases
diff --git a/pom.xml b/pom.xml
index 51d02e18..33253bbb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.eu.habbo
Habbo
- 2.1.0
+ 2.2.0
UTF-8
diff --git a/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql
new file mode 100644
index 00000000..e959f808
--- /dev/null
+++ b/sqlupdates/2_1_1_TO_2_2_0-RC-1.sql
@@ -0,0 +1,56 @@
+ALTER TABLE `permissions`
+ADD COLUMN `auto_credits_amount` INT DEFAULT '0',
+ADD COLUMN `auto_pixels_amount` INT DEFAULT '0',
+ADD COLUMN `auto_gotw_amount` INT DEFAULT '0',
+ADD COLUMN `auto_points_amount` INT DEFAULT '0';
+
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.enabled', '0');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.interval', '600');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.ignore.idled', '1');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.ignore.hotelview', '1');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.type', '4');
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.auto.gotwpoints.name', 'shell');
+
+CREATE TABLE `items_highscore_data` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `item_id` int(11) NOT NULL,
+ `user_ids` varchar(500) NOT NULL,
+ `score` int(11) NOT NULL,
+ `is_win` tinyint(1) NULL DEFAULT 0,
+ `timestamp` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+DROP TABLE IF EXISTS `calendar_rewards`;
+CREATE TABLE `calendar_rewards` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
+ `credits` int(11) NOT NULL DEFAULT 0,
+ `points` int(11) NOT NULL DEFAULT 0,
+ `points_type` int(3) NOT NULL DEFAULT 0,
+ `badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
+ `item_id` int(11) NOT NULL DEFAULT 0,
+ PRIMARY KEY (`id`) USING BTREE
+) ENGINE = MyISAM AUTO_INCREMENT = 3 CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
+
+SET FOREIGN_KEY_CHECKS = 1;
+
+CREATE TABLE `voucher_history` (
+ `id` int(11) NOT NULL AUTO_INCREMENT,
+ `voucher_id` int(11) NOT NULL,
+ `user_id` int(11) NOT NULL,
+ `timestamp` int(11) NOT NULL,
+ PRIMARY KEY (`id`)
+);
+
+ALTER TABLE `vouchers`
+ADD COLUMN `amount` int(11) NOT NULL DEFAULT 1,
+ADD COLUMN `limit` int(11) NOT NULL DEFAULT -1;
+
+ALTER TABLE `users_pets`
+ADD COLUMN `mp_is_dead` tinyint(1) NOT NULL DEFAULT 0;
+
+ALTER TABLE `items` CHARACTER SET = utf8, COLLATE = utf8_general_ci;
+
+ALTER TABLE `items_base`
+ADD COLUMN `clothing_on_walk` varchar(255) NOT NULL DEFAULT '';
diff --git a/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql b/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql
new file mode 100644
index 00000000..14a12715
--- /dev/null
+++ b/sqlupdates/2_2_0-RC-1_TO_2_2_0-RC-2.sql
@@ -0,0 +1 @@
+INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_badge.unknown_user', 'Failed to find the given user.');
diff --git a/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql
new file mode 100644
index 00000000..90e2028c
--- /dev/null
+++ b/sqlupdates/2_2_0-RC-2_TO_2_2_0-RC-3.sql
@@ -0,0 +1,2 @@
+INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('hotel.room.furni.max', '2500');
+UPDATE items_base SET interaction_type = 'vote_counter' WHERE item_name = 'vote_count_add';
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java
index bdebafe6..24b0d0b8 100644
--- a/src/main/java/com/eu/habbo/Emulator.java
+++ b/src/main/java/com/eu/habbo/Emulator.java
@@ -18,10 +18,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
import com.eu.habbo.threading.ThreadPooling;
import com.eu.habbo.util.imager.badges.BadgeImager;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
+import java.io.*;
import java.security.MessageDigest;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
@@ -34,10 +31,10 @@ public final class Emulator {
public final static int MAJOR = 2;
- public final static int MINOR = 1;
+ public final static int MINOR = 2;
- public final static int BUILD = 1;
+ public final static int BUILD = 0;
public final static String PREVIEW = "Stable";
@@ -51,7 +48,7 @@ public final class Emulator {
" / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
- " /____/ \n";
+ " /____/ \n" ;
public static String build = "";
public static boolean isReady = false;
public static boolean isShuttingDown = false;
@@ -117,8 +114,7 @@ public final class Emulator {
Emulator.rconServer.initializePipeline();
Emulator.rconServer.connect();
Emulator.badgeImager = new BadgeImager();
- Emulator.getLogging().logStart("Habbo Hotel Emulator has succesfully loaded.");
- Emulator.getLogging().logStart("You're running: " + Emulator.version);
+ Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version);
Emulator.getLogging().logStart("System launched in: " + (System.nanoTime() - startTime) / 1e6 + "ms. Using: " + (Runtime.getRuntime().availableProcessors() * 2) + " threads!");
Emulator.getLogging().logStart("Memory: " + (runtime.totalMemory() - runtime.freeMemory()) / (1024 * 1024) + "/" + (runtime.freeMemory()) / (1024 * 1024) + "MB");
@@ -137,20 +133,16 @@ public final class Emulator {
}
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- Emulator.getLogging().logStart("Thankyou for downloading Arcturus Morningstar! This is a stable 2.1.0 build, it should be more than stable for daily use on hotels, if you find any bugs please place them on our git repository.");
- Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
- Emulator.getLogging().logStart("https://discord.gg/syuqgN");
- Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!");
- System.out.println("Waiting for commands: ");
- }
- }, 3500);
+ Emulator.getThreading().run(() -> {
+ Emulator.getLogging().logStart("Please note, Arcturus Emulator is a project by TheGeneral, we take no credit for the original work, and only the work we have continued. If you'd like to support the project, join our discord at: ");
+ Emulator.getLogging().logStart("https://discord.gg/syuqgN");
+ Emulator.getLogging().logStart("Please report bugs on our git at Krews.org.");
+ System.out.println("Waiting for commands: ");
+ }, 1500);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- while (!isShuttingDown && isReady && reader.ready()) {
+ while (!isShuttingDown && isReady) {
try {
String line = reader.readLine();
@@ -160,7 +152,9 @@ public final class Emulator {
}
System.out.println("Waiting for command: ");
} catch (Exception e) {
- Emulator.getLogging().logErrorLine(e);
+ if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
+ Emulator.getLogging().logErrorLine(e);
+ }
}
}
} catch (Exception e) {
@@ -181,12 +175,9 @@ public final class Emulator {
FileInputStream fis = new FileInputStream(filepath);
byte[] dataBytes = new byte[1024];
int nread = 0;
-
while ((nread = fis.read(dataBytes)) != -1)
md.update(dataBytes, 0, nread);
-
byte[] mdbytes = md.digest();
-
for (int i = 0; i < mdbytes.length; i++)
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
} catch (Exception e) {
diff --git a/src/main/java/com/eu/habbo/core/CleanerThread.java b/src/main/java/com/eu/habbo/core/CleanerThread.java
index 9c174fca..764770d0 100644
--- a/src/main/java/com/eu/habbo/core/CleanerThread.java
+++ b/src/main/java/com/eu/habbo/core/CleanerThread.java
@@ -147,8 +147,8 @@ public class CleanerThread implements Runnable {
statement.execute("DELETE users_favorite_rooms FROM users_favorite_rooms LEFT JOIN rooms ON room_id = rooms.id WHERE rooms.id IS NULL");
}
- try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp < ? AND activation_timestamp != 0")) {
- statement.setInt(1, Emulator.getIntUnixTimestamp() - 86400);
+ try (PreparedStatement statement = connection.prepareStatement("UPDATE users_effects SET total = total - 1 WHERE activation_timestamp + duration < ? AND activation_timestamp > 0 AND duration > 0")) {
+ statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.execute();
}
diff --git a/src/main/java/com/eu/habbo/core/CreditsScheduler.java b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
index 4c2a44a1..ce136ede 100644
--- a/src/main/java/com/eu/habbo/core/CreditsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/CreditsScheduler.java
@@ -8,14 +8,10 @@ import java.util.Map;
public class CreditsScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW;
-
-
public static boolean IGNORE_IDLED;
-
- public static int CREDITS;
-
public CreditsScheduler() {
+
super(Emulator.getConfig().getInt("hotel.auto.credits.interval"));
this.reloadConfig();
}
@@ -24,7 +20,6 @@ public class CreditsScheduler extends Scheduler {
if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled");
- CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount");
if (this.disposed) {
this.disposed = false;
this.run();
@@ -50,7 +45,7 @@ public class CreditsScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue;
- habbo.giveCredits(CREDITS);
+ habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount());
}
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
diff --git a/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
new file mode 100644
index 00000000..4a85969e
--- /dev/null
+++ b/src/main/java/com/eu/habbo/core/GotwPointsScheduler.java
@@ -0,0 +1,78 @@
+package com.eu.habbo.core;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.users.Habbo;
+
+import java.util.Map;
+
+public class GotwPointsScheduler extends Scheduler {
+
+ public static boolean IGNORE_HOTEL_VIEW;
+ public static boolean IGNORE_IDLED;
+ public static String GOTW_POINTS_NAME;
+
+ public GotwPointsScheduler() { //TODO MOVE TO A PLUGIN. IS NOT PART OF OFFICIAL HABBO.
+
+ super(Emulator.getConfig().getInt("hotel.auto.gotwpoints.interval"));
+ this.reloadConfig();
+ }
+
+ public void reloadConfig() {
+ if (Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.enabled")) {
+ IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.hotelview");
+ IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.gotwpoints.ignore.idled");
+ GOTW_POINTS_NAME = Emulator.getConfig().getValue("hotel.auto.gotwpoints.name");
+
+ if (this.disposed) {
+ this.disposed = false;
+ this.run();
+ }
+ } else {
+ this.disposed = true;
+ }
+ }
+
+ @Override
+ public void run() {
+ super.run();
+
+ Habbo habbo;
+ for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
+ habbo = map.getValue();
+
+ try {
+ if (habbo != null) {
+ if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
+ continue;
+
+ if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
+ continue;
+
+ int type;
+ boolean found = false;
+ for (String s : Emulator.getConfig().getValue("seasonal.currency.names").split(";")) {
+ if (s.equalsIgnoreCase(GOTW_POINTS_NAME) || (GOTW_POINTS_NAME.startsWith(s) && Math.abs(s.length() - GOTW_POINTS_NAME.length()) < 3)) {
+ found = true;
+ break;
+ }
+ }
+ type = Emulator.getConfig().getInt("seasonal.currency." + GOTW_POINTS_NAME, -1);
+ if (found || type != -1) {
+
+ habbo.givePoints(type, habbo.getHabboInfo().getRank().getGotwTimerAmount());
+ }
+ }
+ } catch (Exception e) {
+ Emulator.getLogging().logErrorLine(e);
+ }
+ }
+ }
+
+ public boolean isDisposed() {
+ return this.disposed;
+ }
+
+ public void setDisposed(boolean disposed) {
+ this.disposed = disposed;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/core/PixelScheduler.java b/src/main/java/com/eu/habbo/core/PixelScheduler.java
index 285df17c..13a0cf3d 100644
--- a/src/main/java/com/eu/habbo/core/PixelScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PixelScheduler.java
@@ -8,47 +8,17 @@ import java.util.Map;
public class PixelScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW;
-
-
public static boolean IGNORE_IDLED;
-
- private static int PIXELS;
-
public PixelScheduler() {
super(Emulator.getConfig().getInt("hotel.auto.pixels.interval"));
this.reloadConfig();
}
- public static boolean isIgnoreHotelView() {
- return IGNORE_HOTEL_VIEW;
- }
-
- public static void setIgnoreHotelView(boolean ignoreHotelView) {
- IGNORE_HOTEL_VIEW = ignoreHotelView;
- }
-
- public static boolean isIgnoreIdled() {
- return IGNORE_IDLED;
- }
-
- public static void setIgnoreIdled(boolean ignoreIdled) {
- IGNORE_IDLED = ignoreIdled;
- }
-
- public static int getPIXELS() {
- return PIXELS;
- }
-
- public static void setPIXELS(int PIXELS) {
- PixelScheduler.PIXELS = PIXELS;
- }
-
public void reloadConfig() {
if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled");
- PIXELS = Emulator.getConfig().getInt("hotel.auto.pixels.amount");
if (this.disposed) {
this.disposed = false;
this.run();
@@ -65,7 +35,6 @@ public class PixelScheduler extends Scheduler {
Habbo habbo;
for (Map.Entry map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
habbo = map.getValue();
-
try {
if (habbo != null) {
if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
@@ -74,7 +43,7 @@ public class PixelScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue;
- habbo.givePixels(PIXELS);
+ habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount());
}
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
diff --git a/src/main/java/com/eu/habbo/core/PointsScheduler.java b/src/main/java/com/eu/habbo/core/PointsScheduler.java
index 529d004d..f5c8042d 100644
--- a/src/main/java/com/eu/habbo/core/PointsScheduler.java
+++ b/src/main/java/com/eu/habbo/core/PointsScheduler.java
@@ -8,47 +8,18 @@ import java.util.Map;
public class PointsScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW;
-
-
public static boolean IGNORE_IDLED;
-
- private static int POINTS;
-
public PointsScheduler() {
+
super(Emulator.getConfig().getInt("hotel.auto.points.interval"));
this.reloadConfig();
}
- public static boolean isIgnoreHotelView() {
- return IGNORE_HOTEL_VIEW;
- }
-
- public static void setIgnoreHotelView(boolean ignoreHotelView) {
- IGNORE_HOTEL_VIEW = ignoreHotelView;
- }
-
- public static boolean isIgnoreIdled() {
- return IGNORE_IDLED;
- }
-
- public static void setIgnoreIdled(boolean ignoreIdled) {
- IGNORE_IDLED = ignoreIdled;
- }
-
- public static int getPOINTS() {
- return POINTS;
- }
-
- public static void setPOINTS(int POINTS) {
- PointsScheduler.POINTS = POINTS;
- }
-
public void reloadConfig() {
if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled");
- POINTS = Emulator.getConfig().getInt("hotel.auto.points.amount");
if (this.disposed) {
this.disposed = false;
this.run();
@@ -74,7 +45,8 @@ public class PointsScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue;
- habbo.givePoints(POINTS);
+ //habbo.givePoints(POINTS);
+ habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount());
}
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
diff --git a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
index 99302c6a..02704bd3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
+++ b/src/main/java/com/eu/habbo/habbohotel/GameEnvironment.java
@@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.CreditsScheduler;
+import com.eu.habbo.core.GotwPointsScheduler;
import com.eu.habbo.core.PixelScheduler;
import com.eu.habbo.core.PointsScheduler;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
@@ -26,6 +27,7 @@ public class GameEnvironment {
public CreditsScheduler creditsScheduler;
public PixelScheduler pixelScheduler;
public PointsScheduler pointsScheduler;
+ public GotwPointsScheduler gotwPointsScheduler;
private HabboManager habboManager;
private NavigatorManager navigatorManager;
private GuildManager guildManager;
@@ -76,6 +78,9 @@ public class GameEnvironment {
Emulator.getThreading().run(this.pixelScheduler);
this.pointsScheduler = new PointsScheduler();
Emulator.getThreading().run(this.pointsScheduler);
+ this.gotwPointsScheduler = new GotwPointsScheduler();
+ Emulator.getThreading().run(this.gotwPointsScheduler);
+
Emulator.getLogging().logStart("GameEnvironment -> Loaded!");
}
@@ -84,6 +89,7 @@ public class GameEnvironment {
this.pointsScheduler.setDisposed(true);
this.pixelScheduler.setDisposed(true);
this.creditsScheduler.setDisposed(true);
+ this.gotwPointsScheduler.setDisposed(true);
this.craftingManager.dispose();
this.habboManager.dispose();
this.commandHandler.dispose();
@@ -171,7 +177,9 @@ public class GameEnvironment {
return this.pixelScheduler;
}
- public PointsScheduler getPointsScheduler() {
- return this.pointsScheduler;
+ public PointsScheduler getPointsScheduler() { return this.pointsScheduler;
+ }
+
+ public GotwPointsScheduler getGotwPointsScheduler() { return this.gotwPointsScheduler;
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java
index 6940f759..f2b135b5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CalendarRewardObject.java
@@ -1,30 +1,32 @@
package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
+import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
public class CalendarRewardObject {
private final int id;
- private final String name;
private final String customImage;
private final int credits;
private final int points;
private final int pointsType;
private final String badge;
- private final int catalogItemId;
+ private final int itemId;
public CalendarRewardObject(ResultSet set) throws SQLException {
this.id = set.getInt("id");
- this.name = set.getString("name");
this.customImage = set.getString("custom_image");
this.credits = set.getInt("credits");
this.points = set.getInt("points");
this.pointsType = set.getInt("points_type");
this.badge = set.getString("badge");
- this.catalogItemId = set.getInt("catalog_item_id");
+ this.itemId = set.getInt("item_id");
}
public void give(Habbo habbo) {
@@ -40,11 +42,19 @@ public class CalendarRewardObject {
habbo.addBadge(this.badge);
}
- if (this.catalogItemId > 0) {
- CatalogItem item = this.getCatalogItem();
+ if (this.itemId > 0) {
+ Item item = getItem();
if (item != null) {
- Emulator.getGameEnvironment().getCatalogManager().purchaseItem(null, item, habbo, 1, "", true);
+ HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(
+ habbo.getHabboInfo().getId(),
+ item,
+ 0,
+ 0,
+ "");
+ habbo.getInventory().getItemsComponent().addItem(habboItem);
+ habbo.getClient().sendResponse(new AddHabboItemComposer(habboItem));
+ habbo.getClient().sendResponse(new InventoryRefreshComposer());
}
}
}
@@ -53,10 +63,6 @@ public class CalendarRewardObject {
return this.id;
}
- public String getName() {
- return this.name;
- }
-
public String getCustomImage() {
return this.customImage;
}
@@ -77,7 +83,7 @@ public class CalendarRewardObject {
return this.badge;
}
- public CatalogItem getCatalogItem() {
- return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.catalogItemId);
+ public Item getItem() {
+ return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
index 99296bb2..68db8eea 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogManager.java
@@ -24,6 +24,7 @@ import com.eu.habbo.messages.outgoing.inventory.AddBotComposer;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.AddPetComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
+import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
import com.eu.habbo.messages.outgoing.users.UserPointsComposer;
@@ -283,22 +284,19 @@ public class CatalogManager {
Emulator.getLogging().logSQLException(e);
}
- pages.forEachValue(new TObjectProcedure() {
- @Override
- public boolean execute(CatalogPage object) {
- CatalogPage page = pages.get(object.parentId);
+ pages.forEachValue((object) -> {
+ CatalogPage page = pages.get(object.parentId);
- if (page != null) {
- if (page.id != object.id) {
- page.addChildPage(object);
- }
- } else {
- if (object.parentId != -2) {
- Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")");
- }
+ if (page != null) {
+ if (page.id != object.id) {
+ page.addChildPage(object);
+ }
+ } else {
+ if (object.parentId != -2) {
+ Emulator.getLogging().logStart("Parent Page not found for " + object.getPageName() + " (ID: " + object.id + ", parent_id: " + object.parentId + ")");
}
- return true;
}
+ return true;
});
this.catalogPages.putAll(pages);
@@ -536,35 +534,52 @@ public class CatalogManager {
public void redeemVoucher(GameClient client, String voucherCode) {
Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode);
- if (voucher != null) {
- if (Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) {
- client.getHabbo().getHabboInfo().addCredits(voucher.credits);
+ if (voucher == null) {
+ client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE));
+ return;
+ }
- if (voucher.points > 0) {
- client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points);
- client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType));
- }
+ Habbo habbo = client.getHabbo();
+ if (habbo == null) return;
- if (voucher.credits > 0) {
- client.getHabbo().getHabboInfo().addCredits(voucher.credits);
- client.sendResponse(new UserCreditsComposer(client.getHabbo()));
- }
-
- if (voucher.catalogItemId > 0) {
- CatalogItem item = this.getCatalogItem(voucher.catalogItemId);
-
- if (item != null) {
- this.purchaseItem(null, item, client.getHabbo(), 1, "", true);
- }
- }
-
- client.sendResponse(new RedeemVoucherOKComposer());
-
- return;
+ if (voucher.isExhausted()) {
+ if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) {
+ client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR));
}
}
- client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE));
+ if (voucher.hasUserExhausted(habbo.getHabboInfo().getId())) {
+ client.sendResponse(new ModToolIssueHandledComposer("You have exceeded the limit for redeeming this voucher."));
+ return;
+ }
+
+ voucher.addHistoryEntry(habbo.getHabboInfo().getId());
+
+ if (voucher.isExhausted()) {
+ if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) {
+ client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR));
+ }
+ }
+
+ if (voucher.points > 0) {
+ client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points);
+ client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType));
+ }
+
+ if (voucher.credits > 0) {
+ client.getHabbo().getHabboInfo().addCredits(voucher.credits);
+ client.sendResponse(new UserCreditsComposer(client.getHabbo()));
+ }
+
+ if (voucher.catalogItemId > 0) {
+ CatalogItem item = this.getCatalogItem(voucher.catalogItemId);
+
+ if (item != null) {
+ this.purchaseItem(null, item, client.getHabbo(), 1, "", true);
+ }
+ }
+
+ client.sendResponse(new RedeemVoucherOKComposer());
}
@@ -1122,15 +1137,15 @@ public class CatalogManager {
return offers;
}
- public void claimCalendarReward(Habbo habbo, int day) {
+ public void claimCalendarReward(Habbo habbo, int day, boolean force) {
if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) {
- habbo.getHabboStats().calendarRewardsClaimed.add(day);
- CalendarRewardObject object = this.calendarRewards.get(day);
-
- if (object != null) {
- object.give(habbo);
- habbo.getClient().sendResponse(new InventoryRefreshComposer());
+ CalendarRewardObject object = this.calendarRewards.get((day+1));
+ int actualDay = (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400);
+ int diff = (actualDay - day);
+ if (((diff <= 2 && diff >= 0) || force) && object != null) {
+ habbo.getHabboStats().calendarRewardsClaimed.add(day);
habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object));
+ object.give(habbo);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) {
statement.setInt(1, habbo.getHabboInfo().getId());
@@ -1141,8 +1156,6 @@ public class CatalogManager {
Emulator.getLogging().logSQLException(e);
}
}
-
-
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
index 643a3d1d..7291e193 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/Voucher.java
@@ -1,27 +1,24 @@
package com.eu.habbo.habbohotel.catalog;
+import com.eu.habbo.Emulator;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
public class Voucher {
-
public final int id;
-
-
public final String code;
-
-
public final int credits;
-
-
public final int points;
-
-
public final int pointsType;
-
-
public final int catalogItemId;
-
+ public final int amount;
+ public final int limit;
+ private final List history = new ArrayList<>();
public Voucher(ResultSet set) throws SQLException {
this.id = set.getInt("id");
@@ -30,5 +27,44 @@ public class Voucher {
this.points = set.getInt("points");
this.pointsType = set.getInt("points_type");
this.catalogItemId = set.getInt("catalog_item_id");
+ this.amount = set.getInt("amount");
+ this.limit = set.getInt("limit");
+
+ this.loadHistory();
+ }
+
+ private void loadHistory() {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history")) {
+ try (ResultSet set = statement.executeQuery()) {
+ while (set.next()) {
+ this.history.add(new VoucherHistoryEntry(set));
+ }
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public boolean hasUserExhausted(int userId) {
+ return this.limit > 0 && Math.toIntExact(this.history.stream().filter(h -> h.getUserId() == userId).count()) >= this.limit;
+ }
+
+ public boolean isExhausted() {
+ return this.amount > 0 && this.history.size() >= this.amount;
+ }
+
+ public void addHistoryEntry(int userId) {
+ int timestamp = Emulator.getIntUnixTimestamp();
+ this.history.add(new VoucherHistoryEntry(this.id, userId, timestamp));
+
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO voucher_history (`voucher_id`, `user_id`, `timestamp`) VALUES (?, ?, ?)")) {
+ statement.setInt(1, this.id);
+ statement.setInt(2, userId);
+ statement.setInt(3, timestamp);
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java
new file mode 100644
index 00000000..300c7c8f
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/VoucherHistoryEntry.java
@@ -0,0 +1,34 @@
+package com.eu.habbo.habbohotel.catalog;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class VoucherHistoryEntry {
+ private final int voucherId;
+ private final int userId;
+ private final int timestamp;
+
+ public VoucherHistoryEntry(ResultSet set) throws SQLException {
+ this.voucherId = set.getInt("voucher_id");
+ this.userId = set.getInt("user_id");
+ this.timestamp = set.getInt("timestamp");
+ }
+
+ public VoucherHistoryEntry(int voucherId, int userId, int timestamp) {
+ this.voucherId = voucherId;
+ this.userId = userId;
+ this.timestamp = timestamp;
+ }
+
+ public int getVoucherId() {
+ return voucherId;
+ }
+
+ public int getUserId() {
+ return userId;
+ }
+
+ public int getTimestamp() {
+ return timestamp;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java
index d219baf4..d73e77a6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/CatalogRootLayout.java
@@ -9,6 +9,17 @@ import java.sql.SQLException;
public class CatalogRootLayout extends CatalogPage {
public CatalogRootLayout() {
super();
+
+ this.id = -1;
+ this.parentId = -2;
+ this.rank = 0;
+ this.caption = "root";
+ this.pageName = "root";
+ this.iconColor = 0;
+ this.iconImage = 0;
+ this.orderNum = -10;
+ this.visible = true;
+ this.enabled = true;
}
public CatalogRootLayout(ResultSet set) throws SQLException {
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
index 7e5e1208..eac670e7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
@@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.users.HabboManager;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -38,11 +40,18 @@ public class BadgeCommand extends Command {
return true;
} else {
+ HabboInfo habboInfo = HabboManager.getOfflineHabboInfo(params[1]);
+
+ if (habboInfo == null) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.unknown_user"), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
boolean found;
- try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` INNER JOIN `users` ON `users`.`id` = `user_id` WHERE `users`.`username` = ? AND `badge_code` = ? LIMIT 1")) {
- statement.setString(1, params[1]);
+ try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` WHERE `user_id` = ? AND `badge_code` = ? LIMIT 1")) {
+ statement.setInt(1, habboInfo.getId());
statement.setString(2, params[2]);
try (ResultSet set = statement.executeQuery()) {
found = set.next();
@@ -53,8 +62,8 @@ public class BadgeCommand extends Command {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT);
return true;
} else {
- try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, (SELECT `id` FROM `users` WHERE `username` = ? LIMIT 1), 0, ?)")) {
- statement.setString(1, params[1]);
+ try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, ?, 0, ?)")) {
+ statement.setInt(1, habboInfo.getId());
statement.setString(2, params[2]);
statement.execute();
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java
index de2768e1..1ccd20d0 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/ReloadRoomCommand.java
@@ -17,18 +17,15 @@ public class ReloadRoomCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
- if (room != null) {
- Collection habbos = new ArrayList<>(room.getHabbos());
- Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
- room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
- ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
- for (Habbo habbo : habbos) {
- habbo.getClient().sendResponse(message);
- }
+ Emulator.getThreading().run(() -> {
+ Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
+ if (room != null) {
+ Collection habbos = new ArrayList<>(room.getHabbos());
+ Emulator.getGameEnvironment().getRoomManager().unloadRoom(room);
+ room = Emulator.getGameEnvironment().getRoomManager().loadRoom(room.getId());
+ ServerMessage message = new ForwardToRoomComposer(room.getId()).compose();
+ for (Habbo habbo : habbos) {
+ habbo.getClient().sendResponse(message);
}
}
}, 100);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java
index 9e88bd8b..376f8b94 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/UnmuteCommand.java
@@ -23,12 +23,12 @@ public class UnmuteCommand extends Command {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
return true;
} else {
- if (!habbo.getHabboStats().allowTalk() || habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) {
+ if (!habbo.getHabboStats().allowTalk() || (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo))) {
if (!habbo.getHabboStats().allowTalk()) {
habbo.unMute();
}
- if (habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) {
+ if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) {
habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/Game.java b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
index c52d5115..359792d8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/Game.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/Game.java
@@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreDataEntry;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
-import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.games.GameHabboJoinEvent;
import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent;
@@ -21,6 +21,7 @@ import com.eu.habbo.threading.runnables.SaveScoreForTeam;
import gnu.trove.map.hash.THashMap;
import java.util.Map;
+import java.util.stream.Collectors;
public abstract class Game implements Runnable {
@@ -164,16 +165,29 @@ public abstract class Game implements Runnable {
}
}
+ if (winningTeam.getMembers().size() > 0) {
+ for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), winningTeam.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), winningTeam.getTotalScore(), true, Emulator.getIntUnixTimestamp()));
+ }
+ }
+
for (GameTeam team : this.teams.values()) {
if (team == winningTeam) continue;
- for (GamePlayer player : winningTeam.getMembers()) {
+ for (GamePlayer player : team.getMembers()) {
WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
}
+
+ if (team.getMembers().size() > 0) {
+ for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ Emulator.getGameEnvironment().getItemManager().getHighscoreManager().addHighscoreData(new WiredHighscoreDataEntry(item.getId(), team.getMembers().stream().map(m -> m.getHabbo().getHabboInfo().getId()).collect(Collectors.toList()), team.getTotalScore(), false, Emulator.getIntUnixTimestamp()));
+ }
+ }
}
}
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
+ ((InteractionWiredHighscore) item).reloadData();
this.room.updateItem(item);
}
}
@@ -213,6 +227,14 @@ public abstract class Game implements Runnable {
}
}
+ public void dispose() {
+ for (GameTeam team : this.teams.values()) {
+ team.clearMembers();
+ }
+ this.teams.clear();
+
+ this.stop();
+ }
private void saveScores() {
if (this.room == null)
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
index 8aabcf90..edc62fb4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GamePlayer.java
@@ -27,11 +27,9 @@ public class GamePlayer {
public synchronized void addScore(int amount) {
- if (habbo.getHabboInfo().getGamePlayer() != null || this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
- if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
- this.score += amount;
- WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
- }
+ if (habbo.getHabboInfo().getGamePlayer() != null && this.habbo.getHabboInfo().getCurrentGame() != null && this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo) != null) {
+ this.score += amount;
+ WiredHandler.handle(WiredTriggerType.SCORE_ACHIEVED, this.habbo.getRoomUnit(), this.habbo.getHabboInfo().getCurrentRoom(), new Object[]{this.habbo.getHabboInfo().getCurrentRoom().getGame(this.habbo.getHabboInfo().getCurrentGame()).getTeamForHabbo(this.habbo).getTotalScore(), amount});
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
index 38748c8e..5a5ba98b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/GameTeam.java
@@ -1,6 +1,9 @@
package com.eu.habbo.habbohotel.games;
+import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.plugin.Event;
+import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent;
import gnu.trove.set.hash.THashSet;
public class GameTeam {
@@ -65,6 +68,26 @@ public class GameTeam {
}
}
+ public void clearMembers() {
+ for (GamePlayer player : this.members) {
+ if (player == null || player.getHabbo() == null) continue;
+
+ player.getHabbo().getHabboInfo().getGamePlayer().reset();
+ player.getHabbo().getHabboInfo().setCurrentGame(null);
+ player.getHabbo().getHabboInfo().setGamePlayer(null);
+ }
+
+ this.members.clear();
+ }
+
+ public void resetScores() {
+ for (GamePlayer player : this.members) {
+ if (player == null) continue;
+
+ player.reset();
+ }
+ }
+
public THashSet getMembers() {
return this.members;
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
index 133cf431..cb3bd3c8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/freeze/FreezeGameTeam.java
@@ -14,6 +14,8 @@ public class FreezeGameTeam extends GameTeam {
@Override
public void removeMember(GamePlayer gamePlayer) {
+ if (gamePlayer == null || gamePlayer.getHabbo() == null || gamePlayer.getHabbo().getHabboInfo().getCurrentRoom() == null) return;
+
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
index ff5a8d52..f256cce5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/tag/TagGame.java
@@ -140,14 +140,16 @@ public abstract class TagGame extends Game {
TObjectHashIterator iterator = poles.iterator();
if ((iterator.hasNext())) {
HabboItem item = iterator.next();
- habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1);
+ habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1);
+ this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1));
this.taggers.put(habbo, (InteractionTagPole) item);
return true;
}
}
} else {
if (this.taggers.isEmpty()) {
- habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1);
+ habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getEffect(habbo), -1);
+ this.room.scheduledTasks.add(() -> habbo.getHabboInfo().getCurrentRoom().giveEffect(habbo, this.getTaggedEffect(habbo), -1));
this.taggers.put(habbo, null);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
index 24511b32..80fe874d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
+++ b/src/main/java/com/eu/habbo/habbohotel/games/wired/WiredGame.java
@@ -1,26 +1,29 @@
package com.eu.habbo.habbohotel.games.wired;
-import com.eu.habbo.habbohotel.games.Game;
-import com.eu.habbo.habbohotel.games.GamePlayer;
-import com.eu.habbo.habbohotel.games.GameTeam;
-import com.eu.habbo.habbohotel.games.GameTeamColors;
+import com.eu.habbo.habbohotel.games.*;
import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
public class WiredGame extends Game {
+ public GameState state = GameState.RUNNING;
+
public WiredGame(Room room) {
super(GameTeam.class, GamePlayer.class, room, false);
}
@Override
public void initialise() {
+ this.state = GameState.RUNNING;
+ for (GameTeam team : this.teams.values()) {
+ team.resetScores();
+ }
}
@Override
public void run() {
-
+ this.state = GameState.RUNNING;
}
@Override
@@ -34,4 +37,14 @@ public class WiredGame extends Game {
super.removeHabbo(habbo);
this.room.giveEffect(habbo, 0, -1);
}
+
+ @Override
+ public void stop() {
+ this.state = GameState.RUNNING;
+ }
+
+ @Override
+ public GameState getState() {
+ return GameState.RUNNING;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
index f3dbafe7..87e1caf6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/CrackableReward.java
@@ -43,6 +43,8 @@ public class CrackableReward {
if (prize.contains(":") && prize.split(":").length == 2) {
itemId = Integer.valueOf(prize.split(":")[0]);
chance = Integer.valueOf(prize.split(":")[1]);
+ } else if (prize.contains(":")) {
+ Emulator.getLogging().logErrorLine("Invalid configuration of crackable prizes (item id: " + this.itemId + "). '" + prize + "' format should be itemId:chance.");
} else {
itemId = Integer.valueOf(prize.replace(":", ""));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/Item.java b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
index 8584e582..caf8932a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/Item.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/Item.java
@@ -33,6 +33,7 @@ public class Item {
private TIntArrayList vendingItems;
private double[] multiHeights;
private String customParams;
+ private String clothingOnWalk;
private ItemInteraction interactionType;
@@ -93,6 +94,8 @@ public class Item {
this.effectM = set.getShort("effect_id_male");
this.effectF = set.getShort("effect_id_female");
this.customParams = set.getString("customparams");
+ this.clothingOnWalk = set.getString("clothing_on_walk");
+
if (!set.getString("vending_ids").isEmpty()) {
this.vendingItems = new TIntArrayList();
String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(",");
@@ -215,4 +218,6 @@ public class Item {
public String getCustomParams() {
return customParams;
}
+
+ public String getClothingOnWalk() { return clothingOnWalk; }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
index b475fb1e..a2d7f55c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java
@@ -38,11 +38,15 @@ import com.eu.habbo.habbohotel.items.interactions.games.tag.bunnyrun.Interaction
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole;
import com.eu.habbo.habbohotel.items.interactions.games.tag.rollerskate.InteractionRollerskateField;
+import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemHead;
+import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemLegs;
+import com.eu.habbo.habbohotel.items.interactions.totems.InteractionTotemPlanet;
import com.eu.habbo.habbohotel.items.interactions.wired.conditions.*;
import com.eu.habbo.habbohotel.items.interactions.wired.effects.*;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraUnseen;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@@ -69,6 +73,7 @@ public class ItemManager {
private final THashSet interactionsList;
private final THashMap soundTracks;
private final YoutubeManager youtubeManager;
+ private final WiredHighscoreManager highscoreManager;
private final TreeMap newuserGifts;
public ItemManager() {
@@ -77,6 +82,7 @@ public class ItemManager {
this.interactionsList = new THashSet<>();
this.soundTracks = new THashMap<>();
this.youtubeManager = new YoutubeManager();
+ this.highscoreManager = new WiredHighscoreManager();
this.newuserGifts = new TreeMap<>();
}
@@ -90,6 +96,7 @@ public class ItemManager {
this.loadCrackable();
this.loadSoundTracks();
this.youtubeManager.load();
+ this.highscoreManager.load();
this.loadNewUserGifts();
Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
@@ -351,6 +358,12 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("snowstorm_tree", null));
this.interactionsList.add(new ItemInteraction("snowstorm_machine", null));
this.interactionsList.add(new ItemInteraction("snowstorm_pile", null));
+
+ this.interactionsList.add(new ItemInteraction("vote_counter", InteractionVoteCounter.class));
+
+ this.interactionsList.add(new ItemInteraction("totem_leg", InteractionTotemLegs.class));
+ this.interactionsList.add(new ItemInteraction("totem_head", InteractionTotemHead.class));
+ this.interactionsList.add(new ItemInteraction("totem_planet", InteractionTotemPlanet.class));
}
@@ -784,8 +797,13 @@ public class ItemManager {
return this.youtubeManager;
}
+ public WiredHighscoreManager getHighscoreManager() {
+ return highscoreManager;
+ }
+
public void dispose() {
this.items.clear();
+ this.highscoreManager.dispose();
Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!");
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
index 72b13092..95308f40 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDefault.java
@@ -4,10 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.Room;
-import com.eu.habbo.habbohotel.rooms.RoomTile;
-import com.eu.habbo.habbohotel.rooms.RoomUnit;
-import com.eu.habbo.habbohotel.rooms.RoomUnitType;
+import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
@@ -181,7 +178,14 @@ public class InteractionDefault extends HabboItem {
}
public boolean canToggle(Habbo habbo, Room room) {
- return room.hasRights(habbo);
+ if (room.hasRights(habbo)) return true;
+
+ if (!habbo.getHabboStats().isRentingSpace()) return false;
+
+ HabboItem rentSpace = room.getHabboItem(habbo.getHabboStats().rentedItemId);
+
+ return rentSpace != null && RoomLayout.squareInSquare(RoomLayout.getRectangle(rentSpace.getX(), rentSpace.getY(), rentSpace.getBaseItem().getWidth(), rentSpace.getBaseItem().getLength(), rentSpace.getRotation()), RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
+
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
index f68a0aa8..3b579a54 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionFXBox.java
@@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
+import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
@@ -15,41 +17,54 @@ import java.sql.SQLException;
public class InteractionFXBox extends InteractionDefault {
public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
- this.setExtradata("0");
+ // this.setExtradata("0");
}
public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
- this.setExtradata("0");
+ // this.setExtradata("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
- if (client != null && room.hasRights(client.getHabbo())) {
+ if (client != null && this.getUserId() == client.getHabbo().getHabboInfo().getId()) {
+ if(this.getExtradata().equals("1"))
+ return;
+
+ int effectId = -1;
+
if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) {
if (this.getBaseItem().getEffectM() > 0) {
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM(), -1);
+ effectId = this.getBaseItem().getEffectM();
}
}
if (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) {
if (this.getBaseItem().getEffectF() > 0) {
- room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF(), -1);
+ effectId = this.getBaseItem().getEffectF();
}
}
+ if(effectId < 0)
+ return;
+
+ if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId))
+ return;
+
+ EffectsComponent.HabboEffect effect = client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId, 0);
+ client.sendResponse(new UserEffectsListComposer(client.getHabbo()));
+ client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
+
this.setExtradata("1");
room.updateItemState(this);
room.removeHabboItem(this);
HabboItem item = this;
- Emulator.getThreading().run(new Runnable() {
- @Override
- public void run() {
- new QueryDeleteHabboItem(item.getId()).run();
- room.sendComposer(new RemoveFloorItemComposer(item).compose());
- }
+ Emulator.getThreading().run(() -> {
+ new QueryDeleteHabboItem(item.getId()).run();
+ room.sendComposer(new RemoveFloorItemComposer(item).compose());
+ room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
}, 500);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java
index e6103f97..f9aa57dc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionHabboClubGate.java
@@ -12,7 +12,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet;
import java.sql.SQLException;
-public class InteractionHabboClubGate extends InteractionGate {
+public class InteractionHabboClubGate extends InteractionDefault {
public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
this.setExtradata("0");
@@ -24,19 +24,15 @@ public class InteractionHabboClubGate extends InteractionGate {
}
@Override
- public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
- Habbo habbo = room.getHabbo(roomUnit);
-
- if (habbo != null) {
- return habbo.getHabboStats().hasActiveClub();
- }
-
- return false;
+ public boolean isWalkable() {
+ return true;
}
@Override
- public boolean isWalkable() {
- return true;
+ public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
+ Habbo habbo = room.getHabbo(roomUnit);
+
+ return habbo != null && habbo.getHabboStats().hasActiveClub();
}
@Override
@@ -72,6 +68,6 @@ public class InteractionHabboClubGate extends InteractionGate {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
- Emulator.getThreading().run(new CloseGate(this, room), 500);
+ Emulator.getThreading().run(new CloseGate(this, room), 1000);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
index 0106e1b8..0720fba6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
@@ -21,7 +21,7 @@ public class InteractionTeleport extends HabboItem {
private int targetId;
private int targetRoomId;
private int roomUnitID = -1;
- private boolean walkable = false;
+ private boolean walkable;
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -82,6 +82,7 @@ public class InteractionTeleport extends HabboItem {
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
startTeleport(room, habbo);
+ walkable = true;
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
// set state 1 and walk on item
this.roomUnitID = unit.getId();
@@ -93,11 +94,11 @@ public class InteractionTeleport extends HabboItem {
List onFail = new ArrayList();
onSuccess.add(() -> {
- walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation);
tryTeleport(client, room);
unit.removeOverrideTile(currentLocation);
unit.setCanLeaveRoomByDoor(true);
+ walkable = this.getBaseItem().allowWalk();
});
onFail.add(() -> {
@@ -208,8 +209,10 @@ public class InteractionTeleport extends HabboItem {
}
public void startTeleport(Room room, Habbo habbo, int delay) {
- if (habbo.getRoomUnit().isTeleporting)
+ if (habbo.getRoomUnit().isTeleporting) {
+ walkable = this.getBaseItem().allowWalk();
return;
+ }
this.roomUnitID = -1;
habbo.getRoomUnit().isTeleporting = true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java
new file mode 100644
index 00000000..54ea473b
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionVoteCounter.java
@@ -0,0 +1,106 @@
+package com.eu.habbo.habbohotel.items.interactions;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomUnit;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
+import com.eu.habbo.messages.ServerMessage;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class InteractionVoteCounter extends HabboItem {
+
+ private boolean frozen;
+ private int votes;
+ private List votedUsers;
+
+ public InteractionVoteCounter(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ if(!this.getExtradata().contains(",")) {
+ this.setExtradata("1,0"); // frozen,votes
+ }
+
+ String[] bits = this.getExtradata().split(",");
+ frozen = bits[0].equals("1");
+ votes = Integer.parseInt(bits[1]);
+ votedUsers = new ArrayList<>();
+ }
+
+ public InteractionVoteCounter(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+
+ if(!extradata.contains(",")) {
+ extradata = "1,0";
+ }
+
+ String[] bits = extradata.split(",");
+ frozen = bits[0].equals("1");
+ votes = Integer.parseInt(bits[1]);
+ votedUsers = new ArrayList<>();
+ }
+
+ @Override
+ public void serializeExtradata(ServerMessage serverMessage) {
+ serverMessage.appendInt((this.isLimited() ? 256 : 0) + 3);
+ serverMessage.appendString(this.frozen ? "0" : "1");
+ serverMessage.appendInt(this.votes);
+ super.serializeExtradata(serverMessage);
+ }
+
+ @Override
+ public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
+ return false;
+ }
+
+ @Override
+ public boolean isWalkable() {
+ return false;
+ }
+
+ private void updateExtradata() {
+ this.setExtradata((this.frozen ? "1" : "0") + "," + this.votes);
+ }
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ return;
+
+ this.frozen = !this.frozen;
+
+ if(!frozen) {
+ this.votes = 0;
+ this.votedUsers.clear();
+ }
+
+ updateExtradata();
+ this.needsUpdate(true);
+ room.updateItem(this);
+ }
+
+ @Override
+ public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
+
+ }
+
+ public void vote(Room room, int UserId, int vote) {
+ if(frozen)
+ return;
+
+ if(votedUsers.contains(UserId))
+ return;
+
+ votedUsers.add(UserId);
+
+ votes += vote;
+ updateExtradata();
+ this.needsUpdate(true);
+ room.updateItem(this);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
index 9da022e9..054ce7d8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionWiredHighscore.java
@@ -3,24 +3,23 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreRow;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.habbohotel.wired.WiredHighscoreClearType;
-import com.eu.habbo.habbohotel.wired.WiredHighscoreData;
-import com.eu.habbo.habbohotel.wired.WiredHighscoreScoreType;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType;
import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.List;
public class InteractionWiredHighscore extends HabboItem {
public WiredHighscoreScoreType scoreType;
public WiredHighscoreClearType clearType;
- private THashSet data;
- private int lastUpdate;
+ private List data;
public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -37,13 +36,7 @@ public class InteractionWiredHighscore extends HabboItem {
Emulator.getLogging().logErrorLine(e);
}
- if (this.getRoomId() > 0) {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
-
- if (room != null) {
- this.reloadData(room);
- }
- }
+ this.reloadData();
}
public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
@@ -60,6 +53,8 @@ public class InteractionWiredHighscore extends HabboItem {
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
+
+ this.reloadData();
}
@Override
@@ -86,7 +81,6 @@ public class InteractionWiredHighscore extends HabboItem {
try {
int state = Integer.valueOf(this.getExtradata());
this.setExtradata(Math.abs(state - 1) + "");
- this.reloadData(room);
room.updateItem(this);
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
@@ -98,43 +92,22 @@ public class InteractionWiredHighscore extends HabboItem {
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt(6);
serverMessage.appendString(this.getExtradata());
- serverMessage.appendInt(this.scoreType.type); //score type
- serverMessage.appendInt(this.clearType.type); //clear type
+ serverMessage.appendInt(this.scoreType.type);
+ serverMessage.appendInt(this.clearType.type);
- if (this.getRoomId() == 0) {
- serverMessage.appendInt(0);
- } else {
- Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
+ if (this.data != null) {
+ serverMessage.appendInt(this.data.size());
- if (room == null) {
- serverMessage.appendInt(0);
- } else {
- if (Emulator.getIntUnixTimestamp() - this.lastUpdate > 60 * 60) {
- this.reloadData(room);
- }
+ for (WiredHighscoreRow row : this.data) {
+ serverMessage.appendInt(row.getValue());
- if (this.data != null) {
- serverMessage.appendInt(this.data.size()); //count
-
- for (WiredHighscoreData dataSet : this.data) {
- if (this.scoreType == WiredHighscoreScoreType.PERTEAM) {
- serverMessage.appendInt(dataSet.teamScore); //Team score
- } else if (dataSet.usernames.length == 1) {
- serverMessage.appendInt(dataSet.score);
- } else {
- serverMessage.appendInt(dataSet.totalScore);
- }
-
- serverMessage.appendInt(dataSet.usernames.length); //Users count
-
- for (String codeDragon : dataSet.usernames) {
- serverMessage.appendString(codeDragon);
- }
- }
- } else {
- serverMessage.appendInt(0);
+ serverMessage.appendInt(row.getUsers().size());
+ for (String username : row.getUsers()) {
+ serverMessage.appendString(username);
}
}
+ } else {
+ serverMessage.appendInt(0);
}
super.serializeExtradata(serverMessage);
@@ -142,7 +115,7 @@ public class InteractionWiredHighscore extends HabboItem {
@Override
public void onPlace(Room room) {
- this.reloadData(room);
+ this.reloadData();
super.onPlace(room);
}
@@ -151,11 +124,9 @@ public class InteractionWiredHighscore extends HabboItem {
if (this.data != null) {
this.data.clear();
}
- this.lastUpdate = 0;
}
- private void reloadData(Room room) {
- this.data = room.getWiredHighscoreData(this.scoreType, this.clearType);
- this.lastUpdate = Emulator.getIntUnixTimestamp();
+ public void reloadData() {
+ this.data = Emulator.getGameEnvironment().getItemManager().getHighscoreManager().getHighscoreRowsForItem(this.getId(), this.clearType, this.scoreType);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
index da2a6c73..94e01be1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/games/InteractionGameTimer.java
@@ -16,6 +16,7 @@ import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Arrays;
public class InteractionGameTimer extends HabboItem implements Runnable {
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 };
@@ -77,16 +78,17 @@ public class InteractionGameTimer extends HabboItem implements Runnable {
parseCustomParams(item);
}
- public void parseCustomParams(Item baseItem) {
+ private void parseCustomParams(Item baseItem) {
try {
- String[] intervalSteps = baseItem.getCustomParams().split(",");
- int[] finalSteps = new int[intervalSteps.length];
- for (int i = 0; i < intervalSteps.length; i++) {
- finalSteps[i] = Integer.parseInt(intervalSteps[i]);
- }
- TIMER_INTERVAL_STEPS = finalSteps;
- }
- catch (Exception e) {
+ TIMER_INTERVAL_STEPS = Arrays.stream(baseItem.getCustomParams().split(","))
+ .mapToInt(s -> {
+ try {
+ return Integer.parseInt(s);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }).toArray();
+ } catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
new file mode 100644
index 00000000..65036015
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemHead.java
@@ -0,0 +1,85 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class InteractionTotemHead extends InteractionDefault {
+
+ public InteractionTotemHead(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public InteractionTotemHead(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+ }
+
+ public TotemType getTotemType() {
+ int extraData = Integer.parseInt(this.getExtradata());
+ if(extraData < 3) {
+ return TotemType.fromInt(extraData + 1);
+ }
+ return TotemType.fromInt((int)Math.ceil((extraData - 2) / 4.0f));
+ }
+
+ public TotemColor getTotemColor() {
+ int extraData = Integer.parseInt(this.getExtradata());
+ if(extraData < 3) {
+ return TotemColor.NONE;
+ }
+ return TotemColor.fromInt(extraData - 3 - (4 * (getTotemType().type - 1)));
+ }
+
+ private void update(Room room, RoomTile tile) {
+ InteractionTotemLegs legs = null;
+
+ for(HabboItem item : room.getItemsAt(tile)) {
+ if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
+ legs = (InteractionTotemLegs)item;
+ }
+
+ if(legs == null)
+ return;
+
+ this.setExtradata(((4 * this.getTotemType().type) + legs.getTotemColor().color) - 1 + "");
+ }
+
+ public void updateTotemState(Room room) {
+ updateTotemState(room, room.getLayout().getTile(this.getX(), this.getY()));
+ }
+
+ public void updateTotemState(Room room, RoomTile tile) {
+ this.setExtradata(getTotemType().type - 1 + "");
+ update(room, tile);
+ this.needsUpdate(true);
+ room.updateItem(this);
+ }
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ return;
+
+ TotemType newType = TotemType.fromInt(getTotemType().type + 1);
+ if(newType == TotemType.NONE) {
+ newType = TotemType.TROLL;
+ }
+
+ this.setExtradata(newType.type - 1 + "");
+
+ updateTotemState(room);
+ }
+
+ @Override
+ public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
+ super.onMove(room, oldLocation, newLocation);
+ updateTotemState(room, newLocation);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
new file mode 100644
index 00000000..4070a876
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemLegs.java
@@ -0,0 +1,56 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTile;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.wired.WiredEffectType;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class InteractionTotemLegs extends InteractionDefault {
+ public InteractionTotemLegs(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public InteractionTotemLegs(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+ }
+
+ public TotemType getTotemType() {
+ int extraData = Integer.parseInt(this.getExtradata());
+ return TotemType.fromInt((int)Math.ceil((extraData + 1) / 4.0f));
+ }
+
+ public TotemColor getTotemColor() {
+ int extraData = Integer.parseInt(this.getExtradata());
+ return TotemColor.fromInt(extraData - (4 * (getTotemType().type - 1)));
+ }
+
+ private void updateHead(Room room, RoomTile tile) {
+ for(HabboItem item : room.getItemsAt(tile)) {
+ if(item instanceof InteractionTotemHead && item.getZ() > this.getZ())
+ ((InteractionTotemHead)item).updateTotemState(room);
+ }
+ }
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ super.onClick(client, room, objects);
+
+ if (!((client != null && room != null && room.hasRights(client.getHabbo())) || (objects.length >= 2 && objects[1] instanceof WiredEffectType)))
+ return;
+
+ updateHead(room, room.getLayout().getTile(this.getX(), this.getY()));
+ }
+
+ @Override
+ public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
+ super.onMove(room, oldLocation, newLocation);
+
+ updateHead(room, oldLocation);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
new file mode 100644
index 00000000..bff2b26c
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/InteractionTotemPlanet.java
@@ -0,0 +1,85 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.habbohotel.users.inventory.EffectsComponent;
+import com.eu.habbo.messages.outgoing.inventory.UserEffectsListComposer;
+import gnu.trove.set.hash.THashSet;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class InteractionTotemPlanet extends InteractionDefault {
+ public InteractionTotemPlanet(ResultSet set, Item baseItem) throws SQLException {
+ super(set, baseItem);
+ }
+
+ public InteractionTotemPlanet(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
+ super(id, userId, item, extradata, limitedStack, limitedSells);
+ }
+
+ public TotemPlanetType getPlanetType() {
+ int extraData = Integer.parseInt(this.getExtradata());
+ return TotemPlanetType.fromInt(extraData);
+ }
+
+ @Override
+ public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
+ InteractionTotemLegs legs = null;
+ InteractionTotemHead head = null;
+
+ THashSet items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY()));
+
+ for(HabboItem item : items) {
+ if(item instanceof InteractionTotemLegs && item.getZ() < this.getZ())
+ legs = (InteractionTotemLegs)item;
+ }
+
+ if(legs == null) {
+ super.onClick(client, room, objects);
+ return;
+ }
+
+ for(HabboItem item : items) {
+ if(item instanceof InteractionTotemHead && item.getZ() > legs.getZ())
+ head = (InteractionTotemHead)item;
+ }
+
+ if(head == null) {
+ super.onClick(client, room, objects);
+ return;
+ }
+
+ int effectId = 0;
+
+ if(getPlanetType() == TotemPlanetType.SUN && head.getTotemType() == TotemType.BIRD && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.RED) {
+ effectId = 25;
+ }
+ else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.TROLL && legs.getTotemType() == TotemType.TROLL && legs.getTotemColor() == TotemColor.YELLOW) {
+ effectId = 23;
+ }
+ else if(getPlanetType() == TotemPlanetType.EARTH && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.BIRD && legs.getTotemColor() == TotemColor.YELLOW) {
+ effectId = 26;
+ }
+ else if(getPlanetType() == TotemPlanetType.MOON && head.getTotemType() == TotemType.SNAKE && legs.getTotemType() == TotemType.SNAKE && legs.getTotemColor() == TotemColor.BLUE) {
+ effectId = 24;
+ }
+
+ if(effectId > 0) {
+ if(client.getHabbo().getInventory().getEffectsComponent().ownsEffect(effectId)) {
+ client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
+ return;
+ }
+
+ client.getHabbo().getInventory().getEffectsComponent().createEffect(effectId);
+ client.sendResponse(new UserEffectsListComposer(client.getHabbo()));
+ client.getHabbo().getInventory().getEffectsComponent().enableEffect(effectId);
+ return;
+ }
+
+ super.onClick(client, room, objects);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java
new file mode 100644
index 00000000..340bb47f
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemColor.java
@@ -0,0 +1,24 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+public enum TotemColor {
+
+ NONE(0),
+ RED(1),
+ YELLOW(2),
+ BLUE(3);
+
+ public final int color;
+
+ TotemColor(int color) {
+ this.color = color;
+ }
+
+ public static TotemColor fromInt(int color) {
+ for(TotemColor totemColor : TotemColor.values()) {
+ if(totemColor.color == color)
+ return totemColor;
+ }
+
+ return NONE;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java
new file mode 100644
index 00000000..bf8c7378
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemPlanetType.java
@@ -0,0 +1,22 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+public enum TotemPlanetType {
+ MOON(0),
+ SUN(1),
+ EARTH(2);
+
+ public final int type;
+
+ TotemPlanetType(int type) {
+ this.type = type;
+ }
+
+ public static TotemPlanetType fromInt(int type) {
+ for(TotemPlanetType planetType : TotemPlanetType.values()) {
+ if(planetType.type == type)
+ return planetType;
+ }
+
+ return MOON;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java
new file mode 100644
index 00000000..b82d909b
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/totems/TotemType.java
@@ -0,0 +1,24 @@
+package com.eu.habbo.habbohotel.items.interactions.totems;
+
+public enum TotemType {
+
+ NONE(0),
+ TROLL(1),
+ SNAKE(2),
+ BIRD(3);
+
+ public final int type;
+
+ TotemType(int type) {
+ this.type = type;
+ }
+
+ public static TotemType fromInt(int type) {
+ for(TotemType totemType : TotemType.values()) {
+ if(totemType.type == type)
+ return totemType;
+ }
+
+ return NONE;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java
index 2a094d98..738fc508 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveScoreToTeam.java
@@ -120,7 +120,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
this.points = packet.readInt();
this.count = packet.readInt();
- this.teamColor = GameTeamColors.values()[packet.readInt() - 1];
+ this.teamColor = GameTeamColors.values()[packet.readInt()];
packet.readString();
packet.readInt();
this.setDelay(packet.readInt());
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
index f542b964..e461c25b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMatchFurni.java
@@ -101,7 +101,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
tilesToUpdate.addAll(tiles);
double offsetZ = highestZ - item.getZ();
-
+ double totalHeight = item.getZ() + offsetZ;
+ if(totalHeight > 40) break;
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
if (!slideAnimation) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
index 81456f98..729c50e4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectTeleport.java
@@ -51,6 +51,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
return;
// makes a temporary effect
+ roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);
diff --git a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
index 7489fd23..62d7a862 100644
--- a/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
+++ b/src/main/java/com/eu/habbo/habbohotel/messenger/MessengerBuddy.java
@@ -52,6 +52,7 @@ public class MessengerBuddy implements Runnable, ISerialize {
try {
this.id = set.getInt("id");
this.username = set.getString("username");
+ this.look = set.getString("look");
this.relation = 0;
this.userOne = 0;
} catch (SQLException e) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java
index 45a8db9f..37908488 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolChatRecordDataContext.java
@@ -7,7 +7,8 @@ public enum ModToolChatRecordDataContext {
ROOM_ID("roomId", 1),
GROUP_ID("groupId", 1),
THREAD_ID("threadId", 1),
- MESSAGE_ID("messageId", 1);
+ MESSAGE_ID("messageId", 1),
+ PHOTO_ID("extraDataId", 2);
public final String key;
public final int type;
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
index 531ffb7c..172e29e2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/ModToolIssue.java
@@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.modtool;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.threading.runnables.UpdateModToolIssue;
@@ -28,6 +29,7 @@ public class ModToolIssue implements ISerialize {
public int groupId = -1;
public int threadId = -1;
public int commentId = -1;
+ public HabboItem photoItem = null;
public ModToolIssue(ResultSet set) throws SQLException {
this.id = set.getInt("id");
diff --git a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
index b000c0b4..6b214a77 100644
--- a/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
+++ b/src/main/java/com/eu/habbo/habbohotel/modtool/WordFilter.java
@@ -72,8 +72,15 @@ public class WordFilter {
}
public String normalise(String message) {
- return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD).replaceAll("[,.;:'\"]", "").replace("I", "l")
- .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", "").replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i").replace("2", "z").replace("3", "e").replace("4", "a").replace("5", "s").replace("8", "b").replace("0", "o").replace(" ", "").replace("$", "s").replace("ß", "b").trim()).replaceAll("");
+ return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD)
+ .replaceAll("[,.;:'\"]", " ").replace("I", "l")
+ .replaceAll("[^\\p{ASCII}*$]", "").replaceAll("\\p{M}", " ")
+ .replaceAll("^\\p{M}*$]", "").replaceAll("[1|]", "i")
+ .replace("2", "z").replace("3", "e")
+ .replace("4", "a").replace("5", "s")
+ .replace("8", "b").replace("0", "o")
+ .replace(" ", " ").replace("$", "s")
+ .replace("ß", "b").trim()).replaceAll(" ");
}
public boolean autoReportCheck(RoomChatMessage roomChatMessage) {
@@ -139,7 +146,7 @@ public class WordFilter {
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
continue;
}
- filteredMessage = filteredMessage.replaceAll("(?i)" + word.key, word.replacement);
+ filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement);
foundShit = true;
if (habbo != null && word.muteTime > 0) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java
index 068f050e..20929cd7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java
+++ b/src/main/java/com/eu/habbo/habbohotel/permissions/Rank.java
@@ -29,12 +29,20 @@ public class Rank {
private boolean hasPrefix;
+ private int diamondsTimerAmount;
+ private int creditsTimerAmount;
+ private int pixelsTimerAmount;
+ private int gotwTimerAmount;
public Rank(ResultSet set) throws SQLException {
this.permissions = new THashMap<>();
this.variables = new THashMap<>();
this.id = set.getInt("id");
this.level = set.getInt("level");
+ this.diamondsTimerAmount = 1;
+ this.creditsTimerAmount = 1;
+ this.pixelsTimerAmount = 1;
+ this.gotwTimerAmount = 1;
this.load(set);
}
@@ -47,6 +55,10 @@ public class Rank {
this.logCommands = set.getString("log_commands").equals("1");
this.prefix = set.getString("prefix");
this.prefixColor = set.getString("prefix_color");
+ this.diamondsTimerAmount = set.getInt("auto_points_amount");
+ this.creditsTimerAmount = set.getInt("auto_credits_amount");
+ this.pixelsTimerAmount = set.getInt("auto_pixels_amount");
+ this.gotwTimerAmount = set.getInt("auto_gotw_amount");
this.hasPrefix = !this.prefix.isEmpty();
for (int i = 1; i < meta.getColumnCount() + 1; i++) {
String columnName = meta.getColumnName(i);
@@ -115,4 +127,13 @@ public class Rank {
public boolean hasPrefix() {
return this.hasPrefix;
}
+
+ public int getDiamondsTimerAmount() { return this.diamondsTimerAmount; }
+
+ public int getCreditsTimerAmount() { return this.creditsTimerAmount; }
+
+ public int getPixelsTimerAmount() { return this.pixelsTimerAmount; }
+
+ public int getGotwTimerAmount() { return this.gotwTimerAmount; }
}
+
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
index beea7293..19bb4181 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/MonsterplantPet.java
@@ -71,6 +71,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
private boolean canBreed = true;
private boolean publiclyBreedable = false;
private int growthStage = 0;
+ private boolean hasDied = false;
public MonsterplantPet(ResultSet set) throws SQLException {
super(set);
@@ -85,6 +86,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
this.deathTimestamp = set.getInt("mp_death_timestamp");
this.publiclyBreedable = set.getString("mp_allow_breed").equals("1");
this.canBreed = set.getString("mp_breedable").equals("1");
+ this.hasDied = set.getInt("mp_is_dead") == 1;
}
public MonsterplantPet(int userId, int type, int hue, int nose, int noseColor, int mouth, int mouthColor, int eyes, int eyesColor) {
@@ -120,7 +122,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
if (this.needsUpdate) {
super.run();
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ? WHERE id = ?")) {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_pets SET mp_type = ?, mp_color = ?, mp_nose = ?, mp_eyes = ?, mp_mouth = ?, mp_nose_color = ?, mp_eyes_color = ?, mp_mouth_color = ?, mp_death_timestamp = ?, mp_breedable = ?, mp_allow_breed = ?, mp_is_dead = ? WHERE id = ?")) {
statement.setInt(1, this.type);
statement.setInt(2, this.hue);
statement.setInt(3, this.nose);
@@ -132,7 +134,8 @@ public class MonsterplantPet extends Pet implements IPetLook {
statement.setInt(9, this.deathTimestamp);
statement.setString(10, this.canBreed ? "1" : "0");
statement.setString(11, this.publiclyBreedable ? "1" : "0");
- statement.setInt(12, this.id);
+ statement.setInt(12, this.hasDied ? 1 : 0);
+ statement.setInt(13, this.id);
statement.execute();
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
@@ -146,8 +149,11 @@ public class MonsterplantPet extends Pet implements IPetLook {
if (this.isDead()) {
this.roomUnit.removeStatus(RoomUnitStatus.GESTURE);
- if (!this.roomUnit.hasStatus(RoomUnitStatus.RIP)) {
+ if (!this.hasDied) {
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath"));
+
+ this.hasDied = true;
+ this.needsUpdate = true;
}
this.roomUnit.clearStatus();
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
index 29240ad9..965584c4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/Pet.java
@@ -217,7 +217,7 @@ public class Pet implements ISerialize, Runnable {
int time = Emulator.getIntUnixTimestamp();
if (this.roomUnit != null && this.task != PetTasks.RIDE) {
- if (time - this.gestureTickTimeout > 5) {
+ if (time - this.gestureTickTimeout > 5 && this.roomUnit.hasStatus(RoomUnitStatus.GESTURE)) {
this.roomUnit.removeStatus(RoomUnitStatus.GESTURE);
this.packetUpdate = true;
}
@@ -236,8 +236,6 @@ public class Pet implements ISerialize, Runnable {
}
if (!this.roomUnit.isWalking()) {
- this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
-
if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) {
RoomTile tile = this.room.getRandomWalkableTile();
@@ -399,9 +397,9 @@ public class Pet implements ISerialize, Runnable {
for (Map.Entry entry : keys.entrySet()) {
this.roomUnit.setStatus(entry.getKey(), entry.getValue());
}
- }
- this.packetUpdate = true;
+ if (!keys.isEmpty()) this.packetUpdate = true;
+ }
}
public void updateGesture(int time) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
index 5d806570..be20b9e9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/FurnitureMovementError.java
@@ -12,7 +12,8 @@ public enum FurnitureMovementError {
TILE_HAS_PETS("${room.error.cant_set_item}"),
TILE_HAS_BOTS("${room.error.cant_set_item}"),
MAX_DIMMERS("${room.error.max_dimmers}"),
- MAX_SOUNDFURNI("${room.errors.max_soundfurni}");
+ MAX_SOUNDFURNI("${room.errors.max_soundfurni}"),
+ MAX_ITEMS("${room.error.max_furniture}");
public final String errorCode;
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
index 38555728..174cad24 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java
@@ -105,6 +105,7 @@ public class Room implements Comparable, ISerialize, Runnable {
public static boolean HABBO_CHAT_DELAY = false;
public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10;
+ public static int MAXIMUM_FURNI = 2500;
public static int HAND_ITEM_TIME = 10;
public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480;
@@ -135,7 +136,6 @@ public class Room implements Comparable, ISerialize, Runnable {
private final TIntObjectMap moodlightData;
private final THashSet wordFilterWords;
private final TIntObjectMap roomItems;
- private final THashMap>> wiredHighscoreData;
private final Object loadLock = new Object();
//Use appropriately. Could potentially cause memory leaks when used incorrectly.
public volatile boolean preventUnloading = false;
@@ -289,7 +289,6 @@ public class Room implements Comparable, ISerialize, Runnable {
this.activeTrades = new THashSet<>(0);
this.rights = new TIntArrayList();
- this.wiredHighscoreData = new THashMap<>();
this.userVotes = new ArrayList<>();
}
@@ -418,6 +417,10 @@ public class Room implements Comparable, ISerialize, Runnable {
} catch (SQLException e) {
Emulator.getLogging().logSQLException(e);
}
+
+ if (this.itemCount() > Room.MAXIMUM_FURNI) {
+ Emulator.getLogging().logErrorLine("Room ID: " + this.getId() + " has exceeded the furniture limit (" + this.itemCount() + " > " + Room.MAXIMUM_FURNI + ").");
+ }
}
private synchronized void loadWiredData(Connection connection) {
@@ -855,7 +858,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
for (Game game : this.games) {
- game.stop();
+ game.dispose();
}
this.games.clear();
@@ -1480,12 +1483,7 @@ public class Room implements Comparable, ISerialize, Runnable {
if (newRoller == null || topItem == newRoller) {
List sortedItems = new ArrayList<>(itemsOnRoller);
- sortedItems.sort(new Comparator() {
- @Override
- public int compare(HabboItem o1, HabboItem o2) {
- return o1.getZ() > o2.getZ() ? -1 : 1;
- }
- });
+ sortedItems.sort((o1, o2) -> o1.getZ() > o2.getZ() ? -1 : 1);
for (HabboItem item : sortedItems) {
if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) {
@@ -2132,15 +2130,18 @@ public class Room implements Comparable, ISerialize, Runnable {
public boolean deleteGame(Game game) {
game.stop();
+ game.dispose();
synchronized (this.games) {
return this.games.remove(game);
}
}
public Game getGame(Class extends Game> gameType) {
+ if (gameType == null) return null;
+
synchronized (this.games) {
for (Game game : this.games) {
- if (gameType.isInstance(game)) {
+ if (game != null && gameType.isInstance(game)) {
return game;
}
}
@@ -2989,8 +2990,6 @@ public class Room implements Comparable, ISerialize, Runnable {
return;
}
- habbo.getHabboStats().chatCounter += 2;
-
if (habbo.getHabboInfo().getCurrentRoom() != this)
return;
@@ -3002,6 +3001,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
habbo.getHabboStats().lastChat = millis;
if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) {
+ habbo.getHabboStats().chatCounter += 2;
Emulator.getThreading().run(new YouAreAPirate(habbo, this));
return;
}
@@ -3060,12 +3060,18 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
+ habbo.getHabboStats().chatCounter += 2;
+
ServerMessage prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null;
ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null;
Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation());
- roomChatMessage.setMessage(roomChatMessage.getMessage().trim());
+ String trimmedMessage = roomChatMessage.getMessage().replaceAll("\\s+$","");
+
+ if (trimmedMessage.isEmpty()) trimmedMessage = " ";
+
+ roomChatMessage.setMessage(trimmedMessage);
if (chatType == RoomChatType.WHISPER) {
if (roomChatMessage.getTargetHabbo() == null) {
@@ -3243,17 +3249,17 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public THashSet getItemsAt(RoomTile tile) {
+ THashSet items = new THashSet<>(0);
+
+ if (tile == null)
+ return items;
+
if (this.loaded) {
if (this.tileCache.containsKey(tile)) {
return this.tileCache.get(tile);
}
}
- THashSet items = new THashSet<>(0);
-
- if (tile == null)
- return items;
-
TIntObjectIterator iterator = this.roomItems.iterator();
for (int i = this.roomItems.size(); i-- > 0; ) {
@@ -3407,11 +3413,14 @@ public class Room implements Comparable, ISerialize, Runnable {
continue;
}
+ if (this.layout == null) continue;
+
THashSet tiles = this.layout.getTilesAt(
this.layout.getTile(habboItem.getX(), habboItem.getY()),
habboItem.getBaseItem().getWidth(),
habboItem.getBaseItem().getLength(),
- habboItem.getRotation());
+ habboItem.getRotation()
+ );
for (RoomTile tile : tiles) {
if (((tile.x == x) && (tile.y == y))) {
@@ -3637,7 +3646,7 @@ public class Room implements Comparable, ISerialize, Runnable {
public RoomTile getRandomWalkableTile() {
for (int i = 0; i < 10; i++) {
RoomTile tile = this.layout.getTile((short) (Math.random() * this.layout.getMapSizeX()), (short) (Math.random() * this.layout.getMapSizeY()));
- if (tile != null && tile.isWalkable()) {
+ if (tile != null && tile.getState() != RoomTileState.BLOCKED && tile.getState() != RoomTileState.INVALID) {
return tile;
}
}
@@ -3676,6 +3685,11 @@ public class Room implements Comparable, ISerialize, Runnable {
public void sendComposer(ServerMessage message) {
for (Habbo habbo : this.getHabbos()) {
+ if (habbo.getClient() == null) {
+ this.removeHabbo(habbo, true);
+ continue;
+ }
+
habbo.getClient().sendResponse(message);
}
}
@@ -4152,6 +4166,7 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public void unIdle(Habbo habbo) {
+ if (habbo == null || habbo.getRoomUnit() == null) return;
habbo.getRoomUnit().resetIdleTimer();
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
@@ -4206,70 +4221,6 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
- public THashSet getWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) {
- if (!this.wiredHighscoreData.containsKey(scoreType)) {
- this.loadWiredHighscoreData(scoreType, clearType);
- }
-
- return this.wiredHighscoreData.get(scoreType).get(clearType);
- }
-
- public void loadWiredHighscoreData(WiredHighscoreScoreType scoreType, WiredHighscoreClearType clearType) {
- this.wiredHighscoreData.clear();
- THashSet wiredData = new THashSet<>();
-
- try {
- String query = "SELECT " +
- "SUM(score + team_score) as total_score, " +
- "COUNT(*) as wins, " +
- "users.username, " +
- "room_game_scores.*, " +
- "GROUP_CONCAT(users.username) as usernames " +
- "FROM room_game_scores " +
- "INNER JOIN users ON room_game_scores.user_id = users.id " +
- "WHERE room_id = ? AND game_start_timestamp >= ? ";
-
- int timestamp = 0;
- if (clearType != WiredHighscoreClearType.ALLTIME) {
- if (clearType == WiredHighscoreClearType.MONTHLY) {
- timestamp = Emulator.getIntUnixTimestamp() - (31 * 24 * 60 * 60);
- } else if (clearType == WiredHighscoreClearType.WEEKLY) {
- timestamp = Emulator.getIntUnixTimestamp() - (7 * 24 * 60 * 60);
- } else if (clearType == WiredHighscoreClearType.DAILY) {
- timestamp = Emulator.getIntUnixTimestamp() - (24 * 60 * 60);
- }
- }
-
-
- if (scoreType == WiredHighscoreScoreType.CLASSIC) {
- query += "GROUP BY game_start_timestamp, user_id, team_id ORDER BY total_score DESC";
- } else if (scoreType == WiredHighscoreScoreType.MOSTWIN) {
- query += "GROUP BY game_start_timestamp, game_name, team_id ORDER BY wins DESC, total_score ASC";
- } else if (scoreType == WiredHighscoreScoreType.PERTEAM) {
- query += "GROUP BY game_start_timestamp, team_id ORDER BY team_score DESC";
- }
-
- query += " LIMIT " + Emulator.getConfig().getValue("wired.highscores.displaycount");
-
- try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement(query)) {
- statement.setInt(1, this.id);
- statement.setInt(2, timestamp);
-
- try (ResultSet set = statement.executeQuery()) {
- while (set.next()) {
- wiredData.add(new WiredHighscoreData(set.getString("usernames").split(","), set.getInt("score"), set.getInt("team_score"), set.getInt("total_score")));
- }
- }
- }
- } catch (SQLException e) {
- Emulator.getLogging().logSQLException(e);
- }
-
- THashMap> dataMap = new THashMap<>();
- dataMap.put(clearType, wiredData);
- this.wiredHighscoreData.put(scoreType, dataMap);
- }
-
public void handleWordQuiz(Habbo habbo, String answer) {
synchronized (this.userVotes) {
if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) {
@@ -4352,6 +4303,10 @@ public class Room implements Comparable, ISerialize, Runnable {
}
public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) {
+ if (this.itemCount() >= Room.MAXIMUM_FURNI) {
+ return FurnitureMovementError.MAX_ITEMS;
+ }
+
rotation %= 8;
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) {
return FurnitureMovementError.NONE;
@@ -4487,7 +4442,8 @@ public class Room implements Comparable, ISerialize, Runnable {
THashSet occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
if (topItem != item) {
for (RoomTile t : occupiedTiles) {
- if (!magicTile && ((this.getTopItemAt(t.x, t.y) != item ? t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
+ HabboItem tileTopItem = this.getTopItemAt(t.x, t.y);
+ if (!magicTile && ((tileTopItem != null && tileTopItem != item ? (t.state.equals(RoomTileState.INVALID) || !t.getAllowStack() || !tileTopItem.getBaseItem().allowStack()) : this.calculateTileState(t, item).equals(RoomTileState.INVALID))))
return FurnitureMovementError.CANT_STACK;
if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
@@ -4521,9 +4477,11 @@ public class Room implements Comparable, ISerialize, Runnable {
}
}
//Place at new position
+ double height = this.getStackHeight(tile.x, tile.y, false, item);
+ if(height > 40d) return FurnitureMovementError.CANT_STACK;
item.setX(tile.x);
item.setY(tile.y);
- item.setZ(this.getStackHeight(tile.x, tile.y, false, item));
+ item.setZ(height);
if (magicTile) {
item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100);
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
index 0d8e5da1..9157886e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
@@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.core.RoomUserPetComposer;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.Bot;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.games.football.FootballGame;
@@ -40,8 +41,10 @@ import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetComposer;
import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.users.*;
import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer;
+import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.navigator.NavigatorRoomCreatedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent;
+import com.eu.habbo.plugin.events.rooms.UserVoteRoomEvent;
import com.eu.habbo.plugin.events.users.HabboAddedToRoomEvent;
import com.eu.habbo.plugin.events.users.UserEnterRoomEvent;
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
@@ -432,6 +435,9 @@ public class RoomManager {
if (this.hasVotedForRoom(habbo, room))
return;
+ UserVoteRoomEvent event = new UserVoteRoomEvent(room, habbo);
+ if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return;
+
room.setScore(room.getScore() + 1);
room.setNeedsUpdate(true);
habbo.getHabboStats().votedRooms.push(room.getId());
@@ -706,9 +712,20 @@ public class RoomManager {
List habbos = new ArrayList<>();
if (!room.getCurrentHabbos().isEmpty()) {
+ Collection habbosToSendEnter = room.getCurrentHabbos().values();
- room.sendComposer(new RoomUsersComposer(habbo).compose());
- room.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
+ if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
+ HabboAddedToRoomEvent event = Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room, habbosToSendEnter));
+ habbosToSendEnter = event.habbosToSendEnter;
+ }
+
+ for (Habbo habboToSendEnter : habbosToSendEnter) {
+ GameClient client = habboToSendEnter.getClient();
+ if (client != null) {
+ client.sendResponse(new RoomUsersComposer(habbo).compose());
+ habboToSendEnter.getClient().sendResponse(new RoomUserStatusComposer(habbo.getRoomUnit()).compose());
+ }
+ }
for (Habbo h : room.getHabbos()) {
if (!h.getRoomUnit().isInvisible()) {
@@ -886,10 +903,6 @@ public class RoomManager {
if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) {
UserNuxEvent.handle(habbo);
}
-
- if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
- Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room));
- }
}
void logEnter(Habbo habbo, Room room) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java
index ba56a8e1..eb6ac5cd 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomTrade.java
@@ -8,6 +8,7 @@ import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.messages.outgoing.trading.*;
+import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
import gnu.trove.set.hash.THashSet;
import java.sql.*;
@@ -214,6 +215,33 @@ public class RoomTrade {
userOne.clearItems();
userTwo.clearItems();
+ int creditsForUserTwo = 0;
+ THashSet creditFurniUserOne = new THashSet<>();
+ for (HabboItem item : itemsUserOne) {
+ int worth = RoomTrade.getCreditsByItem(item);
+ if (worth > 0) {
+ creditsForUserTwo += worth;
+ creditFurniUserOne.add(item);
+ new QueryDeleteHabboItem(item).run();
+ }
+ }
+ itemsUserOne.removeAll(creditFurniUserOne);
+
+ int creditsForUserOne = 0;
+ THashSet creditFurniUserTwo = new THashSet<>();
+ for (HabboItem item : itemsUserTwo) {
+ int worth = RoomTrade.getCreditsByItem(item);
+ if (worth > 0) {
+ creditsForUserOne += worth;
+ creditFurniUserTwo.add(item);
+ new QueryDeleteHabboItem(item).run();
+ }
+ }
+ itemsUserTwo.removeAll(creditFurniUserTwo);
+
+ userOne.getHabbo().giveCredits(creditsForUserOne);
+ userTwo.getHabbo().giveCredits(creditsForUserTwo);
+
userOne.getHabbo().getInventory().getItemsComponent().addItems(itemsUserTwo);
userTwo.getHabbo().getInventory().getItemsComponent().addItems(itemsUserOne);
@@ -287,4 +315,14 @@ public class RoomTrade {
public List getRoomTradeUsers() {
return this.users;
}
+
+ public static int getCreditsByItem(HabboItem item) {
+ if (!item.getBaseItem().getName().startsWith("CF_") && !item.getBaseItem().getName().startsWith("CFC_")) return 0;
+
+ try {
+ return Integer.valueOf(item.getBaseItem().getName().split("_")[1]);
+ } catch (Exception e) {
+ return 0;
+ }
+ }
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
index d1c6aa6c..79ba7fab 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java
@@ -2,15 +2,13 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate;
-import com.eu.habbo.habbohotel.items.interactions.InteractionTeleport;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWater;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWaterItem;
+import com.eu.habbo.habbohotel.items.interactions.*;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.generic.alerts.CustomNotificationComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
@@ -285,12 +283,17 @@ public class RoomUnit {
if (item != habboItem || !RoomLayout.pointInSquare(item.getX(), item.getY(), item.getX() + item.getBaseItem().getWidth() - 1, item.getY() + item.getBaseItem().getLength() - 1, this.getX(), this.getY())) {
if (item.canWalkOn(this, room, null)) {
item.onWalkOn(this, room, null);
- } else if (item instanceof InteractionGuildGate) {
+ } else if (item instanceof InteractionGuildGate || item instanceof InteractionHabboClubGate) {
this.setRotation(oldRotation);
this.tilesWalked--;
this.setGoalLocation(this.currentLocation);
this.status.remove(RoomUnitStatus.MOVE);
room.sendComposer(new RoomUserStatusComposer(this).compose());
+
+ if (item instanceof InteractionHabboClubGate && habbo != null) {
+ habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
+ }
+
return false;
}
} else {
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java
index 5ae0885e..3be40d28 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitEffect.java
@@ -198,7 +198,11 @@ public enum RoomUnitEffect {
WATERINGCAN(192),
TRAMPOLINEJUMP(193),
TREADMILL(194),
- CROSSTRAINER(195);
+ CROSSTRAINER(195),
+ STARWARS(196),
+ FLYINGCARPET(197),
+ YELLOWDUCK(198),
+ FLYNGTURTLE(199);
private int id;
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
index 84396d67..0838c76f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java
@@ -22,6 +22,7 @@ import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.sql.ResultSet;
import java.util.*;
import java.util.stream.Collectors;
@@ -109,8 +110,10 @@ public class Habbo implements Runnable {
public void connect() {
- if (!Emulator.getConfig().getBoolean("networking.tcp.proxy")) {
- this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress());
+ if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
+ SocketAddress address = this.client.getChannel().remoteAddress();
+
+ if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress());
}
this.habboInfo.setMachineID(this.client.getMachineId());
@@ -199,7 +202,8 @@ public class Habbo implements Runnable {
return;
this.getHabboInfo().addCredits(event.credits);
- this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo()));
+
+ if (this.client != null) this.client.sendResponse(new UserCreditsComposer(this.client.getHabbo()));
}
@@ -213,7 +217,7 @@ public class Habbo implements Runnable {
return;
this.getHabboInfo().addPixels(event.points);
- this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
+ if (this.client != null) this.client.sendResponse(new UserCurrencyComposer(this.client.getHabbo()));
}
@@ -231,7 +235,7 @@ public class Habbo implements Runnable {
return;
this.getHabboInfo().addCurrencyAmount(event.type, event.points);
- this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(type), event.points, event.type));
+ if (this.client != null) this.client.sendResponse(new UserPointsComposer(this.client.getHabbo().getHabboInfo().getCurrencyAmount(type), event.points, event.type));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
index f8238ca5..0632c0b8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
@@ -50,7 +50,7 @@ public class HabboInfo implements Runnable {
private String photoJSON;
private int webPublishTimestamp;
private String machineID;
- private HashSet savedSearches = new HashSet<>();
+ private List savedSearches = new ArrayList<>();
public HabboInfo(ResultSet set) {
try {
@@ -125,7 +125,7 @@ public class HabboInfo implements Runnable {
}
private void loadSavedSearches() {
- this.savedSearches = new HashSet<>();
+ 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);
@@ -470,7 +470,7 @@ public class HabboInfo implements Runnable {
this.machineID = machineID;
}
- public HashSet getSavedSearches() {
+ public List getSavedSearches() {
return this.savedSearches;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java
index e227aaba..52db8cf6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInventory.java
@@ -147,9 +147,11 @@ public class HabboInventory {
}
public MarketPlaceOffer getOffer(int id) {
- for (MarketPlaceOffer offer : this.items) {
- if (offer.getOfferId() == id)
- return offer;
+ synchronized (this.items) {
+ for (MarketPlaceOffer offer : this.items) {
+ if (offer.getOfferId() == id)
+ return offer;
+ }
}
return null;
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
index 213b3124..5ac1bc7c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
@@ -18,7 +18,11 @@ import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer;
+import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
+import com.eu.habbo.messages.outgoing.users.UpdateUserLookComposer;
+import com.eu.habbo.util.figure.FigureUtil;
import gnu.trove.set.hash.THashSet;
+import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.math3.util.Pair;
import java.sql.Connection;
@@ -26,6 +30,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
public abstract class HabboItem implements Runnable, IEventTriggers {
@@ -294,6 +299,20 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
roomUnit.setDanceType(DanceType.NONE);
room.sendComposer(new RoomUserDanceComposer(roomUnit).compose());
}
+
+ if (!this.getBaseItem().getClothingOnWalk().isEmpty() && roomUnit.getPreviousLocation() != roomUnit.getGoal() && roomUnit.getGoal() == room.getLayout().getTile(this.x, this.y)) {
+ Habbo habbo = room.getHabbo(roomUnit);
+
+ if (habbo != null && habbo.getClient() != null) {
+ String[] clothingKeys = Arrays.stream(this.getBaseItem().getClothingOnWalk().split("\\.")).map(k -> k.split("-")[0]).toArray(String[]::new);
+ habbo.getHabboInfo().setLook(String.join(".", Arrays.stream(habbo.getHabboInfo().getLook().split("\\.")).filter(k -> !ArrayUtils.contains(clothingKeys, k.split("-")[0])).toArray(String[]::new)) + "." + this.getBaseItem().getClothingOnWalk());
+
+ habbo.getClient().sendResponse(new UpdateUserLookComposer(habbo));
+ if (habbo.getHabboInfo().getCurrentRoom() != null) {
+ habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose());
+ }
+ }
+ }
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
index 6be7b4dd..b0da325b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/inventory/EffectsComponent.java
@@ -34,6 +34,10 @@ public class EffectsComponent {
}
public HabboEffect createEffect(int effectId) {
+ return createEffect(effectId, 86400);
+ }
+
+ public HabboEffect createEffect(int effectId, int duration) {
HabboEffect effect;
synchronized (this.effects) {
if (this.effects.containsKey(effectId)) {
@@ -44,6 +48,7 @@ public class EffectsComponent {
}
} else {
effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId());
+ effect.duration = duration;
effect.insert();
}
@@ -159,6 +164,9 @@ public class EffectsComponent {
}
public boolean isRemaining() {
+ if(this.duration <= 0)
+ return true;
+
if (this.total > 0) {
if (this.activationTimestamp >= 0) {
if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) {
@@ -172,6 +180,9 @@ public class EffectsComponent {
}
public int remainingTime() {
+ if(this.duration <= 0) //permanant
+ return Integer.MAX_VALUE;
+
return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java b/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java
deleted file mode 100644
index 07221e5b..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreData.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.eu.habbo.habbohotel.wired;
-
-public class WiredHighscoreData {
- public String[] usernames;
- public int score;
- public int teamScore;
- public int totalScore;
-
- public WiredHighscoreData(String[] usernames, int score, int teamScore, int totalScore) {
- this.usernames = usernames;
-
- this.score = score;
- this.teamScore = teamScore;
- this.totalScore = totalScore;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java
similarity index 80%
rename from src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java
rename to src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java
index aead67bd..602daa09 100644
--- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreClearType.java
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreClearType.java
@@ -1,4 +1,4 @@
-package com.eu.habbo.habbohotel.wired;
+package com.eu.habbo.habbohotel.wired.highscores;
public enum WiredHighscoreClearType {
ALLTIME(0),
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java
new file mode 100644
index 00000000..e063d05e
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreDataEntry.java
@@ -0,0 +1,51 @@
+package com.eu.habbo.habbohotel.wired.highscores;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+public class WiredHighscoreDataEntry {
+ private final int itemId;
+ private final List userIds;
+ private final int score;
+ private final boolean isWin;
+ private final int timestamp;
+
+ public WiredHighscoreDataEntry(int itemId, List userIds, int score, boolean isWin, int timestamp) {
+ this.itemId = itemId;
+ this.userIds = userIds;
+ this.score = score;
+ this.isWin = isWin;
+ this.timestamp = timestamp;
+ }
+
+ public WiredHighscoreDataEntry(ResultSet set) throws SQLException {
+ this.itemId = set.getInt("item_id");
+ this.userIds = Arrays.stream(set.getString("user_ids").split(",")).map(Integer::valueOf).collect(Collectors.toList());
+ this.score = set.getInt("score");
+ this.isWin = set.getInt("is_win") == 1;
+ this.timestamp = set.getInt("timestamp");
+ }
+
+ public int getItemId() {
+ return itemId;
+ }
+
+ public List getUserIds() {
+ return userIds;
+ }
+
+ public int getScore() {
+ return score;
+ }
+
+ public boolean isWin() {
+ return isWin;
+ }
+
+ public int getTimestamp() {
+ return timestamp;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java
new file mode 100644
index 00000000..1873b2de
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreManager.java
@@ -0,0 +1,173 @@
+package com.eu.habbo.habbohotel.wired.highscores;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.plugin.EventHandler;
+import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.time.*;
+import java.time.temporal.TemporalAdjusters;
+import java.time.temporal.WeekFields;
+import java.util.*;
+import java.util.concurrent.ScheduledFuture;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+public class WiredHighscoreManager {
+ private final HashMap> data = new HashMap<>();
+
+ private final static DayOfWeek firstDayOfWeek = WeekFields.of(new Locale(System.getProperty("user.language"), System.getProperty("user.country"))).getFirstDayOfWeek();
+ private final static DayOfWeek lastDayOfWeek = DayOfWeek.of(((firstDayOfWeek.getValue() + 5) % DayOfWeek.values().length) + 1);
+ private final static ZoneId zoneId = ZoneId.systemDefault();
+
+ public static ScheduledFuture midnightUpdater = null;
+
+ public void load() {
+ long millis = System.currentTimeMillis();
+
+ this.data.clear();
+ this.loadHighscoreData();
+
+ Emulator.getLogging().logStart("Highscore Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS, " + this.data.size() + " items)");
+ }
+
+ @EventHandler
+ public static void onEmulatorLoaded(EmulatorLoadedEvent event) {
+ if (midnightUpdater != null) {
+ midnightUpdater.cancel(true);
+ }
+
+ midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), WiredHighscoreMidnightUpdater.getNextUpdaterRun());
+ }
+
+ public void dispose() {
+ if (midnightUpdater != null) {
+ midnightUpdater.cancel(true);
+ }
+
+ this.data.clear();
+ }
+
+ private void loadHighscoreData() {
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM items_highscore_data")) {
+ try (ResultSet set = statement.executeQuery()) {
+ while (set.next()) {
+ WiredHighscoreDataEntry entry = new WiredHighscoreDataEntry(set);
+
+ if (!this.data.containsKey(entry.getItemId())) {
+ this.data.put(entry.getItemId(), new ArrayList<>());
+ }
+
+ this.data.get(entry.getItemId()).add(entry);
+ }
+ }
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public void addHighscoreData(WiredHighscoreDataEntry entry) {
+ if (!this.data.containsKey(entry.getItemId())) {
+ this.data.put(entry.getItemId(), new ArrayList<>());
+ }
+
+ this.data.get(entry.getItemId()).add(entry);
+
+ try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO `items_highscore_data` (`item_id`, `user_ids`, `score`, `is_win`, `timestamp`) VALUES (?, ?, ?, ?, ?)")) {
+ statement.setInt(1, entry.getItemId());
+ statement.setString(2, String.join(",", entry.getUserIds().stream().map(Object::toString).collect(Collectors.toList())));
+ statement.setInt(3, entry.getScore());
+ statement.setInt(4, entry.isWin() ? 1 : 0);
+ statement.setInt(5, entry.getTimestamp());
+
+ statement.execute();
+ } catch (SQLException e) {
+ Emulator.getLogging().logSQLException(e);
+ }
+ }
+
+ public List getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) {
+ if (!this.data.containsKey(itemId)) return null;
+
+ Stream highscores = this.data.get(itemId).stream()
+ .filter(entry -> this.timeMatchesEntry(entry, clearType) && (scoreType != WiredHighscoreScoreType.MOSTWIN || entry.isWin()))
+ .map(entry -> new WiredHighscoreRow(
+ entry.getUserIds().stream()
+ .map(id -> Emulator.getGameEnvironment().getHabboManager().getHabboInfo(id).getUsername())
+ .collect(Collectors.toList()),
+ entry.getScore()
+ ));
+
+ if (scoreType == WiredHighscoreScoreType.CLASSIC) {
+ return highscores.sorted(WiredHighscoreRow::compareTo).collect(Collectors.toList());
+ }
+
+ if (scoreType == WiredHighscoreScoreType.PERTEAM) {
+ return highscores
+ .collect(Collectors.groupingBy(h -> h.getUsers().hashCode()))
+ .entrySet()
+ .stream()
+ .map(e -> e.getValue().stream()
+ .sorted(WiredHighscoreRow::compareTo)
+ .collect(Collectors.toList())
+ .get(0)
+ )
+ .sorted(WiredHighscoreRow::compareTo)
+ .collect(Collectors.toList());
+ }
+
+ if (scoreType == WiredHighscoreScoreType.MOSTWIN) {
+ return highscores
+ .collect(Collectors.groupingBy(h -> h.getUsers().hashCode()))
+ .entrySet()
+ .stream()
+ .map(e -> new WiredHighscoreRow(e.getValue().get(0).getUsers(), e.getValue().size()))
+ .sorted(WiredHighscoreRow::compareTo)
+ .collect(Collectors.toList());
+ }
+
+ return null;
+ }
+
+ private boolean timeMatchesEntry(WiredHighscoreDataEntry entry, WiredHighscoreClearType timeType) {
+ switch (timeType) {
+ case DAILY:
+ return entry.getTimestamp() > this.getTodayStartTimestamp() && entry.getTimestamp() < this.getTodayEndTimestamp();
+ case WEEKLY:
+ return entry.getTimestamp() > this.getWeekStartTimestamp() && entry.getTimestamp() < this.getWeekEndTimestamp();
+ case MONTHLY:
+ return entry.getTimestamp() > this.getMonthStartTimestamp() && entry.getTimestamp() < this.getMonthEndTimestamp();
+ case ALLTIME:
+ return true;
+ }
+
+ return false;
+ }
+
+ private long getTodayStartTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).atZone(zoneId).toEpochSecond();
+ }
+
+ private long getTodayEndTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).atZone(zoneId).toEpochSecond();
+ }
+
+ private long getWeekStartTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).with(TemporalAdjusters.previousOrSame(firstDayOfWeek)).atZone(zoneId).toEpochSecond();
+ }
+
+ private long getWeekEndTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).with(TemporalAdjusters.nextOrSame(lastDayOfWeek)).atZone(zoneId).toEpochSecond();
+ }
+
+ private long getMonthStartTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).with(TemporalAdjusters.firstDayOfMonth()).atZone(zoneId).toEpochSecond();
+ }
+
+ private long getMonthEndTimestamp() {
+ return LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).with(TemporalAdjusters.lastDayOfMonth()).atZone(zoneId).toEpochSecond();
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java
new file mode 100644
index 00000000..7b60b22c
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreMidnightUpdater.java
@@ -0,0 +1,35 @@
+package com.eu.habbo.habbohotel.wired.highscores;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import gnu.trove.set.hash.THashSet;
+
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.ZoneId;
+import java.util.List;
+
+public class WiredHighscoreMidnightUpdater implements Runnable {
+ @Override
+ public void run() {
+ List rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms();
+
+ for (Room room : rooms) {
+ if (room == null || room.getRoomSpecialTypes() == null) continue;
+
+ THashSet items = room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class);
+ for (HabboItem item : items) {
+ ((InteractionWiredHighscore) item).reloadData();
+ room.updateItem(item);
+ }
+ }
+
+ WiredHighscoreManager.midnightUpdater = Emulator.getThreading().run(new WiredHighscoreMidnightUpdater(), getNextUpdaterRun());
+ }
+
+ public static int getNextUpdaterRun() {
+ return Math.toIntExact(LocalDateTime.now().with(LocalTime.MIDNIGHT).plusDays(1).plusSeconds(-1).atZone(ZoneId.systemDefault()).toEpochSecond() - Emulator.getIntUnixTimestamp()) + 5;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java
new file mode 100644
index 00000000..1282a1bc
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreRow.java
@@ -0,0 +1,32 @@
+package com.eu.habbo.habbohotel.wired.highscores;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class WiredHighscoreRow implements Comparable {
+ public static final Comparator COMPARATOR = Comparator.comparing(WiredHighscoreRow::getValue).reversed();
+
+ private final List users;
+ private final int value;
+
+ public WiredHighscoreRow(List users, int value) {
+ Collections.sort(users);
+
+ this.users = users;
+ this.value = value;
+ }
+
+ public List getUsers() {
+ return users;
+ }
+
+ public int getValue() {
+ return value;
+ }
+
+ @Override
+ public int compareTo(WiredHighscoreRow otherRow) {
+ return COMPARATOR.compare(this, otherRow);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java
similarity index 79%
rename from src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java
rename to src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java
index cc2e50a0..d70e07ed 100644
--- a/src/main/java/com/eu/habbo/habbohotel/wired/WiredHighscoreScoreType.java
+++ b/src/main/java/com/eu/habbo/habbohotel/wired/highscores/WiredHighscoreScoreType.java
@@ -1,4 +1,4 @@
-package com.eu.habbo.habbohotel.wired;
+package com.eu.habbo.habbohotel.wired.highscores;
public enum WiredHighscoreScoreType {
PERTEAM(0),
diff --git a/src/main/java/com/eu/habbo/messages/NoAuthMessage.java b/src/main/java/com/eu/habbo/messages/NoAuthMessage.java
new file mode 100644
index 00000000..47487068
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/NoAuthMessage.java
@@ -0,0 +1,7 @@
+package com.eu.habbo.messages;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface NoAuthMessage {}
diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java
index c49fe1b3..7cda01db 100644
--- a/src/main/java/com/eu/habbo/messages/PacketManager.java
+++ b/src/main/java/com/eu/habbo/messages/PacketManager.java
@@ -156,11 +156,20 @@ public class PacketManager {
if (client == null || Emulator.isShuttingDown)
return;
- if (client.getHabbo() == null && !(packet.getMessageId() == Incoming.SecureLoginEvent || packet.getMessageId() == Incoming.MachineIDEvent))
- return;
-
try {
if (this.isRegistered(packet.getMessageId())) {
+ Class extends MessageHandler> handlerClass = this.incoming.get(packet.getMessageId());
+
+ if (handlerClass == null) throw new Exception("Unknown message " + packet.getMessageId());
+
+ if (client.getHabbo() == null && !handlerClass.isAnnotationPresent(NoAuthMessage.class)) {
+ if (DEBUG_SHOW_PACKETS) {
+ Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "NOT LOGGED IN" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody());
+ }
+
+ return;
+ }
+
if (PacketManager.DEBUG_SHOW_PACKETS)
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody());
@@ -168,7 +177,7 @@ public class PacketManager {
System.out.println(("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + client.getHabbo().getHabboInfo().getUsername() + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()));
}
- final MessageHandler handler = this.incoming.get(packet.getMessageId()).newInstance();
+ final MessageHandler handler = handlerClass.newInstance();
handler.client = client;
handler.packet = packet;
@@ -184,7 +193,7 @@ public class PacketManager {
}
} else {
if (PacketManager.DEBUG_SHOW_PACKETS)
- Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_RED + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody());
+ Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + Logging.ANSI_YELLOW + "UNDEFINED" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody());
}
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e);
@@ -468,6 +477,7 @@ public class PacketManager {
this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class);
this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class);
this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class);
+ this.registerHandler(Incoming.ReportPhotoEvent, ReportPhotoEvent.class);
}
void registerTrading() throws Exception {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
index ee4ed6d5..0b70e95b 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/Incoming.java
@@ -292,6 +292,7 @@ public class Incoming {
public static final int UpdateUIFlagsEvent = 2313;
public static final int ReportThreadEvent = 534;
public static final int ReportCommentEvent = 1412;
+ public static final int ReportPhotoEvent = 2492;
public static final int RequestCraftingRecipesEvent = 1173;
public static final int RequestCraftingRecipesAvailableEvent = 3086;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java
index 99f87ad0..1ab77c2c 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarForceOpenEvent.java
@@ -1,5 +1,6 @@
package com.eu.habbo.messages.incoming.events.calendar;
+import com.eu.habbo.Emulator;
import com.eu.habbo.messages.incoming.MessageHandler;
public class AdventCalendarForceOpenEvent extends MessageHandler {
@@ -7,5 +8,7 @@ public class AdventCalendarForceOpenEvent extends MessageHandler {
public void handle() throws Exception {
String campaign = this.packet.readString();
int day = this.packet.readInt();
+
+ Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, true);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java
index 51cbd07a..9c68cfd0 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/events/calendar/AdventCalendarOpenDayEvent.java
@@ -9,6 +9,6 @@ public class AdventCalendarOpenDayEvent extends MessageHandler {
String campaign = this.packet.readString();
int day = this.packet.readInt();
- Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day);
+ Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, false);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
index e7212745..ac8902e4 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/floorplaneditor/FloorPlanEditorSaveEvent.java
@@ -13,14 +13,11 @@ import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
public class FloorPlanEditorSaveEvent extends MessageHandler {
public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64;
public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64;
- public static final String VALID_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
@Override
public void handle() throws Exception {
@@ -35,66 +32,46 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
return;
if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) {
- List errors = new ArrayList<>();
+ StringJoiner errors = new StringJoiner("
");
String map = this.packet.readString();
map = map.replace("X", "x");
- String checkMap = map.replace(((char) 13) + "", "").toUpperCase();
- for (char c : VALID_CHARACTERS.toCharArray())
- {
- checkMap = checkMap.replace(c + "", "");
- }
+ String[] mapRows = map.split("\r");
- if (!checkMap.isEmpty() && Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled"))
- {
- errors.add("${notification.floorplan_editor.error.title}");
- }
+ int firstRowSize = mapRows[0].length();
+ if (Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) {
+ if (!map.matches("[a-zA-Z0-9\r]+")) errors.add("${notification.floorplan_editor.error.title}");
- if (map.isEmpty() || map.replace("x", "").replace(((char) 13) + "", "").length() == 0) {
- errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}");
- }
+ Arrays.stream(mapRows)
+ .filter(line -> line.length() != firstRowSize)
+ .findAny()
+ .ifPresent(s -> errors.add("(General): Line " + (Arrays.asList(mapRows).indexOf(s) + 1) + " is of different length than line 1"));
- int lengthX = -1;
- int lengthY = -1;
+ if (map.isEmpty() || map.replace("x", "").replace("\r", "").isEmpty()) {
+ errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}");
+ }
- String[] data = map.split(((char) 13) + "");
-
- if (errors.isEmpty()) {
if (map.length() > 64 * 64) {
errors.add("${notification.floorplan_editor.error.message.too_large_area}");
}
-
- lengthY = data.length;
- if (data.length > 64) {
- errors.add("${notification.floorplan_editor.error.message.too_large_height}");
- } else {
- for (String s : data) {
- if (lengthX == -1) {
- lengthX = s.length();
- }
-
- if (s.length() != lengthX) {
- break;
- }
-
- if (s.length() > 64 || s.length() == 0) {
- errors.add("${notification.floorplan_editor.error.message.too_large_width}");
- }
- }
- }
+ if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}");
+ else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}");
}
int doorX = this.packet.readInt();
int doorY = this.packet.readInt();
- if (doorX < 0 || doorX > lengthX || doorY < 0 || doorY > lengthY || data[doorY].charAt(doorX) == 'x') {
+ if (doorX < 0 || doorX > firstRowSize || doorY < 0 || doorY >= mapRows.length) {
errors.add("${notification.floorplan_editor.error.message.entry_tile_outside_map}");
}
- int doorRotation = this.packet.readInt();
+ if (doorY < mapRows.length && doorX < mapRows[doorY].length() && mapRows[doorY].charAt(doorX) == 'x') {
+ errors.add("${notification.floorplan_editor.error.message.entry_not_on_tile}");
+ }
+ int doorRotation = this.packet.readInt();
if (doorRotation < 0 || doorRotation > 7) {
errors.add("${notification.floorplan_editor.error.message.invalid_entry_tile_direction}");
}
@@ -108,8 +85,8 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
if (floorSize < -2 || floorSize > 1) {
errors.add("${notification.floorplan_editor.error.message.invalid_floor_thickness}");
}
- int wallHeight = -1;
+ int wallHeight = -1;
if (this.packet.bytesAvailable() >= 4)
wallHeight = this.packet.readInt();
@@ -117,12 +94,18 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}");
}
- if (!errors.isEmpty()) {
- StringBuilder errorMessage = new StringBuilder();
- for (String s : errors) {
- errorMessage.append(s).append("
");
+ blockingRoomItemScan:
+ for (int y = 0; y < mapRows.length; y++) {
+ for (int x = 0; x < firstRowSize; x++) {
+ if (mapRows[y].charAt(x) == "x".charAt(0) && room.getTopItemAt(x, y) != null) {
+ errors.add("${notification.floorplan_editor.error.message.change_blocked_by_room_item}");
+ break blockingRoomItemScan;
+ }
}
- this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errorMessage.toString()));
+ }
+
+ if (errors.length() > 0) {
+ this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FLOORPLAN_EDITOR_ERROR.key, errors.toString()));
return;
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java
index 185e2d47..a2624748 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/friends/InviteFriendsEvent.java
@@ -17,6 +17,8 @@ public class InviteFriendsEvent extends MessageHandler {
String message = this.packet.readString();
+ message = Emulator.getGameEnvironment().getWordFilter().filter(message, this.client.getHabbo());
+
for (int i : userIds) {
if (i == 0)
continue;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java
index 84bbb3fa..a26dbcc5 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveAdminEvent.java
@@ -22,19 +22,20 @@ public class GuildRemoveAdminEvent extends MessageHandler {
int userId = this.packet.readInt();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId());
- Emulator.getGameEnvironment().getGuildManager().removeAdmin(guild, userId);
+ Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
- Habbo habbo = room.getHabbo(userId);
GuildRemovedAdminEvent removedAdminEvent = new GuildRemovedAdminEvent(guild, userId, habbo);
Emulator.getPluginManager().fireEvent(removedAdminEvent);
if (removedAdminEvent.isCancelled())
return;
+ Emulator.getGameEnvironment().getGuildManager().removeAdmin(guild, userId);
+
if (habbo != null) {
habbo.getClient().sendResponse(new GuildInfoComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId)));
- room.refreshRightsForHabbo(habbo);
+ if (room != null && habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom() == room) room.refreshRightsForHabbo(habbo);
}
GuildMember guildMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId);
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java
index 5aaf3e7f..9f92df68 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildRemoveFavoriteEvent.java
@@ -3,6 +3,8 @@ package com.eu.habbo.messages.incoming.guilds;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.guilds.GuildFavoriteRoomUserUpdateComposer;
+import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersAddGuildBadgeComposer;
import com.eu.habbo.messages.outgoing.users.UserProfileComposer;
import com.eu.habbo.plugin.events.guilds.GuildRemovedFavoriteEvent;
@@ -20,6 +22,10 @@ public class GuildRemoveFavoriteEvent extends MessageHandler {
this.client.getHabbo().getHabboStats().guild = 0;
+ if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null && guild != null) {
+ this.client.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new GuildFavoriteRoomUserUpdateComposer(this.client.getHabbo().getRoomUnit(), guild).compose());
+ }
+
this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client));
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
index 0a449e62..b1c1e873 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/RequestGuildMembersEvent.java
@@ -21,7 +21,7 @@ public class RequestGuildMembersEvent extends MessageHandler {
boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin");
if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo());
- isAdmin = member != null && member.getRank().equals(GuildRank.ADMIN);
+ isAdmin = member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.MOD));
}
this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), this.client.getHabbo(), pageId, levelId, query, isAdmin, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, pageId, levelId, query)));
diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java
index fd50c886..7be07c04 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/MachineIDEvent.java
@@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.handshake;
+import com.eu.habbo.messages.NoAuthMessage;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.handshake.MachineIDComposer;
+@NoAuthMessage
public class MachineIDEvent extends MessageHandler {
@Override
diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java
index 4dfe71ae..e9ea57e1 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/ReleaseVersionEvent.java
@@ -1,7 +1,9 @@
package com.eu.habbo.messages.incoming.handshake;
+import com.eu.habbo.messages.NoAuthMessage;
import com.eu.habbo.messages.incoming.MessageHandler;
+@NoAuthMessage
public class ReleaseVersionEvent extends MessageHandler {
@Override
diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
index a899c5b0..6759a1e6 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/SecureLoginEvent.java
@@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboManager;
+import com.eu.habbo.messages.NoAuthMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer;
@@ -31,6 +32,7 @@ import com.eu.habbo.plugin.events.users.UserLoginEvent;
import java.util.ArrayList;
+@NoAuthMessage
public class SecureLoginEvent extends MessageHandler {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java
index 62b4d631..aa4d946f 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/handshake/UsernameEvent.java
@@ -83,8 +83,8 @@ public class UsernameEvent extends MessageHandler {
}
}
- if (calendar && Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
- this.client.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true));
+ if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
+ this.client.sendResponse(new AdventCalendarDataComposer("xmas15", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), this.client.getHabbo().getHabboStats().calendarRewardsClaimed, true));
this.client.sendResponse(new NuxAlertComposer("openView/calendar"));
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java
index 50757290..4eb2756e 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ModToolRequestIssueChatlogEvent.java
@@ -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());
}
}
+ } else if (issue.type == ModToolTicketType.PHOTO) {
+ if (issue.photoItem != null) {
+ chatlogType = ModToolIssueChatlogType.PHOTO;
+
+ chatlog = Emulator.getGameEnvironment().getModToolManager().getRoomChatlog(issue.roomId);
+ }
} else {
chatlogType = ModToolIssueChatlogType.CHAT;
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java
new file mode 100644
index 00000000..04b75b4f
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/ReportPhotoEvent.java
@@ -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);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java
index d689a80a..bf3842ce 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/RoomPlaceItemEvent.java
@@ -75,8 +75,6 @@ public class RoomPlaceItemEvent extends MessageHandler {
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
return;
}
-
- return;
}
RoomTile tile = room.getLayout().getTile(x, y);
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
index 66f02e49..c64d111e 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/ToggleFloorItemEvent.java
@@ -31,6 +31,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
if (item == null || item instanceof InteractionDice)
return;
+ /*
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
THashSet items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
HabboItem totemLeg = null;
@@ -75,7 +76,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
}
}
}
- }
+ }*/
//Do not move to onClick(). Wired could trigger it.
if (item instanceof InteractionMonsterPlantSeed) {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java
index 3e1200e6..3b2aaf93 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserSignEvent.java
@@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.rooms.users;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.items.interactions.InteractionVoteCounter;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
+import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.users.UserSignEvent;
@@ -20,6 +22,16 @@ public class RoomUserSignEvent extends MessageHandler {
if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) {
this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + "");
this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo());
+
+ if(signId <= 10) {
+
+ int userId = this.client.getHabbo().getHabboInfo().getId();
+ for (HabboItem item : room.getFloorItems()) {
+ if (item instanceof InteractionVoteCounter) {
+ ((InteractionVoteCounter)item).vote(room, userId, signId);
+ }
+ }
+ }
}
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
index 08966a11..815fe3e0 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java
@@ -11,32 +11,29 @@ import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent;
-import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler {
@Override
- public void handle() throws Exception
- {
- if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null)
- {
- int x = this.packet.readInt(); ///< Position X
- int y = this.packet.readInt(); /// suggestions = new ArrayList<>(4);
@@ -32,7 +26,7 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler {
errorCode = ChangeNameCheckResultComposer.TOO_SHORT;
} else if (name.length() > 15) {
errorCode = ChangeNameCheckResultComposer.TOO_LONG;
- } else if (HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) {
+ } else if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername()) || HabboManager.getOfflineHabboInfo(name) != null || ConfirmChangeNameEvent.changingUsernames.contains(name.toLowerCase())) {
errorCode = ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS;
suggestions.add(name + Emulator.getRandom().nextInt(9999));
suggestions.add(name + Emulator.getRandom().nextInt(9999));
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java
index 6ac6c009..d171c3b2 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarDataComposer.java
@@ -28,33 +28,28 @@ public class AdventCalendarDataComposer extends MessageComposer {
this.response.appendString("");
this.response.appendInt(this.currentDay);
this.response.appendInt(this.totalDays);
-
this.response.appendInt(this.unlocked.size());
TIntArrayList expired = new TIntArrayList();
for (int i = 0; i < this.totalDays; i++) {
expired.add(i);
- expired.remove(this.currentDay);
}
+ expired.remove(this.currentDay);
+ if(this.currentDay > 1) expired.remove(this.currentDay - 2);
+ if(this.currentDay > 0) expired.remove(this.currentDay - 1);
- this.unlocked.forEach(new TIntProcedure() {
- @Override
- public boolean execute(int value) {
- AdventCalendarDataComposer.this.response.appendInt(value);
- expired.remove(value);
- return true;
- }
+ this.unlocked.forEach(value -> {
+ AdventCalendarDataComposer.this.response.appendInt(value);
+ expired.remove(value);
+ return true;
});
if (this.lockExpired) {
this.response.appendInt(expired.size());
- expired.forEach(new TIntProcedure() {
- @Override
- public boolean execute(int value) {
- AdventCalendarDataComposer.this.response.appendInt(value);
- return true;
- }
+ expired.forEach(value -> {
+ AdventCalendarDataComposer.this.response.appendInt(value);
+ return true;
});
} else {
this.response.appendInt(0);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java
index 5352d886..15c08771 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/events/calendar/AdventCalendarProductComposer.java
@@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.events.calendar;
import com.eu.habbo.habbohotel.catalog.CalendarRewardObject;
+import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
@@ -18,9 +19,9 @@ public class AdventCalendarProductComposer extends MessageComposer {
public ServerMessage compose() {
this.response.init(Outgoing.AdventCalendarProductComposer);
this.response.appendBoolean(this.visible);
- this.response.appendString(this.rewardObject.getName());
+ this.response.appendString(this.rewardObject.getItem().getName());
this.response.appendString(this.rewardObject.getCustomImage());
- this.response.appendString(this.rewardObject.getCatalogItem() != null ? this.rewardObject.getCatalogItem().getName() : this.rewardObject.getName());
+ this.response.appendString(this.rewardObject.getItem().getName());
return this.response;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java
index 8f3ccc3b..46caa6b9 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/FriendsComposer.java
@@ -36,7 +36,7 @@ public class FriendsComposer extends MessageComposer {
this.response.appendInt(row.getValue().getGender().equals(HabboGender.M) ? 0 : 1);
this.response.appendBoolean(row.getValue().getOnline() == 1);
this.response.appendBoolean(row.getValue().inRoom()); //IN ROOM
- this.response.appendString(row.getValue().getLook());
+ this.response.appendString(row.getValue().getOnline() == 1 ? row.getValue().getLook() : "");
this.response.appendInt(0);
this.response.appendString(row.getValue().getMotto());
this.response.appendString("");
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java
index d27df321..0bb07e6b 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/friends/UserSearchResultComposer.java
@@ -7,11 +7,17 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.set.hash.THashSet;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+
public class UserSearchResultComposer extends MessageComposer {
private final THashSet users;
private final THashSet friends;
private final Habbo habbo;
+ private static Comparator COMPARATOR = Comparator.comparing((MessengerBuddy b) -> b.getUsername().length()).thenComparing((MessengerBuddy b, MessengerBuddy b2) -> b.getUsername().compareToIgnoreCase(b2.getUsername()));
+
public UserSearchResultComposer(THashSet users, THashSet friends, Habbo habbo) {
this.users = users;
this.friends = friends;
@@ -21,14 +27,19 @@ public class UserSearchResultComposer extends MessageComposer {
@Override
public ServerMessage compose() {
this.response.init(Outgoing.UserSearchResultComposer);
- THashSet u = new THashSet<>();
+ List u = new ArrayList<>();
for (MessengerBuddy buddy : this.users) {
- if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) {
+ if (!this.inFriendList(buddy)) {
u.add(buddy);
}
}
+ List friends = new ArrayList<>(this.friends);
+
+ u.sort(UserSearchResultComposer.COMPARATOR);
+ friends.sort(UserSearchResultComposer.COMPARATOR);
+
this.response.appendInt(this.friends.size());
for (MessengerBuddy buddy : this.friends) {
this.response.appendInt(buddy.getId());
@@ -51,7 +62,7 @@ public class UserSearchResultComposer extends MessageComposer {
this.response.appendBoolean(false);
this.response.appendString("");
this.response.appendInt(1);
- this.response.appendString(buddy.getLook());
+ this.response.appendString(buddy.getOnline() == 1 ? buddy.getLook() : "");
this.response.appendString("");
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
index fea8a93e..f52c7dff 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/guilds/GuildMembersComposer.java
@@ -52,7 +52,7 @@ public class GuildMembersComposer extends MessageComposer {
this.response.appendString(member.getRank().type < 3 && member.getRank().type > 0 ? cal.get(Calendar.DAY_OF_MONTH) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR) : "");
}
- this.response.appendBoolean(this.isAdmin); //Is owner
+ this.response.appendBoolean(this.isAdmin);
this.response.appendInt(14);
this.response.appendInt(this.pageId);
this.response.appendInt(this.level);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
index ddf8bd80..157c53c9 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/inventory/UserEffectsListComposer.java
@@ -19,21 +19,29 @@ public class UserEffectsListComposer extends MessageComposer {
public ServerMessage compose() {
this.response.init(Outgoing.UserEffectsListComposer);
- synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
- this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size());
- this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure() {
- @Override
- public boolean execute(EffectsComponent.HabboEffect effect) {
+ if (this.habbo == null || this.habbo.getInventory() == null || this.habbo.getInventory().getEffectsComponent() == null || this.habbo.getInventory().getEffectsComponent().effects == null) {
+ this.response.appendInt(0);
+ } else {
+ synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
+ this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size());
+ this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> {
UserEffectsListComposer.this.response.appendInt(effect.effect);
UserEffectsListComposer.this.response.appendInt(0);
- UserEffectsListComposer.this.response.appendInt(effect.duration);
- UserEffectsListComposer.this.response.appendInt(effect.total);
- UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1);
- UserEffectsListComposer.this.response.appendBoolean(effect.isActivated());
+ UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : 1);
+ UserEffectsListComposer.this.response.appendInt(effect.total - (effect.isActivated() ? 1 : 0));
+
+ if(!effect.isActivated()) {
+ UserEffectsListComposer.this.response.appendInt(0);
+ }
+ else {
+ UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? (Emulator.getIntUnixTimestamp() - effect.activationTimestamp) + effect.duration : -1);
+ }
+ UserEffectsListComposer.this.response.appendBoolean(effect.duration <= 0); //effect.isActivated());
return true;
- }
- });
+ });
+ }
}
+
return this.response;
}
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
index 8eef3dc8..dd73279a 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/modtool/ModToolIssueChatlogComposer.java
@@ -8,7 +8,6 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -65,6 +64,14 @@ public class ModToolIssueChatlogComposer extends MessageComposer {
ModToolChatRecordDataContext.GROUP_ID.append(this.response);
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 {
this.response.appendShort(3); //Context Count
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java
index 5fbe97bc..93845f71 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/navigator/NewNavigatorSavedSearchesComposer.java
@@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import java.util.HashSet;
+import java.util.List;
public class NewNavigatorSavedSearchesComposer extends MessageComposer {
- private final HashSet searches;
+ private final List searches;
- public NewNavigatorSavedSearchesComposer(HashSet searches) {
+ public NewNavigatorSavedSearchesComposer(List searches) {
this.searches = searches;
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
index 4f6c3b67..5a99f16c 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/UpdateStackHeightComposer.java
@@ -25,8 +25,21 @@ public class UpdateStackHeightComposer extends MessageComposer {
@Override
public ServerMessage compose() {
+ //TODO: THIS IS A TEMP FIX. THERE IS AN ISSUE WITH BAD PACKET STRUCTURE HERE CAUSING ISSUES WITH MOVING LARGE FURNITURE
this.response.init(Outgoing.UpdateStackHeightComposer);
if (this.updateTiles != null) {
+ if(this.updateTiles.size() > 4) {
+ RoomTile[] tiles = (RoomTile[])this.updateTiles.toArray();
+ this.response.appendByte(4);
+ for(int i = 0; i < 4; i++) {
+ RoomTile t = tiles[i];
+ this.response.appendByte((int) t.x);
+ this.response.appendByte((int) t.y);
+ this.response.appendShort(t.relativeHeight());
+ }
+ return this.response;
+ }
+
this.response.appendByte(this.updateTiles.size());
for (RoomTile t : this.updateTiles) {
this.response.appendByte((int) t.x);
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
index 8537ac4a..9f30152a 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/users/RoomUnitOnRollerComposer.java
@@ -55,7 +55,7 @@ public class RoomUnitOnRollerComposer extends MessageComposer {
this.response.appendString(this.oldZ + "");
this.response.appendString(this.newZ + "");
- if (this.roller != null) {
+ if (this.roller != null && room.getLayout() != null) {
RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY());
Emulator.getThreading().run(() -> {
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java
index 07e0556f..3f28f45c 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/trading/TradeUpdateComposer.java
@@ -20,8 +20,8 @@ public class TradeUpdateComposer extends MessageComposer {
this.response.init(Outgoing.TradeUpdateComposer);
for (RoomTradeUser roomTradeUser : this.roomTrade.getRoomTradeUsers()) {
this.response.appendInt(roomTradeUser.getUserId());
- this.response.appendInt(roomTradeUser.getItems().size());
+ this.response.appendInt(roomTradeUser.getItems().size());
for (HabboItem item : roomTradeUser.getItems()) {
this.response.appendInt(item.getId());
this.response.appendString(item.getBaseItem().getType().code);
@@ -38,8 +38,8 @@ public class TradeUpdateComposer extends MessageComposer {
this.response.appendInt(0);
}
- this.response.appendInt(0);
- this.response.appendInt(0);
+ this.response.appendInt(roomTradeUser.getItems().size());
+ this.response.appendInt(roomTradeUser.getItems().stream().mapToInt(RoomTrade::getCreditsByItem).sum());
}
return this.response;
}
diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java
index 80f56a9b..9881701a 100644
--- a/src/main/java/com/eu/habbo/plugin/PluginManager.java
+++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java
@@ -20,12 +20,14 @@ import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboInventory;
import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.habbohotel.wired.WiredHandler;
+import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
import com.eu.habbo.messages.PacketManager;
import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent;
import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent;
import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent;
import com.eu.habbo.messages.outgoing.catalog.DiscountComposer;
import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
+import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent;
import com.eu.habbo.plugin.events.users.*;
import com.eu.habbo.threading.runnables.RoomTrashing;
@@ -80,6 +82,7 @@ public class PluginManager {
Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.max.friends.hc");
Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room");
Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room");
+ Room.MAXIMUM_FURNI = Emulator.getConfig().getInt("hotel.room.furni.max", 2500);
Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
Room.IDLE_CYCLES = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles", 240);
Room.IDLE_CYCLES_KICK = Emulator.getConfig().getInt("hotel.roomuser.idle.cycles.kick", 480);
@@ -126,6 +129,8 @@ public class PluginManager {
Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig();
Emulator.getGameEnvironment().getPointsScheduler().reloadConfig();
Emulator.getGameEnvironment().getPixelScheduler().reloadConfig();
+ Emulator.getGameEnvironment().getGotwPointsScheduler().reloadConfig();
+
}
}
@@ -202,7 +207,7 @@ public class PluginManager {
}
}
- public Event fireEvent(Event event) {
+ public T fireEvent(T event) {
for (Method method : this.methods) {
if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].isAssignableFrom(event.getClass())) {
try {
@@ -320,6 +325,7 @@ public class PluginManager {
this.methods.add(InteractionFootballGate.class.getMethod("onUserExitRoomEvent", UserExitRoomEvent.class));
this.methods.add(InteractionFootballGate.class.getMethod("onUserSavedLookEvent", UserSavedLookEvent.class));
this.methods.add(PluginManager.class.getMethod("globalOnConfigurationUpdated", EmulatorConfigUpdatedEvent.class));
+ this.methods.add(WiredHighscoreManager.class.getMethod("onEmulatorLoaded", EmulatorLoadedEvent.class));
} catch (NoSuchMethodException e) {
Emulator.getLogging().logStart("Failed to define default events!");
Emulator.getLogging().logErrorLine(e);
diff --git a/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java
new file mode 100644
index 00000000..cac45ea8
--- /dev/null
+++ b/src/main/java/com/eu/habbo/plugin/events/rooms/UserVoteRoomEvent.java
@@ -0,0 +1,15 @@
+package com.eu.habbo.plugin.events.rooms;
+
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.plugin.Event;
+
+public class UserVoteRoomEvent extends Event {
+ public final Room room;
+ public final Habbo habbo;
+
+ public UserVoteRoomEvent(Room room, Habbo habbo) {
+ this.room = room;
+ this.habbo = habbo;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
index be861f8a..d31f4a6c 100644
--- a/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
+++ b/src/main/java/com/eu/habbo/plugin/events/users/HabboAddedToRoomEvent.java
@@ -3,14 +3,18 @@ package com.eu.habbo.plugin.events.users;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
+import java.util.Collection;
+
public class HabboAddedToRoomEvent extends UserEvent {
public final Room room;
+ public final Collection habbosToSendEnter;
- public HabboAddedToRoomEvent(Habbo habbo, Room room) {
+ public HabboAddedToRoomEvent(Habbo habbo, Room room, Collection habbosToSendEnter) {
super(habbo);
this.room = room;
+ this.habbosToSendEnter = habbosToSendEnter;
}
}
diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java
index f8abd365..674dfba3 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionFive.java
@@ -37,6 +37,8 @@ class TeleportActionFive implements Runnable {
//if (!(this.currentTeleport instanceof InteractionTeleportTile))
+ if (this.room.getLayout() == null || this.currentTeleport == null) return;
+
RoomTile currentLocation = this.room.getLayout().getTile(this.currentTeleport.getX(), this.currentTeleport.getY());
RoomTile tile = this.room.getLayout().getTileInFront(currentLocation, this.currentTeleport.getRotation());
diff --git a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java
index 7701a546..036ce89c 100644
--- a/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java
+++ b/src/main/java/com/eu/habbo/threading/runnables/teleport/TeleportActionThree.java
@@ -65,7 +65,7 @@ class TeleportActionThree implements Runnable {
targetTeleport.setExtradata("2");
targetRoom.updateItem(targetTeleport);
- targetRoom.updateHabbo(this.client.getHabbo());
+ //targetRoom.updateHabbo(this.client.getHabbo());
//System.out.println(targetTeleport.getX() + " | " + targetTeleport.getY());
this.client.getHabbo().getHabboInfo().setCurrentRoom(targetRoom);
//Emulator.getThreading().run(new HabboItemNewState(this.currentTeleport, this.room, "0"), 500);
diff --git a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java
index fb9436ec..2872cad8 100644
--- a/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java
+++ b/src/main/java/com/eu/habbo/util/imager/badges/BadgeImager.java
@@ -53,18 +53,9 @@ public class BadgeImager {
float red = (color.getRed() / 255.0F) * (maskColor.getRed() / 255.0F);
float green = (color.getGreen() / 255.0F) * (maskColor.getGreen() / 255.0F);
float blue = (color.getBlue() / 255.0F) * (maskColor.getBlue() / 255.0F);
-//
-
-
-//
-
-
-//
-
color = new Color(red, green, blue, alpha);
-
int rgb = color.getRGB();
image.setRGB(x, y, rgb);
}
@@ -209,6 +200,8 @@ public class BadgeImager {
part = Emulator.getGameEnvironment().getGuildManager().getPart(GuildPartType.SYMBOL, id);
}
+ if (part == null) continue;
+
BufferedImage imagePart = BadgeImager.deepCopy(this.cachedImages.get(part.valueA));
Point point;