Merge branch 'dev' into 'master'

2.2.0 Stable.

See merge request morningstar/Arcturus-Community!62
This commit is contained in:
Harmonic 2020-01-14 14:49:55 -05:00
commit bc3ce27cad
108 changed files with 1758 additions and 594 deletions

View File

@ -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). Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
## Versions ## ## 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/VERSION-2.2.0-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/STATUS-UNSTABLE-red.svg?style=for-the-badge&logo=appveyor)
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/releases

View File

@ -6,7 +6,7 @@
<groupId>com.eu.habbo</groupId> <groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId> <artifactId>Habbo</artifactId>
<version>2.1.0</version> <version>2.2.0</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -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 '';

View File

@ -0,0 +1 @@
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_badge.unknown_user', 'Failed to find the given user.');

View File

@ -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';

View File

@ -18,10 +18,7 @@ import com.eu.habbo.plugin.events.emulator.EmulatorStoppedEvent;
import com.eu.habbo.threading.ThreadPooling; import com.eu.habbo.threading.ThreadPooling;
import com.eu.habbo.util.imager.badges.BadgeImager; import com.eu.habbo.util.imager.badges.BadgeImager;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.security.MessageDigest; import java.security.MessageDigest;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
@ -34,10 +31,10 @@ public final class Emulator {
public final static int MAJOR = 2; 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"; public final static String PREVIEW = "Stable";
@ -51,7 +48,7 @@ public final class Emulator {
" / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" + " / /|_/ / __ \\/ ___/ __ \\/ / __ \\/ __ `/ ___/ __/ __ `/ ___/ \n" +
" / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" + " / / / / /_/ / / / / / / / / / / /_/ (__ ) /_/ /_/ / / \n" +
"/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" + "/_/ /_/\\____/_/ /_/ /_/_/_/ /_/\\__, /____/\\__/\\__,_/_/ \n" +
" /____/ \n"; " /____/ \n" ;
public static String build = ""; public static String build = "";
public static boolean isReady = false; public static boolean isReady = false;
public static boolean isShuttingDown = false; public static boolean isShuttingDown = false;
@ -117,8 +114,7 @@ public final class Emulator {
Emulator.rconServer.initializePipeline(); Emulator.rconServer.initializePipeline();
Emulator.rconServer.connect(); Emulator.rconServer.connect();
Emulator.badgeImager = new BadgeImager(); Emulator.badgeImager = new BadgeImager();
Emulator.getLogging().logStart("Habbo Hotel Emulator has succesfully loaded."); Emulator.getLogging().logStart("Arcturus Morningstar has succesfully loaded. You're running: " + Emulator.version);
Emulator.getLogging().logStart("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("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"); 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() { Emulator.getThreading().run(() -> {
@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("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("https://discord.gg/syuqgN");
Emulator.getLogging().logStart("Please report bugs on our git at Krews.org. Not on our discord!!"); Emulator.getLogging().logStart("Please report bugs on our git at Krews.org.");
System.out.println("Waiting for commands: "); System.out.println("Waiting for commands: ");
} }, 1500);
}, 3500);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
while (!isShuttingDown && isReady && reader.ready()) { while (!isShuttingDown && isReady) {
try { try {
String line = reader.readLine(); String line = reader.readLine();
@ -160,9 +152,11 @@ public final class Emulator {
} }
System.out.println("Waiting for command: "); System.out.println("Waiting for command: ");
} catch (Exception e) { } catch (Exception e) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
} }
} }
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -181,12 +175,9 @@ public final class Emulator {
FileInputStream fis = new FileInputStream(filepath); FileInputStream fis = new FileInputStream(filepath);
byte[] dataBytes = new byte[1024]; byte[] dataBytes = new byte[1024];
int nread = 0; int nread = 0;
while ((nread = fis.read(dataBytes)) != -1) while ((nread = fis.read(dataBytes)) != -1)
md.update(dataBytes, 0, nread); md.update(dataBytes, 0, nread);
byte[] mdbytes = md.digest(); byte[] mdbytes = md.digest();
for (int i = 0; i < mdbytes.length; i++) for (int i = 0; i < mdbytes.length; i++)
sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1)); sb.append(Integer.toString((mdbytes[i] & 0xff) + 0x100, 16).substring(1));
} catch (Exception e) { } catch (Exception e) {

View File

@ -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"); 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")) { 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() - 86400); statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.execute(); statement.execute();
} }

View File

@ -8,14 +8,10 @@ import java.util.Map;
public class CreditsScheduler extends Scheduler { public class CreditsScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED; public static boolean IGNORE_IDLED;
public static int CREDITS;
public CreditsScheduler() { public CreditsScheduler() {
super(Emulator.getConfig().getInt("hotel.auto.credits.interval")); super(Emulator.getConfig().getInt("hotel.auto.credits.interval"));
this.reloadConfig(); this.reloadConfig();
} }
@ -24,7 +20,6 @@ public class CreditsScheduler extends Scheduler {
if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) { if (Emulator.getConfig().getBoolean("hotel.auto.credits.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview"); IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.credits.ignore.idled");
CREDITS = Emulator.getConfig().getInt("hotel.auto.credits.amount");
if (this.disposed) { if (this.disposed) {
this.disposed = false; this.disposed = false;
this.run(); this.run();
@ -50,7 +45,7 @@ public class CreditsScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue; continue;
habbo.giveCredits(CREDITS); habbo.giveCredits(habbo.getHabboInfo().getRank().getCreditsTimerAmount());
} }
} catch (Exception e) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);

View File

@ -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<Integer, Habbo> 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;
}
}

View File

@ -8,47 +8,17 @@ import java.util.Map;
public class PixelScheduler extends Scheduler { public class PixelScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED; public static boolean IGNORE_IDLED;
private static int PIXELS;
public PixelScheduler() { public PixelScheduler() {
super(Emulator.getConfig().getInt("hotel.auto.pixels.interval")); super(Emulator.getConfig().getInt("hotel.auto.pixels.interval"));
this.reloadConfig(); 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() { public void reloadConfig() {
if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) { if (Emulator.getConfig().getBoolean("hotel.auto.pixels.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview"); IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.pixels.ignore.idled");
PIXELS = Emulator.getConfig().getInt("hotel.auto.pixels.amount");
if (this.disposed) { if (this.disposed) {
this.disposed = false; this.disposed = false;
this.run(); this.run();
@ -65,7 +35,6 @@ public class PixelScheduler extends Scheduler {
Habbo habbo; Habbo habbo;
for (Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { for (Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
habbo = map.getValue(); habbo = map.getValue();
try { try {
if (habbo != null) { if (habbo != null) {
if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW) if (habbo.getHabboInfo().getCurrentRoom() == null && IGNORE_HOTEL_VIEW)
@ -74,7 +43,7 @@ public class PixelScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue; continue;
habbo.givePixels(PIXELS); habbo.givePixels(habbo.getHabboInfo().getRank().getPixelsTimerAmount());
} }
} catch (Exception e) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);

View File

@ -8,47 +8,18 @@ import java.util.Map;
public class PointsScheduler extends Scheduler { public class PointsScheduler extends Scheduler {
public static boolean IGNORE_HOTEL_VIEW; public static boolean IGNORE_HOTEL_VIEW;
public static boolean IGNORE_IDLED; public static boolean IGNORE_IDLED;
private static int POINTS;
public PointsScheduler() { public PointsScheduler() {
super(Emulator.getConfig().getInt("hotel.auto.points.interval")); super(Emulator.getConfig().getInt("hotel.auto.points.interval"));
this.reloadConfig(); 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() { public void reloadConfig() {
if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) { if (Emulator.getConfig().getBoolean("hotel.auto.points.enabled")) {
IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview"); IGNORE_HOTEL_VIEW = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.hotelview");
IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled"); IGNORE_IDLED = Emulator.getConfig().getBoolean("hotel.auto.points.ignore.idled");
POINTS = Emulator.getConfig().getInt("hotel.auto.points.amount");
if (this.disposed) { if (this.disposed) {
this.disposed = false; this.disposed = false;
this.run(); this.run();
@ -74,7 +45,8 @@ public class PointsScheduler extends Scheduler {
if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED) if (habbo.getRoomUnit().isIdle() && IGNORE_IDLED)
continue; continue;
habbo.givePoints(POINTS); //habbo.givePoints(POINTS);
habbo.givePoints(habbo.getHabboInfo().getRank().getDiamondsTimerAmount());
} }
} catch (Exception e) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.core.CreditsScheduler; import com.eu.habbo.core.CreditsScheduler;
import com.eu.habbo.core.GotwPointsScheduler;
import com.eu.habbo.core.PixelScheduler; import com.eu.habbo.core.PixelScheduler;
import com.eu.habbo.core.PointsScheduler; import com.eu.habbo.core.PointsScheduler;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
@ -26,6 +27,7 @@ public class GameEnvironment {
public CreditsScheduler creditsScheduler; public CreditsScheduler creditsScheduler;
public PixelScheduler pixelScheduler; public PixelScheduler pixelScheduler;
public PointsScheduler pointsScheduler; public PointsScheduler pointsScheduler;
public GotwPointsScheduler gotwPointsScheduler;
private HabboManager habboManager; private HabboManager habboManager;
private NavigatorManager navigatorManager; private NavigatorManager navigatorManager;
private GuildManager guildManager; private GuildManager guildManager;
@ -76,6 +78,9 @@ public class GameEnvironment {
Emulator.getThreading().run(this.pixelScheduler); Emulator.getThreading().run(this.pixelScheduler);
this.pointsScheduler = new PointsScheduler(); this.pointsScheduler = new PointsScheduler();
Emulator.getThreading().run(this.pointsScheduler); Emulator.getThreading().run(this.pointsScheduler);
this.gotwPointsScheduler = new GotwPointsScheduler();
Emulator.getThreading().run(this.gotwPointsScheduler);
Emulator.getLogging().logStart("GameEnvironment -> Loaded!"); Emulator.getLogging().logStart("GameEnvironment -> Loaded!");
} }
@ -84,6 +89,7 @@ public class GameEnvironment {
this.pointsScheduler.setDisposed(true); this.pointsScheduler.setDisposed(true);
this.pixelScheduler.setDisposed(true); this.pixelScheduler.setDisposed(true);
this.creditsScheduler.setDisposed(true); this.creditsScheduler.setDisposed(true);
this.gotwPointsScheduler.setDisposed(true);
this.craftingManager.dispose(); this.craftingManager.dispose();
this.habboManager.dispose(); this.habboManager.dispose();
this.commandHandler.dispose(); this.commandHandler.dispose();
@ -171,7 +177,9 @@ public class GameEnvironment {
return this.pixelScheduler; return this.pixelScheduler;
} }
public PointsScheduler getPointsScheduler() { public PointsScheduler getPointsScheduler() { return this.pointsScheduler;
return this.pointsScheduler; }
public GotwPointsScheduler getGotwPointsScheduler() { return this.gotwPointsScheduler;
} }
} }

View File

@ -1,30 +1,32 @@
package com.eu.habbo.habbohotel.catalog; package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator; 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.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.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
public class CalendarRewardObject { public class CalendarRewardObject {
private final int id; private final int id;
private final String name;
private final String customImage; private final String customImage;
private final int credits; private final int credits;
private final int points; private final int points;
private final int pointsType; private final int pointsType;
private final String badge; private final String badge;
private final int catalogItemId; private final int itemId;
public CalendarRewardObject(ResultSet set) throws SQLException { public CalendarRewardObject(ResultSet set) throws SQLException {
this.id = set.getInt("id"); this.id = set.getInt("id");
this.name = set.getString("name");
this.customImage = set.getString("custom_image"); this.customImage = set.getString("custom_image");
this.credits = set.getInt("credits"); this.credits = set.getInt("credits");
this.points = set.getInt("points"); this.points = set.getInt("points");
this.pointsType = set.getInt("points_type"); this.pointsType = set.getInt("points_type");
this.badge = set.getString("badge"); this.badge = set.getString("badge");
this.catalogItemId = set.getInt("catalog_item_id"); this.itemId = set.getInt("item_id");
} }
public void give(Habbo habbo) { public void give(Habbo habbo) {
@ -40,11 +42,19 @@ public class CalendarRewardObject {
habbo.addBadge(this.badge); habbo.addBadge(this.badge);
} }
if (this.catalogItemId > 0) { if (this.itemId > 0) {
CatalogItem item = this.getCatalogItem(); Item item = getItem();
if (item != null) { 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; return this.id;
} }
public String getName() {
return this.name;
}
public String getCustomImage() { public String getCustomImage() {
return this.customImage; return this.customImage;
} }
@ -77,7 +83,7 @@ public class CalendarRewardObject {
return this.badge; return this.badge;
} }
public CatalogItem getCatalogItem() { public Item getItem() {
return Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.catalogItemId); return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId);
} }
} }

View File

@ -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.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; 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.AddUserBadgeComposer;
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer; import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
import com.eu.habbo.messages.outgoing.users.UserPointsComposer; import com.eu.habbo.messages.outgoing.users.UserPointsComposer;
@ -283,9 +284,7 @@ public class CatalogManager {
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);
} }
pages.forEachValue(new TObjectProcedure<CatalogPage>() { pages.forEachValue((object) -> {
@Override
public boolean execute(CatalogPage object) {
CatalogPage page = pages.get(object.parentId); CatalogPage page = pages.get(object.parentId);
if (page != null) { if (page != null) {
@ -298,7 +297,6 @@ public class CatalogManager {
} }
} }
return true; return true;
}
}); });
this.catalogPages.putAll(pages); this.catalogPages.putAll(pages);
@ -536,9 +534,32 @@ public class CatalogManager {
public void redeemVoucher(GameClient client, String voucherCode) { public void redeemVoucher(GameClient client, String voucherCode) {
Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode); Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode);
if (voucher != null) { if (voucher == null) {
if (Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) { client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE));
client.getHabbo().getHabboInfo().addCredits(voucher.credits); return;
}
Habbo habbo = client.getHabbo();
if (habbo == null) return;
if (voucher.isExhausted()) {
if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) {
client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR));
}
}
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) { if (voucher.points > 0) {
client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points); client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points);
@ -559,12 +580,6 @@ public class CatalogManager {
} }
client.sendResponse(new RedeemVoucherOKComposer()); client.sendResponse(new RedeemVoucherOKComposer());
return;
}
}
client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE));
} }
@ -1122,15 +1137,15 @@ public class CatalogManager {
return offers; return offers;
} }
public void claimCalendarReward(Habbo habbo, int day) { public void claimCalendarReward(Habbo habbo, int day, boolean force) {
if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) { if (!habbo.getHabboStats().calendarRewardsClaimed.contains(day)) {
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.getHabboStats().calendarRewardsClaimed.add(day);
CalendarRewardObject object = this.calendarRewards.get(day);
if (object != null) {
object.give(habbo);
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object)); 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 (?, ?, ?)")) { 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()); statement.setInt(1, habbo.getHabboInfo().getId());
@ -1141,8 +1156,6 @@ public class CatalogManager {
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);
} }
} }
} }
} }

