Merge branch 'dev' into 'dev'

# Conflicts:
#   src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java
This commit is contained in:
Harmonic 2022-04-11 00:24:35 +00:00
commit df35e727bb
176 changed files with 2431 additions and 1209 deletions

161
README.md
View File

@ -1,84 +1,59 @@
# Arcturus Morningstar #
## What is Arcturus Morningstar? ##
Arcturus Morningstar is the community project for the Arcturus Emulator by TheGeneral.
The community project was made because the Arcturus Emulator has been abandoned by TheGeneral with lack of updates, an intent to monetize the project, and make the project private.
TheGeneral's own words were "dont like it then dont use it". We did not like what he was doing, so we made our own version.
## License ##
Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt).
## Versions ##
[![image](https://img.shields.io/badge/VERSION-3.0.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/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=DISCORD&logoColor=fff)](https://discord.gg/BzfFsTp)
Compiled Download: https://git.krews.org/morningstar/Arcturus-Community/-/releases
Client build: **PRODUCTION-201611291003-338511768**
## Reporting problems ##
You can report problems via the Issue Tracker at https://git.krews.org/morningstar/Arcturus-Community/issues
When making an bug report or a feature request use the template we provide so that it can be categorized correctly and we have more information to replicate a bug or implement a feature correctly.
## Credits ##
- TheGeneral
- Beny
- Alejandro
- Capheus
- Skeletor
- Harmonic
- Mike
- Remco
- zGrav
- Quadral
- Harmony
- Swirny
- ArpyAge
- Mikkel
- Rodolfo
- Rasmus
- Kitt Mustang
- Snaiker
- nttzx
- necmi
- Dome
- Jose Flores
- Cam
- Oliver
- Narzo
- Tenshie
- MartenM
- Ridge
- SenpaiDipper
- Snaiker
- Thijmen
Arcturus Morningstar is as a fork of Arcturus Emulator by TheGeneral. Arcturus Morningstar is released under the [GNU General Public License v3](https://www.gnu.org/licenses/gpl-3.0.txt) and is developed for free by talented developers at Krews.org and is compatible with the following client revision/community projects:
## Discord ##
Join us on Discord at https://discord.gg/BzfFsTp
| Flash | Community Clients |
| ------------- | ------------- |
| [PRODUCTION-201611291003-338511768](https://git.krews.org/morningstar/apollyon/uploads/dc669a26613bf2356e48eb653734ab29/patched-habbo.swf) | [Nitro (Recommended)*](https://git.krews.org/nitro) |
###### *Note to use Nitro you will need to use the following [plugin](https://git.krews.org/nitro/ms-websockets/-/releases) with Arcturus Morningstar #######
## Contributing ##
Anyone is allowed to fork the project and make pull requests. We make no guarantee that pull requests will be approved into the project.
## Branches ##
There will be 2 branches of the Arcturus Morningstar emulator:
`master` - The master branch will be the stable branch. Everything here has been tested on a live hotel and contains no known problems.
`dev` - The dev branch will be the unstable branch. This one is the most up to date, but things may not work as intended.
There is no set timeframe on when new versions will be released or when the stable branch will be updated.
[![image](https://img.shields.io/discord/557240155040251905?style=for-the-badge&logo=discord&color=7289DA&label=KREWS&logoColor=fff)](https://discord.gg/BzfFsTp)
## Custom features ##
Do not implement custom features into the source.
A custom feature will be defined as a feature or ability which is not possible in Habbo.com
Use plugins for custom features, and if a plugin is not possible, you should adapt the source to enable plugins to do that.
## Download ##
[![image](https://img.shields.io/badge/STABLE%20RELEASES-3.0.0-success.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/releases)
## Why always make things as plugins? ##
Why always make things as plugins?
[![image](https://img.shields.io/badge/DEVELOPER%20BUILDS-3.1.0-red.svg?style=for-the-badge&logo=appveyor)](https://git.krews.org/morningstar/Arcturus-Community/-/jobs) *
[![image](https://img.shields.io/badge/RECOMMENDED%20PLUGINS-blue.svg?style=for-the-badge&logo=)](https://git.krews.org/official-plugins)
###### * Note to use these builds you will need to run any database updates from [here](https://git.krews.org/morningstar/Arcturus-Community/-/tree/dev/sqlupdates) #######
### Branches ###
There are two main branches in use on the Arcturus Morningstar git. Below the pros an
| master | Tested on a production hotel and is stable for every day use with no known serious exploits. |
| ------------- | ------------- |
| dev | The most up-to-date, but features may not work as intended. |
| ------------- | ------------- |
There is no set timeframe on when new versions will be released or when the stable branch will be updated
## Can I Help!? ##
#### Reporting Bugs: ####
You can report problems via the [Issue Tracker](https://git.krews.org/morningstar/Arcturus-Community/issues)*
###### * When making an bug report or a feature request use the template we provide so that it can be categorized correctly and we have more information to replicate a bug or implement a feature correctly. ######
#### Can I contribute code to this project? ####
Of Course! if you have fixed a bug from the git please feel free to do a [merge request](https://git.krews.org/morningstar/Arcturus-Community/issues)*
###### * Anyone is allowed to fork the project and make pull requests, we make no guarantee that pull requests will be approved into the project. Please Do NOT push code which does not replicate behaviour on habbo.com, instead make the behaviour configurable or as a plugin. ######
## Plugin System ##
The robust Plugin System included in the original Arcturus release is also included in Arcturus Morningstar, if you're interested in making your own plugins, feel free to ask around on our discord and we'll point you in the right direction!
A lot of the community aren't used to modifying things in this way, so we've written a few pros:
1. Other people will see that plugins are the normal way of adding custom features
2. Plugins can be added and removed at the hotel owner's choice, it makes customizing the hotel easier
3. Developers will be able to read plugin source code to learn how to make their own plugins, without the need to look in complicated source code
@ -91,8 +66,48 @@ Sale of a special edition of a *source code* will not be permitted. You may use
If we ever are to make paid features or plugins, we will not prevent or discourage developers from creating alternative options for users.
## Plugins - Official Plugins ##
You can find official plugins to add custom features to Arcturus Morningstar at the following URL:
[View the respository here.](https://git.krews.org/official-plugins)
### Credits ###
- TheGeneral (Arcturus Emulator)
- Beny
- Alejandro
- Capheus
- Skeletor
- Harmonic
- Mike
- Remco
- zGrav
- Quadral
- Harmony
- Swirny
- ArpyAge
- Mikkel
- Rodolfo
- Rasmus
- Kitt Mustang
- Snaiker
- nttzx
- necmi
- Dome
- Jose Flores
- Cam
- Oliver
- Narzo
- Tenshie
- MartenM
- Ridge
- SenpaiDipper
- Thijmen
- Brenoepic
- Stankman
- Laynester

View File

@ -106,7 +106,7 @@
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.49</version>
<version>8.0.22</version>
<scope>runtime</scope>
</dependency>

View File

@ -0,0 +1,87 @@
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.place.under', '0');
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('wired.custom.enabled', '0');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_stalk.forgot_username', 'Specify the username of the Habbo you want to follow!');
-- Enable or Disable TTY in console (Default is enabled)
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('console.mode', '1');
-- Youtube Api v3 key to YoutubeManager
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('youtube.apikey', '');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.gifts.length.max', '300');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.trophies.length.max', '300');
-- Add friendship categories table
CREATE TABLE `messenger_categories` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(25) NOT NULL,
`user_id` int NOT NULL,
UNIQUE KEY `identifier` (`id`)
);
-- Set an ID (int) from category list items
ALTER TABLE messenger_friendships ADD category int NOT NULL DEFAULT '0' AFTER friends_since;
-- ----------------------------
-- Table structure for calendar_campaigns
-- ----------------------------
DROP TABLE IF EXISTS `calendar_campaigns`;
CREATE TABLE `calendar_campaigns` (
`id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`image` varchar(255) NOT NULL DEFAULT '',
`start_timestamp` int NOT NULL DEFAULT '0',
`total_days` int NOT NULL DEFAULT '30',
`lock_expired` enum('1','0') NOT NULL DEFAULT '1',
`enabled` enum('1','0') NOT NULL DEFAULT '1',
UNIQUE KEY `id` (`id`)
);
-- ----------------------------
-- Table structure for calendar_rewards
-- ----------------------------
DROP TABLE IF EXISTS `calendar_rewards`;
CREATE TABLE `calendar_rewards` (
`id` int NOT NULL AUTO_INCREMENT,
`campaign_id` int NOT NULL DEFAULT '0',
`product_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
`custom_image` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
`credits` int NOT NULL DEFAULT '0',
`pixels` int NOT NULL DEFAULT '0',
`points` int NOT NULL DEFAULT '0',
`points_type` int NOT NULL DEFAULT '0',
`badge` varchar(25) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT '',
`item_id` int NOT NULL DEFAULT '0',
`subscription_type` varchar(128) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT '',
`subscription_days` int NOT NULL DEFAULT '0',
PRIMARY KEY (`id`) USING BTREE
);
-- ----------------------------
-- Table structure for calendar_rewards_claimed
-- ----------------------------
DROP TABLE IF EXISTS `calendar_rewards_claimed`;
CREATE TABLE `calendar_rewards_claimed` (
`user_id` int NOT NULL,
`campaign_id` int NOT NULL DEFAULT '0',
`day` int NOT NULL,
`reward_id` int NOT NULL,
`timestamp` int NOT NULL
);
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.default', 'test');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.calendar.pixels.hc_modifier', '2.0');
-- Calendar force open
ALTER TABLE `permissions` ADD COLUMN `acc_calendar_force` enum('0','1') NULL DEFAULT '0';
-- UpdateCalendar command.
ALTER TABLE `permissions` ADD `cmd_update_calendar` ENUM('0', '1') NOT NULL DEFAULT '0';
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.description.cmd_update_calendar', ':update_calendar'), ('commands.keys.cmd_update_calendar', 'update_calendar');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.success.cmd_update_calendar', 'Calendar updated successfully!');
-- add moodlight configuration
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('moodlight.color_check.enabled', '1');

View File

@ -32,8 +32,8 @@ import java.util.regex.Pattern;
public final class Emulator {
private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
private static final String OS_NAME = System.getProperty("os.name");
private static final String CLASS_PATH = System.getProperty("java.class.path");
private static final String OS_NAME = (System.getProperty("os.name") != null ? System.getProperty("os.name") : "Unknown");
private static final String CLASS_PATH = (System.getProperty("java.class.path") != null ? System.getProperty("java.class.path") : "Unknown");
public final static int MAJOR = 3;
public final static int MINOR = 0;
@ -119,8 +119,7 @@ public final class Emulator {
LOGGER.info("This project is for educational purposes only. This Emulator is an open-source fork of Arcturus created by TheGeneral.");
LOGGER.info("Version: {}", version);
LOGGER.info("Build: {}", build);
LOGGER.info("Remember to sign up your hotel to join our toplist beta at https://bit.ly/2NN0rxq");
LOGGER.info("Join our discord at https://discord.gg/syuqgN");
LOGGER.info("Follow our development at https://git.krews.org/morningstar/Arcturus-Community");
long startTime = System.nanoTime();
@ -170,31 +169,35 @@ public final class Emulator {
Emulator.timeStarted = getIntUnixTimestamp();
if (Emulator.getConfig().getInt("runtime.threads") < (Runtime.getRuntime().availableProcessors() * 2)) {
LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to {} to possibly increase performance.",
LOGGER.warn("Emulator settings runtime.threads ({}) can be increased to ({}) to possibly increase performance.",
Emulator.getConfig().getInt("runtime.threads"),
Runtime.getRuntime().availableProcessors() * 2);
}
Emulator.getThreading().run(() -> {
}, 1500);
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Check if console mode is true or false, default is true
if (Emulator.getConfig().getBoolean("console.mode", true)) {
while (!isShuttingDown && isReady) {
try {
String line = reader.readLine();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
if (line != null) {
ConsoleCommand.handle(line);
}
System.out.println("Waiting for command: ");
} catch (Exception e) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
LOGGER.error("Error while reading command", e);
while (!isShuttingDown && isReady) {
try {
String line = reader.readLine();
if (line != null) {
ConsoleCommand.handle(line);
}
System.out.println("Waiting for command: ");
} catch (Exception e) {
if (!(e instanceof IOException && e.getMessage().equals("Bad file descriptor"))) {
LOGGER.error("Error while reading command", e);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
@ -499,4 +502,4 @@ public final class Emulator {
public int getRoomCount() {
return gameEnvironment.getRoomManager().getActiveRooms().size();
}
}
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.guilds.forums.ForumThread;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.friends.SearchUserEvent;
import com.eu.habbo.messages.incoming.navigator.SearchRoomsEvent;
import com.eu.habbo.messages.outgoing.users.UserDataComposer;
import com.eu.habbo.threading.runnables.AchievementUpdater;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -146,6 +147,7 @@ public class CleanerThread implements Runnable {
for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) {
habbo.getHabboStats().respectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect");
habbo.getHabboStats().petRespectPointsToGive = Emulator.getConfig().getInt("hotel.daily.respect.pets");
habbo.getClient().sendResponse(new UserDataComposer(habbo));
}
}
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.core.*;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.BotManager;
import com.eu.habbo.habbohotel.campaign.calendar.CalendarManager;
import com.eu.habbo.habbohotel.catalog.CatalogManager;
import com.eu.habbo.habbohotel.commands.CommandHandler;
import com.eu.habbo.habbohotel.crafting.CraftingManager;
@ -54,6 +55,7 @@ public class GameEnvironment {
private CraftingManager craftingManager;
private PollManager pollManager;
private SubscriptionManager subscriptionManager;
private CalendarManager calendarManager;
public void load() throws Exception {
LOGGER.info("GameEnvironment -> Loading...");
@ -78,6 +80,7 @@ public class GameEnvironment {
this.wordFilter = new WordFilter();
this.craftingManager = new CraftingManager();
this.pollManager = new PollManager();
this.calendarManager = new CalendarManager();
this.roomManager.loadPublicRooms();
this.navigatorManager.loadNavigator();
@ -114,6 +117,7 @@ public class GameEnvironment {
this.itemManager.dispose();
this.hotelViewManager.dispose();
this.subscriptionManager.dispose();
this.calendarManager.dispose();
LOGGER.info("GameEnvironment -> Disposed!");
}
@ -206,4 +210,6 @@ public class GameEnvironment {
public SubscriptionManager getSubscriptionManager() {
return this.subscriptionManager;
}
public CalendarManager getCalendarManager() { return this.calendarManager; }
}

View File

@ -0,0 +1,64 @@
package com.eu.habbo.habbohotel.campaign.calendar;
import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Map;
public class CalendarCampaign {
private int id;
private final String name;
private final String image;
private Map<Integer , CalendarRewardObject> rewards = new THashMap<>();
private final Integer start_timestamp;
private final int total_days;
private final boolean lock_expired;
public CalendarCampaign(ResultSet set) throws SQLException {
this.id = set.getInt("id");
this.name = set.getString("name");
this.image = set.getString("image");
this.start_timestamp = set.getInt("start_timestamp");
this.total_days = set.getInt("total_days");
this.lock_expired = set.getInt("lock_expired") == 1;
}
public CalendarCampaign(int id, String name, String image, Integer start_timestamp, int total_days, boolean lock_expired) {
this.id = id;
this.name = name;
this.image = image;
this.start_timestamp = start_timestamp;
this.total_days = total_days;
this.lock_expired = lock_expired;
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public String getImage() {
return this.image;
}
public Integer getStartTimestamp() {
return this.start_timestamp;
}
public int getTotalDays() { return this.total_days; }
public boolean getLockExpired() { return this.lock_expired; }
public Map<Integer, CalendarRewardObject> getRewards() { return rewards; }
public void setId(int id) { this.id = id; }
public void setRewards(Map<Integer, CalendarRewardObject> rewards) { this.rewards = rewards; }
public void addReward(CalendarRewardObject reward) { this.rewards.put(reward.getId(), reward); }
}

View File

@ -0,0 +1,154 @@
package com.eu.habbo.habbohotel.campaign.calendar;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer;
import com.eu.habbo.plugin.events.users.calendar.UserClaimRewardEvent;
import gnu.trove.map.hash.THashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.*;
import java.util.*;
import java.util.Date;
import static java.time.temporal.ChronoUnit.DAYS;
public class CalendarManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CalendarCampaign.class);
final private static Map<Integer, CalendarCampaign> calendarCampaigns = new THashMap<>();
public static double HC_MODIFIER;
public CalendarManager() {
long millis = System.currentTimeMillis();
this.reload();
LOGGER.info("Calendar Manager -> Loaded! ({} MS)", (System.currentTimeMillis() - millis));
}
public void dispose(){
calendarCampaigns.clear();
}
public boolean reload() {
this.dispose();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_campaigns WHERE enabled = 1")) {
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
calendarCampaigns.put(set.getInt("id"), new CalendarCampaign(set));
}
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
return false;
}
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) {
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
CalendarCampaign campaign = calendarCampaigns.get(set.getInt("campaign_id"));
if(campaign != null){
campaign.addReward(new CalendarRewardObject(set));
}
}
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
return false;
}
HC_MODIFIER = Emulator.getConfig().getDouble("hotel.calendar.pixels.hc_modifier", 2.0);
return true;
}
public void addCampaign(CalendarCampaign campaign) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_campaigns ( name, image, start_timestamp, total_days, lock_expired) VALUES (?, ?, ?, ? , ?)", Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, campaign.getName());
statement.setString(2, campaign.getImage());
statement.setInt(3, campaign.getStartTimestamp());
statement.setInt(4, campaign.getTotalDays());
statement.setBoolean(5, campaign.getLockExpired());
int affectedRows = statement.executeUpdate();
if (affectedRows == 0) {
throw new SQLException("Creating calendar campaign failed, no rows affected.");
}
try (ResultSet generatedKeys = statement.getGeneratedKeys()) {
if (generatedKeys.next()) {
campaign.setId(generatedKeys.getInt(1));
} else {
throw new SQLException("Creating calendar campaign failed, no ID found.");
}
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
calendarCampaigns.put(campaign.getId(), campaign);
}
public boolean deleteCampaign(CalendarCampaign campaign) {
calendarCampaigns.remove(campaign.getId());
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM calendar_campaigns WHERE id = ? LIMIT 1")) {
statement.setInt(1, campaign.getId());
return statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
return false;
}
public CalendarCampaign getCalendarCampaign(String campaignName) {
return calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null);
}
public Map<Integer, CalendarCampaign> getCalendarCampaigns() {
return calendarCampaigns;
}
public void claimCalendarReward(Habbo habbo, String campaignName, int day, boolean force) {
CalendarCampaign campaign = calendarCampaigns.values().stream().filter(cc -> Objects.equals(cc.getName(), campaignName)).findFirst().orElse(null);
if(campaign == null) return;
if (habbo.getHabboStats().calendarRewardsClaimed.stream().noneMatch(claimed -> claimed.getCampaignId() == campaign.getId() && claimed.getDay() == day)) {
Set<Integer> keys = campaign.getRewards().keySet();
Map<Integer, Integer> rewards = new THashMap<>();
if(keys.isEmpty()) return;
keys.forEach(key -> rewards.put(rewards.size() + 1, key));
int rand = Emulator.getRandom().nextInt(rewards.size() - 1 + 1) + 1;
int random = rewards.get(rand);
CalendarRewardObject object = campaign.getRewards().get(random);
if (object == null) return;
int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
if(daysBetween >= 0 && daysBetween <= campaign.getTotalDays()) {
int diff = (daysBetween - day);
if ((((diff <= 2 || !campaign.getLockExpired()) && diff >= 0) || (force && habbo.hasPermission("acc_calendar_force")))) {
if (Emulator.getPluginManager().fireEvent(new UserClaimRewardEvent(habbo, campaign, day, object, force)).isCancelled()) {
return;
}
habbo.getHabboStats().calendarRewardsClaimed.add(new CalendarRewardClaimed(habbo.getHabboInfo().getId(), campaign.getId(), day, object.getId(), new Timestamp(System.currentTimeMillis())));
habbo.getClient().sendResponse(new AdventCalendarProductComposer(true, object, habbo));
object.give(habbo);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, campaign_id, day, reward_id, timestamp) VALUES (?, ?, ?, ?, ?)")) {
statement.setInt(1, habbo.getHabboInfo().getId());
statement.setInt(2, campaign.getId());
statement.setInt(3, day);
statement.setInt(4, object.getId());
statement.setInt(5, Emulator.getIntUnixTimestamp());
statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
}
}
}
}

View File

@ -0,0 +1,50 @@
package com.eu.habbo.habbohotel.campaign.calendar;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
public class CalendarRewardClaimed {
private final int user_id;
private final int campaign;
private final int day;
private final int reward_id;
private final Timestamp timestamp;
public CalendarRewardClaimed(ResultSet set) throws SQLException {
this.user_id = set.getInt("user_id");
this.campaign = set.getInt("campaign_id");
this.day = set.getInt("day");
this.reward_id = set.getInt("reward_id");
this.timestamp = new Timestamp(set.getInt("timestamp") * 1000L);
}
public CalendarRewardClaimed(int user_id, int campaign, int day, int reward_id, Timestamp timestamp) {
this.user_id = user_id;
this.campaign = campaign;
this.day = day;
this.reward_id = reward_id;
this.timestamp = timestamp;
}
public int getUserId() {
return this.user_id;
}
public int getCampaignId() {
return this.campaign;
}
public int getDay() {
return this.day;
}
public int getRewardId() {
return this.reward_id;
}
public Timestamp getTimestamp() {
return this.timestamp;
}
}

View File

@ -1,32 +1,47 @@
package com.eu.habbo.habbohotel.catalog;
package com.eu.habbo.habbohotel.campaign.calendar;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
public class CalendarRewardObject {
private static final Logger LOGGER = LoggerFactory.getLogger(CalendarRewardObject.class);
private final int id;
private final String productName;
private final String customImage;
private final int credits;
private final int pixels;
private final int points;
private final int pointsType;
private final String badge;
private final int itemId;
private final String subscription_type;
private final int subscription_days;
public CalendarRewardObject(ResultSet set) throws SQLException {
this.id = set.getInt("id");
this.productName = set.getString("product_name");
this.customImage = set.getString("custom_image");
this.credits = set.getInt("credits");
this.pixels = set.getInt("pixels");
this.points = set.getInt("points");
this.pointsType = set.getInt("points_type");
this.badge = set.getString("badge");
this.itemId = set.getInt("item_id");
this.subscription_type = set.getString("subscription_type");
this.subscription_days = set.getInt("subscription_days");
}
public void give(Habbo habbo) {
@ -34,6 +49,10 @@ public class CalendarRewardObject {
habbo.giveCredits(this.credits);
}
if (this.pixels > 0) {
habbo.givePixels((int)(this.pixels * (habbo.getHabboStats().hasActiveClub() ? CalendarManager.HC_MODIFIER : 1.0)));
}
if (this.points > 0) {
habbo.givePoints(this.pointsType, this.points);
}
@ -42,6 +61,14 @@ public class CalendarRewardObject {
habbo.addBadge(this.badge);
}
if(this.subscription_type != null && !this.subscription_type.isEmpty()) {
if ("HABBO_CLUB".equals(this.subscription_type)) {
habbo.getHabboStats().createSubscription(SubscriptionHabboClub.HABBO_CLUB, this.subscription_days * 86400);
} else {
habbo.getHabboStats().createSubscription(this.subscription_type, this.subscription_days * 86400);
}
}
if (this.itemId > 0) {
Item item = getItem();
@ -71,6 +98,9 @@ public class CalendarRewardObject {
return this.credits;
}
public int getPixels() {
return this.pixels;
}
public int getPoints() {
return this.points;
}
@ -79,6 +109,18 @@ public class CalendarRewardObject {
return this.pointsType;
}
public String getProductName() {
return productName;
}
public String getSubscriptionType() {
return subscription_type;
}
public int getSubscriptionDays() {
return subscription_days;
}
public String getBadge() {
return this.badge;
}
@ -86,4 +128,5 @@ public class CalendarRewardObject {
public Item getItem() {
return Emulator.getGameEnvironment().getItemManager().getItem(this.itemId);
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.catalog;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.campaign.calendar.CalendarRewardObject;
import com.eu.habbo.habbohotel.catalog.layouts.*;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.guilds.Guild;
@ -190,7 +191,6 @@ public class CatalogManager {
public final TIntIntHashMap offerDefs;
public final Item ecotronItem;
public final THashMap<Integer, CatalogLimitedConfiguration> limitedNumbers;
public final THashMap<Integer, CalendarRewardObject> calendarRewards;
private final List<Voucher> vouchers;
public CatalogManager() {
@ -207,7 +207,6 @@ public class CatalogManager {
this.offerDefs = new TIntIntHashMap();
this.vouchers = new ArrayList<>();
this.limitedNumbers = new THashMap<>();
this.calendarRewards = new THashMap<>();
this.initialize();
@ -230,7 +229,6 @@ public class CatalogManager {
this.loadClothing();
this.loadRecycler();
this.loadGiftWrappers();
this.loadCalendarRewards();
}
private synchronized void loadLimitedNumbers() {
@ -482,23 +480,6 @@ public class CatalogManager {
}
}
private void loadCalendarRewards() {
synchronized (this.calendarRewards) {
this.calendarRewards.clear();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM calendar_rewards")) {
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
this.calendarRewards.put(set.getInt("id"), new CalendarRewardObject(set));
}
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
}
private void loadClothing() {
synchronized (this.clothing) {
this.clothing.clear();
@ -523,7 +504,6 @@ public class CatalogManager {
return null;
}
public Voucher getVoucher(String code) {
synchronized (this.vouchers) {
for (Voucher voucher : this.vouchers) {
@ -535,22 +515,20 @@ public class CatalogManager {
return null;
}
public void redeemVoucher(GameClient client, String voucherCode) {
Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode);
Habbo habbo = client.getHabbo();
if (habbo == null)
return;
Voucher voucher = Emulator.getGameEnvironment().getCatalogManager().getVoucher(voucherCode);
if (voucher == null) {
client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.INVALID_CODE));
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));
}
client.sendResponse(new RedeemVoucherErrorComposer(Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher) ? RedeemVoucherErrorComposer.INVALID_CODE : RedeemVoucherErrorComposer.TECHNICAL_ERROR));
return;
}
if (voucher.hasUserExhausted(habbo.getHabboInfo().getId())) {
@ -560,12 +538,6 @@ public class CatalogManager {
voucher.addHistoryEntry(habbo.getHabboInfo().getId());
if (voucher.isExhausted()) {
if (!Emulator.getGameEnvironment().getCatalogManager().deleteVoucher(voucher)) {
client.sendResponse(new RedeemVoucherErrorComposer(RedeemVoucherErrorComposer.TECHNICAL_ERROR));
}
}
if (voucher.points > 0) {
client.getHabbo().getHabboInfo().addCurrencyAmount(voucher.pointsType, voucher.points);
client.sendResponse(new UserPointsComposer(client.getHabbo().getHabboInfo().getCurrencyAmount(voucher.pointsType), voucher.points, voucher.pointsType));
@ -578,7 +550,6 @@ public class CatalogManager {
if (voucher.catalogItemId > 0) {
CatalogItem item = this.getCatalogItem(voucher.catalogItemId);
if (item != null) {
this.purchaseItem(null, item, client.getHabbo(), 1, "", true);
}
@ -587,7 +558,6 @@ public class CatalogManager {
client.sendResponse(new RedeemVoucherOKComposer());
}
public boolean deleteVoucher(Voucher voucher) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM vouchers WHERE code = ?")) {
statement.setString(1, voucher.code);
@ -1013,6 +983,10 @@ public class CatalogManager {
extradata = "UMAD";
}
if (extradata.length() > Emulator.getConfig().getInt("hotel.trophies.length.max", 300)) {
extradata = extradata.substring(0, Emulator.getConfig().getInt("hotel.trophies.length.max", 300));
}
extradata = habbo.getClient().getHabbo().getHabboInfo().getUsername() + (char) 9 + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "-" + (Calendar.getInstance().get(Calendar.MONTH) + 1) + "-" + Calendar.getInstance().get(Calendar.YEAR) + (char) 9 + Emulator.getGameEnvironment().getWordFilter().filter(extradata.replace(((char) 9) + "", ""), habbo);
}
@ -1079,12 +1053,9 @@ public class CatalogManager {
}
}
if (badgeFound) {
if (badgeFound && item.getBaseItems().size() == 1) {
habbo.getClient().sendResponse(new AlertPurchaseFailedComposer(AlertPurchaseFailedComposer.ALREADY_HAVE_BADGE));
if (item.getBaseItems().size() == 1) {
return;
}
}
UserCatalogItemPurchasedEvent purchasedEvent = new UserCatalogItemPurchasedEvent(habbo, item, itemsList, totalCredits, totalPoints, badges);
@ -1181,28 +1152,6 @@ public class CatalogManager {
return offers;
}
public void claimCalendarReward(Habbo habbo, int day, boolean force) {
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.getClient().sendResponse(new AdventCalendarProductComposer(true, object));
object.give(habbo);
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO calendar_rewards_claimed (user_id, reward_id, timestamp) VALUES (?, ?, ?)")) {
statement.setInt(1, habbo.getHabboInfo().getId());
statement.setInt(2, day);
statement.setInt(3, Emulator.getIntUnixTimestamp());
statement.execute();
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
}
}
public TargetOffer getTargetOffer(int offerId) {
return this.targetOffers.get(offerId);
}

View File

@ -38,7 +38,8 @@ public class Voucher {
}
private void loadHistory() {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM voucher_history WHERE voucher_id = ?")) {
statement.setInt(1, this.id);
try (ResultSet set = statement.executeQuery()) {
while (set.next()) {
this.history.add(new VoucherHistoryEntry(set));

View File

@ -67,7 +67,7 @@ public class MarketPlace {
if (offer != null && habbo.getInventory().getMarketplaceItems().contains(offer)) {
RequestOffersEvent.cachedResults.clear();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) {
try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?")) {
try (PreparedStatement ownerCheck = connection.prepareStatement("SELECT user_id FROM marketplace_items WHERE id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
ownerCheck.setInt(1, offer.getOfferId());
try (ResultSet ownerSet = ownerCheck.executeQuery()) {
ownerSet.last();
@ -122,7 +122,7 @@ public class MarketPlace {
query += " AND CEIL(price + (price / 100)) <= " + maxPrice;
}
if (search.length() > 0) {
query += " AND bi.public_name LIKE ? OR ci.catalog_name LIKE ?";
query += " AND ( bi.public_name LIKE ? OR ci.catalog_name LIKE ? ) ";
}
query += " GROUP BY base_item_id, ltd_data";
@ -177,7 +177,7 @@ public class MarketPlace {
public static void serializeItemInfo(int itemId, ServerMessage message) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT avg(marketplace_items.price) as price, COUNT(*) as sold, (datediff(NOW(), DATE(from_unixtime(marketplace_items.timestamp)))) as day FROM marketplace_items INNER JOIN items ON items.id = marketplace_items.item_id INNER JOIN items_base ON items.item_id = items_base.id WHERE items.limited_data = '0:0' AND marketplace_items.state = 2 AND items_base.sprite_id = ? AND DATE(from_unixtime(marketplace_items.timestamp)) >= NOW() - INTERVAL 30 DAY GROUP BY DATE(from_unixtime(marketplace_items.timestamp))", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
statement.setInt(1, itemId);
message.appendInt(avarageLastXDays(itemId, 7));
@ -206,7 +206,7 @@ public class MarketPlace {
public static int itemsOnSale(int baseItemId) {
int number = 0;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 1 AND timestamp >= ? AND items_base.sprite_id = ?")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as number, AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 1 AND timestamp >= ? AND items_base.sprite_id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
statement.setInt(1, Emulator.getIntUnixTimestamp() - 172800);
statement.setInt(2, baseItemId);
try (ResultSet set = statement.executeQuery()) {
@ -223,7 +223,7 @@ public class MarketPlace {
private static int avarageLastXDays(int baseItemId, int days) {
int avg = 0;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?")) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT AVG(price) as avg FROM marketplace_items INNER JOIN items ON marketplace_items.item_id = items.id INNER JOIN items_base ON items.item_id = items_base.id WHERE state = 2 AND DATE(from_unixtime(timestamp)) >= NOW() - INTERVAL ? DAY AND items_base.sprite_id = ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
statement.setInt(1, days);
statement.setInt(2, baseItemId);
@ -246,7 +246,7 @@ public class MarketPlace {
statement.setInt(1, offerId);
try (ResultSet set = statement.executeQuery()) {
if (set.next()) {
try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1")) {
try (PreparedStatement itemStatement = connection.prepareStatement("SELECT * FROM items WHERE id = ? LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
itemStatement.setInt(1, set.getInt("item_id"));
try (ResultSet itemSet = itemStatement.executeQuery()) {
itemSet.first();
@ -315,7 +315,7 @@ public class MarketPlace {
"FROM items_base\n" +
"WHERE items_base.id = ? LIMIT 1)\n" +
"ORDER BY price ASC\n" +
"LIMIT 1")) {
"LIMIT 1", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
statement.setInt(1, baseItemId);
try (ResultSet countSet = statement.executeQuery()) {
countSet.last();

View File

@ -1,10 +1,17 @@
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.campaign.calendar.CalendarCampaign;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer;
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
import java.sql.Timestamp;
import java.time.Duration;
import java.util.Date;
import static java.time.temporal.ChronoUnit.DAYS;
public class CalendarCommand extends Command {
public CalendarCommand() {
super("cmd_calendar", Emulator.getTexts().getValue("commands.keys.cmd_calendar").split(";"));
@ -13,8 +20,17 @@ public class CalendarCommand extends Command {
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (Emulator.getConfig().getBoolean("hotel.calendar.enabled")) {
gameClient.sendResponse(new AdventCalendarDataComposer("xmas11", Emulator.getGameEnvironment().getCatalogManager().calendarRewards.size(), (int) Math.floor((Emulator.getIntUnixTimestamp() - Emulator.getConfig().getInt("hotel.calendar.starttimestamp")) / 86400), gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, true));
gameClient.sendResponse(new NuxAlertComposer("openView/calendar"));
String campaignName = Emulator.getConfig().getValue("hotel.calendar.default");
if(params.length > 1 && gameClient.getHabbo().hasPermission("cmd_calendar_staff")) {
campaignName = params[1];
}
CalendarCampaign campaign = Emulator.getGameEnvironment().getCalendarManager().getCalendarCampaign(campaignName);
if(campaign == null) return false;
int daysBetween = (int) DAYS.between(new Timestamp(campaign.getStartTimestamp() * 1000L).toInstant(), new Date().toInstant());
if(daysBetween >= 0) {
gameClient.sendResponse(new AdventCalendarDataComposer(campaign.getName(), campaign.getImage(), campaign.getTotalDays(), daysBetween, gameClient.getHabbo().getHabboStats().calendarRewardsClaimed, campaign.getLockExpired()));
}
}
return true;

View File

@ -275,6 +275,7 @@ public class CommandHandler {
addCommand(new UnmuteCommand());
addCommand(new UpdateAchievements());
addCommand(new UpdateBotsCommand());
addCommand(new UpdateCalendarCommand());
addCommand(new UpdateCatalogCommand());
addCommand(new UpdateConfigCommand());
addCommand(new UpdateGuildPartsCommand());

View File

@ -43,6 +43,7 @@ public class EmptyInventoryCommand extends Command {
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems()));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
} else {

View File

@ -51,6 +51,15 @@ public class RedeemCommand extends Command {
pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]);
pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]);
points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount);
}
else if (item.getBaseItem().getName().startsWith("CF_diamond_")) {
int pointsType;
int pointsAmount;
pointsType = 5;
pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]);
points.adjustOrPutValue(pointsType, pointsAmount, pointsAmount);
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
@ -30,7 +31,9 @@ public class SoftKickCommand extends Command {
final Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
if (room != null) {
room.kickHabbo(habbo, false);
if (!(habbo.hasPermission(Permission.ACC_UNKICKABLE) || habbo.hasPermission(Permission.ACC_SUPPORTTOOL) || room.isOwner(habbo))) {
room.kickHabbo(habbo, false);
}
}
}
return true;

View File

@ -43,7 +43,7 @@ public class StalkCommand extends Command {
//gameClient.sendResponse(new ForwardToRoomComposer(habbo.getHabboInfo().getCurrentRoom().getId()));
return true;
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_summon.forgot_username"), RoomChatMessageBubbles.ALERT);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_stalk.forgot_username"), RoomChatMessageBubbles.ALERT);
return true;
}
}

View File

@ -2,11 +2,10 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
import com.eu.habbo.messages.outgoing.rooms.HideDoorbellComposer;
public class SummonCommand extends Command {
public SummonCommand() {
@ -36,22 +35,21 @@ public class SummonCommand extends Command {
return true;
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summon.summoning").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
Room room = habbo.getHabboInfo().getCurrentRoom();
if (room != null) {
Emulator.getGameEnvironment().getRoomManager().logExit(habbo);
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, habbo.getHabboInfo().getCurrentRoom());
room.removeHabbo(habbo, true);
habbo.getHabboInfo().setCurrentRoom(null);
}
Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
habbo.getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
Emulator.getGameEnvironment().getRoomManager().enterRoom(habbo, gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
habbo.getClient().sendResponse(new HideDoorbellComposer(""));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_summon.summoned").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
RoomTile t = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTileInFront(gameClient.getHabbo().getRoomUnit().getCurrentLocation(), gameClient.getHabbo().getRoomUnit().getBodyRotation().getValue());
if (t != null && gameClient.getHabbo().getHabboInfo().getCurrentRoom().tileWalkable(t)) {
habbo.getRoomUnit().setGoalLocation(t);
}
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername()));
return true;

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
@ -19,7 +20,7 @@ public class SummonRankCommand extends Command {
if (params.length >= 2) {
try {
minRank = Integer.valueOf(params[1]);
minRank = Integer.parseInt(params[1]);
} catch (Exception e) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.generic.cmd_summonrank.error"), RoomChatMessageBubbles.ALERT);
return true;
@ -33,9 +34,19 @@ public class SummonRankCommand extends Command {
if (set.getValue().getHabboInfo().getCurrentRoom() == gameClient.getHabbo().getHabboInfo().getCurrentRoom())
continue;
Emulator.getGameEnvironment().getRoomManager().leaveRoom(set.getValue(), set.getValue().getHabboInfo().getCurrentRoom());
set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
Room room = set.getValue().getHabboInfo().getCurrentRoom();
if (room != null) {
Emulator.getGameEnvironment().getRoomManager().logExit(set.getValue());
room.removeHabbo(set.getValue(), true);
set.getValue().getHabboInfo().setCurrentRoom(null);
}
Emulator.getGameEnvironment().getRoomManager().enterRoom(set.getValue(), gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId(), "", true);
set.getValue().getClient().sendResponse(new ForwardToRoomComposer(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId()));
}
}
}

View File

@ -0,0 +1,21 @@
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.messages.outgoing.catalog.*;
import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer;
public class UpdateCalendarCommand extends Command {
public UpdateCalendarCommand() {
super("cmd_update_calendar", Emulator.getTexts().getValue("commands.keys.cmd_update_calendar").split(";"));
}
@Override
public boolean handle(GameClient gameClient, String[] params) {
Emulator.getGameEnvironment().getCalendarManager().reload();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.success.cmd_update_calendar"), RoomChatMessageBubbles.ALERT);
return true;
}
}

View File

@ -203,8 +203,9 @@ public class BattleBanzaiGame extends Game {
item.setExtradata((6 + winningTeam.teamColor.type) + "");
this.room.updateItemState(item);
}
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
synchronized (this.lockedTiles) {
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
}
}
super.onEnd();
@ -222,7 +223,9 @@ public class BattleBanzaiGame extends Game {
this.room.updateItem(tile);
}
}
this.lockedTiles.clear();
synchronized (this.lockedTiles) {
this.lockedTiles.clear();
}
}
@ -249,52 +252,54 @@ public class BattleBanzaiGame extends Game {
}
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo, boolean doNotCheckFill) {
if (item instanceof InteractionBattleBanzaiTile) {
if (!this.lockedTiles.containsKey(teamColor)) {
this.lockedTiles.put(teamColor, new THashSet<>());
}
this.lockedTiles.get(teamColor).add(item);
}
if (habbo != null) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked"));
}
if (doNotCheckFill) return;
final int x = item.getX();
final int y = item.getY();
final List<List<RoomTile>> filledAreas = new ArrayList<>();
final THashSet<HabboItem> lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor));
executor.execute(() -> {
filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x, y + 1, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x - 1, y, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x + 1, y, lockedTiles, new ArrayList<>(), teamColor));
Optional<List<RoomTile>> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size));
if (largestAreaOfAll.isPresent()) {
for (RoomTile tile : largestAreaOfAll.get()) {
Optional<HabboItem> tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny();
tileItem.ifPresent(habboItem -> {
this.tileLocked(teamColor, habboItem, habbo, true);
habboItem.setExtradata((2 + (teamColor.type * 3)) + "");
this.room.updateItem(habboItem);
});
synchronized (this.lockedTiles) {
if (item instanceof InteractionBattleBanzaiTile) {
if (!this.lockedTiles.containsKey(teamColor)) {
this.lockedTiles.put(teamColor, new THashSet<>());
}
this.refreshCounters(teamColor);
if (habbo != null) {
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size());
}
this.lockedTiles.get(teamColor).add(item);
}
});
if (habbo != null) {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("BattleBallTilesLocked"));
}
if (doNotCheckFill) return;
final int x = item.getX();
final int y = item.getY();
final List<List<RoomTile>> filledAreas = new ArrayList<>();
final THashSet<HabboItem> lockedTiles = new THashSet<>(this.lockedTiles.get(teamColor));
executor.execute(() -> {
filledAreas.add(this.floodFill(x, y - 1, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x, y + 1, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x - 1, y, lockedTiles, new ArrayList<>(), teamColor));
filledAreas.add(this.floodFill(x + 1, y, lockedTiles, new ArrayList<>(), teamColor));
Optional<List<RoomTile>> largestAreaOfAll = filledAreas.stream().filter(Objects::nonNull).max(Comparator.comparing(List::size));
if (largestAreaOfAll.isPresent()) {
for (RoomTile tile : largestAreaOfAll.get()) {
Optional<HabboItem> tileItem = this.gameTiles.values().stream().filter(i -> i.getX() == tile.x && i.getY() == tile.y && i instanceof InteractionBattleBanzaiTile).findAny();
tileItem.ifPresent(habboItem -> {
this.tileLocked(teamColor, habboItem, habbo, true);
habboItem.setExtradata((2 + (teamColor.type * 3)) + "");
this.room.updateItem(habboItem);
});
}
this.refreshCounters(teamColor);
if (habbo != null) {
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE * largestAreaOfAll.get().size());
}
}
});
}
}
private List<RoomTile> floodFill(int x, int y, THashSet<HabboItem> lockedTiles, List<RoomTile> stack, GameTeamColors color) {

View File

@ -161,6 +161,7 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("viking_cotie", InteractionVikingCotie.class));
this.interactionsList.add(new ItemInteraction("tile_fxprovider_nfs", InteractionTileEffectProvider.class));
this.interactionsList.add(new ItemInteraction("mutearea", InteractionMuteArea.class));
this.interactionsList.add(new ItemInteraction("buildarea", InteractionBuildArea.class));
this.interactionsList.add(new ItemInteraction("information_terminal", InteractionInformationTerminal.class));
this.interactionsList.add(new ItemInteraction("external_image", InteractionExternalImage.class));
this.interactionsList.add(new ItemInteraction("youtube", InteractionYoutubeTV.class));
@ -179,6 +180,7 @@ public class ItemManager {
this.interactionsList.add(new ItemInteraction("handitem_tile", InteractionHanditemTile.class));
this.interactionsList.add(new ItemInteraction("effect_giver", InteractionEffectGiver.class));
this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class));
this.interactionsList.add(new ItemInteraction("effect_vendingmachine_no_sides", InteractionEffectVendingMachineNoSides.class));
this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class));
this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class));
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));

View File

@ -11,10 +11,12 @@ import org.slf4j.LoggerFactory;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.*;
import java.time.Duration;
import java.util.ArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -23,7 +25,7 @@ import java.util.concurrent.TimeUnit;
public class YoutubeManager {
private static final Logger LOGGER = LoggerFactory.getLogger(YoutubeManager.class);
public class YoutubeVideo {
public static class YoutubeVideo {
private final String id;
private final int duration;
@ -41,7 +43,7 @@ public class YoutubeManager {
}
}
public class YoutubePlaylist {
public static class YoutubePlaylist {
private final String id;
private final String name;
private final String description;
@ -71,8 +73,9 @@ public class YoutubeManager {
}
}
private THashMap<Integer, ArrayList<YoutubePlaylist>> playlists = new THashMap<>();
private THashMap<String, YoutubePlaylist> playlistCache = new THashMap<>();
private final THashMap<Integer, ArrayList<YoutubePlaylist>> playlists = new THashMap<>();
private final THashMap<String, YoutubePlaylist> playlistCache = new THashMap<>();
private final String apiKey = Emulator.getConfig().getValue("youtube.apikey");
public void load() {
this.playlists.clear();
@ -94,11 +97,15 @@ public class YoutubeManager {
youtubeDataLoaderPool.submit(() -> {
ArrayList<YoutubePlaylist> playlists = this.playlists.getOrDefault(itemId, new ArrayList<>());
YoutubePlaylist playlist = this.getPlaylistDataById(playlistId);
if (playlist != null) {
playlists.add(playlist);
} else {
LOGGER.error("Failed to load YouTube playlist: " + playlistId);
YoutubePlaylist playlist;
try {
playlist = this.getPlaylistDataById(playlistId);
if (playlist != null) {
playlists.add(playlist);
}
} catch (IOException e) {
LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, e);
}
this.playlists.put(itemId, playlists);
@ -120,56 +127,102 @@ public class YoutubeManager {
});
}
public YoutubePlaylist getPlaylistDataById(String playlistId) {
public YoutubePlaylist getPlaylistDataById(String playlistId) throws IOException {
if (this.playlistCache.containsKey(playlistId)) return this.playlistCache.get(playlistId);
if(apiKey.isEmpty()) return null;
try {
URL myUrl = new URL("https://www.youtube.com/playlist?list=" + playlistId);
YoutubePlaylist playlist;
URL playlistInfo = new URL("https://youtube.googleapis.com/youtube/v3/playlists?part=snippet&id=" + playlistId + "&maxResults=1&key=" + apiKey);
HttpsURLConnection playlistCon = (HttpsURLConnection) playlistInfo.openConnection();
if (playlistCon.getResponseCode() != 200) {
InputStream errorInputStream = playlistCon.getErrorStream();
InputStreamReader playlistISR = new InputStreamReader(errorInputStream);
BufferedReader playlistBR = new BufferedReader(playlistISR);
JsonObject errorObj = JsonParser.parseReader(playlistBR).getAsJsonObject();
String message = errorObj.get("error").getAsJsonObject().get("message").getAsString();
LOGGER.error("Failed to load YouTube playlist {} ERROR: {}", playlistId, message);
return null;
}
InputStream playlistInputStream = playlistCon.getInputStream();
InputStreamReader playlistISR = new InputStreamReader(playlistInputStream);
BufferedReader playlistBR = new BufferedReader(playlistISR);
HttpsURLConnection conn = (HttpsURLConnection) myUrl.openConnection();
conn.setRequestProperty("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3");
conn.setRequestProperty("accept-language", "en-GB,en-US;q=0.9,en;q=0.8");
conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3731.0 Safari/537.36");
JsonObject playlistData = JsonParser.parseReader(playlistBR).getAsJsonObject();
InputStream is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
YoutubePlaylist playlist;
try (BufferedReader br = new BufferedReader(isr)) {
playlist = null;
String inputLine;
while ((inputLine = br.readLine()) != null) {
if (inputLine.contains("window[\"ytInitialData\"]")) {
JsonObject obj = new JsonParser().parse(inputLine.substring(inputLine.indexOf("{")).replace(";", "")).getAsJsonObject();
JsonObject meta = obj.get("microformat").getAsJsonObject().get("microformatDataRenderer").getAsJsonObject();
String name = meta.get("title").getAsString();
String description = meta.get("description").getAsString();
ArrayList<YoutubeVideo> videos = new ArrayList<>();
JsonArray rawVideos = obj.get("contents").getAsJsonObject().get("twoColumnBrowseResultsRenderer").getAsJsonObject().get("tabs").getAsJsonArray().get(0).getAsJsonObject().get("tabRenderer").getAsJsonObject().get("content").getAsJsonObject().get("sectionListRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("itemSectionRenderer").getAsJsonObject().get("contents").getAsJsonArray().get(0).getAsJsonObject().get("playlistVideoListRenderer").getAsJsonObject().get("contents").getAsJsonArray();
for (JsonElement rawVideo : rawVideos) {
JsonObject videoData = rawVideo.getAsJsonObject().get("playlistVideoRenderer").getAsJsonObject();
if (!videoData.has("lengthSeconds")) continue; // removed videos
videos.add(new YoutubeVideo(videoData.get("videoId").getAsString(), Integer.valueOf(videoData.get("lengthSeconds").getAsString())));
}
playlist = new YoutubePlaylist(playlistId, name, description, videos);
break;
}
}
JsonArray playlists = playlistData.get("items").getAsJsonArray();
if (playlists.size() == 0) {
LOGGER.error("Playlist {} not found!", playlistId);
return null;
}
JsonObject playlistItem = playlists.get(0).getAsJsonObject().get("snippet").getAsJsonObject();
String name = playlistItem.get("title").getAsString();
String description = playlistItem.get("description").getAsString();
ArrayList < YoutubeVideo > videos = new ArrayList < > ();
String nextPageToken = "";
do {
ArrayList < String > videoIds = new ArrayList < > ();
URL playlistItems;
if (nextPageToken.isEmpty()) {
playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&maxResults=50&key=" + apiKey);
} else {
playlistItems = new URL("https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet%2Cstatus&playlistId=" + playlistId + "&pageToken=" + nextPageToken + "&maxResults=50&key=" + apiKey);
}
this.playlistCache.put(playlistId, playlist);
HttpsURLConnection con = (HttpsURLConnection) playlistItems.openConnection();
return playlist;
} catch (java.io.IOException e) {
e.printStackTrace();
InputStream is = con.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
JsonObject object = JsonParser.parseReader(br).getAsJsonObject();
JsonArray rawV = object.get("items").getAsJsonArray();
for (JsonElement rawVideo: rawV) {
JsonObject videoData = rawVideo.getAsJsonObject().get("snippet").getAsJsonObject();
JsonObject videoStatus = rawVideo.getAsJsonObject().get("status").getAsJsonObject();
if (!videoStatus.get("privacyStatus").getAsString().equals("public"))
continue; // removed videos
videoIds.add(videoData.get("resourceId").getAsJsonObject().get("videoId").getAsString());
}
if (!videoIds.isEmpty()) {
URL VideoItems;
String commaSeparatedVideos = String.join(",", videoIds);
VideoItems = new URL("https://youtube.googleapis.com/youtube/v3/videos?part=contentDetails&id=" + commaSeparatedVideos + "&maxResults=50&key=" + apiKey);
HttpsURLConnection con1 = (HttpsURLConnection) VideoItems.openConnection();
InputStream is1 = con1.getInputStream();
InputStreamReader isr1 = new InputStreamReader(is1);
BufferedReader br1 = new BufferedReader(isr1);
JsonObject object1 = JsonParser.parseReader(br1).getAsJsonObject();
JsonArray Vds = object1.get("items").getAsJsonArray();
for (JsonElement rawVideo: Vds) {
JsonObject contentDetails = rawVideo.getAsJsonObject().get("contentDetails").getAsJsonObject();
int duration = (int) Duration.parse(contentDetails.get("duration").getAsString()).getSeconds();
if (duration < 1) continue;
videos.add(new YoutubeVideo(rawVideo.getAsJsonObject().get("id").getAsString(), duration));
}
}
if (object.has("nextPageToken")) {
nextPageToken = object.get("nextPageToken").getAsString();
} else {
nextPageToken = null;
}
} while (nextPageToken != null);
if (videos.isEmpty()) {
LOGGER.warn("Playlist {} has no videos!", playlistId);
return null;
}
playlist = new YoutubePlaylist(playlistId, name, description, videos);
this.playlistCache.put(playlistId, playlist);
return playlist;
return null;
}
public ArrayList<YoutubePlaylist> getPlaylistsForItemId(int itemId) {

View File

@ -0,0 +1,253 @@
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.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.users.HabboManager;
import com.eu.habbo.messages.outgoing.rooms.items.RemoveFloorItemComposer;
import com.eu.habbo.messages.outgoing.rooms.items.RoomFloorItemsComposer;
import gnu.trove.TCollections;
import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
public class InteractionBuildArea extends InteractionCustomValues {
public static THashMap<String, String> defaultValues = new THashMap<String, String>() {
{
this.put("tilesLeft", "0");
}
{
this.put("tilesRight", "0");
}
{
this.put("tilesFront", "0");
}
{
this.put("tilesBack", "0");
}
{
this.put("builders", "");
}
};
private THashSet<RoomTile> tiles;
public InteractionBuildArea(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem, defaultValues);
tiles = new THashSet<>();
}
public InteractionBuildArea(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells, defaultValues);
tiles = new THashSet<>();
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
this.regenAffectedTiles(room);
}
@Override
public void onPickUp(Room room) {
super.onPickUp(room);
ArrayList<String> builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";")));
THashSet<Integer> canBuild = new THashSet<>();
for (String builderName : builderNames) {
Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName);
HabboInfo builderInfo;
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
builderInfo = HabboManager.getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
}
}
if (!canBuild.isEmpty()) {
for (RoomTile tile : this.tiles) {
THashSet<HabboItem> tileItems = room.getItemsAt(tile);
for (HabboItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
room.pickUpItem(tileItem, null);
}
}
}
}
this.tiles.clear();
}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation) {
super.onMove(room, oldLocation, newLocation);
ArrayList<String> builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";")));
THashSet<Integer> canBuild = new THashSet<>();
for (String builderName : builderNames) {
Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName);
HabboInfo builderInfo;
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
builderInfo = HabboManager.getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
}
}
THashSet<RoomTile> oldTiles = this.tiles;
THashSet<RoomTile> newTiles = new THashSet<>();
int minX = Math.max(0, newLocation.x - Integer.parseInt(this.values.get("tilesBack")));
int minY = Math.max(0, newLocation.y - Integer.parseInt(this.values.get("tilesRight")));
int maxX = Math.min(room.getLayout().getMapSizeX(), newLocation.x + Integer.parseInt(this.values.get("tilesFront")));
int maxY = Math.min(room.getLayout().getMapSizeY(), newLocation.y + Integer.parseInt(this.values.get("tilesLeft")));
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
if (tile != null && tile.state != RoomTileState.INVALID)
newTiles.add(tile);
}
}
if (!canBuild.isEmpty()) {
for (RoomTile tile : oldTiles) {
THashSet<HabboItem> tileItems = room.getItemsAt(tile);
if(newTiles.contains(tile)) continue;
for (HabboItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
room.pickUpItem(tileItem, null);
}
}
}
}
this.regenAffectedTiles(room);
}
public boolean inSquare(RoomTile location) {
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room != null && this.tiles.size() == 0) {
regenAffectedTiles(room);
}
return this.tiles.contains(location);
}
private void regenAffectedTiles(Room room) {
int minX = Math.max(0, this.getX() - Integer.parseInt(this.values.get("tilesBack")));
int minY = Math.max(0, this.getY() - Integer.parseInt(this.values.get("tilesRight")));
int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(this.values.get("tilesFront")));
int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(this.values.get("tilesLeft")));
this.tiles.clear();
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
if (tile != null && tile.state != RoomTileState.INVALID)
this.tiles.add(tile);
}
}
}
@Override
public void onCustomValuesSaved(Room room, GameClient client, THashMap<String, String> oldValues) {
regenAffectedTiles(room);
ArrayList<String> builderNames = new ArrayList<>(Arrays.asList(this.values.get("builders").split(";")));
THashSet<Integer> canBuild = new THashSet<>();
for (String builderName : builderNames) {
Habbo builder = Emulator.getGameEnvironment().getHabboManager().getHabbo(builderName);
HabboInfo builderInfo;
if (builder != null) {
builderInfo = builder.getHabboInfo();
} else {
builderInfo = HabboManager.getOfflineHabboInfo(builderName);
}
if (builderInfo != null) {
canBuild.add(builderInfo.getId());
}
}
THashSet<RoomTile> oldTiles = new THashSet<>();
int minX = Math.max(0, this.getX() - Integer.parseInt(oldValues.get("tilesBack")));
int minY = Math.max(0, this.getY() - Integer.parseInt(oldValues.get("tilesRight")));
int maxX = Math.min(room.getLayout().getMapSizeX(), this.getX() + Integer.parseInt(oldValues.get("tilesFront")));
int maxY = Math.min(room.getLayout().getMapSizeY(), this.getY() + Integer.parseInt(oldValues.get("tilesLeft")));
for (int x = minX; x <= maxX; x++) {
for (int y = minY; y <= maxY; y++) {
RoomTile tile = room.getLayout().getTile((short) x, (short) y);
if (tile != null && tile.state != RoomTileState.INVALID && !this.tiles.contains(tile))
oldTiles.add(tile);
}
}
if (!canBuild.isEmpty()) {
for (RoomTile tile : oldTiles) {
THashSet<HabboItem> tileItems = room.getItemsAt(tile);
for (HabboItem tileItem : tileItems) {
if (canBuild.contains(tileItem.getUserId()) && tileItem != this) {
room.pickUpItem(tileItem, null);
}
}
}
}
// show the effect
Item effectItem = Emulator.getGameEnvironment().getItemManager().getItem("mutearea_sign2");
if(effectItem != null) {
TIntObjectMap<String> ownerNames = TCollections.synchronizedMap(new TIntObjectHashMap<>(0));
ownerNames.put(-1, "System");
THashSet<HabboItem> items = new THashSet<>();
int id = 0;
for(RoomTile tile : this.tiles) {
id--;
HabboItem item = new InteractionDefault(id, -1, effectItem, "1", 0, 0);
item.setX(tile.x);
item.setY(tile.y);
item.setZ(tile.relativeHeight());
items.add(item);
}
client.sendResponse(new RoomFloorItemsComposer(ownerNames, items));
Emulator.getThreading().run(() -> {
for(HabboItem item : items) {
client.sendResponse(new RemoveFloorItemComposer(item, true));
}
}, 3000);
}
}
public boolean isBuilder(String Username){
return Arrays.asList(this.values.get("builders").split(";")).contains(Username);
}
}

View File

@ -49,7 +49,7 @@ public class InteractionColorWheel extends HabboItem {
if (!room.hasRights(client.getHabbo()))
return;
if (this.rollTaks == null) {
if (this.rollTaks == null && !this.getExtradata().equalsIgnoreCase("-1")) {
this.setExtradata("-1");
room.sendComposer(new WallItemUpdateComposer(this).compose());
Emulator.getThreading().run(this);

View File

@ -101,6 +101,11 @@ public class InteractionCrackable extends HabboItem {
if (rewardData.requiredEffect > 0 && habbo.getRoomUnit().getEffectId() != rewardData.requiredEffect)
return;
if(this.ticks < 1)
{
// If there are no ticks (for example because the room has been reloaded), check the current extradata of the item and update the ticks.
this.ticks = Integer.parseInt(this.getExtradata());
}
this.ticks++;
this.setExtradata("" + (this.ticks));
this.needsUpdate(true);

View File

@ -80,7 +80,7 @@ public abstract class InteractionCustomValues extends HabboItem {
super.serializeExtradata(serverMessage);
}
public void onCustomValuesSaved(Room room, GameClient client) {
public void onCustomValuesSaved(Room room, GameClient client, THashMap<String, String> oldValues) {
}
}

View File

@ -0,0 +1,43 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionEffectVendingMachineNoSides extends InteractionVendingMachine {
public InteractionEffectVendingMachineNoSides(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
this.setExtradata("0");
}
public InteractionEffectVendingMachineNoSides(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
}
@Override
public void giveVendingMachineItem(Room room, RoomUnit unit) {
room.giveEffect(unit, this.getBaseItem().getRandomVendingItem(), 30);
}
@Override
public THashSet<RoomTile> getActivatorTiles(Room room) {
THashSet<RoomTile> tiles = new THashSet<RoomTile>();
for(int x = -1; x <= 1; x++) {
for(int y = -1; y <= 1; y++) {
RoomTile tile = room.getLayout().getTile((short)(this.getX() + x), (short)(this.getY() + y));
if(tile != null) {
tiles.add(tile);
}
}
}
return tiles;
}
}

View File

@ -17,7 +17,6 @@ import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.set.hash.THashSet;
import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -125,8 +124,8 @@ public class InteractionMuteArea extends InteractionCustomValues {
}
@Override
public void onCustomValuesSaved(Room room, GameClient client) {
super.onCustomValuesSaved(room, client);
public void onCustomValuesSaved(Room room, GameClient client, THashMap<String, String> oldValues) {
super.onCustomValuesSaved(room, client, oldValues);
this.regenAffectedTiles(room);

View File

@ -37,7 +37,7 @@ public class InteractionPressurePlate extends InteractionDefault {
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
}
@Override
@ -66,6 +66,11 @@ public class InteractionPressurePlate extends InteractionDefault {
updateState(room);
}
@Override
public void onPickUp(Room room) {
this.setExtradata("0");
}
public void updateState(Room room) {
boolean occupied = false;

View File

@ -22,40 +22,40 @@ public class InteractionTrap extends InteractionDefault {
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOn(roomUnit, room, objects);
if (!this.getExtradata().equals("0")) {
Habbo habbo = room.getHabbo(roomUnit);
int effect = habbo.getClient().getHabbo().getRoomUnit().getEffectId();
roomUnit.stopWalking();
super.onWalkOn(roomUnit, room, objects);
int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName());
if (delay == 0) {
Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000");
delay = 3000;
}
if (!this.getExtradata().equals("1"))
return;
if (roomUnit != null) {
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
int delay = Emulator.getConfig().getInt("hotel.item.trap." + this.getBaseItem().getName());
if (habbo != null) {
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
return;
}
if (delay == 0) {
Emulator.getConfig().register("hotel.item.trap." + this.getBaseItem().getName(), "3000");
delay = 3000;
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
return;
}
if (roomUnit != null) {
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0) {
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER)) {
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null) {
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectM()) {
room.giveEffect(habbo, this.getBaseItem().getEffectM(), -1);
return;
roomUnit.setCanWalk(false);
Emulator.getThreading().run(() -> {
room.giveEffect(roomUnit, 0, -1);
roomUnit.setCanWalk(true);
room.giveEffect(roomUnit, effect, -1);
}, delay);
}
if (habbo.getHabboInfo().getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && habbo.getRoomUnit().getEffectId() != this.getBaseItem().getEffectF()) {
room.giveEffect(habbo, this.getBaseItem().getEffectF(), -1);
return;
}
roomUnit.setCanWalk(false);
Emulator.getThreading().run(() -> {
room.giveEffect(roomUnit, 0, -1);
roomUnit.setCanWalk(true);
}, delay);
}
}
}

View File

@ -2,11 +2,13 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
import gnu.trove.map.hash.TLongLongHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -18,6 +20,7 @@ import java.sql.SQLException;
public abstract class InteractionWired extends InteractionDefault {
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionWired.class);
private long cooldown;
private TLongLongHashMap userExecutionCache = new TLongLongHashMap(3);
InteractionWired(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@ -69,10 +72,16 @@ public abstract class InteractionWired extends InteractionDefault {
public abstract void onPickUp();
public void activateBox(Room room) {
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
room.sendComposer(new ItemStateComposer(this).compose());
this.activateBox(room, (RoomUnit)null, 0L);
}
public void activateBox(Room room, RoomUnit roomUnit, long millis) {
this.setExtradata(this.getExtradata().equals("1") ? "0" : "1");
room.sendComposer(new ItemStateComposer(this).compose());
if (roomUnit != null) {
this.addUserExecutionCache(roomUnit.getId(), millis);
}
}
protected long requiredCooldown() {
return 50L;
@ -96,4 +105,58 @@ public abstract class InteractionWired extends InteractionDefault {
public boolean isUsable() {
return true;
}
public boolean userCanExecute(int roomUnitId, long timestamp) {
if (roomUnitId == -1) {
return true;
} else {
if (this.userExecutionCache.containsKey((long)roomUnitId)) {
long lastTimestamp = this.userExecutionCache.get((long)roomUnitId);
if (timestamp - lastTimestamp < 100L) {
return false;
}
}
return true;
}
}
public void clearUserExecutionCache() {
this.userExecutionCache.clear();
}
public void addUserExecutionCache(int roomUnitId, long timestamp) {
this.userExecutionCache.put((long)roomUnitId, timestamp);
}
public static WiredSettings readSettings(ClientMessage packet, boolean isEffect)
{
int intParamCount = packet.readInt();
int[] intParams = new int[intParamCount];
for(int i = 0; i < intParamCount; i++)
{
intParams[i] = packet.readInt();
}
String stringParam = packet.readString();
int itemCount = packet.readInt();
int[] itemIds = new int[itemCount];
for(int i = 0; i < itemCount; i++)
{
itemIds[i] = packet.readInt();
}
WiredSettings settings = new WiredSettings(intParams, stringParam, itemIds, -1);
if(isEffect)
{
settings.setDelay(packet.readInt());
}
settings.setStuffTypeSelectionCode(packet.readInt());
return settings;
}
}

View File

@ -2,11 +2,11 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
import java.sql.ResultSet;
@ -43,7 +43,7 @@ public abstract class InteractionWiredCondition extends InteractionWired {
public abstract WiredConditionType getType();
public abstract boolean saveData(ClientMessage packet);
public abstract boolean saveData(WiredSettings settings);
public WiredConditionOperator operator() {
return WiredConditionOperator.AND;

View File

@ -2,10 +2,10 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.wired.WiredEffectDataComposer;
@ -43,7 +43,7 @@ public abstract class InteractionWiredEffect extends InteractionWired {
}
}
public abstract boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException;
public abstract boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException;
public int getDelay() {
return this.delay;

View File

@ -110,15 +110,23 @@ public class InteractionWiredHighscore extends HabboItem {
serverMessage.appendInt(this.clearType.type);
if (this.data != null) {
serverMessage.appendInt(this.data.size());
int size = this.data.size();
if(size > 50) {
size = 50;
}
serverMessage.appendInt(size);
int count = 0;
for (WiredHighscoreRow row : this.data) {
serverMessage.appendInt(row.getValue());
if(count < 50) {
serverMessage.appendInt(row.getValue());
serverMessage.appendInt(row.getUsers().size());
for (String username : row.getUsers()) {
serverMessage.appendString(username);
serverMessage.appendInt(row.getUsers().size());
for (String username : row.getUsers()) {
serverMessage.appendString(username);
}
}
count++;
}
} else {
serverMessage.appendInt(0);

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -44,7 +45,7 @@ public abstract class InteractionWiredTrigger extends InteractionWired {
public abstract WiredTriggerType getType();
public abstract boolean saveData(ClientMessage packet);
public abstract boolean saveData(WiredSettings settings);
protected int getDelay() {
return this.delay;

View File

@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.items.ItemStateComposer;
import com.eu.habbo.util.pathfinding.Rotation;
import java.math.BigDecimal;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -151,7 +152,44 @@ public class InteractionFootball extends InteractionPushable {
public boolean validMove(Room room, RoomTile from, RoomTile to) {
if (to == null || to.state == RoomTileState.INVALID) return false;
HabboItem topItem = room.getTopItemAt(to.x, to.y, this);
return (topItem == null || topItem.getBaseItem().allowStack());
// Move is valid if there isnt any furni yet
if (topItem == null) {
return true;
}
// If any furni on tile is not stackable, move is invalid (tested on 22-03-2022)
if (room.getItemsAt(to).stream().anyMatch(x -> !x.getBaseItem().allowStack())) {
return false;
}
// Ball can only go up by 1.65 according to Habbo (tested using stack tile on 22-03-2022)
BigDecimal topItemHeight = BigDecimal.valueOf(topItem.getZ() + topItem.getBaseItem().getHeight());
BigDecimal ballHeight = BigDecimal.valueOf(this.getZ());
if (topItemHeight.subtract(ballHeight).compareTo(new BigDecimal(1.65)) > 0) {
return false;
}
// If top item is a football goal, the move is only valid if ball is coming from the front side
// Ball shouldn't come from the back or from the sides (tested on 22-03-2022)
if (topItem instanceof InteractionFootballGoal) {
int ballDirection = Rotation.Calculate(from.x, from.y, to.x, to.y);
int goalRotation = topItem.getRotation();
switch (goalRotation) {
case 0:
return ballDirection > 2 && ballDirection < 6;
case 2:
return ballDirection > 4;
case 4:
return ballDirection > 6 || ballDirection < 2;
case 6:
return ballDirection > 0 && ballDirection < 4;
}
}
return topItem.getBaseItem().allowStack();
}
//Events

View File

@ -0,0 +1,63 @@
package com.eu.habbo.habbohotel.items.interactions.wired;
public class WiredSettings {
private int[] intParams;
private String stringParam;
private int[] furniIds;
private int stuffTypeSelectionCode;
private int delay;
public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode, int delay)
{
this.furniIds = furniIds;
this.intParams = intParams;
this.stringParam = stringParam;
this.stuffTypeSelectionCode = stuffTypeSelectionCode;
this.delay = delay;
}
public WiredSettings(int[] intParams, String stringParam, int[] furniIds, int stuffTypeSelectionCode)
{
this(intParams, stringParam, furniIds, stuffTypeSelectionCode, 0);
}
public int getStuffTypeSelectionCode() {
return stuffTypeSelectionCode;
}
public void setStuffTypeSelectionCode(int stuffTypeSelectionCode) {
this.stuffTypeSelectionCode = stuffTypeSelectionCode;
}
public int[] getFurniIds() {
return furniIds;
}
public void setFurniIds(int[] furniIds) {
this.furniIds = furniIds;
}
public String getStringParam() {
return stringParam;
}
public void setStringParam(String stringParam) {
this.stringParam = stringParam;
}
public int[] getIntParams() {
return intParams;
}
public void setIntParams(int[] intParams) {
this.intParams = intParams;
}
public int getDelay() {
return delay;
}
public void setDelay(int delay) {
this.delay = delay;
}
}

View File

@ -3,12 +3,13 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -50,10 +51,10 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.startDate = packet.readInt();
this.endDate = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 2) return false;
this.startDate = settings.getIntParams()[0];
this.endDate = settings.getIntParams()[1];
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -136,15 +137,12 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
int count;
packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.all = packet.readInt() == 1;
this.all = settings.getIntParams()[0] == 1;
packet.readString();
count = packet.readInt();
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -153,7 +151,7 @@ public class WiredConditionFurniHaveFurni extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
if (item != null)
this.items.add(item);

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
@ -24,8 +25,6 @@ import java.util.stream.Collectors;
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
protected boolean all;
protected THashSet<HabboItem> items;
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
@ -41,7 +40,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
@Override
public void onPickUp() {
this.items.clear();
this.all = false;
}
@Override
@ -67,7 +65,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
public String getWiredData() {
this.refresh();
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.all,
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
));
}
@ -79,7 +76,6 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
if (wiredData.startsWith("{")) {
JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, JsonData.class);
this.all = data.all;
for(int id : data.itemIds) {
HabboItem item = room.getHabboItem(id);
@ -92,17 +88,14 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
String[] data = wiredData.split(":");
if (data.length >= 1) {
this.all = (data[0].equals("1"));
if (data.length == 2) {
String[] items = data[1].split(";");
String[] items = data[1].split(";");
for (String s : items) {
HabboItem item = room.getHabboItem(Integer.parseInt(s));
for (String s : items) {
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null)
this.items.add(item);
}
if (item != null)
this.items.add(item);
}
}
}
@ -127,8 +120,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(1);
message.appendInt(this.all ? 1 : 0);
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(0);
@ -136,13 +128,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
int count;
packet.readInt();
public boolean saveData(WiredSettings settings) {
int count = settings.getFurniIds().length;
packet.readString();
count = packet.readInt();
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -151,7 +139,7 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
if (item != null)
this.items.add(item);
@ -182,11 +170,9 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition {
}
static class JsonData {
boolean all;
List<Integer> itemIds;
public JsonData(boolean all, List<Integer> itemIds) {
this.all = all;
public JsonData(List<Integer> itemIds) {
this.itemIds = itemIds;
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -117,11 +118,8 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
int count = packet.readInt();
public boolean saveData(WiredSettings settings) {
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -130,7 +128,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
this.items.add(room.getHabboItem(packet.readInt()));
this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -69,7 +70,7 @@ public class WiredConditionGroupMember extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
public boolean saveData(WiredSettings settings) {
return true;
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -86,11 +87,10 @@ public class WiredConditionHabboCount extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.lowerLimit = packet.readInt();
this.upperLimit = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 2) return false;
this.lowerLimit = settings.getIntParams()[0];
this.upperLimit = settings.getIntParams()[1];
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -76,10 +77,9 @@ public class WiredConditionHabboHasEffect extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.effectId = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.effectId = settings.getIntParams()[0];
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -51,10 +52,9 @@ public class WiredConditionHabboHasHandItem extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.handItem = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.handItem = settings.getIntParams()[0];
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -88,10 +89,8 @@ public class WiredConditionHabboWearsBadge extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.badge = packet.readString();
public boolean saveData(WiredSettings settings) {
this.badge = settings.getStringParam();
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -81,11 +82,9 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.cycles = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.cycles = settings.getIntParams()[0];
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -69,28 +70,24 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
}
@Override
public boolean saveData(ClientMessage packet) {
int count;
packet.readInt();
this.state = packet.readInt() == 1;
this.direction = packet.readInt() == 1;
this.position = packet.readInt() == 1;
packet.readString();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 3) return false;
this.state = settings.getIntParams()[0] == 1;
this.direction = settings.getIntParams()[1] == 1;
this.position = settings.getIntParams()[2] == 1;
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null)
return true;
count = packet.readInt();
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.settings.clear();
for (int i = 0; i < count; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem item = room.getHabboItem(itemId);
if (item != null)

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -81,11 +82,9 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.cycles = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.cycles = settings.getIntParams()[0];
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -137,14 +138,11 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.all = settings.getIntParams()[0] == 1;
this.all = packet.readInt() == 1;
packet.readString();
int count = packet.readInt();
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -153,7 +151,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
if (item != null)
this.items.add(item);

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
@ -24,8 +25,7 @@ import java.util.stream.Collectors;
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
protected boolean all;
protected THashSet<HabboItem> items;
public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException {
@ -41,7 +41,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
@Override
public void onPickUp() {
this.items.clear();
this.all = false;
}
@Override
@ -67,7 +66,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
public String getWiredData() {
this.refresh();
return WiredHandler.getGsonBuilder().create().toJson(new JsonData(
this.all,
this.items.stream().map(HabboItem::getId).collect(Collectors.toList())
));
}
@ -79,7 +77,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
if (wiredData.startsWith("{")) {
WiredConditionFurniHaveHabbo.JsonData data = WiredHandler.getGsonBuilder().create().fromJson(wiredData, WiredConditionFurniHaveHabbo.JsonData.class);
this.all = data.all;
for(int id : data.itemIds) {
HabboItem item = room.getHabboItem(id);
@ -92,17 +89,13 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
String[] data = wiredData.split(":");
if (data.length >= 1) {
this.all = (data[0].equals("1"));
String[] items = data[1].split(";");
if (data.length == 2) {
String[] items = data[1].split(";");
for (String s : items) {
HabboItem item = room.getHabboItem(Integer.parseInt(s));
for (String s : items) {
HabboItem item = room.getHabboItem(Integer.parseInt(s));
if (item != null)
this.items.add(item);
}
if (item != null)
this.items.add(item);
}
}
}
@ -127,8 +120,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(1);
message.appendInt(this.all ? 1 : 0);
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(0);
@ -136,12 +128,8 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
int count = packet.readInt();
public boolean saveData(WiredSettings settings) {
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -150,7 +138,7 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
if (item != null)
this.items.add(item);
@ -181,11 +169,9 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition {
}
static class JsonData {
boolean all;
List<Integer> itemIds;
public JsonData(boolean all, List<Integer> itemIds) {
this.all = all;
public JsonData(List<Integer> itemIds) {
this.itemIds = itemIds;
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -117,11 +118,8 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
int count = packet.readInt();
public boolean saveData(WiredSettings settings) {
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -130,7 +128,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
this.items.add(room.getHabboItem(packet.readInt()));
this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -85,11 +86,10 @@ public class WiredConditionNotHabboCount extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.lowerLimit = packet.readInt();
this.upperLimit = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 2) return false;
this.lowerLimit = settings.getIntParams()[0];
this.upperLimit = settings.getIntParams()[1];
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
@ -76,10 +77,9 @@ public class WiredConditionNotHabboHasEffect extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.effectId = packet.readInt();
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.effectId = settings.getIntParams()[0];
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -89,10 +90,8 @@ public class WiredConditionNotHabboWearsBadge extends InteractionWiredCondition
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.badge = packet.readString();
public boolean saveData(WiredSettings settings) {
this.badge = settings.getStringParam();
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -69,7 +70,7 @@ public class WiredConditionNotInGroup extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
public boolean saveData(WiredSettings settings) {
return true;
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -89,10 +90,9 @@ public class WiredConditionNotInTeam extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt()];
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]];
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -91,10 +92,9 @@ public class WiredConditionTeamMember extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.teamColor = GameTeamColors.values()[packet.readInt()];
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.teamColor = GameTeamColors.values()[settings.getIntParams()[0]];
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -46,28 +47,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
}
protected boolean triggerOnFurni(RoomUnit roomUnit, Room room) {
/*
* 1. If a Habbo IS NOT walking we only have to check if the Habbo is on one of the selected tiles.
* 2. If a Habbo IS walking we have to check if the next tile in the walking path is one of the selected items
* */
if (!roomUnit.isWalking()) {
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
return this.items.stream().anyMatch(itemsAtUser::contains);
} else {
RoomTile firstTileInPath = room.getLayout()
.findPath(roomUnit.getCurrentLocation(), roomUnit.getGoal(), roomUnit.getGoal(), roomUnit)
.peek();
if (firstTileInPath == null)
return false;
return this.items
.stream()
.anyMatch(conditionItem -> conditionItem
.getOccupyingTiles(room.getLayout())
.contains(firstTileInPath)
);
}
THashSet<HabboItem> itemsAtUser = room.getItemsAt(roomUnit.getCurrentLocation());
return this.items.stream().anyMatch(itemsAtUser::contains);
}
@Override
@ -138,11 +119,8 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
int count = packet.readInt();
public boolean saveData(WiredSettings settings) {
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) return false;
this.items.clear();
@ -151,7 +129,7 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition {
if (room != null) {
for (int i = 0; i < count; i++) {
HabboItem item = room.getHabboItem(packet.readInt());
HabboItem item = room.getHabboItem(settings.getFurniIds()[i]);
if (item != null) {
this.items.add(item);

View File

@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.google.gson.Gson;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -49,11 +48,9 @@ public class WiredEffectBotClothes extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
String dataString = packet.readString();
packet.readInt();
int delay = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
String dataString = settings.getStringParam();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -6,12 +6,12 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import gnu.trove.procedure.TObjectProcedure;
@ -70,17 +70,18 @@ public class WiredEffectBotFollowHabbo extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
int mode = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid");
int mode = settings.getIntParams()[0];
if(mode != 0 && mode != 1)
throw new WiredSaveException("Mode is invalid");
String botName = packet.readString().replace("\t", "");
String botName = settings.getStringParam().replace("\t", "");
botName = botName.substring(0, Math.min(botName.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -13,7 +14,6 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.threading.runnables.RoomUnitGiveHanditem;
@ -74,17 +74,17 @@ public class WiredEffectBotGiveHandItem extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing item id");
int itemId = packet.readInt();
int itemId = settings.getIntParams()[0];
if(itemId < 0)
itemId = 0;
String botName = packet.readString();
packet.readInt();
int delay = packet.readInt();
String botName = settings.getStringParam();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,13 +5,13 @@ import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
@ -52,15 +52,14 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
int mode = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("Mode is invalid");
int mode = settings.getIntParams()[0];
if(mode != 0 && mode != 1)
throw new WiredSaveException("Mode is invalid");
String dataString = packet.readString();
String dataString = settings.getStringParam();
String splitBy = "\t";
if(!dataString.contains(splitBy))
@ -71,8 +70,7 @@ public class WiredEffectBotTalk extends InteractionWiredEffect {
if (data.length != 2)
throw new WiredSaveException("Malformed data string. Invalid data length");
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -6,13 +6,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import gnu.trove.procedure.TObjectProcedure;
@ -73,15 +73,14 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
int mode = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("Missing mode");
int mode = settings.getIntParams()[0];
if(mode != 0 && mode != 1)
throw new WiredSaveException("Mode is invalid");
String dataString = packet.readString();
String dataString = settings.getStringParam();
String splitBy = "\t";
if(!dataString.contains(splitBy))
throw new WiredSaveException("Malformed data string");
@ -91,8 +90,7 @@ public class WiredEffectBotTalkToHabbo extends InteractionWiredEffect {
if (data.length != 2)
throw new WiredSaveException("Malformed data string. Invalid data length");
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
@ -114,10 +115,9 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
String botName = packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
String botName = settings.getStringParam();
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -126,7 +126,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -135,7 +135,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -67,10 +68,9 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
String botName = packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
String botName = settings.getStringParam();
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -79,7 +79,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -88,7 +88,7 @@ public class WiredEffectBotWalkToFurni extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.*;
@ -210,9 +211,10 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
int startDirectionInt = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data");
int startDirectionInt = settings.getIntParams()[0];
if(startDirectionInt < 0 || startDirectionInt > 7 || (startDirectionInt % 2) != 0) {
throw new WiredSaveException("Start direction is invalid");
@ -220,15 +222,13 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
RoomUserRotation startDirection = RoomUserRotation.fromValue(startDirectionInt);
int blockedActionInt = packet.readInt();
int blockedActionInt = settings.getIntParams()[1];
if(blockedActionInt < 0 || blockedActionInt > 6) {
throw new WiredSaveException("Blocked action is invalid");
}
packet.readString();
int itemsCount = packet.readInt();
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -237,7 +237,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
THashMap<HabboItem, WiredChangeDirectionSetting> newItems = new THashMap<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -246,7 +246,7 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
newItems.put(it, new WiredChangeDirectionSetting(it.getId(), it.getRotation(), startDirection));
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -67,17 +68,14 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) {
try {
this.amount = Integer.parseInt(packet.readString());
this.amount = Integer.parseInt(settings.getStringParam());
} catch (Exception e) {
return false;
}
packet.readInt();
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
return true;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -66,16 +67,14 @@ public class WiredEffectGiveHotelviewHofPoints extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) {
try {
this.amount = Integer.valueOf(packet.readString());
this.amount = Integer.parseInt(settings.getStringParam());
} catch (Exception e) {
return false;
}
packet.readInt();
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
return true;
}

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -67,17 +68,14 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) {
try {
this.respects = Integer.valueOf(packet.readString());
this.respects = Integer.parseInt(settings.getStringParam());
} catch (Exception e) {
return false;
}
packet.readInt();
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
return true;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
@ -15,6 +16,7 @@ import com.eu.habbo.habbohotel.wired.WiredGiveRewardItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.generic.alerts.UpdateFailedComposer;
import gnu.trove.procedure.TObjectProcedure;
import gnu.trove.set.hash.THashSet;
@ -174,16 +176,16 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if (gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
int argsLength = packet.readInt();
this.rewardTime = packet.readInt();
this.uniqueRewards = packet.readInt() == 1;
this.limit = packet.readInt();
this.limitationInterval = packet.readInt();
if(settings.getIntParams().length < 4) throw new WiredSaveException("Invalid data");
this.rewardTime = settings.getIntParams()[0];
this.uniqueRewards = settings.getIntParams()[1] == 1;
this.limit = settings.getIntParams()[2];
this.limitationInterval = settings.getIntParams()[3];
this.given = 0;
String data = packet.readString();
String data = settings.getStringParam();
String[] items = data.split(";");
@ -204,8 +206,7 @@ public class WiredEffectGiveReward extends InteractionWiredEffect {
return false;
}
packet.readInt();
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
WiredHandler.dropRewards(this.getId());
return true;

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -52,15 +53,19 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
if (game == null)
return false;
TObjectIntIterator<Map.Entry<Integer, Integer>> iterator = this.data.iterator();
int gameStartTime = game.getStartTime();
for (int i = this.data.size(); i-- > 0; ) {
TObjectIntMap<Map.Entry<Integer, Integer>> dataClone = new TObjectIntHashMap<>(this.data);
TObjectIntIterator<Map.Entry<Integer, Integer>> iterator = dataClone.iterator();
for (int i = dataClone.size(); i-- > 0; ) {
iterator.advance();
Map.Entry<Integer, Integer> map = iterator.key();
if (map.getValue() == habbo.getHabboInfo().getId()) {
if (map.getKey() == game.getStartTime()) {
if (map.getKey() == gameStartTime) {
if (iterator.value() < this.count) {
iterator.setValue(iterator.value() + 1);
@ -74,7 +79,13 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
}
}
this.data.put(new AbstractMap.SimpleEntry<>(game.getStartTime(), habbo.getHabboInfo().getId()), 1);
try {
this.data.put(new AbstractMap.SimpleEntry<>(gameStartTime, habbo.getHabboInfo().getId()), 1);
}
catch(IllegalArgumentException e) {
}
if (habbo.getHabboInfo().getGamePlayer() != null) {
habbo.getHabboInfo().getGamePlayer().addScore(this.score, true);
@ -162,23 +173,20 @@ public class WiredEffectGiveScore extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 2) throw new WiredSaveException("Invalid data");
int score = packet.readInt();
int score = settings.getIntParams()[0];
if(score < 1 || score > 100)
throw new WiredSaveException("Score is invalid");
int timesPerGame = packet.readInt();
int timesPerGame = settings.getIntParams()[1];
if(timesPerGame < 1 || timesPerGame > 10)
throw new WiredSaveException("Times per game is invalid");
packet.readString();
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -121,28 +122,25 @@ public class WiredEffectGiveScoreToTeam extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data");
int points = packet.readInt();
int points = settings.getIntParams()[0];
if(points < 1 || points > 100)
throw new WiredSaveException("Points is invalid");
int timesPerGame = packet.readInt();
int timesPerGame = settings.getIntParams()[1];
if(timesPerGame < 1 || timesPerGame > 10)
throw new WiredSaveException("Times per game is invalid");
int team = packet.readInt();
int team = settings.getIntParams()[2];
if(team < 1 || team > 4)
throw new WiredSaveException("Team is invalid");
packet.readString();
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -134,16 +135,15 @@ public class WiredEffectJoinTeam extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
int team = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data");
int team = settings.getIntParams()[0];
if(team < 1 || team > 4)
throw new WiredSaveException("Team is invalid");
packet.readInt();
packet.readString();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
@ -148,11 +149,9 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
String message = packet.readString();
packet.readInt();
int delay = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
String message = settings.getStringParam();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.games.wired.WiredGame;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -116,11 +117,8 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
packet.readInt();
int delay = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.interfaces.InteractionWiredMatchFurniSettings;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -175,21 +176,18 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
boolean setState = packet.readInt() == 1;
boolean setDirection = packet.readInt() == 1;
boolean setPosition = packet.readInt() == 1;
packet.readString();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 3) throw new WiredSaveException("Invalid data");
boolean setState = settings.getIntParams()[0] == 1;
boolean setDirection = settings.getIntParams()[1] == 1;
boolean setPosition = settings.getIntParams()[2] == 1;
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null)
throw new WiredSaveException("Trying to save wired in unloaded room");
int itemsCount = packet.readInt();
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -198,7 +196,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
List<WiredMatchFurniSetting> newSettings = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -207,7 +205,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect implements Int
newSettings.add(new WiredMatchFurniSetting(it.getId(), this.checkForWiredResetPermission && it.allowWiredResetState() ? it.getExtradata() : " ", it.getRotation(), it.getX(), it.getY()));
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -178,10 +179,8 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -190,7 +189,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -199,7 +198,7 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -12,6 +13,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import gnu.trove.set.hash.THashSet;
@ -39,7 +41,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null)
@ -48,18 +50,16 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
this.items.clear();
this.indexOffset.clear();
packet.readInt();
if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data");
this.direction = settings.getIntParams()[0];
this.spacing = settings.getIntParams()[1];
this.direction = packet.readInt();
this.spacing = packet.readInt();
packet.readString();
int count = packet.readInt();
int count = settings.getFurniIds().length;
for (int i = 0; i < count; i++) {
this.items.add(room.getHabboItem(packet.readInt()));
this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
}
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
return true;
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -314,11 +315,8 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -327,7 +325,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -336,7 +334,7 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,12 +5,14 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer;
import gnu.trove.set.hash.THashSet;
import org.slf4j.Logger;
@ -185,28 +187,26 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect implement
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room == null)
return false;
packet.readInt();
if(settings.getIntParams().length < 2) throw new WiredSaveException("invalid data");
this.direction = packet.readInt();
this.rotation = packet.readInt();
this.direction = settings.getIntParams()[0];
this.rotation = settings.getIntParams()[1];
packet.readString();
int count = packet.readInt();
int count = settings.getFurniIds().length;
if (count > Emulator.getConfig().getInt("hotel.wired.furni.selection.count", 5)) return false;
this.items.clear();
for (int i = 0; i < count; i++) {
this.items.add(room.getHabboItem(packet.readInt()));
this.items.add(room.getHabboItem(settings.getFurniIds()[i]));
}
this.setDelay(packet.readInt());
this.setDelay(settings.getDelay());
return true;
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessage;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
@ -13,6 +14,7 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
import java.sql.ResultSet;
@ -49,12 +51,13 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt();
this.length = packet.readInt();
this.message = packet.readString();
packet.readInt();
this.setDelay(packet.readInt());
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
if(settings.getIntParams().length < 1) throw new WiredSaveException("invalid data");
this.length = settings.getIntParams()[0];
this.message = settings.getStringParam();
this.setDelay(settings.getDelay());
return true;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -67,13 +68,8 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) {
packet.readInt();
packet.readString();
packet.readInt();
this.delay = packet.readInt();
this.setDelay(this.delay);
public boolean saveData(WiredSettings settings, GameClient gameClient) {
this.setDelay(settings.getDelay());
return true;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
@ -130,11 +131,8 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -143,7 +141,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -152,7 +150,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -17,6 +17,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.items.interactions.pets.*;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -142,11 +143,8 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -155,7 +153,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -164,7 +162,7 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -15,6 +15,7 @@ import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreeze
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagField;
import com.eu.habbo.habbohotel.items.interactions.games.tag.InteractionTagPole;
import com.eu.habbo.habbohotel.items.interactions.pets.*;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -137,11 +138,8 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -150,7 +148,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -159,7 +157,7 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -85,11 +86,8 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
packet.readString();
int itemsCount = packet.readInt();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
int itemsCount = settings.getFurniIds().length;
if(itemsCount > Emulator.getConfig().getInt("hotel.wired.furni.selection.count")) {
throw new WiredSaveException("Too many furni selected");
@ -98,7 +96,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
List<HabboItem> newItems = new ArrayList<>();
for (int i = 0; i < itemsCount; i++) {
int itemId = packet.readInt();
int itemId = settings.getFurniIds()[i];
HabboItem it = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(itemId);
if(it == null)
@ -107,7 +105,7 @@ public class WiredEffectTriggerStacks extends InteractionWiredEffect {
newItems.add(it);
}
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -5,14 +5,13 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredChangeDirectionSetting;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
@ -70,19 +69,15 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient) throws WiredSaveException {
packet.readInt();
String message = packet.readString();
public boolean saveData(WiredSettings settings, GameClient gameClient) throws WiredSaveException {
String message = settings.getStringParam();
if(gameClient.getHabbo() == null || !gameClient.getHabbo().hasPermission(Permission.ACC_SUPERWIRED)) {
message = Emulator.getGameEnvironment().getWordFilter().filter(message, null);
message = message.substring(0, Math.min(message.length(), Emulator.getConfig().getInt("hotel.wired.message.max_length", 100)));
}
packet.readInt();
int delay = packet.readInt();
int delay = settings.getDelay();
if(delay > Emulator.getConfig().getInt("hotel.wired.max_delay", 20))
throw new WiredSaveException("Delay too long");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -110,9 +111,9 @@ public class WiredTriggerAtSetTime extends InteractionWiredTrigger implements Wi
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.executeTime = packet.readInt() * 500;
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.executeTime = settings.getIntParams()[0] * 500;
this.resetTimer();

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -109,10 +110,9 @@ public class WiredTriggerAtTimeLong extends InteractionWiredTrigger implements W
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.executeTime = packet.readInt() * 500;
public boolean saveData(WiredSettings settings) {
if(settings.getIntParams().length < 1) return false;
this.executeTime = settings.getIntParams()[0] * 500;
return true;
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -97,17 +98,15 @@ public class WiredTriggerBotReachedFurni extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.botName = packet.readString();
public boolean saveData(WiredSettings settings) {
this.botName = settings.getStringParam();
this.items.clear();
int count = packet.readInt();
int count = settings.getFurniIds().length;
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i]));
}
return true;

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@ -48,10 +49,8 @@ public class WiredTriggerBotReachedHabbo extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.botName = packet.readString();
public boolean saveData(WiredSettings settings) {
this.botName = settings.getStringParam();
return true;
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -65,7 +66,7 @@ public class WiredTriggerCollision extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
public boolean saveData(WiredSettings settings) {
return true;
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -135,16 +136,13 @@ public class WiredTriggerFurniStateToggled extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
packet.readString();
public boolean saveData(WiredSettings settings) {
this.items.clear();
int count = packet.readInt();
int count = settings.getFurniIds().length;
for (int i = 0; i < count; i++) {
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt()));
this.items.add(Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(settings.getFurniIds()[i]));
}
return true;

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -83,7 +84,7 @@ public class WiredTriggerGameEnds extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
public boolean saveData(WiredSettings settings) {
return true;
}
}

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -83,7 +84,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
public boolean saveData(WiredSettings settings) {
return true;
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
@ -85,9 +86,8 @@ public class WiredTriggerHabboEntersRoom extends InteractionWiredTrigger {
}
@Override
public boolean saveData(ClientMessage packet) {
packet.readInt();
this.username = packet.readString();
public boolean saveData(WiredSettings settings) {
this.username = settings.getStringParam();
return true;
}

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