View File

@ -1,27 +1,24 @@
package com.eu.habbo.habbohotel.catalog; 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.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class Voucher { public class Voucher {
public final int id; public final int id;
public final String code; public final String code;
public final int credits; public final int credits;
public final int points; public final int points;
public final int pointsType; public final int pointsType;
public final int catalogItemId; public final int catalogItemId;
public final int amount;
public final int limit;
private final List<VoucherHistoryEntry> history = new ArrayList<>();
public Voucher(ResultSet set) throws SQLException { public Voucher(ResultSet set) throws SQLException {
this.id = set.getInt("id"); this.id = set.getInt("id");
@ -30,5 +27,44 @@ public class Voucher {
this.points = set.getInt("points"); this.points = set.getInt("points");
this.pointsType = set.getInt("points_type"); this.pointsType = set.getInt("points_type");
this.catalogItemId = set.getInt("catalog_item_id"); 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);
}
} }
} }

View File

@ -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;
}
}

View File

@ -9,6 +9,17 @@ import java.sql.SQLException;
public class CatalogRootLayout extends CatalogPage { public class CatalogRootLayout extends CatalogPage {
public CatalogRootLayout() { public CatalogRootLayout() {
super(); 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 { public CatalogRootLayout(ResultSet set) throws SQLException {

View File

@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo; 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.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -38,11 +40,18 @@ public class BadgeCommand extends Command {
return true; return true;
} else { } 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()) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
boolean found; 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")) { try (PreparedStatement statement = connection.prepareStatement("SELECT `badge_code` FROM `users_badges` WHERE `user_id` = ? AND `badge_code` = ? LIMIT 1")) {
statement.setString(1, params[1]); statement.setInt(1, habboInfo.getId());
statement.setString(2, params[2]); statement.setString(2, params[2]);
try (ResultSet set = statement.executeQuery()) { try (ResultSet set = statement.executeQuery()) {
found = set.next(); 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); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owns").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT);
return true; return true;
} else { } 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, ?)")) { try (PreparedStatement statement = connection.prepareStatement("INSERT INTO users_badges (`id`, `user_id`, `slot_id`, `badge_code`) VALUES (null, ?, 0, ?)")) {
statement.setString(1, params[1]); statement.setInt(1, habboInfo.getId());
statement.setString(2, params[2]); statement.setString(2, params[2]);
statement.execute(); statement.execute();
} }

View File

@ -17,9 +17,7 @@ public class ReloadRoomCommand extends Command {
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception { public boolean handle(GameClient gameClient, String[] params) throws Exception {
Emulator.getThreading().run(new Runnable() { Emulator.getThreading().run(() -> {
@Override
public void run() {
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom(); Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
if (room != null) { if (room != null) {
Collection<Habbo> habbos = new ArrayList<>(room.getHabbos()); Collection<Habbo> habbos = new ArrayList<>(room.getHabbos());
@ -30,7 +28,6 @@ public class ReloadRoomCommand extends Command {
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
} }
} }
}
}, 100); }, 100);
return true; return true;

View File

@ -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); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_unmute.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
return true; return true;
} else { } 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()) { if (!habbo.getHabboStats().allowTalk()) {
habbo.unMute(); habbo.unMute();
} }
if (habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) { if (habbo.getHabboInfo().getCurrentRoom() != null && habbo.getHabboInfo().getCurrentRoom().isMuted(habbo)) {
habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1); habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1);
} }

View File

@ -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.InteractionWiredHighscore;
import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer; import com.eu.habbo.habbohotel.items.interactions.games.InteractionGameTimer;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; 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.WiredTriggerTeamLoses;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins; import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler; 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.Event;
import com.eu.habbo.plugin.events.games.GameHabboJoinEvent; import com.eu.habbo.plugin.events.games.GameHabboJoinEvent;
import com.eu.habbo.plugin.events.games.GameHabboLeaveEvent; 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 gnu.trove.map.hash.THashMap;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
public abstract class Game implements Runnable { 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()) { for (GameTeam team : this.teams.values()) {
if (team == winningTeam) continue; 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}); 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)) { for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(InteractionWiredHighscore.class)) {
((InteractionWiredHighscore) item).reloadData();
this.room.updateItem(item); 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() { private void saveScores() {
if (this.room == null) if (this.room == null)

View File

@ -27,13 +27,11 @@ public class GamePlayer {
public synchronized void addScore(int amount) { 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().getCurrentGame() != 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; 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}); 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});
} }
} }
}
public Habbo getHabbo() { public Habbo getHabbo() {
return this.habbo; return this.habbo;

View File

@ -1,6 +1,9 @@
package com.eu.habbo.habbohotel.games; package com.eu.habbo.habbohotel.games;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo; 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; import gnu.trove.set.hash.THashSet;
public class GameTeam { 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<GamePlayer> getMembers() { public THashSet<GamePlayer> getMembers() {
return this.members; return this.members;

View File

@ -14,6 +14,8 @@ public class FreezeGameTeam extends GameTeam {
@Override @Override
public void removeMember(GamePlayer gamePlayer) { 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); Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
Room room = gamePlayer.getHabbo().getRoomUnit().getRoom(); Room room = gamePlayer.getHabbo().getRoomUnit().getRoom();

View File

@ -140,14 +140,16 @@ public abstract class TagGame extends Game {
TObjectHashIterator<HabboItem> iterator = poles.iterator(); TObjectHashIterator<HabboItem> iterator = poles.iterator();
if ((iterator.hasNext())) { if ((iterator.hasNext())) {
HabboItem item = iterator.next(); 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); this.taggers.put(habbo, (InteractionTagPole) item);
return true; return true;
} }
} }
} else { } else {
if (this.taggers.isEmpty()) { 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); this.taggers.put(habbo, null);
return true; return true;
} }

View File

@ -1,26 +1,29 @@
package com.eu.habbo.habbohotel.games.wired; package com.eu.habbo.habbohotel.games.wired;
import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.*;
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.freeze.FreezeGame; import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
public class WiredGame extends Game { public class WiredGame extends Game {
public GameState state = GameState.RUNNING;
public WiredGame(Room room) { public WiredGame(Room room) {
super(GameTeam.class, GamePlayer.class, room, false); super(GameTeam.class, GamePlayer.class, room, false);
} }
@Override @Override
public void initialise() { public void initialise() {
this.state = GameState.RUNNING;
for (GameTeam team : this.teams.values()) {
team.resetScores();
}
} }
@Override @Override
public void run() { public void run() {
this.state = GameState.RUNNING;
} }
@Override @Override
@ -34,4 +37,14 @@ public class WiredGame extends Game {
super.removeHabbo(habbo); super.removeHabbo(habbo);
this.room.giveEffect(habbo, 0, -1); this.room.giveEffect(habbo, 0, -1);
} }
@Override
public void stop() {
this.state = GameState.RUNNING;
}
@Override
public GameState getState() {
return GameState.RUNNING;
}
} }

View File

@ -43,6 +43,8 @@ public class CrackableReward {
if (prize.contains(":") && prize.split(":").length == 2) { if (prize.contains(":") && prize.split(":").length == 2) {
itemId = Integer.valueOf(prize.split(":")[0]); itemId = Integer.valueOf(prize.split(":")[0]);
chance = Integer.valueOf(prize.split(":")[1]); 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 { } else {
itemId = Integer.valueOf(prize.replace(":", "")); itemId = Integer.valueOf(prize.replace(":", ""));
} }

View File

@ -33,6 +33,7 @@ public class Item {
private TIntArrayList vendingItems; private TIntArrayList vendingItems;
private double[] multiHeights; private double[] multiHeights;
private String customParams; private String customParams;
private String clothingOnWalk;
private ItemInteraction interactionType; private ItemInteraction interactionType;
@ -93,6 +94,8 @@ public class Item {
this.effectM = set.getShort("effect_id_male"); this.effectM = set.getShort("effect_id_male");
this.effectF = set.getShort("effect_id_female"); this.effectF = set.getShort("effect_id_female");
this.customParams = set.getString("customparams"); this.customParams = set.getString("customparams");
this.clothingOnWalk = set.getString("clothing_on_walk");
if (!set.getString("vending_ids").isEmpty()) { if (!set.getString("vending_ids").isEmpty()) {
this.vendingItems = new TIntArrayList(); this.vendingItems = new TIntArrayList();
String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(","); String[] vendingIds = set.getString("vending_ids").replace(";", ",").split(",");
@ -215,4 +218,6 @@ public class Item {
public String getCustomParams() { public String getCustomParams() {
return customParams; return customParams;
} }
public String getClothingOnWalk() { return clothingOnWalk; }
} }

View File

@ -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.InteractionIceTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.icetag.InteractionIceTagPole; 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.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.conditions.*;
import com.eu.habbo.habbohotel.items.interactions.wired.effects.*; 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.WiredBlob;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredExtraRandom; 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.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.items.interactions.wired.triggers.*;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
@ -69,6 +73,7 @@ public class ItemManager {
private final THashSet<ItemInteraction> interactionsList; private final THashSet<ItemInteraction> interactionsList;
private final THashMap<String, SoundTrack> soundTracks; private final THashMap<String, SoundTrack> soundTracks;
private final YoutubeManager youtubeManager; private final YoutubeManager youtubeManager;
private final WiredHighscoreManager highscoreManager;
private final TreeMap<Integer, NewUserGift> newuserGifts; private final TreeMap<Integer, NewUserGift> newuserGifts;
public ItemManager() { public ItemManager() {
@ -77,6 +82,7 @@ public class ItemManager {
this.interactionsList = new THashSet<>(); this.interactionsList = new THashSet<>();
this.soundTracks = new THashMap<>(); this.soundTracks = new THashMap<>();
this.youtubeManager = new YoutubeManager(); this.youtubeManager = new YoutubeManager();
this.highscoreManager = new WiredHighscoreManager();
this.newuserGifts = new TreeMap<>(); this.newuserGifts = new TreeMap<>();
} }
@ -90,6 +96,7 @@ public class ItemManager {
this.loadCrackable(); this.loadCrackable();
this.loadSoundTracks(); this.loadSoundTracks();
this.youtubeManager.load(); this.youtubeManager.load();
this.highscoreManager.load();
this.loadNewUserGifts(); this.loadNewUserGifts();
Emulator.getLogging().logStart("Item Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); 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_tree", null));
this.interactionsList.add(new ItemInteraction("snowstorm_machine", null)); this.interactionsList.add(new ItemInteraction("snowstorm_machine", null));
this.interactionsList.add(new ItemInteraction("snowstorm_pile", 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; return this.youtubeManager;
} }
public WiredHighscoreManager getHighscoreManager() {
return highscoreManager;
}
public void dispose() { public void dispose() {
this.items.clear(); this.items.clear();
this.highscoreManager.dispose();
Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!"); Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!");
} }

View File

@ -4,10 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot; import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.*;
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.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
@ -181,7 +178,14 @@ public class InteractionDefault extends HabboItem {
} }
public boolean canToggle(Habbo habbo, Room room) { 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 @Override

View File

@ -6,6 +6,8 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem; 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.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem; import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
@ -15,41 +17,54 @@ import java.sql.SQLException;
public class InteractionFXBox extends InteractionDefault { public class InteractionFXBox extends InteractionDefault {
public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException { public InteractionFXBox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem); super(set, baseItem);
this.setExtradata("0"); // this.setExtradata("0");
} }
public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { public InteractionFXBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells); super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0"); // this.setExtradata("0");
} }
@Override @Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception { public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects); 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 (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.M)) {
if (this.getBaseItem().getEffectM() > 0) { 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 (client.getHabbo().getHabboInfo().getGender().equals(HabboGender.F)) {
if (this.getBaseItem().getEffectF() > 0) { 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"); this.setExtradata("1");
room.updateItemState(this); room.updateItemState(this);
room.removeHabboItem(this); room.removeHabboItem(this);
HabboItem item = this; HabboItem item = this;
Emulator.getThreading().run(new Runnable() { Emulator.getThreading().run(() -> {
@Override
public void run() {
new QueryDeleteHabboItem(item.getId()).run(); new QueryDeleteHabboItem(item.getId()).run();
room.sendComposer(new RemoveFloorItemComposer(item).compose()); room.sendComposer(new RemoveFloorItemComposer(item).compose());
} room.updateTile(room.getLayout().getTile(this.getX(), this.getY()));
}, 500); }, 500);
} }
} }

View File

@ -12,7 +12,7 @@ import com.eu.habbo.threading.runnables.CloseGate;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
public class InteractionHabboClubGate extends InteractionGate { public class InteractionHabboClubGate extends InteractionDefault {
public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException { public InteractionHabboClubGate(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem); super(set, baseItem);
this.setExtradata("0"); this.setExtradata("0");
@ -24,19 +24,15 @@ public class InteractionHabboClubGate extends InteractionGate {
} }
@Override @Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) { public boolean isWalkable() {
Habbo habbo = room.getHabbo(roomUnit); return true;
if (habbo != null) {
return habbo.getHabboStats().hasActiveClub();
}
return false;
} }
@Override @Override
public boolean isWalkable() { public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return true; Habbo habbo = room.getHabbo(roomUnit);
return habbo != null && habbo.getHabboStats().hasActiveClub();
} }
@Override @Override
@ -72,6 +68,6 @@ public class InteractionHabboClubGate extends InteractionGate {
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception { public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects); super.onWalkOff(roomUnit, room, objects);
Emulator.getThreading().run(new CloseGate(this, room), 500); Emulator.getThreading().run(new CloseGate(this, room), 1000);
} }
} }

View File

@ -21,7 +21,7 @@ public class InteractionTeleport extends HabboItem {
private int targetId; private int targetId;
private int targetRoomId; private int targetRoomId;
private int roomUnitID = -1; private int roomUnitID = -1;
private boolean walkable = false; private boolean walkable;
public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException { public InteractionTeleport(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem); super(set, baseItem);
@ -82,6 +82,7 @@ public class InteractionTeleport extends HabboItem {
if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) { if (this.roomUnitID == unit.getId() && unit.getCurrentLocation().equals(currentLocation)) {
startTeleport(room, habbo); startTeleport(room, habbo);
walkable = true;
} else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) { } else if (unit.getCurrentLocation().equals(currentLocation) || unit.getCurrentLocation().equals(infrontTile)) {
// set state 1 and walk on item // set state 1 and walk on item
this.roomUnitID = unit.getId(); this.roomUnitID = unit.getId();
@ -93,11 +94,11 @@ public class InteractionTeleport extends HabboItem {
List<Runnable> onFail = new ArrayList<Runnable>(); List<Runnable> onFail = new ArrayList<Runnable>();
onSuccess.add(() -> { onSuccess.add(() -> {
walkable = this.getBaseItem().allowWalk();
room.updateTile(currentLocation); room.updateTile(currentLocation);
tryTeleport(client, room); tryTeleport(client, room);
unit.removeOverrideTile(currentLocation); unit.removeOverrideTile(currentLocation);
unit.setCanLeaveRoomByDoor(true); unit.setCanLeaveRoomByDoor(true);
walkable = this.getBaseItem().allowWalk();
}); });
onFail.add(() -> { onFail.add(() -> {
@ -208,8 +209,10 @@ public class InteractionTeleport extends HabboItem {
} }
public void startTeleport(Room room, Habbo habbo, int delay) { public void startTeleport(Room room, Habbo habbo, int delay) {
if (habbo.getRoomUnit().isTeleporting) if (habbo.getRoomUnit().isTeleporting) {
walkable = this.getBaseItem().allowWalk();
return; return;
}
this.roomUnitID = -1; this.roomUnitID = -1;
habbo.getRoomUnit().isTeleporting = true; habbo.getRoomUnit().isTeleporting = true;

View File

@ -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<Integer> 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);
}
}

View File

@ -3,24 +3,23 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; 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.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHighscoreClearType; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreClearType;
import com.eu.habbo.habbohotel.wired.WiredHighscoreData; import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreScoreType;
import com.eu.habbo.habbohotel.wired.WiredHighscoreScoreType;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.List;
public class InteractionWiredHighscore extends HabboItem { public class InteractionWiredHighscore extends HabboItem {
public WiredHighscoreScoreType scoreType; public WiredHighscoreScoreType scoreType;
public WiredHighscoreClearType clearType; public WiredHighscoreClearType clearType;
private THashSet<WiredHighscoreData> data; private List<WiredHighscoreRow> data;
private int lastUpdate;
public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException { public InteractionWiredHighscore(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem); super(set, baseItem);
@ -37,13 +36,7 @@ public class InteractionWiredHighscore extends HabboItem {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
} }
if (this.getRoomId() > 0) { this.reloadData();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room != null) {
this.reloadData(room);
}
}
} }
public InteractionWiredHighscore(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) { 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) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
} }
this.reloadData();
} }
@Override @Override
@ -86,7 +81,6 @@ public class InteractionWiredHighscore extends HabboItem {
try { try {
int state = Integer.valueOf(this.getExtradata()); int state = Integer.valueOf(this.getExtradata());
this.setExtradata(Math.abs(state - 1) + ""); this.setExtradata(Math.abs(state - 1) + "");
this.reloadData(room);
room.updateItem(this); room.updateItem(this);
} catch (Exception e) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
@ -98,51 +92,30 @@ public class InteractionWiredHighscore extends HabboItem {
public void serializeExtradata(ServerMessage serverMessage) { public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt(6); serverMessage.appendInt(6);
serverMessage.appendString(this.getExtradata()); serverMessage.appendString(this.getExtradata());
serverMessage.appendInt(this.scoreType.type); //score type serverMessage.appendInt(this.scoreType.type);
serverMessage.appendInt(this.clearType.type); //clear type serverMessage.appendInt(this.clearType.type);
if (this.getRoomId() == 0) {
serverMessage.appendInt(0);
} else {
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null) {
serverMessage.appendInt(0);
} else {
if (Emulator.getIntUnixTimestamp() - this.lastUpdate > 60 * 60) {
this.reloadData(room);
}
if (this.data != null) { if (this.data != null) {
serverMessage.appendInt(this.data.size()); //count serverMessage.appendInt(this.data.size());
for (WiredHighscoreData dataSet : this.data) { for (WiredHighscoreRow row : this.data) {
if (this.scoreType == WiredHighscoreScoreType.PERTEAM) { serverMessage.appendInt(row.getValue());
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 serverMessage.appendInt(row.getUsers().size());
for (String username : row.getUsers()) {
for (String codeDragon : dataSet.usernames) { serverMessage.appendString(username);
serverMessage.appendString(codeDragon);
} }
} }
} else { } else {
serverMessage.appendInt(0); serverMessage.appendInt(0);
} }
}
}
super.serializeExtradata(serverMessage); super.serializeExtradata(serverMessage);
} }
@Override @Override
public void onPlace(Room room) { public void onPlace(Room room) {
this.reloadData(room); this.reloadData();
super.onPlace(room); super.onPlace(room);
} }
@ -151,11 +124,9 @@ public class InteractionWiredHighscore extends HabboItem {
if (this.data != null) { if (this.data != null) {
this.data.clear(); this.data.clear();
} }
this.lastUpdate = 0;
} }
private void reloadData(Room room) { public void reloadData() {
this.data = room.getWiredHighscoreData(this.scoreType, this.clearType); this.data = Emulator.getGameEnvironment().getItemManager().getHighscoreManager().getHighscoreRowsForItem(this.getId(), this.clearType, this.scoreType);
this.lastUpdate = Emulator.getIntUnixTimestamp();
} }
} }

View File

@ -16,6 +16,7 @@ import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays;
public class InteractionGameTimer extends HabboItem implements Runnable { public class InteractionGameTimer extends HabboItem implements Runnable {
private int[] TIMER_INTERVAL_STEPS = new int[] { 30, 60, 120, 180, 300, 600 }; 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); parseCustomParams(item);
} }
public void parseCustomParams(Item baseItem) { private void parseCustomParams(Item baseItem) {
try { try {
String[] intervalSteps = baseItem.getCustomParams().split(","); TIMER_INTERVAL_STEPS = Arrays.stream(baseItem.getCustomParams().split(","))
int[] finalSteps = new int[intervalSteps.length]; .mapToInt(s -> {
for (int i = 0; i < intervalSteps.length; i++) { try {
finalSteps[i] = Integer.parseInt(intervalSteps[i]); return Integer.parseInt(s);
} catch (NumberFormatException e) {
return 0;
} }
TIMER_INTERVAL_STEPS = finalSteps; }).toArray();
} } catch (Exception e) {
catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
} }
} }

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<HabboItem> 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);
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -120,7 +120,7 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
this.points = packet.readInt(); this.points = packet.readInt();
this.count = packet.readInt(); this.count = packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt() - 1]; this.teamColor = GameTeamColors.values()[packet.readInt()];
packet.readString(); packet.readString();
packet.readInt(); packet.readInt();
this.setDelay(packet.readInt()); this.setDelay(packet.readInt());

View File

@ -101,7 +101,8 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect {
tilesToUpdate.addAll(tiles); tilesToUpdate.addAll(tiles);
double offsetZ = highestZ - item.getZ(); 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)); tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
if (!slideAnimation) { if (!slideAnimation) {

View File

@ -51,6 +51,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
return; return;
// makes a temporary effect // makes a temporary effect
roomUnit.getRoom().unIdle(roomUnit.getRoom().getHabbo(roomUnit));
room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose()); room.sendComposer(new RoomUserEffectComposer(roomUnit, 4).compose());
Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000); Emulator.getThreading().run(new SendRoomUnitEffectComposer(room, roomUnit), WiredHandler.TELEPORT_DELAY + 1000);

View File

@ -52,6 +52,7 @@ public class MessengerBuddy implements Runnable, ISerialize {
try { try {
this.id = set.getInt("id"); this.id = set.getInt("id");
this.username = set.getString("username"); this.username = set.getString("username");
this.look = set.getString("look");
this.relation = 0; this.relation = 0;
this.userOne = 0; this.userOne = 0;
} catch (SQLException e) { } catch (SQLException e) {

View File

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

View File

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

View File

@ -72,8 +72,15 @@ public class WordFilter {
} }
public String normalise(String message) { public String normalise(String message) {
return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD).replaceAll("[,.;:'\"]", "").replace("I", "l") return DIACRITICS_AND_FRIENDS.matcher(Normalizer.normalize(StringUtils.stripAccents(message), Normalizer.Form.NFKD)
.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(""); .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) { public boolean autoReportCheck(RoomChatMessage roomChatMessage) {
@ -139,7 +146,7 @@ public class WordFilter {
if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled()) if (Emulator.getPluginManager().fireEvent(new UserTriggerWordFilterEvent(habbo, word)).isCancelled())
continue; continue;
} }
filteredMessage = filteredMessage.replaceAll("(?i)" + word.key, word.replacement); filteredMessage = filteredMessage.replace("(?i)" + word.key, word.replacement);
foundShit = true; foundShit = true;
if (habbo != null && word.muteTime > 0) { if (habbo != null && word.muteTime > 0) {

View File

@ -29,12 +29,20 @@ public class Rank {
private boolean hasPrefix; private boolean hasPrefix;
private int diamondsTimerAmount;
private int creditsTimerAmount;
private int pixelsTimerAmount;
private int gotwTimerAmount;
public Rank(ResultSet set) throws SQLException { public Rank(ResultSet set) throws SQLException {
this.permissions = new THashMap<>(); this.permissions = new THashMap<>();
this.variables = new THashMap<>(); this.variables = new THashMap<>();
this.id = set.getInt("id"); this.id = set.getInt("id");
this.level = set.getInt("level"); this.level = set.getInt("level");
this.diamondsTimerAmount = 1;
this.creditsTimerAmount = 1;
this.pixelsTimerAmount = 1;
this.gotwTimerAmount = 1;
this.load(set); this.load(set);
} }
@ -47,6 +55,10 @@ public class Rank {
this.logCommands = set.getString("log_commands").equals("1"); this.logCommands = set.getString("log_commands").equals("1");
this.prefix = set.getString("prefix"); this.prefix = set.getString("prefix");
this.prefixColor = set.getString("prefix_color"); 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(); this.hasPrefix = !this.prefix.isEmpty();
for (int i = 1; i < meta.getColumnCount() + 1; i++) { for (int i = 1; i < meta.getColumnCount() + 1; i++) {
String columnName = meta.getColumnName(i); String columnName = meta.getColumnName(i);
@ -115,4 +127,13 @@ public class Rank {
public boolean hasPrefix() { public boolean hasPrefix() {
return this.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; }
} }

View File

@ -71,6 +71,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
private boolean canBreed = true; private boolean canBreed = true;
private boolean publiclyBreedable = false; private boolean publiclyBreedable = false;
private int growthStage = 0; private int growthStage = 0;
private boolean hasDied = false;
public MonsterplantPet(ResultSet set) throws SQLException { public MonsterplantPet(ResultSet set) throws SQLException {
super(set); super(set);
@ -85,6 +86,7 @@ public class MonsterplantPet extends Pet implements IPetLook {
this.deathTimestamp = set.getInt("mp_death_timestamp"); this.deathTimestamp = set.getInt("mp_death_timestamp");
this.publiclyBreedable = set.getString("mp_allow_breed").equals("1"); this.publiclyBreedable = set.getString("mp_allow_breed").equals("1");
this.canBreed = set.getString("mp_breedable").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) { 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) { if (this.needsUpdate) {
super.run(); 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(1, this.type);
statement.setInt(2, this.hue); statement.setInt(2, this.hue);
statement.setInt(3, this.nose); statement.setInt(3, this.nose);
@ -132,7 +134,8 @@ public class MonsterplantPet extends Pet implements IPetLook {
statement.setInt(9, this.deathTimestamp); statement.setInt(9, this.deathTimestamp);
statement.setString(10, this.canBreed ? "1" : "0"); statement.setString(10, this.canBreed ? "1" : "0");
statement.setString(11, this.publiclyBreedable ? "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(); statement.execute();
} catch (SQLException e) { } catch (SQLException e) {
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);
@ -146,8 +149,11 @@ public class MonsterplantPet extends Pet implements IPetLook {
if (this.isDead()) { if (this.isDead()) {
this.roomUnit.removeStatus(RoomUnitStatus.GESTURE); 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")); AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("MonsterPlantGardenOfDeath"));
this.hasDied = true;
this.needsUpdate = true;
} }
this.roomUnit.clearStatus(); this.roomUnit.clearStatus();

View File

@ -217,7 +217,7 @@ public class Pet implements ISerialize, Runnable {
int time = Emulator.getIntUnixTimestamp(); int time = Emulator.getIntUnixTimestamp();
if (this.roomUnit != null && this.task != PetTasks.RIDE) { 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.roomUnit.removeStatus(RoomUnitStatus.GESTURE);
this.packetUpdate = true; this.packetUpdate = true;
} }
@ -236,8 +236,6 @@ public class Pet implements ISerialize, Runnable {
} }
if (!this.roomUnit.isWalking()) { if (!this.roomUnit.isWalking()) {
this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) { if (this.roomUnit.getWalkTimeOut() < time && this.canWalk()) {
RoomTile tile = this.room.getRandomWalkableTile(); RoomTile tile = this.room.getRandomWalkableTile();
@ -399,9 +397,9 @@ public class Pet implements ISerialize, Runnable {
for (Map.Entry<RoomUnitStatus, String> entry : keys.entrySet()) { for (Map.Entry<RoomUnitStatus, String> entry : keys.entrySet()) {
this.roomUnit.setStatus(entry.getKey(), entry.getValue()); this.roomUnit.setStatus(entry.getKey(), entry.getValue());
} }
}
this.packetUpdate = true; if (!keys.isEmpty()) this.packetUpdate = true;
}
} }
public void updateGesture(int time) { public void updateGesture(int time) {

View File

@ -12,7 +12,8 @@ public enum FurnitureMovementError {
TILE_HAS_PETS("${room.error.cant_set_item}"), TILE_HAS_PETS("${room.error.cant_set_item}"),
TILE_HAS_BOTS("${room.error.cant_set_item}"), TILE_HAS_BOTS("${room.error.cant_set_item}"),
MAX_DIMMERS("${room.error.max_dimmers}"), 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; public final String errorCode;

View File

@ -105,6 +105,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public static boolean HABBO_CHAT_DELAY = false; public static boolean HABBO_CHAT_DELAY = false;
public static int MAXIMUM_BOTS = 10; public static int MAXIMUM_BOTS = 10;
public static int MAXIMUM_PETS = 10; public static int MAXIMUM_PETS = 10;
public static int MAXIMUM_FURNI = 2500;
public static int HAND_ITEM_TIME = 10; public static int HAND_ITEM_TIME = 10;
public static int IDLE_CYCLES = 240; public static int IDLE_CYCLES = 240;
public static int IDLE_CYCLES_KICK = 480; public static int IDLE_CYCLES_KICK = 480;
@ -135,7 +136,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
private final TIntObjectMap<RoomMoodlightData> moodlightData; private final TIntObjectMap<RoomMoodlightData> moodlightData;
private final THashSet<String> wordFilterWords; private final THashSet<String> wordFilterWords;
private final TIntObjectMap<HabboItem> roomItems; private final TIntObjectMap<HabboItem> roomItems;
private final THashMap<WiredHighscoreScoreType, THashMap<WiredHighscoreClearType, THashSet<WiredHighscoreData>>> wiredHighscoreData;
private final Object loadLock = new Object(); private final Object loadLock = new Object();
//Use appropriately. Could potentially cause memory leaks when used incorrectly. //Use appropriately. Could potentially cause memory leaks when used incorrectly.
public volatile boolean preventUnloading = false; public volatile boolean preventUnloading = false;
@ -289,7 +289,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.activeTrades = new THashSet<>(0); this.activeTrades = new THashSet<>(0);
this.rights = new TIntArrayList(); this.rights = new TIntArrayList();
this.wiredHighscoreData = new THashMap<>();
this.userVotes = new ArrayList<>(); this.userVotes = new ArrayList<>();
} }
@ -418,6 +417,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} catch (SQLException e) { } catch (SQLException e) {
Emulator.getLogging().logSQLException(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) { private synchronized void loadWiredData(Connection connection) {
@ -855,7 +858,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
for (Game game : this.games) { for (Game game : this.games) {
game.stop(); game.dispose();
} }
this.games.clear(); this.games.clear();
@ -1480,12 +1483,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
if (newRoller == null || topItem == newRoller) { if (newRoller == null || topItem == newRoller) {
List<HabboItem> sortedItems = new ArrayList<>(itemsOnRoller); List<HabboItem> sortedItems = new ArrayList<>(itemsOnRoller);
sortedItems.sort(new Comparator<HabboItem>() { sortedItems.sort((o1, o2) -> o1.getZ() > o2.getZ() ? -1 : 1);
@Override
public int compare(HabboItem o1, HabboItem o2) {
return o1.getZ() > o2.getZ() ? -1 : 1;
}
});
for (HabboItem item : sortedItems) { for (HabboItem item : sortedItems) {
if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) { if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0) {
@ -2132,15 +2130,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public boolean deleteGame(Game game) { public boolean deleteGame(Game game) {
game.stop(); game.stop();
game.dispose();
synchronized (this.games) { synchronized (this.games) {
return this.games.remove(game); return this.games.remove(game);
} }
} }
public Game getGame(Class<? extends Game> gameType) { public Game getGame(Class<? extends Game> gameType) {
if (gameType == null) return null;
synchronized (this.games) { synchronized (this.games) {
for (Game game : this.games) { for (Game game : this.games) {
if (gameType.isInstance(game)) { if (game != null && gameType.isInstance(game)) {
return game; return game;
} }
} }
@ -2989,8 +2990,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
return; return;
} }
habbo.getHabboStats().chatCounter += 2;
if (habbo.getHabboInfo().getCurrentRoom() != this) if (habbo.getHabboInfo().getCurrentRoom() != this)
return; return;
@ -3002,6 +3001,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
habbo.getHabboStats().lastChat = millis; habbo.getHabboStats().lastChat = millis;
if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) { if (roomChatMessage != null && roomChatMessage.getMessage().equalsIgnoreCase("i am a pirate")) {
habbo.getHabboStats().chatCounter += 2;
Emulator.getThreading().run(new YouAreAPirate(habbo, this)); Emulator.getThreading().run(new YouAreAPirate(habbo, this));
return; return;
} }
@ -3060,12 +3060,18 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
habbo.getHabboStats().chatCounter += 2;
ServerMessage prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null; ServerMessage prefixMessage = roomChatMessage.getHabbo().getHabboInfo().getRank().hasPrefix() ? new RoomUserNameChangedComposer(habbo, true).compose() : null;
ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null; ServerMessage clearPrefixMessage = prefixMessage != null ? new RoomUserNameChangedComposer(habbo).compose() : null;
Rectangle show = this.roomSpecialTypes.tentAt(habbo.getRoomUnit().getCurrentLocation()); 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 (chatType == RoomChatType.WHISPER) {
if (roomChatMessage.getTargetHabbo() == null) { if (roomChatMessage.getTargetHabbo() == null) {
@ -3243,17 +3249,17 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public THashSet<HabboItem> getItemsAt(RoomTile tile) { public THashSet<HabboItem> getItemsAt(RoomTile tile) {
THashSet<HabboItem> items = new THashSet<>(0);
if (tile == null)
return items;
if (this.loaded) { if (this.loaded) {
if (this.tileCache.containsKey(tile)) { if (this.tileCache.containsKey(tile)) {
return this.tileCache.get(tile); return this.tileCache.get(tile);
} }
} }
THashSet<HabboItem> items = new THashSet<>(0);
if (tile == null)
return items;
TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator(); TIntObjectIterator<HabboItem> iterator = this.roomItems.iterator();
for (int i = this.roomItems.size(); i-- > 0; ) { for (int i = this.roomItems.size(); i-- > 0; ) {
@ -3407,11 +3413,14 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
continue; continue;
} }
if (this.layout == null) continue;
THashSet<RoomTile> tiles = this.layout.getTilesAt( THashSet<RoomTile> tiles = this.layout.getTilesAt(
this.layout.getTile(habboItem.getX(), habboItem.getY()), this.layout.getTile(habboItem.getX(), habboItem.getY()),
habboItem.getBaseItem().getWidth(), habboItem.getBaseItem().getWidth(),
habboItem.getBaseItem().getLength(), habboItem.getBaseItem().getLength(),
habboItem.getRotation()); habboItem.getRotation()
);
for (RoomTile tile : tiles) { for (RoomTile tile : tiles) {
if (((tile.x == x) && (tile.y == y))) { if (((tile.x == x) && (tile.y == y))) {
@ -3637,7 +3646,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public RoomTile getRandomWalkableTile() { public RoomTile getRandomWalkableTile() {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
RoomTile tile = this.layout.getTile((short) (Math.random() * this.layout.getMapSizeX()), (short) (Math.random() * this.layout.getMapSizeY())); 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; return tile;
} }
} }
@ -3676,6 +3685,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
public void sendComposer(ServerMessage message) { public void sendComposer(ServerMessage message) {
for (Habbo habbo : this.getHabbos()) { for (Habbo habbo : this.getHabbos()) {
if (habbo.getClient() == null) {
this.removeHabbo(habbo, true);
continue;
}
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
} }
} }
@ -4152,6 +4166,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public void unIdle(Habbo habbo) { public void unIdle(Habbo habbo) {
if (habbo == null || habbo.getRoomUnit() == null) return;
habbo.getRoomUnit().resetIdleTimer(); habbo.getRoomUnit().resetIdleTimer();
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose()); this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo}); WiredHandler.handle(WiredTriggerType.UNIDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
@ -4206,70 +4221,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
public THashSet<WiredHighscoreData> 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<WiredHighscoreData> 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<WiredHighscoreClearType, THashSet<WiredHighscoreData>> dataMap = new THashMap<>();
dataMap.put(clearType, wiredData);
this.wiredHighscoreData.put(scoreType, dataMap);
}
public void handleWordQuiz(Habbo habbo, String answer) { public void handleWordQuiz(Habbo habbo, String answer) {
synchronized (this.userVotes) { synchronized (this.userVotes) {
if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) { if (!this.wordQuiz.isEmpty() && !this.hasVotedInWordQuiz(habbo)) {
@ -4352,6 +4303,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) { public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) {
if (this.itemCount() >= Room.MAXIMUM_FURNI) {
return FurnitureMovementError.MAX_ITEMS;
}
rotation %= 8; rotation %= 8;
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) { if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE)) {
return FurnitureMovementError.NONE; return FurnitureMovementError.NONE;
@ -4487,7 +4442,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
if (topItem != item) { if (topItem != item) {
for (RoomTile t : occupiedTiles) { 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; return FurnitureMovementError.CANT_STACK;
if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS; if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS; if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
@ -4521,9 +4477,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
} }
} }
//Place at new position //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.setX(tile.x);
item.setY(tile.y); item.setY(tile.y);
item.setZ(this.getStackHeight(tile.x, tile.y, false, item)); item.setZ(height);
if (magicTile) { if (magicTile) {
item.setZ(tile.z); item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100); item.setExtradata("" + item.getZ() * 100);

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.core.RoomUserPetComposer; import com.eu.habbo.core.RoomUserPetComposer;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.Bot; 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.Game;
import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame; import com.eu.habbo.habbohotel.games.battlebanzai.BattleBanzaiGame;
import com.eu.habbo.habbohotel.games.football.FootballGame; 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.promotions.RoomPromotionMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.rooms.users.*;
import com.eu.habbo.messages.outgoing.users.MutedWhisperComposer; 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.navigator.NavigatorRoomCreatedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent; 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.HabboAddedToRoomEvent;
import com.eu.habbo.plugin.events.users.UserEnterRoomEvent; import com.eu.habbo.plugin.events.users.UserEnterRoomEvent;
import com.eu.habbo.plugin.events.users.UserExitRoomEvent; import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
@ -432,6 +435,9 @@ public class RoomManager {
if (this.hasVotedForRoom(habbo, room)) if (this.hasVotedForRoom(habbo, room))
return; return;
UserVoteRoomEvent event = new UserVoteRoomEvent(room, habbo);
if (Emulator.getPluginManager().fireEvent(event).isCancelled()) return;
room.setScore(room.getScore() + 1); room.setScore(room.getScore() + 1);
room.setNeedsUpdate(true); room.setNeedsUpdate(true);
habbo.getHabboStats().votedRooms.push(room.getId()); habbo.getHabboStats().votedRooms.push(room.getId());
@ -706,9 +712,20 @@ public class RoomManager {
List<Habbo> habbos = new ArrayList<>(); List<Habbo> habbos = new ArrayList<>();
if (!room.getCurrentHabbos().isEmpty()) { if (!room.getCurrentHabbos().isEmpty()) {
Collection<Habbo> habbosToSendEnter = room.getCurrentHabbos().values();
room.sendComposer(new RoomUsersComposer(habbo).compose()); if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
room.sendComposer(new RoomUserStatusComposer(habbo.getRoomUnit()).compose()); 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()) { for (Habbo h : room.getHabbos()) {
if (!h.getRoomUnit().isInvisible()) { if (!h.getRoomUnit().isInvisible()) {
@ -886,10 +903,6 @@ public class RoomManager {
if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) { if (!habbo.getHabboStats().nux && (room.isOwner(habbo) || room.isPublicRoom())) {
UserNuxEvent.handle(habbo); UserNuxEvent.handle(habbo);
} }
if (Emulator.getPluginManager().isRegistered(HabboAddedToRoomEvent.class, false)) {
Emulator.getPluginManager().fireEvent(new HabboAddedToRoomEvent(habbo, room));
}
} }
void logEnter(Habbo habbo, Room room) { void logEnter(Habbo habbo, Room room) {

View File

@ -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.inventory.InventoryRefreshComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.messages.outgoing.trading.*; import com.eu.habbo.messages.outgoing.trading.*;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.sql.*; import java.sql.*;
@ -214,6 +215,33 @@ public class RoomTrade {
userOne.clearItems(); userOne.clearItems();
userTwo.clearItems(); userTwo.clearItems();
int creditsForUserTwo = 0;
THashSet<HabboItem> 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<HabboItem> 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); userOne.getHabbo().getInventory().getItemsComponent().addItems(itemsUserTwo);
userTwo.getHabbo().getInventory().getItemsComponent().addItems(itemsUserOne); userTwo.getHabbo().getInventory().getItemsComponent().addItems(itemsUserOne);
@ -287,4 +315,14 @@ public class RoomTrade {
public List<RoomTradeUser> getRoomTradeUsers() { public List<RoomTradeUser> getRoomTradeUsers() {
return this.users; 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;
}
}
} }

View File

@ -2,15 +2,13 @@ package com.eu.habbo.habbohotel.rooms;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildGate; import com.eu.habbo.habbohotel.items.interactions.*;
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.pets.Pet; import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.RideablePet; import com.eu.habbo.habbohotel.pets.RideablePet;
import com.eu.habbo.habbohotel.users.DanceType; import com.eu.habbo.habbohotel.users.DanceType;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; 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.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.plugin.Event; import com.eu.habbo.plugin.Event;
import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; 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 != 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)) { if (item.canWalkOn(this, room, null)) {
item.onWalkOn(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.setRotation(oldRotation);
this.tilesWalked--; this.tilesWalked--;
this.setGoalLocation(this.currentLocation); this.setGoalLocation(this.currentLocation);
this.status.remove(RoomUnitStatus.MOVE); this.status.remove(RoomUnitStatus.MOVE);
room.sendComposer(new RoomUserStatusComposer(this).compose()); room.sendComposer(new RoomUserStatusComposer(this).compose());
if (item instanceof InteractionHabboClubGate && habbo != null) {
habbo.getClient().sendResponse(new CustomNotificationComposer(CustomNotificationComposer.GATE_NO_HC));
}
return false; return false;
} }
} else { } else {

View File

@ -198,7 +198,11 @@ public enum RoomUnitEffect {
WATERINGCAN(192), WATERINGCAN(192),
TRAMPOLINEJUMP(193), TRAMPOLINEJUMP(193),
TREADMILL(194), TREADMILL(194),
CROSSTRAINER(195); CROSSTRAINER(195),
STARWARS(196),
FLYINGCARPET(197),
YELLOWDUCK(198),
FLYNGTURTLE(199);
private int id; private int id;

View File

@ -22,6 +22,7 @@ import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -109,8 +110,10 @@ public class Habbo implements Runnable {
public void connect() { public void connect() {
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy")) { if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
this.habboInfo.setIpLogin(((InetSocketAddress) this.client.getChannel().remoteAddress()).getAddress().getHostAddress()); SocketAddress address = this.client.getChannel().remoteAddress();
if (address != null) this.habboInfo.setIpLogin(((InetSocketAddress) address).getAddress().getHostAddress());
} }
this.habboInfo.setMachineID(this.client.getMachineId()); this.habboInfo.setMachineID(this.client.getMachineId());
@ -199,7 +202,8 @@ public class Habbo implements Runnable {
return; return;
this.getHabboInfo().addCredits(event.credits); 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; return;
this.getHabboInfo().addPixels(event.points); 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; return;
this.getHabboInfo().addCurrencyAmount(event.type, event.points); 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));
} }

View File

@ -50,7 +50,7 @@ public class HabboInfo implements Runnable {
private String photoJSON; private String photoJSON;
private int webPublishTimestamp; private int webPublishTimestamp;
private String machineID; private String machineID;
private HashSet<NavigatorSavedSearch> savedSearches = new HashSet<>(); private List<NavigatorSavedSearch> savedSearches = new ArrayList<>();
public HabboInfo(ResultSet set) { public HabboInfo(ResultSet set) {
try { try {
@ -125,7 +125,7 @@ public class HabboInfo implements Runnable {
} }
private void loadSavedSearches() { 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 = ?")) { try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_saved_searches WHERE user_id = ?")) {
statement.setInt(1, this.id); statement.setInt(1, this.id);
@ -470,7 +470,7 @@ public class HabboInfo implements Runnable {
this.machineID = machineID; this.machineID = machineID;
} }
public HashSet<NavigatorSavedSearch> getSavedSearches() { public List<NavigatorSavedSearch> getSavedSearches() {
return this.savedSearches; return this.savedSearches;
} }

View File

@ -147,10 +147,12 @@ public class HabboInventory {
} }
public MarketPlaceOffer getOffer(int id) { public MarketPlaceOffer getOffer(int id) {
synchronized (this.items) {
for (MarketPlaceOffer offer : this.items) { for (MarketPlaceOffer offer : this.items) {
if (offer.getOfferId() == id) if (offer.getOfferId() == id)
return offer; return offer;
} }
}
return null; return null;
} }

View File

@ -18,7 +18,11 @@ import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDanceComposer; 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 gnu.trove.set.hash.THashSet;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.math3.util.Pair; import org.apache.commons.math3.util.Pair;
import java.sql.Connection; import java.sql.Connection;
@ -26,6 +30,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public abstract class HabboItem implements Runnable, IEventTriggers { public abstract class HabboItem implements Runnable, IEventTriggers {
@ -294,6 +299,20 @@ public abstract class HabboItem implements Runnable, IEventTriggers {
roomUnit.setDanceType(DanceType.NONE); roomUnit.setDanceType(DanceType.NONE);
room.sendComposer(new RoomUserDanceComposer(roomUnit).compose()); 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 @Override

View File

@ -34,6 +34,10 @@ public class EffectsComponent {
} }
public HabboEffect createEffect(int effectId) { public HabboEffect createEffect(int effectId) {
return createEffect(effectId, 86400);
}
public HabboEffect createEffect(int effectId, int duration) {
HabboEffect effect; HabboEffect effect;
synchronized (this.effects) { synchronized (this.effects) {
if (this.effects.containsKey(effectId)) { if (this.effects.containsKey(effectId)) {
@ -44,6 +48,7 @@ public class EffectsComponent {
} }
} else { } else {
effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId()); effect = new HabboEffect(effectId, this.habbo.getHabboInfo().getId());
effect.duration = duration;
effect.insert(); effect.insert();
} }
@ -159,6 +164,9 @@ public class EffectsComponent {
} }
public boolean isRemaining() { public boolean isRemaining() {
if(this.duration <= 0)
return true;
if (this.total > 0) { if (this.total > 0) {
if (this.activationTimestamp >= 0) { if (this.activationTimestamp >= 0) {
if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) { if (Emulator.getIntUnixTimestamp() - this.activationTimestamp >= this.duration) {
@ -172,6 +180,9 @@ public class EffectsComponent {
} }
public int remainingTime() { public int remainingTime() {
if(this.duration <= 0) //permanant
return Integer.MAX_VALUE;
return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration; return Emulator.getIntUnixTimestamp() - this.activationTimestamp + this.duration;
} }

View File

@ -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;
}
}

View File

@ -1,4 +1,4 @@
package com.eu.habbo.habbohotel.wired; package com.eu.habbo.habbohotel.wired.highscores;
public enum WiredHighscoreClearType { public enum WiredHighscoreClearType {
ALLTIME(0), ALLTIME(0),

View File

@ -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<Integer> userIds;
private final int score;
private final boolean isWin;
private final int timestamp;
public WiredHighscoreDataEntry(int itemId, List<Integer> 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<Integer> getUserIds() {
return userIds;
}
public int getScore() {
return score;
}
public boolean isWin() {
return isWin;
}
public int getTimestamp() {
return timestamp;
}
}

View File

@ -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<Integer, List<WiredHighscoreDataEntry>> 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<WiredHighscoreRow> getHighscoreRowsForItem(int itemId, WiredHighscoreClearType clearType, WiredHighscoreScoreType scoreType) {
if (!this.data.containsKey(itemId)) return null;
Stream<WiredHighscoreRow> 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();
}
}

View File

@ -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<Room> rooms = Emulator.getGameEnvironment().getRoomManager().getActiveRooms();
for (Room room : rooms) {
if (room == null || room.getRoomSpecialTypes() == null) continue;
THashSet<HabboItem> 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;
}
}

View File

@ -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<WiredHighscoreRow> {
public static final Comparator<WiredHighscoreRow> COMPARATOR = Comparator.comparing(WiredHighscoreRow::getValue).reversed();
private final List<String> users;
private final int value;
public WiredHighscoreRow(List<String> users, int value) {
Collections.sort(users);
this.users = users;
this.value = value;
}
public List<String> getUsers() {
return users;
}
public int getValue() {
return value;
}
@Override
public int compareTo(WiredHighscoreRow otherRow) {
return COMPARATOR.compare(this, otherRow);
}
}

View File

@ -1,4 +1,4 @@
package com.eu.habbo.habbohotel.wired; package com.eu.habbo.habbohotel.wired.highscores;
public enum WiredHighscoreScoreType { public enum WiredHighscoreScoreType {
PERTEAM(0), PERTEAM(0),

View File

@ -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 {}

View File

@ -156,11 +156,20 @@ public class PacketManager {
if (client == null || Emulator.isShuttingDown) if (client == null || Emulator.isShuttingDown)
return; return;
if (client.getHabbo() == null && !(packet.getMessageId() == Incoming.SecureLoginEvent || packet.getMessageId() == Incoming.MachineIDEvent))
return;
try { try {
if (this.isRegistered(packet.getMessageId())) { 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) if (PacketManager.DEBUG_SHOW_PACKETS)
Emulator.getLogging().logPacketLine("[" + Logging.ANSI_CYAN + "CLIENT" + Logging.ANSI_RESET + "][" + packet.getMessageId() + "] => " + packet.getMessageBody()); 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())); 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.client = client;
handler.packet = packet; handler.packet = packet;
@ -184,7 +193,7 @@ public class PacketManager {
} }
} else { } else {
if (PacketManager.DEBUG_SHOW_PACKETS) 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) { } catch (Exception e) {
Emulator.getLogging().logErrorLine(e); Emulator.getLogging().logErrorLine(e);
@ -468,6 +477,7 @@ public class PacketManager {
this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class); this.registerHandler(Incoming.ReportFriendPrivateChatEvent, ReportFriendPrivateChatEvent.class);
this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class); this.registerHandler(Incoming.ReportThreadEvent, ReportThreadEvent.class);
this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class); this.registerHandler(Incoming.ReportCommentEvent, ReportCommentEvent.class);
this.registerHandler(Incoming.ReportPhotoEvent, ReportPhotoEvent.class);
} }
void registerTrading() throws Exception { void registerTrading() throws Exception {

View File

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

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.incoming.events.calendar; package com.eu.habbo.messages.incoming.events.calendar;
import com.eu.habbo.Emulator;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
public class AdventCalendarForceOpenEvent extends MessageHandler { public class AdventCalendarForceOpenEvent extends MessageHandler {
@ -7,5 +8,7 @@ public class AdventCalendarForceOpenEvent extends MessageHandler {
public void handle() throws Exception { public void handle() throws Exception {
String campaign = this.packet.readString(); String campaign = this.packet.readString();
int day = this.packet.readInt(); int day = this.packet.readInt();
Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, true);
} }
} }

View File

@ -9,6 +9,6 @@ public class AdventCalendarOpenDayEvent extends MessageHandler {
String campaign = this.packet.readString(); String campaign = this.packet.readString();
int day = this.packet.readInt(); int day = this.packet.readInt();
Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day); Emulator.getGameEnvironment().getCatalogManager().claimCalendarReward(this.client.getHabbo(), day, false);
} }
} }

View File

@ -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.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
public class FloorPlanEditorSaveEvent extends MessageHandler { public class FloorPlanEditorSaveEvent extends MessageHandler {
public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64; public static int MAXIMUM_FLOORPLAN_WIDTH_LENGTH = 64;
public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64; public static int MAXIMUM_FLOORPLAN_SIZE = 64 * 64;
public static final String VALID_CHARACTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
@Override @Override
public void handle() throws Exception { public void handle() throws Exception {
@ -35,66 +32,46 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
return; return;
if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) { if (room.getOwnerId() == this.client.getHabbo().getHabboInfo().getId() || this.client.getHabbo().hasPermission(Permission.ACC_ANYROOMOWNER)) {
List<String> errors = new ArrayList<>(); StringJoiner errors = new StringJoiner("<br />");
String map = this.packet.readString(); String map = this.packet.readString();
map = map.replace("X", "x"); map = map.replace("X", "x");
String checkMap = map.replace(((char) 13) + "", "").toUpperCase(); String[] mapRows = map.split("\r");
for (char c : VALID_CHARACTERS.toCharArray())
{
checkMap = checkMap.replace(c + "", "");
}
if (!checkMap.isEmpty() && Emulator.getConfig().getBoolean("hotel.room.floorplan.check.enabled")) int firstRowSize = mapRows[0].length();
{
errors.add("${notification.floorplan_editor.error.title}");
}
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) { 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"));
if (map.isEmpty() || map.replace("x", "").replace("\r", "").isEmpty()) {
errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}"); errors.add("${notification.floorplan_editor.error.message.effective_height_is_0}");
} }
int lengthX = -1;
int lengthY = -1;
String[] data = map.split(((char) 13) + "");
if (errors.isEmpty()) {
if (map.length() > 64 * 64) { if (map.length() > 64 * 64) {
errors.add("${notification.floorplan_editor.error.message.too_large_area}"); errors.add("${notification.floorplan_editor.error.message.too_large_area}");
} }
if (mapRows.length > 64) errors.add("${notification.floorplan_editor.error.message.too_large_height}");
lengthY = data.length; else if (Arrays.stream(mapRows).anyMatch(l -> l.length() > 64 || l.length() == 0)) errors.add("${notification.floorplan_editor.error.message.too_large_width}");
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}");
}
}
}
} }
int doorX = this.packet.readInt(); int doorX = this.packet.readInt();
int doorY = 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}"); 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) { if (doorRotation < 0 || doorRotation > 7) {
errors.add("${notification.floorplan_editor.error.message.invalid_entry_tile_direction}"); 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) { if (floorSize < -2 || floorSize > 1) {
errors.add("${notification.floorplan_editor.error.message.invalid_floor_thickness}"); errors.add("${notification.floorplan_editor.error.message.invalid_floor_thickness}");
} }
int wallHeight = -1;
int wallHeight = -1;
if (this.packet.bytesAvailable() >= 4) if (this.packet.bytesAvailable() >= 4)
wallHeight = this.packet.readInt(); wallHeight = this.packet.readInt();
@ -117,12 +94,18 @@ public class FloorPlanEditorSaveEvent extends MessageHandler {
errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}"); errors.add("${notification.floorplan_editor.error.message.invalid_walls_fixed_height}");
} }
if (!errors.isEmpty()) { blockingRoomItemScan:
StringBuilder errorMessage = new StringBuilder(); for (int y = 0; y < mapRows.length; y++) {
for (String s : errors) { for (int x = 0; x < firstRowSize; x++) {
errorMessage.append(s).append("<br />"); 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; return;
} }

View File

@ -17,6 +17,8 @@ public class InviteFriendsEvent extends MessageHandler {
String message = this.packet.readString(); String message = this.packet.readString();
message = Emulator.getGameEnvironment().getWordFilter().filter(message, this.client.getHabbo());
for (int i : userIds) { for (int i : userIds) {
if (i == 0) if (i == 0)
continue; continue;

View File

@ -22,19 +22,20 @@ public class GuildRemoveAdminEvent extends MessageHandler {
int userId = this.packet.readInt(); int userId = this.packet.readInt();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(guild.getRoomId()); 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); GuildRemovedAdminEvent removedAdminEvent = new GuildRemovedAdminEvent(guild, userId, habbo);
Emulator.getPluginManager().fireEvent(removedAdminEvent); Emulator.getPluginManager().fireEvent(removedAdminEvent);
if (removedAdminEvent.isCancelled()) if (removedAdminEvent.isCancelled())
return; return;
Emulator.getGameEnvironment().getGuildManager().removeAdmin(guild, userId);
if (habbo != null) { if (habbo != null) {
habbo.getClient().sendResponse(new GuildInfoComposer(guild, this.client, false, Emulator.getGameEnvironment().getGuildManager().getGuildMember(guild.getId(), userId))); 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); GuildMember guildMember = Emulator.getGameEnvironment().getGuildManager().getGuildMember(guildId, userId);

View File

@ -3,6 +3,8 @@ package com.eu.habbo.messages.incoming.guilds;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.guilds.Guild; import com.eu.habbo.habbohotel.guilds.Guild;
import com.eu.habbo.messages.incoming.MessageHandler; 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.messages.outgoing.users.UserProfileComposer;
import com.eu.habbo.plugin.events.guilds.GuildRemovedFavoriteEvent; import com.eu.habbo.plugin.events.guilds.GuildRemovedFavoriteEvent;
@ -20,6 +22,10 @@ public class GuildRemoveFavoriteEvent extends MessageHandler {
this.client.getHabbo().getHabboStats().guild = 0; 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)); this.client.sendResponse(new UserProfileComposer(this.client.getHabbo(), this.client));
} }
} }

View File

@ -21,7 +21,7 @@ public class RequestGuildMembersEvent extends MessageHandler {
boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin"); boolean isAdmin = this.client.getHabbo().hasPermission("acc_guild_admin");
if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) { if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); 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))); 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)));

View File

@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.handshake; 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.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.handshake.MachineIDComposer; import com.eu.habbo.messages.outgoing.handshake.MachineIDComposer;
@NoAuthMessage
public class MachineIDEvent extends MessageHandler { public class MachineIDEvent extends MessageHandler {
@Override @Override

View File

@ -1,7 +1,9 @@
package com.eu.habbo.messages.incoming.handshake; 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.incoming.MessageHandler;
@NoAuthMessage
public class ReleaseVersionEvent extends MessageHandler { public class ReleaseVersionEvent extends MessageHandler {
@Override @Override

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.navigation.NavigatorSavedSearch;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.messages.NoAuthMessage;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer; import com.eu.habbo.messages.outgoing.achievements.AchievementListComposer;
@ -31,6 +32,7 @@ import com.eu.habbo.plugin.events.users.UserLoginEvent;
import java.util.ArrayList; import java.util.ArrayList;
@NoAuthMessage
public class SecureLoginEvent extends MessageHandler { public class SecureLoginEvent extends MessageHandler {

View File

@ -83,8 +83,8 @@ public class UsernameEvent extends MessageHandler {
} }
} }
if (calendar && Emulator.getConfig().getBoolean("hotel.calendar.enabled")) { if (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)); 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")); this.client.sendResponse(new NuxAlertComposer("openView/calendar"));
} }

View File

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

View File

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

View File

@ -75,8 +75,6 @@ public class RoomPlaceItemEvent extends MessageHandler {
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode)); this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
return; return;
} }
return;
} }
RoomTile tile = room.getLayout().getTile(x, y); RoomTile tile = room.getLayout().getTile(x, y);

View File

@ -31,6 +31,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
if (item == null || item instanceof InteractionDice) if (item == null || item instanceof InteractionDice)
return; return;
/*
if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) { if (item.getBaseItem().getName().equalsIgnoreCase("totem_planet")) {
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY())); THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(item.getX(), item.getY()));
HabboItem totemLeg = null; HabboItem totemLeg = null;
@ -75,7 +76,7 @@ public class ToggleFloorItemEvent extends MessageHandler {
} }
} }
} }
} }*/
//Do not move to onClick(). Wired could trigger it. //Do not move to onClick(). Wired could trigger it.
if (item instanceof InteractionMonsterPlantSeed) { if (item instanceof InteractionMonsterPlantSeed) {

View File

@ -1,8 +1,10 @@
package com.eu.habbo.messages.incoming.rooms.users; package com.eu.habbo.messages.incoming.rooms.users;
import com.eu.habbo.Emulator; 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.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; 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.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.users.UserSignEvent; import com.eu.habbo.plugin.events.users.UserSignEvent;
@ -20,6 +22,16 @@ public class RoomUserSignEvent extends MessageHandler {
if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) { if (!Emulator.getPluginManager().fireEvent(event).isCancelled()) {
this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + ""); this.client.getHabbo().getRoomUnit().setStatus(RoomUnitStatus.SIGN, event.sign + "");
this.client.getHabbo().getHabboInfo().getCurrentRoom().unIdle(this.client.getHabbo()); 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);
}
}
}
} }
} }
} }

View File

@ -11,32 +11,29 @@ import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import com.eu.habbo.plugin.events.users.UserIdleEvent; import com.eu.habbo.plugin.events.users.UserIdleEvent;
import gnu.trove.set.hash.THashSet;
public class RoomUserWalkEvent extends MessageHandler { public class RoomUserWalkEvent extends MessageHandler {
@Override @Override
public void handle() throws Exception public void handle() throws Exception {
{ if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) {
if (this.client.getHabbo().getHabboInfo().getCurrentRoom() != null) int x = this.packet.readInt(); // Position X
{ int y = this.packet.readInt(); // Position Y
int x = this.packet.readInt(); ///< Position X
int y = this.packet.readInt(); ///<Position Y
/// Get Habbo object // Get Habbo object
Habbo habbo = this.client.getHabbo(); Habbo habbo = this.client.getHabbo();
/// Get Room Habbo object (Unique GUID?) // Get Room Habbo object (Unique GUID?)
RoomUnit roomUnit = this.client.getHabbo().getRoomUnit(); RoomUnit roomUnit = this.client.getHabbo().getRoomUnit();
/// If habbo is teleporting, dont calculate a new path // If habbo is teleporting, dont calculate a new path
if (roomUnit.isTeleporting) if (roomUnit.isTeleporting)
return; return;
/// If habbo is being kicked dont calculate a new path // If habbo is being kicked dont calculate a new path
if (roomUnit.isKicked) if (roomUnit.isKicked)
return; return;
/// If habbo has control (im assuming admin, do something else, but we dont care about this part here) // If habbo has control (im assuming admin, do something else, but we dont care about this part here)
if (roomUnit.getCacheable().get("control") != null) { if (roomUnit.getCacheable().get("control") != null) {
habbo = (Habbo) roomUnit.getCacheable().get("control"); habbo = (Habbo) roomUnit.getCacheable().get("control");
@ -47,54 +44,50 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
/// Get room unit? // Get room unit?
roomUnit = habbo.getRoomUnit(); roomUnit = habbo.getRoomUnit();
/// Get the room the habbo is in // Get the room the habbo is in
Room room = habbo.getHabboInfo().getCurrentRoom(); Room room = habbo.getHabboInfo().getCurrentRoom();
try try {
{ // If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path
/// If our room unit is not nullptr and we are in a room and we can walk, then calculate a new path if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) {
if (roomUnit != null && roomUnit.isInRoom() && roomUnit.canWalk()) // If we are not teleporting calcualte a new path
{ if (!roomUnit.cmdTeleport) {
/// If we are not teleporting calcualte a new path // Don't calculate a new path if we are on a horse
if (!roomUnit.cmdTeleport)
{
/// Don't calculate a new path if we are on a horse
if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP)) if (habbo.getHabboInfo().getRiding() != null && habbo.getHabboInfo().getRiding().getTask() != null && habbo.getHabboInfo().getRiding().getTask().equals(PetTasks.JUMP))
return; return;
/// Don't calulcate a new path if are already at the end position // Don't calulcate a new path if are already at the end position
if (x == roomUnit.getX() && y == roomUnit.getY()) if (x == roomUnit.getX() && y == roomUnit.getY())
return; return;
if (room == null || room.getLayout() == null) if (room == null || room.getLayout() == null)
return; return;
/// Reset idle status // Reset idle status
if (roomUnit.isIdle()) if (roomUnit.isIdle()) {
{
UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false); UserIdleEvent event = new UserIdleEvent(habbo, UserIdleEvent.IdleReason.WALKED, false);
Emulator.getPluginManager().fireEvent(event); Emulator.getPluginManager().fireEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
if (!event.idle) { if (!event.idle) {
roomUnit.getRoom().unIdle(habbo); if (roomUnit.getRoom() != null) roomUnit.getRoom().unIdle(habbo);
roomUnit.resetIdleTimer(); roomUnit.resetIdleTimer();
} }
} }
} }
/// Get room height map // Get room height map
RoomTile tile = room.getLayout().getTile((short) x, (short) y); RoomTile tile = room.getLayout().getTile((short) x, (short) y);
/// this should never happen, if it does it would be a design flaw // this should never happen, if it does it would be a design flaw
if (tile == null) { if (tile == null) {
return; return;
} }
/// Don't care // Don't care
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) {
if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile))
return; return;
@ -107,11 +100,11 @@ public class RoomUserWalkEvent extends MessageHandler {
switch (bed.getRotation()) { switch (bed.getRotation()) {
case 0: case 0:
case 4: case 4:
pillow = room.getLayout().getTile((short)x, bed.getY()); pillow = room.getLayout().getTile((short) x, bed.getY());
break; break;
case 2: case 2:
case 8: case 8:
pillow = room.getLayout().getTile(bed.getX(), (short)y); pillow = room.getLayout().getTile(bed.getX(), (short) y);
break; break;
} }
@ -122,7 +115,7 @@ public class RoomUserWalkEvent extends MessageHandler {
} }
} }
/// This is where we set the end location and begin finding a path // This is where we set the end location and begin finding a path
if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) { if (tile.isWalkable() || room.canSitOrLayAt(tile.x, tile.y)) {
roomUnit.setGoalLocation(tile); roomUnit.setGoalLocation(tile);
} }

View File

@ -19,12 +19,6 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler {
String name = this.packet.readString(); String name = this.packet.readString();
if (name.equalsIgnoreCase(this.client.getHabbo().getHabboInfo().getUsername())) {
this.client.getHabbo().getHabboStats().allowNameChange = false;
this.client.sendResponse(new RoomUserNameChangedComposer(this.client.getHabbo()));
return;
}
int errorCode = ChangeNameCheckResultComposer.AVAILABLE; int errorCode = ChangeNameCheckResultComposer.AVAILABLE;
List<String> suggestions = new ArrayList<>(4); List<String> suggestions = new ArrayList<>(4);
@ -32,7 +26,7 @@ public class ChangeNameCheckUsernameEvent extends MessageHandler {
errorCode = ChangeNameCheckResultComposer.TOO_SHORT; errorCode = ChangeNameCheckResultComposer.TOO_SHORT;
} else if (name.length() > 15) { } else if (name.length() > 15) {
errorCode = ChangeNameCheckResultComposer.TOO_LONG; 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; errorCode = ChangeNameCheckResultComposer.TAKEN_WITH_SUGGESTIONS;
suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999));
suggestions.add(name + Emulator.getRandom().nextInt(9999)); suggestions.add(name + Emulator.getRandom().nextInt(9999));

View File

@ -28,33 +28,28 @@ public class AdventCalendarDataComposer extends MessageComposer {
this.response.appendString(""); this.response.appendString("");
this.response.appendInt(this.currentDay); this.response.appendInt(this.currentDay);
this.response.appendInt(this.totalDays); this.response.appendInt(this.totalDays);
this.response.appendInt(this.unlocked.size()); this.response.appendInt(this.unlocked.size());
TIntArrayList expired = new TIntArrayList(); TIntArrayList expired = new TIntArrayList();
for (int i = 0; i < this.totalDays; i++) { for (int i = 0; i < this.totalDays; i++) {
expired.add(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() { this.unlocked.forEach(value -> {
@Override
public boolean execute(int value) {
AdventCalendarDataComposer.this.response.appendInt(value); AdventCalendarDataComposer.this.response.appendInt(value);
expired.remove(value); expired.remove(value);
return true; return true;
}
}); });
if (this.lockExpired) { if (this.lockExpired) {
this.response.appendInt(expired.size()); this.response.appendInt(expired.size());
expired.forEach(new TIntProcedure() { expired.forEach(value -> {
@Override
public boolean execute(int value) {
AdventCalendarDataComposer.this.response.appendInt(value); AdventCalendarDataComposer.this.response.appendInt(value);
return true; return true;
}
}); });
} else { } else {
this.response.appendInt(0); this.response.appendInt(0);

View File

@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.events.calendar; package com.eu.habbo.messages.outgoing.events.calendar;
import com.eu.habbo.habbohotel.catalog.CalendarRewardObject; 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.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
@ -18,9 +19,9 @@ public class AdventCalendarProductComposer extends MessageComposer {
public ServerMessage compose() { public ServerMessage compose() {
this.response.init(Outgoing.AdventCalendarProductComposer); this.response.init(Outgoing.AdventCalendarProductComposer);
this.response.appendBoolean(this.visible); 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.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; return this.response;
} }
} }

View File

@ -36,7 +36,7 @@ public class FriendsComposer extends MessageComposer {
this.response.appendInt(row.getValue().getGender().equals(HabboGender.M) ? 0 : 1); this.response.appendInt(row.getValue().getGender().equals(HabboGender.M) ? 0 : 1);
this.response.appendBoolean(row.getValue().getOnline() == 1); this.response.appendBoolean(row.getValue().getOnline() == 1);
this.response.appendBoolean(row.getValue().inRoom()); //IN ROOM 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.appendInt(0);
this.response.appendString(row.getValue().getMotto()); this.response.appendString(row.getValue().getMotto());
this.response.appendString(""); this.response.appendString("");

View File

@ -7,11 +7,17 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class UserSearchResultComposer extends MessageComposer { public class UserSearchResultComposer extends MessageComposer {
private final THashSet<MessengerBuddy> users; private final THashSet<MessengerBuddy> users;
private final THashSet<MessengerBuddy> friends; private final THashSet<MessengerBuddy> friends;
private final Habbo habbo; 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<MessengerBuddy> users, THashSet<MessengerBuddy> friends, Habbo habbo) { public UserSearchResultComposer(THashSet<MessengerBuddy> users, THashSet<MessengerBuddy> friends, Habbo habbo) {
this.users = users; this.users = users;
this.friends = friends; this.friends = friends;
@ -21,14 +27,19 @@ public class UserSearchResultComposer extends MessageComposer {
@Override @Override
public ServerMessage compose() { public ServerMessage compose() {
this.response.init(Outgoing.UserSearchResultComposer); this.response.init(Outgoing.UserSearchResultComposer);
THashSet<MessengerBuddy> u = new THashSet<>(); List<MessengerBuddy> u = new ArrayList<>();
for (MessengerBuddy buddy : this.users) { for (MessengerBuddy buddy : this.users) {
if (!buddy.getUsername().equals(this.habbo.getHabboInfo().getUsername()) && !this.inFriendList(buddy)) { if (!this.inFriendList(buddy)) {
u.add(buddy); u.add(buddy);
} }
} }
List<MessengerBuddy> friends = new ArrayList<>(this.friends);
u.sort(UserSearchResultComposer.COMPARATOR);
friends.sort(UserSearchResultComposer.COMPARATOR);
this.response.appendInt(this.friends.size()); this.response.appendInt(this.friends.size());
for (MessengerBuddy buddy : this.friends) { for (MessengerBuddy buddy : this.friends) {
this.response.appendInt(buddy.getId()); this.response.appendInt(buddy.getId());
@ -51,7 +62,7 @@ public class UserSearchResultComposer extends MessageComposer {
this.response.appendBoolean(false); this.response.appendBoolean(false);
this.response.appendString(""); this.response.appendString("");
this.response.appendInt(1); this.response.appendInt(1);
this.response.appendString(buddy.getLook()); this.response.appendString(buddy.getOnline() == 1 ? buddy.getLook() : "");
this.response.appendString(""); this.response.appendString("");
} }

View File

@ -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.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(14);
this.response.appendInt(this.pageId); this.response.appendInt(this.pageId);
this.response.appendInt(this.level); this.response.appendInt(this.level);

View File

@ -19,21 +19,29 @@ public class UserEffectsListComposer extends MessageComposer {
public ServerMessage compose() { public ServerMessage compose() {
this.response.init(Outgoing.UserEffectsListComposer); this.response.init(Outgoing.UserEffectsListComposer);
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) { synchronized (this.habbo.getInventory().getEffectsComponent().effects) {
this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size()); this.response.appendInt(this.habbo.getInventory().getEffectsComponent().effects.size());
this.habbo.getInventory().getEffectsComponent().effects.forEachValue(new TObjectProcedure<EffectsComponent.HabboEffect>() { this.habbo.getInventory().getEffectsComponent().effects.forEachValue(effect -> {
@Override
public boolean execute(EffectsComponent.HabboEffect effect) {
UserEffectsListComposer.this.response.appendInt(effect.effect); UserEffectsListComposer.this.response.appendInt(effect.effect);
UserEffectsListComposer.this.response.appendInt(0); UserEffectsListComposer.this.response.appendInt(0);
UserEffectsListComposer.this.response.appendInt(effect.duration); UserEffectsListComposer.this.response.appendInt(effect.duration > 0 ? effect.duration : 1);
UserEffectsListComposer.this.response.appendInt(effect.total); UserEffectsListComposer.this.response.appendInt(effect.total - (effect.isActivated() ? 1 : 0));
UserEffectsListComposer.this.response.appendInt(effect.activationTimestamp >= 0 ? Emulator.getIntUnixTimestamp() - effect.activationTimestamp : -1);
UserEffectsListComposer.this.response.appendBoolean(effect.isActivated()); if(!effect.isActivated()) {
return true; 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; return this.response;
} }
} }

View File

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

View File

@ -6,11 +6,12 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing; import com.eu.habbo.messages.outgoing.Outgoing;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
public class NewNavigatorSavedSearchesComposer extends MessageComposer { public class NewNavigatorSavedSearchesComposer extends MessageComposer {
private final HashSet<NavigatorSavedSearch> searches; private final List<NavigatorSavedSearch> searches;
public NewNavigatorSavedSearchesComposer(HashSet<NavigatorSavedSearch> searches) { public NewNavigatorSavedSearchesComposer(List<NavigatorSavedSearch> searches) {
this.searches = searches; this.searches = searches;
} }

View File

@ -25,8 +25,21 @@ public class UpdateStackHeightComposer extends MessageComposer {
@Override @Override
public ServerMessage compose() { 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); this.response.init(Outgoing.UpdateStackHeightComposer);
if (this.updateTiles != null) { 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()); this.response.appendByte(this.updateTiles.size());
for (RoomTile t : this.updateTiles) { for (RoomTile t : this.updateTiles) {
this.response.appendByte((int) t.x); this.response.appendByte((int) t.x);

Some files were not shown because too many files have changed in this diff Show More