Updated to 1.16 decompiled.

This commit is contained in:
capheus 2019-04-21 23:42:00 +00:00
parent bc572ce79a
commit 51be59d071
80 changed files with 1525 additions and 616 deletions

View File

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

View File

@ -0,0 +1,19 @@
#DATABASE UPDATE: 1.15.2 -> 1.16.0
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.room.rollers.norules', '0');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('postit.charlimit', '366');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.max.friends.hc', '300');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.navigator.populartab.publics', '0');
ALTER TABLE `items_base` CHANGE `stack_height` `stack_height` DOUBLE(4,2) NOT NULL DEFAULT '0.00';
ALTER TABLE `permissions` ADD `badge` VARCHAR(12) NOT NULL DEFAULT '' AFTER `rank_name`;
ALTER TABLE `permissions` ADD `acc_ads_background` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `acc_camera`;
ALTER TABLE `permissions` ADD `cmd_update_achievements` ENUM('0','1') NOT NULL DEFAULT '0' AFTER `cmd_unmute`;
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.errors.cmd_give_rank.not_found', 'Rank %id% could not be given to %username% as it does not exist!');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.wired.giveachievement.invalid.points', 'This is not a number!'), ('hotel.wired.giveachievement.invalid.achievement', '%achievement% does not exist!');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('hotel.error.roomads.nopermission', 'You have no permission to modify room ads!');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_update_achievements', 'uach;update_achievements'), ('commands.description.cmd_update_achievements', ':update_achievements');
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.succes.cmd_update_achievements.updated', 'Achievements have been reloaded!');
#END DATABASE UPDATE: 1.15.2 -> 1.16.0

View File

@ -33,10 +33,10 @@ public final class Emulator
public final static int MAJOR = 1; public final static int MAJOR = 1;
public final static int MINOR = 15; public final static int MINOR = 16;
public final static int BUILD = 2; public final static int BUILD = 0;
public static final String version = "Version: " + MAJOR + "." + MINOR + "." + BUILD; public static final String version = "Version: " + MAJOR + "." + MINOR + "." + BUILD;
@ -198,6 +198,7 @@ public final class Emulator
private static void dispose() private static void dispose()
{ {
Emulator.getThreading().setCanAdd(false);
Emulator.isShuttingDown = true; Emulator.isShuttingDown = true;
Emulator.isReady = false; Emulator.isReady = false;
Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "..."); Emulator.getLogging().logShutdownLine("Stopping Arcturus Emulator " + version + "...");
@ -339,11 +340,13 @@ public final class Emulator
return pluginManager; return pluginManager;
} }
public static Random getRandom() public static Random getRandom()
{ {
return random; return random;
} }
public static BadgeImager getBadgeImager() public static BadgeImager getBadgeImager()
{ {
return badgeImager; return badgeImager;
@ -359,11 +362,18 @@ public final class Emulator
cameraClient = client; cameraClient = client;
} }
public static int getTimeStarted() public static int getTimeStarted()
{ {
return timeStarted; return timeStarted;
} }
public static int getOnlineTime()
{
return getIntUnixTimestamp() - timeStarted;
}
public static void prepareShutdown() public static void prepareShutdown()
{ {
System.exit(0); System.exit(0);

View File

@ -83,4 +83,9 @@ public class Achievement
{ {
return this.levels.get(1); return this.levels.get(1);
} }
public void clearLevels()
{
this.levels.clear();
}
} }

View File

@ -45,7 +45,10 @@ public class AchievementManager
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
synchronized (this.achievements) synchronized (this.achievements)
{ {
this.achievements.clear(); for (Achievement achievement : this.achievements.values())
{
achievement.clearLevels();
}
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
{ {
@ -294,6 +297,11 @@ public class AchievementManager
habbo.getHabboStats().addAchievementScore(newLevel.points); habbo.getHabboStats().addAchievementScore(newLevel.points);
if (newLevel.rewardAmount > 0)
{
habbo.givePoints(newLevel.rewardType, newLevel.rewardAmount);
}
if (habbo.getHabboInfo().getCurrentRoom() != null) if (habbo.getHabboInfo().getCurrentRoom() != null)
{ {
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose()); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserDataComposer(habbo).compose());

View File

@ -163,7 +163,7 @@ public class Bot implements Runnable
{ {
if(this.needsUpdate) if(this.needsUpdate)
{ {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ? WHERE id = ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bots SET name = ?, motto = ?, figure = ?, gender = ?, user_id = ?, room_id = ?, x = ?, y = ?, z = ?, rot = ?, dance = ?, freeroam = ?, chat_lines = ?, chat_auto = ?, chat_random = ?, chat_delay = ?, effect = ? WHERE id = ?"))
{ {
statement.setString(1, this.name); statement.setString(1, this.name);
statement.setString(2, this.motto); statement.setString(2, this.motto);
@ -186,7 +186,8 @@ public class Bot implements Runnable
statement.setString(14, this.chatAuto ? "1" : "0"); statement.setString(14, this.chatAuto ? "1" : "0");
statement.setString(15, this.chatRandom ? "1" : "0"); statement.setString(15, this.chatRandom ? "1" : "0");
statement.setInt(16, this.chatDelay); statement.setInt(16, this.chatDelay);
statement.setInt(17, this.id); statement.setInt(17, this.effect);
statement.setInt(18, this.id);
statement.execute(); statement.execute();
this.needsUpdate = false; this.needsUpdate = false;
} }
@ -290,7 +291,10 @@ public class Bot implements Runnable
public void onPlace(Habbo habbo, Room room) public void onPlace(Habbo habbo, Room room)
{ {
if (this.roomUnit != null)
{
room.giveEffect(this.roomUnit, this.effect, -1);
}
} }

View File

@ -18,7 +18,6 @@ import com.eu.habbo.messages.outgoing.catalog.*;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer; import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarProductComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys; import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.inventory.AddBotComposer; import com.eu.habbo.messages.outgoing.inventory.AddBotComposer;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer; import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.AddPetComposer; import com.eu.habbo.messages.outgoing.inventory.AddPetComposer;
@ -799,6 +798,7 @@ public class CatalogManager
item.setPageId(pageId); item.setPageId(pageId);
item.run();
return true; return true;
} }

View File

@ -75,6 +75,12 @@ public class RoomBundleLayout extends SingleBundle
} }
}); });
if (this.room.isPreLoaded())
{
this.room.loadData();
this.room.preventUncaching = true;
this.room.preventUnloading = true;
}
if(item[0] != null) if(item[0] != null)
{ {
item[0].getBundle().clear(); item[0].getBundle().clear();

View File

@ -397,7 +397,7 @@ public class MarketPlace
"SELECT items_base.sprite_id\n" + "SELECT items_base.sprite_id\n" +
"FROM items_base\n" + "FROM items_base\n" +
"WHERE items_base.id = ? LIMIT 1)\n" + "WHERE items_base.id = ? LIMIT 1)\n" +
"ORDER BY price DESC\n" + "ORDER BY price ASC\n" +
"LIMIT 1")) "LIMIT 1"))
{ {
statement.setInt(1, baseItemId); statement.setInt(1, baseItemId);

View File

@ -4,11 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
import gnu.trove.map.hash.THashMap;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -42,26 +37,15 @@ public class BadgeCommand extends Command
if(habbo != null) if(habbo != null)
{ {
if(habbo.getInventory().getBadgesComponent().hasBadge(params[2])) if (habbo.addBadge(params[2]))
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT);
}
else
{ {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owned").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_badge.already_owned").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT);
return true;
} }
HabboBadge badge = new HabboBadge(0, params[2], 0, habbo);
badge.run();
habbo.getInventory().getBadgesComponent().addBadge(badge);
habbo.getClient().sendResponse(new AddUserBadgeComposer(badge));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_badge.given").replace("%user%", params[1]).replace("%badge%", params[2]), RoomChatMessageBubbles.ALERT);
THashMap<String, String> keys = new THashMap<>();
keys.put("display", "BUBBLE");
keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif");
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys));
return true; return true;
} }
else else
@ -70,7 +54,7 @@ public class BadgeCommand extends Command
{ {
boolean found; boolean found;
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1")) try (PreparedStatement statement = connection.prepareStatement("SELECT badge_code FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1"))
{ {
statement.setString(1, params[1]); statement.setString(1, params[1]);
statement.setString(2, params[2]); statement.setString(2, params[2]);

View File

@ -126,6 +126,7 @@ public class CommandHandler
addCommand(new UnbanCommand()); addCommand(new UnbanCommand());
addCommand(new UnloadRoomCommand()); addCommand(new UnloadRoomCommand());
addCommand(new UnmuteCommand()); addCommand(new UnmuteCommand());
addCommand(new UpdateAchievements());
addCommand(new UpdateBotsCommand()); addCommand(new UpdateBotsCommand());
addCommand(new UpdateCatalogCommand()); addCommand(new UpdateCatalogCommand());
addCommand(new UpdateConfigCommand()); addCommand(new UpdateConfigCommand());

View File

@ -56,7 +56,7 @@ public class TestCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
if (true) return true;
if (params[1].equalsIgnoreCase("ut")) if (params[1].equalsIgnoreCase("ut"))
{ {
RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation(); RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation();

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;
public class UpdateAchievements extends Command
{
public UpdateAchievements()
{
super("cmd_update_achievements", Emulator.getTexts().getValue("commands.keys.cmd_update_achievements").split(";"));
}
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception
{
Emulator.getGameEnvironment().getAchievementManager().reload();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_update_achievements.updated"), RoomChatMessageBubbles.ALERT);
return true;
}
}

View File

@ -4,6 +4,8 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredHighscore;
import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob; import com.eu.habbo.habbohotel.items.interactions.wired.extra.WiredBlob;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamLoses;
import com.eu.habbo.habbohotel.items.interactions.wired.triggers.WiredTriggerTeamWins;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
@ -193,6 +195,33 @@ public abstract class Game implements Runnable
this.saveScores(); this.saveScores();
GameTeam winningTeam = null;
for (GameTeam team : this.teams.values())
{
if (winningTeam == null || team.getTotalScore() > winningTeam.getTotalScore())
{
winningTeam = team;
}
}
if (winningTeam != null)
{
for (GamePlayer player : winningTeam.getMembers())
{
WiredHandler.handleCustomTrigger(WiredTriggerTeamWins.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
}
for (GameTeam team : this.teams.values())
{
if (team == winningTeam) continue;
for (GamePlayer player : winningTeam.getMembers())
{
WiredHandler.handleCustomTrigger(WiredTriggerTeamLoses.class, player.getHabbo().getRoomUnit(), this.room, new Object[]{this});
}
}
}
if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true)) if(Emulator.getPluginManager().isRegistered(GameStoppedEvent.class, true))
{ {
Event gameStoppedEvent = new GameStoppedEvent(this); Event gameStoppedEvent = new GameStoppedEvent(this);

View File

@ -502,6 +502,30 @@ public class GuildManager
return guildMembers; return guildMembers;
} }
public int getGuildMembersCount(Guild guild, int levelId, String query)
{
int rows = 0;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count FROM guilds_members INNER JOIN users ON guilds_members.user_id = users.id WHERE guilds_members.guild_id = ? " + (this.rankQuery(levelId)) + " AND users.username LIKE ? ORDER BY level_id, member_since"))
{
statement.setInt(1, guild.getId());
statement.setString(2, "%" + query + "%");
try (ResultSet set = statement.executeQuery())
{
if (set.next())
{
rows = set.getInt("row_count");
}
}
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
return rows;
}
public THashMap<Integer, GuildMember> getOnlyAdmins(Guild guild) public THashMap<Integer, GuildMember> getOnlyAdmins(Guild guild)
{ {

View File

@ -173,6 +173,8 @@ public class ItemManager
this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class)); this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class));
this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class)); this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class));
this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class)); this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class));
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
@ -196,6 +198,8 @@ public class ItemManager
this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class)); this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class));
this.interactionsList.add(new ItemInteraction("wf_trg_starts_dancing", WiredTriggerHabboStartsDancing.class)); this.interactionsList.add(new ItemInteraction("wf_trg_starts_dancing", WiredTriggerHabboStartsDancing.class));
this.interactionsList.add(new ItemInteraction("wf_trg_stops_dancing", WiredTriggerHabboStopsDancing.class)); this.interactionsList.add(new ItemInteraction("wf_trg_stops_dancing", WiredTriggerHabboStopsDancing.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_win", WiredTriggerTeamWins.class));
this.interactionsList.add(new ItemInteraction("wf_trg_game_team_lose", WiredTriggerTeamLoses.class));
this.interactionsList.add(new ItemInteraction("wf_act_toggle_state", WiredEffectToggleFurni.class)); this.interactionsList.add(new ItemInteraction("wf_act_toggle_state", WiredEffectToggleFurni.class));
@ -237,6 +241,8 @@ public class ItemManager
this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_handitem", WiredEffectGiveHandItem.class));
this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot2", WiredEffectMatchFurniStaff.class)); this.interactionsList.add(new ItemInteraction("wf_act_match_to_sshot2", WiredEffectMatchFurniStaff.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class)); this.interactionsList.add(new ItemInteraction("wf_act_give_effect", WiredEffectGiveEffect.class));
this.interactionsList.add(new ItemInteraction("wf_act_open_habbo_pages", WiredEffectOpenHabboPages.class));
this.interactionsList.add(new ItemInteraction("wf_act_give_achievement", WiredEffectGiveAchievement.class));
this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class)); this.interactionsList.add(new ItemInteraction("wf_cnd_has_furni_on", WiredConditionFurniHaveFurni.class));
@ -445,7 +451,8 @@ public class ItemManager
} }
catch (Exception e) catch (Exception e)
{ {
Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("ïtem_id")); Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("item_id"));
Emulator.getLogging().logErrorLine(e);
continue; continue;
} }
this.crackableRewards.put(set.getInt("item_id"), reward); this.crackableRewards.put(set.getInt("item_id"), reward);

View File

@ -0,0 +1,25 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionGroupEffectTile extends InteractionEffectTile
{
public InteractionGroupEffectTile(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionGroupEffectTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean requiresAllTilesOccupied()
{
return true;
}
}

View File

@ -0,0 +1,25 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.items.Item;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionGroupPressurePlate extends InteractionPressurePlate
{
public InteractionGroupPressurePlate(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionGroupPressurePlate(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean requiresAllTilesOccupied()
{
return true;
}
}

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions; 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.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
@ -21,10 +22,17 @@ public class InteractionMusicDisc extends HabboItem
String[] stuff = this.getExtradata().split("\n"); String[] stuff = this.getExtradata().split("\n");
if(stuff.length >= 7) if(stuff.length >= 7 && !stuff[6].isEmpty())
{
try
{ {
this.songId = Integer.valueOf(stuff[6]); this.songId = Integer.valueOf(stuff[6]);
} }
catch (Exception e)
{
Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
}
} }
public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) public InteractionMusicDisc(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
@ -33,9 +41,15 @@ public class InteractionMusicDisc extends HabboItem
String[] stuff = this.getExtradata().split("\n"); String[] stuff = this.getExtradata().split("\n");
if(stuff.length >= 7) if(stuff.length >= 7 && !stuff[6].isEmpty())
{
try
{ {
this.songId = Integer.valueOf(stuff[6]); this.songId = Integer.valueOf(stuff[6]);
} catch (Exception e)
{
Emulator.getLogging().logErrorLine("Warning: Item " + this.getId() + " has an invalid song id set for its music disk!");
}
} }
} }

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions; package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
@ -61,21 +62,14 @@ public class InteractionPressurePlate extends HabboItem
{ {
super.onWalkOn(roomUnit, room, objects); super.onWalkOn(roomUnit, room, objects);
this.setExtradata("1"); Emulator.getThreading().run(new Runnable()
if (this.getBaseItem().getWidth() > 1 || this.getBaseItem().getLength() > 1)
{ {
for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation())) @Override
public void run()
{ {
if (!room.hasHabbosAt(tile.x, tile.y) && !roomUnit.getGoal().is(tile.x, tile.y)) updateState(room);
{
this.setExtradata("0");
break;
} }
} }, 100);
}
room.updateItemState(this);
} }
@Override @Override
@ -83,8 +77,14 @@ public class InteractionPressurePlate extends HabboItem
{ {
super.onWalkOff(roomUnit, room, objects); super.onWalkOff(roomUnit, room, objects);
this.setExtradata("0"); Emulator.getThreading().run(new Runnable()
room.updateItemState(this); {
@Override
public void run()
{
updateState(room);
}
}, 100);
} }
@Override @Override
@ -92,11 +92,30 @@ public class InteractionPressurePlate extends HabboItem
{ {
super.onMove(room, oldLocation, newLocation); super.onMove(room, oldLocation, newLocation);
if (oldLocation != newLocation && oldLocation.getStackHeight() != newLocation.getStackHeight() && !room.hasHabbosAt(newLocation.x, newLocation.y)) updateState(room);
{
this.setExtradata("0");
room.updateItemState(this);
} }
public void updateState(Room room)
{
boolean occupied = false;
for (RoomTile tile : room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()))
{
boolean hasHabbos = room.hasHabbosAt(tile.x, tile.y);
if (!hasHabbos && this.requiresAllTilesOccupied())
{
occupied = false;
break;
}
if (hasHabbos)
{
occupied = true;
}
}
this.setExtradata(occupied ? "1" : "0");
room.updateItem(this);
} }
@Override @Override
@ -105,5 +124,9 @@ public class InteractionPressurePlate extends HabboItem
return true; return true;
} }
public boolean requiresAllTilesOccupied()
{
return false;
}
} }

View File

@ -64,6 +64,7 @@ public abstract class InteractionPushable extends InteractionDefault {
{ {
super.onClick(client, room, objects); super.onClick(client, room, objects);
if (client == null) return;
if(RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY()))) if(RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())))
{ {
int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room); int velocity = this.getTackleVelocity(client.getHabbo().getRoomUnit(), room);

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions; package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
@ -16,6 +17,7 @@ import java.util.List;
public class InteractionRoller extends HabboItem public class InteractionRoller extends HabboItem
{ {
public static boolean NO_RULES = false;
public InteractionRoller(ResultSet set, Item baseItem) throws SQLException public InteractionRoller(ResultSet set, Item baseItem) throws SQLException
{ {
super(set, baseItem); super(set, baseItem);
@ -75,6 +77,7 @@ public class InteractionRoller extends HabboItem
@Override @Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation) public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation)
{ {
if (NO_RULES) return true;
if (itemsAtLocation.isEmpty()) return false; if (itemsAtLocation.isEmpty()) return false;
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation) for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation)

View File

@ -21,7 +21,7 @@ public class InteractionGameTimer extends HabboItem
private int baseTime = 0; private int baseTime = 0;
private int lastToggle = 0; private int lastToggle = 0;
protected InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException public InteractionGameTimer(ResultSet set, Item baseItem) throws SQLException
{ {
super(set, baseItem); super(set, baseItem);
@ -38,7 +38,7 @@ public class InteractionGameTimer extends HabboItem
} }
} }
protected InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) public InteractionGameTimer(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{ {
super(id, userId, item, extradata, limitedStack, limitedSells); super(id, userId, item, extradata, limitedStack, limitedSells);
} }

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions; 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.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
@ -15,6 +16,9 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition
{ {
public static final WiredConditionType type = WiredConditionType.DATE_RANGE; public static final WiredConditionType type = WiredConditionType.DATE_RANGE;
private int startDate;
private int endDate;
public WiredConditionDateRangeActive(ResultSet set, Item baseItem) throws SQLException public WiredConditionDateRangeActive(ResultSet set, Item baseItem) throws SQLException
{ {
super(set, baseItem); super(set, baseItem);
@ -40,40 +44,59 @@ public class WiredConditionDateRangeActive extends InteractionWiredCondition
message.appendInt(this.getBaseItem().getSpriteId()); message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId()); message.appendInt(this.getId());
message.appendString(""); message.appendString("");
message.appendInt(0); message.appendInt(2);
message.appendInt(this.startDate);
message.appendInt(this.endDate);
message.appendInt(0); message.appendInt(0);
message.appendInt(this.getType().code); message.appendInt(this.getType().code);
message.appendInt(0); message.appendInt(this.startDate);
message.appendInt(0); message.appendInt(this.endDate);
} }
@Override @Override
public boolean saveData(ClientMessage packet) public boolean saveData(ClientMessage packet)
{ {
return false; packet.readInt();
this.startDate = packet.readInt();
this.endDate = packet.readInt();
return true;
} }
@Override @Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff) public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{ {
return false; int time = Emulator.getIntUnixTimestamp();
return this.startDate < time && this.endDate >= time;
} }
@Override @Override
public String getWiredData() public String getWiredData()
{ {
return ""; return this.startDate + "\t" + this.endDate;
} }
@Override @Override
public void loadWiredData(ResultSet set, Room room) throws SQLException public void loadWiredData(ResultSet set, Room room) throws SQLException
{ {
String[] data = set.getString("wired_data").split("\t");
if (data.length == 2)
{
try
{
this.startDate = Integer.valueOf(data[0]);
this.endDate = Integer.valueOf(data[1]);
}
catch (Exception e)
{
}
}
} }
@Override @Override
public void onPickUp() public void onPickUp()
{ {
this.startDate = 0;
this.endDate = 0;
} }
} }

View File

@ -0,0 +1,195 @@
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
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.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.procedure.TObjectProcedure;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class WiredEffectGiveAchievement extends WiredEffectGiveBadge
{
public static final WiredEffectType type = WiredEffectType.SHOW_MESSAGE;
public static final String DEFAULT_CONTENT = "ach_achievement:points <- Points are optional";
private String achievement = DEFAULT_CONTENT;
public WiredEffectGiveAchievement(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredEffectGiveAchievement(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void serializeWiredData(ServerMessage message, Room room)
{
message.appendBoolean(true);
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString(this.achievement + "");
message.appendInt(0);
message.appendInt(0);
message.appendInt(type.code);
message.appendInt(this.getDelay());
if (this.requiresTriggeringUser())
{
List<Integer> invalidTriggers = new ArrayList<>();
room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure<InteractionWiredTrigger>()
{
@Override
public boolean execute(InteractionWiredTrigger object)
{
if (!object.isTriggeredByRoomUnit())
{
invalidTriggers.add(object.getBaseItem().getSpriteId());
}
return true;
}
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers)
{
message.appendInt(i);
}
} else
{
message.appendInt(0);
}
}
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient)
{
packet.readInt();
try
{
this.achievement = packet.readString();
int points = 1;
String a = achievement;
if (a.contains(":"))
{
a = achievement.split(":")[0];
try
{
points = Integer.valueOf(achievement.split(":")[1]);
} catch (Exception e)
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.points"), RoomChatMessageBubbles.WIRED);
}
}
Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a);
if (ach == null)
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("hotel.wired.giveachievement.invalid.achievement").replace("%achievement%", a), RoomChatMessageBubbles.WIRED);
}
}
catch (Exception e)
{
e.printStackTrace();
return false;
}
packet.readInt();
this.setDelay(packet.readInt());
return true;
}
@Override
public WiredEffectType getType()
{
return type;
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
if (!this.achievement.equals(DEFAULT_CONTENT))
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
int points = 1;
String a = achievement;
if (a.contains(":"))
{
a = achievement.split(":")[0];
try
{
points = Integer.valueOf(achievement.split(":")[1]);
} catch (Exception e)
{
return false;
}
}
Achievement ach = Emulator.getGameEnvironment().getAchievementManager().getAchievement(a);
if (ach != null)
{
AchievementManager.progressAchievement(habbo, ach, points);
}
}
}
return true;
}
@Override
public String getWiredData()
{
return this.getDelay() + "\t" + this.achievement;
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
String wireData = set.getString("wired_data");
String[] data = wireData.split("\t");
this.achievement = DEFAULT_CONTENT;
if (data.length >= 2)
{
super.setDelay(Integer.valueOf(data[0]));
this.achievement = data[1];
}
}
@Override
public void onPickUp()
{
this.achievement = DEFAULT_CONTENT;
this.setDelay(0);
}
@Override
public boolean requiresTriggeringUser()
{
return true;
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.Game;
import com.eu.habbo.habbohotel.games.wired.WiredGame;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
@ -43,14 +44,20 @@ public class WiredEffectLeaveTeam extends InteractionWiredEffect
{ {
Game game = room.getGame(habbo.getHabboInfo().getCurrentGame()); Game game = room.getGame(habbo.getHabboInfo().getCurrentGame());
if (game == null)
{
game = room.getGame(WiredGame.class);
}
if (game != null) if (game != null)
{ {
game.removeHabbo(habbo); game.removeHabbo(habbo);
}
}
}
return true; return true;
} }
}
}
return false;
}
@Override @Override
public String getWiredData() public String getWiredData()

View File

@ -65,7 +65,6 @@ public class WiredEffectMoveFurniAway extends InteractionWiredEffect
if(target != null) if(target != null)
{ {
if(RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY())) if(RoomLayout.tilesAdjecent(target.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY())) && (target.getRoomUnit().getX() == item.getX() || target.getRoomUnit().getY() == item.getY()))
{ {
final Habbo finalTarget = target; final Habbo finalTarget = target;

View File

@ -4,10 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect; import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomTileState;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType; import com.eu.habbo.habbohotel.wired.WiredEffectType;
@ -15,7 +12,7 @@ import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage; import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemOnRollerComposer; import com.eu.habbo.util.pathfinding.Rotation;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -54,14 +51,18 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
for(HabboItem item : this.items) for(HabboItem item : this.items)
{ {
RoomTile t = room.getLayout().getTile(item.getX(), item.getY()); RoomTile furniLocation = room.getLayout().getTile(item.getX(), item.getY());
boolean collided = false; boolean collided = false;
double shortest = 4; double shortest = 3 + Math.max(item.getBaseItem().getWidth(), item.getBaseItem().getLength());
Habbo target = null; Habbo target = null;
THashSet<RoomTile> tiles = room.getLayout().getTilesAt(furniLocation, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
for (Habbo habbo : room.getHabbos()) for (Habbo habbo : room.getHabbos())
{ {
if (habbo.getRoomUnit().getCurrentLocation().x == t.x || habbo.getRoomUnit().getCurrentLocation().y == t.y) RoomTile currentLocation = habbo.getRoomUnit().getCurrentLocation();
for (RoomTile t : tiles)
{
if (currentLocation.x == t.x || currentLocation.y == t.y)
{ {
double distance = t.distance(habbo.getRoomUnit().getCurrentLocation()); double distance = t.distance(habbo.getRoomUnit().getCurrentLocation());
if (distance == 1) if (distance == 1)
@ -79,13 +80,30 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
break; break;
} }
if (distance <= shortest) boolean valid = true;
for (RoomTile tile : room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), Rotation.Calculate(currentLocation.x, currentLocation.y, t.x, t.y), (int) Math.ceil(distance)))
{
if (tile.state == RoomTileState.INVALID)
{
valid = false;
break;
}
if (tile == t)
{
//Do not look further in case of rounding error.
break;
}
}
if (valid && distance <= shortest)
{ {
target = habbo; target = habbo;
shortest = distance; shortest = distance;
} }
} }
} }
}
if (collided) if (collided)
{ {
@ -96,30 +114,38 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
int y = 0; int y = 0;
if(target != null) if(target != null)
{ {
if (target.getRoomUnit().getX() == item.getX()) for (RoomTile tile : tiles)
{ {
if (item.getY() < target.getRoomUnit().getY()) if (target.getRoomUnit().getX() == tile.x)
{
if (tile.y < target.getRoomUnit().getY())
y++; y++;
else else
y--; y--;
} else if (target.getRoomUnit().getY() == item.getY())
break;
} else if (target.getRoomUnit().getY() == tile.y)
{ {
if (item.getX() < target.getRoomUnit().getX()) if (tile.x < target.getRoomUnit().getX())
x++; x++;
else else
x--; x--;
} else if (target.getRoomUnit().getX() - item.getX() > target.getRoomUnit().getY() - item.getY()) break;
} else if (target.getRoomUnit().getX() - tile.x > target.getRoomUnit().getY() - tile.y)
{ {
if (target.getRoomUnit().getX() - item.getX() > 0) if (target.getRoomUnit().getX() - tile.x > 0)
x++; x++;
else else
x--; x--;
break;
} else } else
{ {
if (target.getRoomUnit().getY() - item.getY() > 0) if (target.getRoomUnit().getY() - tile.y > 0)
y++; y++;
else else
y--; y--;
break;
}
} }
} }
else else
@ -135,26 +161,15 @@ public class WiredEffectMoveFurniTowards extends InteractionWiredEffect
RoomTile newTile = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y)); RoomTile newTile = room.getLayout().getTile((short) (item.getX() + x), (short) (item.getY() + y));
if (newTile != null && newTile.state == RoomTileState.OPEN && newTile.isWalkable()) if (newTile != null && ((newTile.state == RoomTileState.OPEN && newTile.isWalkable()) || newTile.state == RoomTileState.BLOCKED && room.getTopItemAt(newTile.x, newTile.y) == item) && room.furnitureFitsAt(newTile, item, item.getRotation()) == FurnitureMovementError.NONE)
{ {
if (room.getLayout().tileExists(newTile.x, newTile.y)) if (room.getLayout().tileExists(newTile.x, newTile.y))
{ {
HabboItem topItem = room.getTopItemAt(newTile.x, newTile.y); room.slideFurniTo(item, newTile, item.getRotation());
if (topItem == null || topItem.getBaseItem().allowStack())
{
double offsetZ = 0;
if (topItem != null)
offsetZ = topItem.getZ() + topItem.getBaseItem().getHeight() - item.getZ();
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offsetZ, room).compose());
} }
} }
} }
}
return true; return true;
} }

View File

@ -60,29 +60,41 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
for (HabboItem item : this.items) for (HabboItem item : this.items)
{ {
//Handle rotation
int rotationToAdd = 0;
if (this.rotation > 0) if (this.rotation > 0)
{ {
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
if (this.rotation == 1) if (this.rotation == 1)
{ {
item.setRotation(item.getRotation() + 2); rotationToAdd = 2;
} }
else if (this.rotation == 2) else if (this.rotation == 2)
{ {
item.setRotation(item.getRotation() + 6); rotationToAdd = 6;
} }
//Random rotation
else if (this.rotation == 3) else if (this.rotation == 3)
{ {
if (Emulator.getRandom().nextInt(2) == 1) if (Emulator.getRandom().nextInt(2) == 1)
{ {
item.setRotation(item.getRotation() + 2); rotationToAdd = 2;
} }
else else
{ {
item.setRotation(item.getRotation() + 6); rotationToAdd = 6;
} }
} }
}
int newRotation = ((item.getRotation() + rotationToAdd) % 8) % (item.getBaseItem().getWidth() > 1 || item.getBaseItem().getLength() > 1 ? 4 : 8);
//Verify if rotation result in a valid position
if (rotationToAdd > 0 && room.furnitureFitsAt(room.getLayout().getTile(item.getX(), item.getY()), item, newRotation).equals(FurnitureMovementError.NONE))//room.canPlaceFurnitureAt(item, null, room.getLayout().getTile(item.getX(), item.getY()), item.getRotation() + rotationToAdd))
{
item.setRotation(newRotation);
if (this.direction == 0) if (this.direction == 0)
{ {
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation())); tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));

View File

@ -0,0 +1,36 @@
package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredEffectOpenHabboPages extends WiredEffectWhisper
{
public WiredEffectOpenHabboPages(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredEffectOpenHabboPages(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
habbo.getClient().sendResponse(new NuxAlertComposer(this.message));
}
return true;
}
}

View File

@ -69,7 +69,7 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger
message.appendString(""); message.appendString("");
message.appendInt(0); message.appendInt(0);
message.appendInt(0); message.appendInt(0);
message.appendInt(this.getType().code); message.appendInt(this.type.code);
if (!this.isTriggeredByRoomUnit()) if (!this.isTriggeredByRoomUnit())
{ {

View File

@ -43,7 +43,7 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger
{ {
if (stuff[0] instanceof String) if (stuff[0] instanceof String)
{ {
if (((String) stuff[0]).equalsIgnoreCase(this.key)) if (((String) stuff[0]).replace(":", "").startsWith(this.key + " "))
{ {
if (this.ownerOnly && room.getOwnerId() != habbo.getHabboInfo().getId()) if (this.ownerOnly && room.getOwnerId() != habbo.getHabboInfo().getId())
return false; return false;
@ -72,7 +72,7 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger
if(data.length == 2) if(data.length == 2)
{ {
this.ownerOnly = data[0].equalsIgnoreCase("1"); this.ownerOnly = data[0].equalsIgnoreCase("1");
this.key = data[1]; this.setKey(data[1]);
} }
} }
@ -110,11 +110,22 @@ public class WiredTriggerHabboSaysCommand extends InteractionWiredTrigger
{ {
packet.readInt(); packet.readInt();
this.ownerOnly = packet.readInt() == 1; this.ownerOnly = packet.readInt() == 1;
this.key = packet.readString(); setKey(packet.readString());
return true; return true;
} }
private void setKey(String key)
{
if (key.contains(":"))
{
key = key.replaceAll(":", "");
}
this.key = key;
}
@Override @Override
public boolean isTriggeredByRoomUnit() public boolean isTriggeredByRoomUnit()
{ {

View File

@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers; package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -23,4 +25,10 @@ public class WiredTriggerHabboStartsDancing extends WiredTriggerCollision
{ {
return WiredTriggerType.STARTS_DANCING; return WiredTriggerType.STARTS_DANCING;
} }
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
return true;
}
} }

View File

@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers; package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item; import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import java.sql.ResultSet; import java.sql.ResultSet;
@ -23,4 +25,10 @@ public class WiredTriggerHabboStopsDancing extends WiredTriggerCollision
{ {
return WiredTriggerType.STOPS_DANCING; return WiredTriggerType.STOPS_DANCING;
} }
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
return true;
}
} }

View File

@ -0,0 +1,26 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredTriggerTeamLoses extends WiredTriggerGameStarts
{
public WiredTriggerTeamLoses(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredTriggerTeamLoses(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public WiredTriggerType getType()
{
return WiredTriggerType.CUSTOM;
}
}

View File

@ -0,0 +1,26 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredTriggerTeamWins extends WiredTriggerGameStarts
{
public WiredTriggerTeamWins(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredTriggerTeamWins(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public WiredTriggerType getType()
{
return WiredTriggerType.CUSTOM;
}
}

View File

@ -1,6 +1,8 @@
package com.eu.habbo.habbohotel.messenger; package com.eu.habbo.habbohotel.messenger;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo; import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.HabboManager;
@ -22,6 +24,7 @@ public class Messenger
//Configuration. Loaded from database & updated accordingly. //Configuration. Loaded from database & updated accordingly.
public static boolean SAVE_PRIVATE_CHATS = false; public static boolean SAVE_PRIVATE_CHATS = false;
public static int MAXIMUM_FRIENDS = 200; public static int MAXIMUM_FRIENDS = 200;
public static int MAXIMUM_FRIENDS_HC = 500;
private final ConcurrentHashMap<Integer, MessengerBuddy> friends; private final ConcurrentHashMap<Integer, MessengerBuddy> friends;
private final THashSet<FriendRequest> friendRequests; private final THashSet<FriendRequest> friendRequests;
@ -470,4 +473,42 @@ public class Messenger
} }
} }
public static int friendLimit(Habbo habbo)
{
if (habbo.hasPermission("acc_infinite_friends"))
{
return Integer.MAX_VALUE;
}
if (habbo.getHabboStats().hasActiveClub())
{
return MAXIMUM_FRIENDS_HC;
}
return MAXIMUM_FRIENDS;
}
public static void checkFriendSizeProgress(Habbo habbo)
{
int progress = habbo.getHabboStats().getAchievementProgress(Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize"));
int toProgress = 1;
Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize");
if(achievement == null)
return;
if (progress > 0)
{
toProgress = habbo.getMessenger().getFriends().size() - progress;
if(toProgress < 0)
{
return;
}
}
AchievementManager.progressAchievement(habbo, achievement, toProgress);
}
} }

View File

@ -3,21 +3,27 @@ package com.eu.habbo.habbohotel.permissions;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.plugin.HabboPlugin; import com.eu.habbo.plugin.HabboPlugin;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.map.hash.TIntObjectHashMap; import gnu.trove.map.hash.TIntObjectHashMap;
import java.sql.*; import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class PermissionsManager public class PermissionsManager
{ {
private final TIntObjectHashMap<Rank> ranks; private final TIntObjectHashMap<Rank> ranks;
private final TIntIntHashMap enables; private final TIntIntHashMap enables;
private final THashMap<String, List<Rank>> badges;
public PermissionsManager() public PermissionsManager()
{ {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
this.ranks = new TIntObjectHashMap<>(); this.ranks = new TIntObjectHashMap<>();
this.enables = new TIntIntHashMap(); this.enables = new TIntIntHashMap();
this.badges = new THashMap<String, List<Rank>>();
this.reload(); this.reload();
@ -32,18 +38,33 @@ public class PermissionsManager
private void loadPermissions() private void loadPermissions()
{ {
this.badges.clear();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permissions ORDER BY id ASC")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM permissions ORDER BY id ASC"))
{ {
try (ResultSet set = statement.executeQuery()) try (ResultSet set = statement.executeQuery())
{ {
while (set.next()) while (set.next())
{ {
Rank rank = null;
if (!this.ranks.containsKey(set.getInt("id"))) if (!this.ranks.containsKey(set.getInt("id")))
{ {
this.ranks.put(set.getInt("id"), new Rank(set)); rank = new Rank(set);
this.ranks.put(set.getInt("id"), rank);
} else } else
{ {
this.ranks.get(set.getInt("id")).load(set); rank = this.ranks.get(set.getInt("id"));
rank.load(set);
}
if (rank != null && !rank.getBadge().isEmpty())
{
if (!this.badges.containsKey(rank.getBadge()))
{
this.badges.put(rank.getBadge(), new ArrayList<Rank>());
}
this.badges.get(rank.getBadge()).add(rank);
} }
} }
} }
@ -134,4 +155,14 @@ public class PermissionsManager
{ {
return rank.hasPermission(permission, withRoomRights); return rank.hasPermission(permission, withRoomRights);
} }
public Set<String> getStaffBadges()
{
return this.badges.keySet();
}
public List<Rank> getRanks(String code)
{
return this.badges.get(code);
}
} }

View File

@ -18,6 +18,9 @@ public class Rank
private String name; private String name;
private String badge;
private final THashMap<String, Permission> permissions; private final THashMap<String, Permission> permissions;
@ -52,6 +55,7 @@ public class Rank
{ {
ResultSetMetaData meta = set.getMetaData(); ResultSetMetaData meta = set.getMetaData();
this.name = set.getString("rank_name"); this.name = set.getString("rank_name");
this.badge = set.getString("badge");
this.roomEffect = set.getInt("room_effect"); this.roomEffect = set.getInt("room_effect");
this.logCommands = set.getString("log_commands").equals("1"); this.logCommands = set.getString("log_commands").equals("1");
this.prefix = set.getString("prefix"); this.prefix = set.getString("prefix");
@ -102,6 +106,11 @@ public class Rank
return this.name; return this.name;
} }
public String getBadge()
{
return this.badge;
}
public THashMap<String, Permission> getPermissions() public THashMap<String, Permission> getPermissions()
{ {
return this.permissions; return this.permissions;

View File

@ -595,21 +595,30 @@ public class Pet implements ISerialize, Runnable
public void randomHappyAction() public void randomHappyAction()
{
if (this.petData.actionsHappy.length > 0)
{ {
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), ""); this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), "");
} }
}
public void randomSadAction() public void randomSadAction()
{
if (this.petData.actionsTired.length > 0)
{ {
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), ""); this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), "");
} }
}
public void randomAction() public void randomAction()
{
if (this.petData.actionsRandom.length > 0)
{ {
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), ""); this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), "");
} }
}
public void addExperience(int amount) public void addExperience(int amount)
@ -633,11 +642,11 @@ public class Pet implements ISerialize, Runnable
if (this.level >= PetManager.experiences.length) if (this.level >= PetManager.experiences.length)
return; return;
this.level++;
if (this.experience < PetManager.experiences[this.level]) if (this.experience < PetManager.experiences[this.level])
{ {
this.experience = PetManager.experiences[this.level]; this.experience = PetManager.experiences[this.level];
} }
this.level++;
this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP)); this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP));
this.addHappyness(100); this.addHappyness(100);
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp"); this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp");

View File

@ -93,26 +93,7 @@ public class PetData implements Comparable<PetData>
this.actionsTired = set.getString("tired_actions").split(";"); this.actionsTired = set.getString("tired_actions").split(";");
this.actionsRandom = set.getString("random_actions").split(";"); this.actionsRandom = set.getString("random_actions").split(";");
this.petCommands = new ArrayList<>(); this.reset();
this.nestItems = new ArrayList<>();
this.foodItems = new ArrayList<>();
this.drinkItems = new ArrayList<>();
this.toyItems = new ArrayList<>();
this.petVocals = new THashMap<>();
for(PetVocalsType type : PetVocalsType.values())
{
this.petVocals.put(type, new THashSet<>());
}
if(PetData.generalPetVocals.isEmpty())
{
for(PetVocalsType type : PetVocalsType.values())
{
PetData.generalPetVocals.put(type, new THashSet<>());
}
}
} }
public void setPetCommands(List<PetCommand> petCommands) public void setPetCommands(List<PetCommand> petCommands)
@ -352,4 +333,28 @@ public class PetData implements Comparable<PetData>
{ {
return this.getType() - o.getType(); return this.getType() - o.getType();
} }
public void reset()
{
this.petCommands = new ArrayList<>();
this.nestItems = new ArrayList<>();
this.foodItems = new ArrayList<>();
this.drinkItems = new ArrayList<>();
this.toyItems = new ArrayList<>();
this.petVocals = new THashMap<>();
for(PetVocalsType type : PetVocalsType.values())
{
this.petVocals.put(type, new THashSet<>());
}
if(PetData.generalPetVocals.isEmpty())
{
for(PetVocalsType type : PetVocalsType.values())
{
PetData.generalPetVocals.put(type, new THashSet<>());
}
}
}
} }

View File

@ -127,11 +127,7 @@ public class PetManager
for(PetData data : this.petData.values()) for(PetData data : this.petData.values())
{ {
data.getDrinkItems().clear(); data.reset();
data.getFoodItems().clear();
data.getToyItems().clear();
data.getNests().clear();
data.petVocals.clear();
} }
this.loadPetItems(connection); this.loadPetItems(connection);

View File

@ -538,6 +538,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]); b.getRoomUnit().setDanceType(DanceType.values()[set.getInt("dance")]);
//b.getRoomUnit().setCanWalk(set.getBoolean("freeroam")); //b.getRoomUnit().setCanWalk(set.getBoolean("freeroam"));
b.getRoomUnit().setInRoom(true); b.getRoomUnit().setInRoom(true);
this.giveEffect(b.getRoomUnit(), set.getInt("effect"), Integer.MAX_VALUE);
this.addBot(b); this.addBot(b);
} }
} }
@ -840,6 +841,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
if((item == null && !roomUnit.cmdSit) || (item != null && !item.getBaseItem().allowSit())) if((item == null && !roomUnit.cmdSit) || (item != null && !item.getBaseItem().allowSit()))
roomUnit.removeStatus(RoomUnitStatus.SIT); roomUnit.removeStatus(RoomUnitStatus.SIT);
double oldZ = roomUnit.getZ();
if(item != null) if(item != null)
{ {
@ -851,6 +853,24 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
{ {
roomUnit.setZ(item.getZ() + item.getBaseItem().getHeight()); roomUnit.setZ(item.getZ() + item.getBaseItem().getHeight());
} }
if (oldZ != roomUnit.getZ())
{
this.scheduledTasks.add(new Runnable()
{
@Override
public void run()
{
try
{
item.onWalkOn(roomUnit, Room.this, null);
} catch (Exception e)
{
}
}
});
}
} }
this.sendComposer(new RoomUserStatusComposer(roomUnit).compose()); this.sendComposer(new RoomUserStatusComposer(roomUnit).compose());
@ -892,6 +912,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
else else
{ {
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight()); habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
} }
roomUnits.add(habbo.getRoomUnit()); roomUnits.add(habbo.getRoomUnit());
} }
@ -1156,10 +1177,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
base = base | 8; base = base | 8;
} }
if (this.allowPets)
{
base = base | 16;
}
message.appendInt(base); message.appendInt(base);
@ -1363,282 +1384,6 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
final Room room = this; final Room room = this;
final long millis = System.currentTimeMillis(); final long millis = System.currentTimeMillis();
if(this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed)
{
this.rollerCycle = 0;
THashSet<MessageComposer> messages = new THashSet<>();
//Find alternative for this.
//Reason is that tile gets updated after every roller.
List<Integer> rollerFurniIds = new ArrayList<>();
List<Integer> rolledUnitIds = new ArrayList<>();
this.roomSpecialTypes.getRollers().forEachValue(new TObjectProcedure<InteractionRoller>()
{
@Override
public boolean execute(InteractionRoller roller)
{
//if(Double.compare(roller.getZ(), this.layout.getHeightAtSquare(roller.getX(), roller.getY())) != 0)
//}
HabboItem newRoller = null;
THashSet<Habbo> habbosOnRoller = Room.this.getHabbosAt(roller.getX(), roller.getY());
THashSet<HabboItem> itemsOnRoller = new THashSet<>(getItemsAt(roller.getX(), roller.getY()));
itemsOnRoller.remove(roller);
if (habbosOnRoller.isEmpty())
{
if (itemsOnRoller.isEmpty())
return true;
}
RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getX(), roller.getY()), roller.getRotation());
RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY());
if (tileInFront == null)
return true;
if (roller.getZ() != rollerTile.z)
return true;
if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y))
return true;
if (tileInFront.state == RoomTileState.INVALID)
return true;
if (!tileInFront.getAllowStack() && !(tileInFront.isWalkable() || tileInFront.state == RoomTileState.SIT || tileInFront.state == RoomTileState.LAY))
return true;
if (tileInFront.getStackHeight() > Item.getCurrentHeight(roller) + rollerTile.z)
return true;
if (Room.this.hasHabbosAt(tileInFront.x, tileInFront.y))
return true;
THashSet<HabboItem> itemsNewTile = new THashSet<>(getItemsAt(tileInFront.x, tileInFront.y));
itemsNewTile.removeAll(itemsOnRoller);
List<HabboItem> toRemove = new ArrayList<>();
for (HabboItem item : itemsOnRoller)
{
if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId()))
{
toRemove.add(item);
}
}
itemsOnRoller.removeAll(toRemove);
HabboItem topItem = Room.this.getTopItemAt(tileInFront.x, tileInFront.y);
boolean allowUsers = true;
boolean allowFurniture = true;
boolean stackContainsRoller = false;
for (HabboItem item : itemsNewTile)
{
if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1")))
{
allowUsers = false;
}
if (item instanceof InteractionRoller)
{
newRoller = item;
stackContainsRoller = true;
if (item.getZ() != roller.getZ() || (itemsNewTile.size() > 1 && item != topItem))
{
allowUsers = false;
allowFurniture = false;
continue;
}
break;
} else
{
allowFurniture = false;
}
}
if (allowFurniture)
{
allowFurniture = tileInFront.getAllowStack();
}
double zOffset = 0;
if (newRoller != null)
{
if (!itemsNewTile.isEmpty() && (itemsNewTile.size() > 1))
{
return true;
}
}
else
{
zOffset = -roller.getBaseItem().getHeight() + tileInFront.getStackHeight() - rollerTile.z;
}
if (allowUsers)
{
Event roomUserRolledEvent = null;
if (Emulator.getPluginManager().isRegistered(UserRolledEvent.class, true))
{
roomUserRolledEvent = new UserRolledEvent(null, null, null);
}
for (Habbo habbo : habbosOnRoller)
{
if (rolledUnitIds.contains(habbo.getRoomUnit().getId())) continue;
rolledUnitIds.add(habbo.getRoomUnit().getId());
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
if (!habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
{
RoomTile tile = tileInFront.copy();
tile.setStackHeight(habbo.getRoomUnit().getZ() + zOffset);
if (roomUserRolledEvent != null)
{
roomUserRolledEvent = new UserRolledEvent(habbo, roller, tile);
Emulator.getPluginManager().fireEvent(roomUserRolledEvent);
if (roomUserRolledEvent.isCancelled())
continue;
}
messages.add(new RoomUnitOnRollerComposer(habbo.getRoomUnit(), roller, tile, room));
if (itemsOnRoller.isEmpty())
{
HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y);
if (item != null && itemsNewTile.contains(item))
{
try
{
item.onWalkOn(habbo.getRoomUnit(), room, null);
} catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
}
//
//
}
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT))
habbo.getRoomUnit().sitUpdate = true;
break;
}
}
if (!messages.isEmpty())
{
for (MessageComposer message : messages)
{
room.sendComposer(message.compose());
}
messages.clear();
}
if (allowFurniture || !stackContainsRoller)
{
Event furnitureRolledEvent = null;
if (Emulator.getPluginManager().isRegistered(FurnitureRolledEvent.class, true))
{
furnitureRolledEvent = new FurnitureRolledEvent(null, null, null);
}
if (newRoller == null || topItem == newRoller)
{
List<HabboItem> sortedItems = new ArrayList<>(itemsOnRoller);
sortedItems.sort(new Comparator<HabboItem>()
{
@Override
public int compare(HabboItem o1, HabboItem o2)
{
return o1.getZ() > o2.getZ() ? -1 : 1;
}
});
for (HabboItem item : sortedItems)
{
if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0)
{
if (item != roller)
{
if (furnitureRolledEvent != null)
{
furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront);
Emulator.getPluginManager().fireEvent(furnitureRolledEvent);
if (furnitureRolledEvent.isCancelled())
continue;
}
messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, room));
rollerFurniIds.add(item.getId());
}
}
}
}
}
if (!messages.isEmpty())
{
for (MessageComposer message : messages)
{
room.sendComposer(message.compose());
}
messages.clear();
}
return true;
}
});
int currentTime = (int) (this.cycleTimestamp / 1000);
for(HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class))
{
if(pyramid instanceof InteractionPyramid)
{
if(((InteractionPyramid) pyramid).getNextChange() < currentTime)
{
((InteractionPyramid) pyramid).change(this);
}
}
}
}
else
{
this.rollerCycle++;
}
for (Habbo habbo : this.currentHabbos.values()) for (Habbo habbo : this.currentHabbos.values())
{ {
@ -1848,6 +1593,267 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
} }
} }
if(this.rollerSpeed != -1 && this.rollerCycle >= this.rollerSpeed)
{
this.rollerCycle = 0;
THashSet<MessageComposer> messages = new THashSet<>();
//Find alternative for this.
//Reason is that tile gets updated after every roller.
List<Integer> rollerFurniIds = new ArrayList<>();
List<Integer> rolledUnitIds = new ArrayList<>();
this.roomSpecialTypes.getRollers().forEachValue(new TObjectProcedure<InteractionRoller>()
{
@Override
public boolean execute(InteractionRoller roller)
{
//if(Double.compare(roller.getZ(), this.layout.getHeightAtSquare(roller.getX(), roller.getY())) != 0)
//}
HabboItem newRoller = null;
THashSet<Habbo> habbosOnRoller = Room.this.getHabbosAt(roller.getX(), roller.getY());
THashSet<HabboItem> itemsOnRoller = new THashSet<>(getItemsAt(roller.getX(), roller.getY()));
itemsOnRoller.remove(roller);
if (habbosOnRoller.isEmpty())
{
if (itemsOnRoller.isEmpty())
return true;
}
RoomTile tileInFront = Room.this.layout.getTileInFront(Room.this.layout.getTile(roller.getX(), roller.getY()), roller.getRotation());
RoomTile rollerTile = Room.this.layout.getTile(roller.getX(), roller.getY());
if (tileInFront == null)
return true;
if (!InteractionRoller.NO_RULES && roller.getZ() != rollerTile.z)
return true;
if (!Room.this.layout.tileExists(tileInFront.x, tileInFront.y))
return true;
if (tileInFront.state == RoomTileState.INVALID)
return true;
if (!tileInFront.getAllowStack() && !(tileInFront.isWalkable() || tileInFront.state == RoomTileState.SIT || tileInFront.state == RoomTileState.LAY))
return true;
if (tileInFront.getStackHeight() > Item.getCurrentHeight(roller) + rollerTile.z)
return true;
if (Room.this.hasHabbosAt(tileInFront.x, tileInFront.y))
return true;
THashSet<HabboItem> itemsNewTile = new THashSet<>(getItemsAt(tileInFront.x, tileInFront.y));
itemsNewTile.removeAll(itemsOnRoller);
List<HabboItem> toRemove = new ArrayList<>();
for (HabboItem item : itemsOnRoller)
{
if (item.getX() != roller.getX() || item.getY() != roller.getY() || rollerFurniIds.contains(item.getId()))
{
toRemove.add(item);
}
}
itemsOnRoller.removeAll(toRemove);
HabboItem topItem = Room.this.getTopItemAt(tileInFront.x, tileInFront.y);
boolean allowUsers = true;
boolean allowFurniture = true;
boolean stackContainsRoller = false;
for (HabboItem item : itemsNewTile)
{
if (!(item.getBaseItem().allowWalk() || item.getBaseItem().allowSit()) && !(item instanceof InteractionGate && item.getExtradata().equals("1")))
{
allowUsers = false;
}
if (item instanceof InteractionRoller)
{
newRoller = item;
stackContainsRoller = true;
if ((item.getZ() != roller.getZ() || (itemsNewTile.size() > 1 && item != topItem)) && !InteractionRoller.NO_RULES)
{
allowUsers = false;
allowFurniture = false;
continue;
}
break;
} else
{
allowFurniture = false;
}
}
if (allowFurniture)
{
allowFurniture = tileInFront.getAllowStack();
}
double zOffset = 0;
if (newRoller != null)
{
if ((!itemsNewTile.isEmpty() && (itemsNewTile.size() > 1)) && !InteractionRoller.NO_RULES)
{
return true;
}
}
else
{
zOffset = -roller.getBaseItem().getHeight() + tileInFront.getStackHeight() - rollerTile.z;
}
if (allowUsers)
{
Event roomUserRolledEvent = null;
if (Emulator.getPluginManager().isRegistered(UserRolledEvent.class, true))
{
roomUserRolledEvent = new UserRolledEvent(null, null, null);
}
for (Habbo habbo : habbosOnRoller)
{
if (rolledUnitIds.contains(habbo.getRoomUnit().getId())) continue;
rolledUnitIds.add(habbo.getRoomUnit().getId());
if (stackContainsRoller && !allowFurniture && !(topItem != null && topItem.isWalkable()))
continue;
if (!habbo.getRoomUnit().hasStatus(RoomUnitStatus.MOVE))
{
RoomTile tile = tileInFront.copy();
tile.setStackHeight(habbo.getRoomUnit().getZ() + zOffset);
if (roomUserRolledEvent != null)
{
roomUserRolledEvent = new UserRolledEvent(habbo, roller, tile);
Emulator.getPluginManager().fireEvent(roomUserRolledEvent);
if (roomUserRolledEvent.isCancelled())
continue;
}
updatedUnit.remove(habbo.getRoomUnit());
messages.add(new RoomUnitOnRollerComposer(habbo.getRoomUnit(), roller, habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getZ(), tile, tile.getStackHeight(), room));
if (itemsOnRoller.isEmpty())
{
HabboItem item = room.getTopItemAt(tileInFront.x, tileInFront.y);
if (item != null && itemsNewTile.contains(item))
{
try
{
item.onWalkOn(habbo.getRoomUnit(), room, null);
} catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
}
}
if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.SIT))
habbo.getRoomUnit().sitUpdate = true;
break;
}
}
if (!messages.isEmpty())
{
for (MessageComposer message : messages)
{
room.sendComposer(message.compose());
}
messages.clear();
}
if ((allowFurniture || !stackContainsRoller) && !InteractionRoller.NO_RULES)
{
Event furnitureRolledEvent = null;
if (Emulator.getPluginManager().isRegistered(FurnitureRolledEvent.class, true))
{
furnitureRolledEvent = new FurnitureRolledEvent(null, null, null);
}
if (newRoller == null || topItem == newRoller)
{
List<HabboItem> sortedItems = new ArrayList<>(itemsOnRoller);
sortedItems.sort(new Comparator<HabboItem>()
{
@Override
public int compare(HabboItem o1, HabboItem o2)
{
return o1.getZ() > o2.getZ() ? -1 : 1;
}
});
for (HabboItem item : sortedItems)
{
if (item.getX() == roller.getX() && item.getY() == roller.getY() && zOffset <= 0)
{
if (item != roller)
{
if (furnitureRolledEvent != null)
{
furnitureRolledEvent = new FurnitureRolledEvent(item, roller, tileInFront);
Emulator.getPluginManager().fireEvent(furnitureRolledEvent);
if (furnitureRolledEvent.isCancelled())
continue;
}
messages.add(new FloorItemOnRollerComposer(item, roller, tileInFront, zOffset, room));
rollerFurniIds.add(item.getId());
}
}
}
}
}
if (!messages.isEmpty())
{
for (MessageComposer message : messages)
{
room.sendComposer(message.compose());
}
messages.clear();
}
return true;
}
});
int currentTime = (int) (this.cycleTimestamp / 1000);
for(HabboItem pyramid : this.roomSpecialTypes.getItemsOfType(InteractionPyramid.class))
{
if(pyramid instanceof InteractionPyramid)
{
if(((InteractionPyramid) pyramid).getNextChange() < currentTime)
{
((InteractionPyramid) pyramid).change(this);
}
}
}
}
else
{
this.rollerCycle++;
}
if(!updatedUnit.isEmpty()) if(!updatedUnit.isEmpty())
{ {
@ -3569,6 +3575,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
roomUnit.setZ(z); roomUnit.setZ(z);
roomUnit.setPreviousLocationZ(z); roomUnit.setPreviousLocationZ(z);
this.updateRoomUnit(roomUnit); this.updateRoomUnit(roomUnit);
} }
} }
@ -4401,7 +4409,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
} }
} }
if(topItem == null || item.getZ() > topItem.getZ()) if(topItem == null || Item.getCurrentHeight(item) > Item.getCurrentHeight(topItem))
{ {
topItem = item; topItem = item;
} }
@ -4855,7 +4863,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
public void giveEffect(RoomUnit roomUnit, int effectId, int duration) public void giveEffect(RoomUnit roomUnit, int effectId, int duration)
{ {
if (duration == - 1) if (duration == - 1 || duration == Integer.MAX_VALUE)
{ {
duration = Integer.MAX_VALUE; duration = Integer.MAX_VALUE;
} }
@ -5350,7 +5358,8 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation) public FurnitureMovementError canPlaceFurnitureAt(HabboItem item, Habbo habbo, RoomTile tile, int rotation)
{ {
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2) rotation %= 8;
if (this.hasRights(habbo) || this.guildRightLevel(habbo) >= 2 || habbo.hasPermission(Permission.ACC_MOVEROTATE))
{ {
return FurnitureMovementError.NONE; return FurnitureMovementError.NONE;
} }
@ -5375,6 +5384,36 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
return FurnitureMovementError.NO_RIGHTS; return FurnitureMovementError.NO_RIGHTS;
} }
public FurnitureMovementError furnitureFitsAt(RoomTile tile, HabboItem item, int rotation)
{
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
for (RoomTile t : occupiedTiles)
{
if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
}
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles)
{
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
HabboItem topItem = this.getTopItemAt(t.x, t.y, item);
if (topItem != null && !topItem.getBaseItem().allowStack())
{
return FurnitureMovementError.CANT_STACK;
}
}
if (!item.canStackAt(this, tileFurniList))
{
return FurnitureMovementError.CANT_STACK;
}
return FurnitureMovementError.NONE;
}
public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) throws Exception public FurnitureMovementError placeFloorFurniAt(HabboItem item, RoomTile tile, int rotation, Habbo owner) throws Exception
{ {
if(Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true)) if(Emulator.getPluginManager().isRegistered(FurniturePlacedEvent.class, true))
@ -5388,25 +5427,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation); THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
//if (!item.getBaseItem().allowSit() && !item.getBaseItem().allowLay()) FurnitureMovementError fits = furnitureFitsAt(tile, item, rotation);
{
for (RoomTile t : occupiedTiles)
{
if (this.hasHabbosAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_HABBOS;
if (this.hasBotsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_BOTS;
if (this.hasPetsAt(t.x, t.y)) return FurnitureMovementError.TILE_HAS_PETS;
}
}
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>(); if (!fits.equals(FurnitureMovementError.NONE))
for (RoomTile t : occupiedTiles)
{ {
tileFurniList.add(Pair.create(t, this.getItemsAt(t))); return fits;
}
if (!item.canStackAt(this, tileFurniList))
{
return FurnitureMovementError.CANT_STACK;
} }
item.setZ(tile.getStackHeight()); item.setZ(tile.getStackHeight());
@ -5506,17 +5531,21 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
int oldRotation = item.getRotation(); int oldRotation = item.getRotation();
item.setRotation(rotation); item.setRotation(rotation);
if(Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true))
if (oldRotation != rotation)
{
if (Emulator.getPluginManager().isRegistered(FurnitureRotatedEvent.class, true))
{ {
Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation); Event furnitureRotatedEvent = new FurnitureRotatedEvent(item, actor, oldRotation);
Emulator.getPluginManager().fireEvent(furnitureRotatedEvent); Emulator.getPluginManager().fireEvent(furnitureRotatedEvent);
if(furnitureRotatedEvent.isCancelled()) if (furnitureRotatedEvent.isCancelled())
{ {
item.setRotation(oldRotation); item.setRotation(oldRotation);
return FurnitureMovementError.CANCEL_PLUGIN_ROTATE; return FurnitureMovementError.CANCEL_PLUGIN_ROTATE;
} }
} }
}
//Place at new position //Place at new position
item.setX(tile.x); item.setX(tile.x);
item.setY(tile.y); item.setY(tile.y);
@ -5524,6 +5553,7 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
if (magicTile) if (magicTile)
{ {
item.setZ(tile.z); item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100);
} }
if (item.getZ() > 40d) if (item.getZ() > 40d)
{ {
@ -5550,5 +5580,53 @@ public class Room implements Comparable<Room>, ISerialize, Runnable
return FurnitureMovementError.NONE; return FurnitureMovementError.NONE;
} }
public FurnitureMovementError slideFurniTo(HabboItem item, RoomTile tile, int rotation)
{
RoomTile oldLocation = this.layout.getTile(item.getX(), item.getY());
HabboItem topItem = this.getTopItemAt(tile.x, tile.y);
boolean magicTile = item instanceof InteractionStackHelper;
//Check if can be placed at new position
THashSet<RoomTile> occupiedTiles = this.layout.getTilesAt(tile, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), rotation);
List<Pair<RoomTile, THashSet<HabboItem>>> tileFurniList = new ArrayList<>();
for (RoomTile t : occupiedTiles)
{
tileFurniList.add(Pair.create(t, this.getItemsAt(t)));
}
if (!magicTile && !item.canStackAt(this, tileFurniList))
{
return FurnitureMovementError.CANT_STACK;
}
THashSet<RoomTile> oldOccupiedTiles = this.layout.getTilesAt(this.layout.getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
int oldRotation = item.getRotation();
item.setRotation(rotation);
//Place at new position
if (magicTile)
{
item.setZ(tile.z);
item.setExtradata("" + item.getZ() * 100);
}
if (item.getZ() > 40d)
{
item.setZ(40);
}
this.sendComposer(new FloorItemOnRollerComposer(item, null, tile, this.getStackHeight(tile.x, tile.y, false, item), this).compose());
//Update Habbos at old position
for (RoomTile t : occupiedTiles)
{
this.updateHabbosAt(t.x, t.y);
}
return FurnitureMovementError.NONE;
}
} }

View File

@ -298,7 +298,8 @@ public class RoomLayout
(currentAdj.state == RoomTileState.BLOCKED) || (currentAdj.state == RoomTileState.BLOCKED) ||
((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation))) ((currentAdj.state == RoomTileState.SIT || currentAdj.state == RoomTileState.LAY) && !currentAdj.equals(goalLocation)))
{ {
closedList.add(currentAdj);openList.remove(currentAdj); closedList.add(currentAdj);
openList.remove(currentAdj);
continue; continue;
} }
////if (!room.getLayout().tileWalkable((short) currentAdj.x, (short) currentAdj.y)) continue; ////if (!room.getLayout().tileWalkable((short) currentAdj.x, (short) currentAdj.y)) continue;
@ -376,7 +377,7 @@ public class RoomLayout
RoomTile curr = goal; RoomTile curr = goal;
while (curr != null) while (curr != null)
{ {
path.addFirst(curr); path.addFirst(this.getTile(curr.x, curr.y));
curr = curr.getPrevious(); curr = curr.getPrevious();
if ((curr != null) && (curr.equals(start))) { if ((curr != null) && (curr.equals(start))) {
return path; return path;
@ -614,11 +615,10 @@ public class RoomLayout
RoomTile previous = tile; RoomTile previous = tile;
for (int i = 0; i < amount; i++) for (int i = 0; i < amount; i++)
{ {
RoomTile t = this.getTileInFront(previous, rotation, 1); RoomTile t = this.getTileInFront(previous, rotation, i);
if (t != null) if (t != null)
{ {
previous = t;
tiles.add(t); tiles.add(t);
} }
else else

View File

@ -52,6 +52,7 @@ public class RoomManager
public static int MAXIMUM_ROOMS_USER = 25; public static int MAXIMUM_ROOMS_USER = 25;
public static int MAXIMUM_ROOMS_VIP = 35; public static int MAXIMUM_ROOMS_VIP = 35;
public static int HOME_ROOM_ID = 0; public static int HOME_ROOM_ID = 0;
public static boolean SHOW_PUBLIC_IN_POPULAR_TAB = false;
private final THashMap<Integer, RoomCategory> roomCategories; private final THashMap<Integer, RoomCategory> roomCategories;
private final List<String> mapNames; private final List<String> mapNames;
@ -318,6 +319,11 @@ public class RoomManager
} }
public Room loadRoom(int id) public Room loadRoom(int id)
{
return loadRoom(id, false);
}
public Room loadRoom(int id, boolean loadData)
{ {
Room room = null; Room room = null;
@ -325,10 +331,13 @@ public class RoomManager
{ {
room = this.activeRooms.get(id); room = this.activeRooms.get(id);
if (loadData)
{
if (room.isPreLoaded() && !room.isLoaded()) if (room.isPreLoaded() && !room.isLoaded())
{ {
room.loadData(); room.loadData();
} }
}
return room; return room;
} }
@ -342,9 +351,12 @@ public class RoomManager
while (set.next()) while (set.next())
{ {
room = new Room(set); room = new Room(set);
if (loadData)
{
room.loadData(); room.loadData();
} }
} }
}
if(room != null) if(room != null)
{ {
@ -564,7 +576,7 @@ public class RoomManager
public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks, RoomTile doorLocation) public void enterRoom(Habbo habbo, int roomId, String password, boolean overrideChecks, RoomTile doorLocation)
{ {
Room room = this.loadRoom(roomId); Room room = this.loadRoom(roomId, true);
if(room == null) if(room == null)
return; return;
@ -1155,8 +1167,10 @@ public class RoomManager
for (Room room : this.activeRooms.values()) for (Room room : this.activeRooms.values())
{ {
if (!room.isPublicRoom() && room.getUserCount() > 0) if (room.getUserCount() > 0)
{ {
if (!RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB && room.isPublicRoom()) continue;
rooms.add(room); rooms.add(room);
} }
} }
@ -1437,10 +1451,15 @@ public class RoomManager
@Override @Override
public boolean execute(int value) public boolean execute(int value)
{ {
Room room = RoomManager.this.loadRoom(value); Room room = RoomManager.this.getRoom(value);
if (room != null) if (room != null)
{ {
if (room.getState() == RoomState.INVISIBLE)
{
room.loadData();
if (!room.hasRights(habbo)) return true;
}
rooms.add(room); rooms.add(room);
} }
return true; return true;

View File

@ -8,9 +8,7 @@ import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.pets.Pet; import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.*; import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent; import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer; import com.eu.habbo.messages.outgoing.generic.alerts.*;
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.StaffAlertWithLinkComposer;
import com.eu.habbo.messages.outgoing.inventory.*; import com.eu.habbo.messages.outgoing.inventory.*;
import com.eu.habbo.messages.outgoing.rooms.FloodCounterComposer; import com.eu.habbo.messages.outgoing.rooms.FloodCounterComposer;
import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer; import com.eu.habbo.messages.outgoing.rooms.ForwardToRoomComposer;
@ -74,7 +72,7 @@ public class Habbo implements Runnable
void update() void update()
{ {
this.update = true; this.update = true;
Emulator.getThreading().run(this); this.run();
} }
void needsUpdate(boolean value) void needsUpdate(boolean value)
@ -417,6 +415,13 @@ public class Habbo implements Runnable
HabboBadge badge = BadgesComponent.createBadge(code, this); HabboBadge badge = BadgesComponent.createBadge(code, this);
this.habboInventory.getBadgesComponent().addBadge(badge); this.habboInventory.getBadgesComponent().addBadge(badge);
this.client.sendResponse(new AddUserBadgeComposer(badge)); this.client.sendResponse(new AddUserBadgeComposer(badge));
THashMap<String, String> keys = new THashMap<>();
keys.put("display", "BUBBLE");
keys.put("image", "${image.library.url}album1584/" + badge.getCode() + ".gif");
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
this.client.sendResponse(new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys));
return true; return true;
} }
@ -425,11 +430,14 @@ public class Habbo implements Runnable
public void deleteBadge(HabboBadge badge) public void deleteBadge(HabboBadge badge)
{
if (badge != null)
{ {
this.habboInventory.getBadgesComponent().removeBadge(badge); this.habboInventory.getBadgesComponent().removeBadge(badge);
BadgesComponent.deleteBadge(this.getHabboInfo().getUsername(), badge); BadgesComponent.deleteBadge(this.getHabboInfo().getId(), badge.getCode());
this.client.sendResponse(new InventoryBadgesComposer(this)); this.client.sendResponse(new InventoryBadgesComposer(this));
} }
}
public void mute(int seconds) public void mute(int seconds)
{ {

View File

@ -457,7 +457,7 @@ public class HabboInfo implements Runnable
{ {
this.saveCurrencies(); this.saveCurrencies();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, rank = ?, machine_id = ?, username = ? WHERE id = ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET motto = ?, online = ?, look = ?, gender = ?, credits = ?, last_login = ?, last_online = ?, home_room = ?, ip_current = ?, `rank` = ?, machine_id = ?, username = ? WHERE id = ?"))
{ {
statement.setString(1, this.motto); statement.setString(1, this.motto);
statement.setString(2, this.online ? "1" : "0"); statement.setString(2, this.online ? "1" : "0");

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.modtool.ModToolBan; import com.eu.habbo.habbohotel.modtool.ModToolBan;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.permissions.Rank; import com.eu.habbo.habbohotel.permissions.Rank;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.catalog.*; import com.eu.habbo.messages.outgoing.catalog.*;
import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer; import com.eu.habbo.messages.outgoing.catalog.marketplace.MarketplaceConfigComposer;
@ -23,7 +24,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
public class HabboManager public class HabboManager
{ {
@ -229,33 +229,33 @@ public class HabboManager
public synchronized void dispose() public synchronized void dispose()
{ {
Object[] toDisconnect = this.onlineHabbos.values().toArray();
List<ScheduledFuture> scheduledFutures = new ArrayList<>();
this.onlineHabbos.clear();
for (Object habbo : toDisconnect)
{
scheduledFutures.add(Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
((Habbo) habbo).disconnect();
}
}));
}
while (!scheduledFutures.isEmpty())
{
List<ScheduledFuture> toRemove = new ArrayList<>();
for (ScheduledFuture future : scheduledFutures)
{
if (future.isDone())
{
toRemove.add(future);
}
}
scheduledFutures.removeAll(toRemove);
}
//
Emulator.getLogging().logShutdownLine("Habbo Manager -> Disposed!"); Emulator.getLogging().logShutdownLine("Habbo Manager -> Disposed!");
} }
@ -319,11 +319,23 @@ public class HabboManager
{ {
throw new Exception("Rank ID (" + rankId + ") does not exist"); throw new Exception("Rank ID (" + rankId + ") does not exist");
} }
Rank rank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId); Rank newRank = Emulator.getGameEnvironment().getPermissionsManager().getRank(rankId);
if(habbo != null && habbo.getHabboStats() != null) if(habbo != null && habbo.getHabboStats() != null)
{ {
habbo.getHabboInfo().setRank(rank); Rank oldRank = habbo.getHabboInfo().getRank();
if (!oldRank.getBadge().isEmpty())
{
habbo.deleteBadge(habbo.getInventory().getBadgesComponent().getBadge(oldRank.getBadge()));
BadgesComponent.deleteBadge(userId, oldRank.getBadge());
}
habbo.getHabboInfo().setRank(newRank);
if (!newRank.getBadge().isEmpty())
{
habbo.addBadge(newRank.getBadge());
}
habbo.getClient().sendResponse(new UserPermissionsComposer(habbo)); habbo.getClient().sendResponse(new UserPermissionsComposer(habbo));
habbo.getClient().sendResponse(new UserPerksComposer(habbo)); habbo.getClient().sendResponse(new UserPerksComposer(habbo));
@ -339,11 +351,11 @@ public class HabboManager
habbo.getClient().sendResponse(new MarketplaceConfigComposer()); habbo.getClient().sendResponse(new MarketplaceConfigComposer());
habbo.getClient().sendResponse(new GiftConfigurationComposer()); habbo.getClient().sendResponse(new GiftConfigurationComposer());
habbo.getClient().sendResponse(new RecyclerLogicComposer()); habbo.getClient().sendResponse(new RecyclerLogicComposer());
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_give_rank.new_rank").replace("id", rank.getName())); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_give_rank.new_rank").replace("id", newRank.getName()));
} }
else else
{ {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET rank = ? WHERE id = ? LIMIT 1")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users SET `rank` = ? WHERE id = ? LIMIT 1"))
{ {
statement.setInt(1, rankId); statement.setInt(1, rankId);
statement.setInt(2, userId); statement.setInt(2, userId);

View File

@ -1,6 +1,7 @@
package com.eu.habbo.habbohotel.users.inventory; package com.eu.habbo.habbohotel.users.inventory;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.permissions.Rank;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge; import com.eu.habbo.habbohotel.users.HabboBadge;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
@ -10,8 +11,8 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Set;
public class BadgesComponent public class BadgesComponent
{ {
@ -25,6 +26,7 @@ public class BadgesComponent
private static THashSet<HabboBadge> loadBadges(Habbo habbo) private static THashSet<HabboBadge> loadBadges(Habbo habbo)
{ {
THashSet<HabboBadge> badgesList = new THashSet<>(); THashSet<HabboBadge> badgesList = new THashSet<>();
Set<String> staffBadges = Emulator.getGameEnvironment().getPermissionsManager().getStaffBadges();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE user_id = ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users_badges WHERE user_id = ?"))
{ {
statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(1, habbo.getHabboInfo().getId());
@ -33,7 +35,29 @@ public class BadgesComponent
{ {
while (set.next()) while (set.next())
{ {
badgesList.add(new HabboBadge(set, habbo)); HabboBadge badge = new HabboBadge(set, habbo);
if (staffBadges.contains(badge.getCode()))
{
boolean delete = true;
for (Rank rank : Emulator.getGameEnvironment().getPermissionsManager().getRanks(badge.getCode()))
{
if (rank.getId() == habbo.getHabboInfo().getId())
{
delete = false;
break;
}
}
if (delete)
{
deleteBadge(habbo.getHabboInfo().getUsername(), badge.getCode());
continue;
}
}
badgesList.add(badge);
} }
} }
} }
@ -176,12 +200,13 @@ public class BadgesComponent
return badge; return badge;
} }
@Deprecated
public static void deleteBadge(String username, HabboBadge badge) public static void deleteBadge(String username, HabboBadge badge)
{ {
deleteBadge(username, badge.getCode()); deleteBadge(username, badge.getCode());
} }
@Deprecated
public static void deleteBadge(String username, String badge) public static void deleteBadge(String username, String badge)
{ {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges INNER JOIN users ON users_badges.user_id = users.id WHERE users.username LIKE ? AND badge_code LIKE ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges INNER JOIN users ON users_badges.user_id = users.id WHERE users.username LIKE ? AND badge_code LIKE ?"))
@ -195,4 +220,18 @@ public class BadgesComponent
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);
} }
} }
public static void deleteBadge(int userId, String badge)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE users_badges FROM users_badges WHERE user_id = ? AND badge_code LIKE ?"))
{
statement.setInt(1, userId);
statement.setString(2, badge);
statement.execute();
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
}
} }

View File

@ -232,6 +232,7 @@ public class WiredHandler
try try
{ {
if (!effect.execute(roomUnit, room, stuff)) return; if (!effect.execute(roomUnit, room, stuff)) return;
effect.setCooldown(millis);
} }
catch (Exception e) catch (Exception e)
{ {
@ -396,7 +397,7 @@ public class WiredHandler
} }
} }
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as rows, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT COUNT(*) as row_count, wired_rewards_given.* FROM wired_rewards_given WHERE user_id = ? AND wired_item = ? ORDER BY timestamp DESC LIMIT ?"))
{ {
statement.setInt(1, habbo.getHabboInfo().getId()); statement.setInt(1, habbo.getHabboInfo().getId());
statement.setInt(2, wiredBox.getId()); statement.setInt(2, wiredBox.getId());
@ -406,7 +407,7 @@ public class WiredHandler
{ {
if (set.first()) if (set.first())
{ {
if (set.getInt("rows") >= 1) if (set.getInt("row_count") >= 1)
{ {
if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_ONCE) if (wiredBox.rewardTime == WiredEffectGiveReward.LIMIT_ONCE)
{ {
@ -429,7 +430,7 @@ public class WiredHandler
if (wiredBox.uniqueRewards) if (wiredBox.uniqueRewards)
{ {
if (set.getInt("rows") == wiredBox.rewardItems.size()) if (set.getInt("row_count") == wiredBox.rewardItems.size())
{ {
habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALL_COLLECTED)); habbo.getClient().sendResponse(new WiredRewardAlertComposer(WiredRewardAlertComposer.REWARD_ALL_COLLECTED));
return false; return false;

View File

@ -447,6 +447,7 @@ public class PacketManager
this.registerHandler(Incoming.YoutubeRequestVideoDataEvent, YoutubeRequestVideoDataEvent.class); this.registerHandler(Incoming.YoutubeRequestVideoDataEvent, YoutubeRequestVideoDataEvent.class);
this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class); this.registerHandler(Incoming.RoomFavoriteEvent, RoomFavoriteEvent.class);
this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class); this.registerHandler(Incoming.LoveLockStartConfirmEvent, LoveLockStartConfirmEvent.class);
this.registerHandler(Incoming.RoomUnFavoriteEvent, RoomUnFavoriteEvent.class);
} }
void registerPolls() throws Exception void registerPolls() throws Exception

View File

@ -299,6 +299,7 @@ public class Incoming
public static final int AdventCalendarForceOpenEvent = 3889; public static final int AdventCalendarForceOpenEvent = 3889;
public static final int CameraPurchaseEvent = 2408; public static final int CameraPurchaseEvent = 2408;
public static final int RoomFavoriteEvent = 3817; public static final int RoomFavoriteEvent = 3817;
public static final int RoomUnFavoriteEvent = 309;
public static final int YoutubeRequestPlayListEvent = 336; public static final int YoutubeRequestPlayListEvent = 336;
public static final int YoutubeRequestNextVideoEvent = 3005; public static final int YoutubeRequestNextVideoEvent = 3005;

View File

@ -2,7 +2,6 @@ package com.eu.habbo.messages.incoming.camera;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.networking.camera.CameraClient; import com.eu.habbo.networking.camera.CameraClient;
import com.eu.habbo.networking.camera.messages.outgoing.CameraRenderImageComposer; import com.eu.habbo.networking.camera.messages.outgoing.CameraRenderImageComposer;
import com.eu.habbo.util.crypto.ZIP; import com.eu.habbo.util.crypto.ZIP;

View File

@ -1,8 +1,8 @@
package com.eu.habbo.messages.incoming.friends; package com.eu.habbo.messages.incoming.friends;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement; import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
public class AcceptFriendRequestEvent extends MessageHandler public class AcceptFriendRequestEvent extends MessageHandler
@ -25,26 +25,14 @@ public class AcceptFriendRequestEvent extends MessageHandler
this.client.getHabbo().getMessenger().acceptFriendRequest(userId, this.client.getHabbo().getHabboInfo().getId()); this.client.getHabbo().getMessenger().acceptFriendRequest(userId, this.client.getHabbo().getHabboInfo().getId());
int progress = this.client.getHabbo().getHabboStats().getAchievementProgress(Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize")); Messenger.checkFriendSizeProgress(this.client.getHabbo());
int toProgress = 1; Habbo target = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);
Achievement achievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("FriendListSize"); if (target != null)
if(achievement == null)
return;
if (progress > 0)
{ {
toProgress = this.client.getHabbo().getMessenger().getFriends().size() - progress; Messenger.checkFriendSizeProgress(target);
if(toProgress < 0)
{
return;
} }
} }
AchievementManager.progressAchievement(this.client.getHabbo(), achievement, toProgress);
}
} }
} }

View File

@ -81,7 +81,7 @@ public class FriendRequestEvent extends MessageHandler
return; return;
} }
if(this.client.getHabbo().getMessenger().getFriends().values().size() >= Messenger.MAXIMUM_FRIENDS && !this.client.getHabbo().hasPermission("acc_infinite_friends")) if(this.client.getHabbo().getMessenger().getFriends().values().size() >= Messenger.friendLimit(this.client.getHabbo()) && !this.client.getHabbo().hasPermission("acc_infinite_friends"))
{ {
this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_OWN_FULL)); this.client.sendResponse(new FriendRequestErrorComposer(FriendRequestErrorComposer.FRIEND_LIST_OWN_FULL));
return; return;

View File

@ -39,7 +39,7 @@ public class GuideReportHelperEvent extends MessageHandler
Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED)); this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message));
this.client.sendResponse(new GuideSessionDetachedComposer()); this.client.sendResponse(new GuideSessionDetachedComposer());
this.client.sendResponse(new GuideSessionEndedComposer(GuideSessionEndedComposer.HELP_CASE_CLOSED)); this.client.sendResponse(new GuideSessionEndedComposer(GuideSessionEndedComposer.HELP_CASE_CLOSED));

View File

@ -29,7 +29,7 @@ public class GuildDeclineMembershipEvent extends MessageHandler
{ {
guild.decreaseRequestCount(); guild.decreaseRequestCount();
Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId); Emulator.getGameEnvironment().getGuildManager().removeMember(guild, userId);
this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 0, ""), 0, 0, "", true)); this.client.sendResponse(new GuildMembersComposer(guild, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(guild, 2, ""), Emulator.getGameEnvironment().getGuildManager().getGuildMembers(guild, 0, 2, ""), 0, 2, "", true));
this.client.sendResponse(new GuildRefreshMembersListComposer(guild)); this.client.sendResponse(new GuildRefreshMembersListComposer(guild));
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(userId);

View File

@ -25,10 +25,10 @@ public class RequestGuildMembersEvent extends MessageHandler
if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId())) if (!isAdmin && this.client.getHabbo().getHabboStats().hasGuild(g.getId()))
{ {
GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo()); GuildMember member = Emulator.getGameEnvironment().getGuildManager().getGuildMember(g, this.client.getHabbo());
isAdmin = member != null && member.getRank().equals(GuildRank.ADMIN); isAdmin = member != null && (member.getRank().equals(GuildRank.ADMIN) || member.getRank().equals(GuildRank.MOD) && levelId == 2);
} }
this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), pageId, levelId, query, isAdmin)); this.client.sendResponse(new GuildMembersComposer(g, Emulator.getGameEnvironment().getGuildManager().getGuildMembersCount(g, levelId, query), Emulator.getGameEnvironment().getGuildManager().getGuildMembers(g, pageId, levelId, query), pageId, levelId, query, isAdmin));
} }
} }
} }

View File

@ -1,6 +1,7 @@
package com.eu.habbo.messages.incoming.handshake; package com.eu.habbo.messages.incoming.handshake;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.permissions.Permission; import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboManager; import com.eu.habbo.habbohotel.users.HabboManager;
@ -83,6 +84,12 @@ public class SecureLoginEvent extends MessageHandler
Emulator.getGameServer().getGameClientManager().disposeClient(this.client); Emulator.getGameServer().getGameClientManager().disposeClient(this.client);
return; return;
} }
if (this.client.getHabbo().getHabboInfo().getRank() == null)
{
throw new NullPointerException(habbo.getHabboInfo().getUsername() + " has a NON EXISTING RANK!");
}
Emulator.getThreading().run(habbo); Emulator.getThreading().run(habbo);
Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo); Emulator.getGameEnvironment().getHabboManager().addHabbo(habbo);
} }
@ -156,6 +163,8 @@ public class SecureLoginEvent extends MessageHandler
} }
}, Emulator.getConfig().getInt("hotel.welcome.alert.delay", 5000)); }, Emulator.getConfig().getInt("hotel.welcome.alert.delay", 5000));
} }
Messenger.checkFriendSizeProgress(habbo);
} }
else else
{ {

View File

@ -77,7 +77,7 @@ public class ReportEvent extends MessageHandler
Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED)); this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, cfhTopic.reply));
if (cfhTopic != null) if (cfhTopic != null)
{ {
@ -112,7 +112,7 @@ public class ReportEvent extends MessageHandler
issue.category = topic; issue.category = topic;
new InsertModToolIssue(issue).run(); new InsertModToolIssue(issue).run();
this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED)); this.client.sendResponse(new ModToolReportReceivedAlertComposer(ModToolReportReceivedAlertComposer.REPORT_RECEIVED, message));
Emulator.getGameEnvironment().getModToolManager().addTicket(issue); Emulator.getGameEnvironment().getModToolManager().addTicket(issue);
Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue); Emulator.getGameEnvironment().getModToolManager().updateTicketToMods(issue);

View File

@ -0,0 +1,27 @@
package com.eu.habbo.messages.incoming.rooms;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.FavoriteRoomChangedComposer;
public class RoomUnFavoriteEvent extends MessageHandler
{
@Override
public void handle() throws Exception
{
int roomId = this.packet.readInt();
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(roomId);
if (room != null)
{
if (this.client.getHabbo().getHabboStats().hasFavoriteRoom(roomId))
{
this.client.getHabbo().getHabboStats().removeFavoriteRoom(roomId);
}
this.client.sendResponse(new FavoriteRoomChangedComposer(roomId, false));
}
}
}

View File

@ -2,6 +2,7 @@ package com.eu.habbo.messages.incoming.rooms.items;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.interactions.InteractionCustomValues; import com.eu.habbo.habbohotel.items.interactions.InteractionCustomValues;
import com.eu.habbo.habbohotel.items.interactions.InteractionRoomAds;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler; import com.eu.habbo.messages.incoming.MessageHandler;
@ -12,16 +13,21 @@ public class AdvertisingSaveEvent extends MessageHandler
public void handle() throws Exception public void handle() throws Exception
{ {
Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom(); Room room = this.client.getHabbo().getHabboInfo().getCurrentRoom();
if(room == null) if (room == null)
return; return;
if(!room.hasRights(this.client.getHabbo())) if (!room.hasRights(this.client.getHabbo()))
return; return;
HabboItem item = room.getHabboItem(this.packet.readInt()); HabboItem item = room.getHabboItem(this.packet.readInt());
if(item == null) if (item == null)
return; return;
if (item instanceof InteractionRoomAds && !this.client.getHabbo().hasPermission("acc_ads_background"))
{
this.client.getHabbo().alert(Emulator.getTexts().getValue("hotel.error.roomads.nopermission"));
return;
}
if(item instanceof InteractionCustomValues) if(item instanceof InteractionCustomValues)
{ {
int count = this.packet.readInt(); int count = this.packet.readInt();

View File

@ -16,11 +16,11 @@ public class PostItSaveDataEvent extends MessageHandler
String color = this.packet.readString(); String color = this.packet.readString();
String text = this.packet.readString(); String text = this.packet.readString();
if (text.length() > 366) if (text.length() > Emulator.getConfig().getInt("postit.charlimit"))
{ {
Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.sticky.size").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%amount%", text.length() + "").replace("%limit%", "366")); Emulator.getGameEnvironment().getModToolManager().quickTicket(this.client.getHabbo(), "Scripter", Emulator.getTexts().getValue("scripter.warning.sticky.size").replace("%username%", this.client.getHabbo().getHabboInfo().getUsername()).replace("%amount%", text.length() + "").replace("%limit%", "366"));
if (text.length() >= 400) if (text.length() >= Emulator.getConfig().getInt("postit.charlimit") + 50)
{ {
this.client.getHabbo().alert("8=====D~~~~~<br><br>Computer Says:<b><u>NO</u></b>"); this.client.getHabbo().alert("8=====D~~~~~<br><br>Computer Says:<b><u>NO</u></b>");
} }

View File

@ -74,11 +74,11 @@ public class RoomUserWalkEvent extends MessageHandler
else else
{ {
RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y); RoomTile t = habbo.getHabboInfo().getCurrentRoom().getLayout().getTile((short) x, (short) y);
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, null, t, habbo.getHabboInfo().getCurrentRoom()).compose()); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(roomUnit, t, habbo.getHabboInfo().getCurrentRoom()).compose());
if (habbo.getHabboInfo().getRiding() != null) if (habbo.getHabboInfo().getRiding() != null)
{ {
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), null, t, habbo.getHabboInfo().getCurrentRoom()).compose()); habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUnitOnRollerComposer(habbo.getHabboInfo().getRiding().getRoomUnit(), t, habbo.getHabboInfo().getCurrentRoom()).compose());
} }
} }
} }

View File

@ -16,6 +16,7 @@ public class UserWearBadgeEvent extends MessageHandler
BadgesComponent.resetSlots(this.client.getHabbo()); BadgesComponent.resetSlots(this.client.getHabbo());
ArrayList<HabboBadge> updatedBadges = new ArrayList<>(); ArrayList<HabboBadge> updatedBadges = new ArrayList<>();
ArrayList<Integer> usedSlots = new ArrayList<>();
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
int slot = this.packet.readInt(); int slot = this.packet.readInt();
@ -28,8 +29,9 @@ public class UserWearBadgeEvent extends MessageHandler
continue; continue;
HabboBadge badge = this.client.getHabbo().getInventory().getBadgesComponent().getBadge(badgeId); HabboBadge badge = this.client.getHabbo().getInventory().getBadgesComponent().getBadge(badgeId);
if(badge != null) if(badge != null && !updatedBadges.contains(badge) && !usedSlots.contains(slot))
{ {
usedSlots.add(slot);
badge.setSlot(slot); badge.setSlot(slot);
badge.needsUpdate(true); badge.needsUpdate(true);
Emulator.getThreading().run(badge); Emulator.getThreading().run(badge);

View File

@ -1,6 +1,7 @@
package com.eu.habbo.messages.outgoing.friends; package com.eu.habbo.messages.outgoing.friends;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.messenger.MessengerBuddy; import com.eu.habbo.habbohotel.messenger.MessengerBuddy;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboGender;
@ -29,8 +30,8 @@ public class FriendsComposer extends MessageComposer
//this.response.appendInt(300); //this.response.appendInt(300);
//this.response.appendInt(300); //this.response.appendInt(300);
//this.response.appendInt(3); //Club level //this.response.appendInt(3); //Club level
this.response.appendInt(300); this.response.appendInt(this.habbo.hasPermission("acc_infinite_friends") ? Integer.MAX_VALUE : Messenger.MAXIMUM_FRIENDS);
this.response.appendInt(300); this.response.appendInt(this.habbo.hasPermission("acc_infinite_friends") ? Integer.MAX_VALUE : Messenger.MAXIMUM_FRIENDS);
this.response.appendInt(this.habbo.getMessenger().getFriends().size() + (this.habbo.hasPermission("acc_staff_chat") ? 1 : 0)); this.response.appendInt(this.habbo.getMessenger().getFriends().size() + (this.habbo.hasPermission("acc_staff_chat") ? 1 : 0));
for (Map.Entry<Integer, MessengerBuddy> row : this.habbo.getMessenger().getFriends().entrySet()) { for (Map.Entry<Integer, MessengerBuddy> row : this.habbo.getMessenger().getFriends().entrySet()) {

View File

@ -1,5 +1,6 @@
package com.eu.habbo.messages.outgoing.friends; package com.eu.habbo.messages.outgoing.friends;
import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage; import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer; import com.eu.habbo.messages.outgoing.MessageComposer;
@ -18,17 +19,19 @@ public class MessengerInitComposer extends MessageComposer
public ServerMessage compose() public ServerMessage compose()
{ {
this.response.init(Outgoing.MessengerInitComposer); this.response.init(Outgoing.MessengerInitComposer);
this.response.appendInt(300);
this.response.appendInt(1337);
if (this.habbo.hasPermission("acc_infinite_friends")) if (this.habbo.hasPermission("acc_infinite_friends"))
{ {
this.response.appendInt(10000); this.response.appendInt(Integer.MAX_VALUE);
this.response.appendInt(1337);
this.response.appendInt(Integer.MAX_VALUE);
} }
else else
{ {
this.response.appendInt(500); this.response.appendInt(Messenger.MAXIMUM_FRIENDS);
this.response.appendInt(1337);
this.response.appendInt(Messenger.MAXIMUM_FRIENDS_HC);
} }
//this.response.appendInt(1000); //this.response.appendInt(1000);
this.response.appendInt(0); this.response.appendInt(0);
return this.response; return this.response;

View File

@ -45,13 +45,13 @@ public class GuildInfoComposer extends MessageComposer
this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group this.response.appendBoolean(this.client.getHabbo().getHabboStats().guild == this.guild.getId()); //favorite group
this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L))); this.response.appendString(new SimpleDateFormat("dd-MM-yyyy").format(new Date(this.guild.getDateCreated() * 1000L)));
this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId())); this.response.appendBoolean(adminPermissions || (this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()));
this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.MOD) || this.response.appendBoolean(adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.MOD) || this.member.getRank().equals(GuildRank.ADMIN)))); //Is admin. //this.member.getRank().equals(GuildRank.MOD) ||
//Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId()); //Habbo owner = Emulator.getGameEnvironment().getHabboManager().getHabbo(this.guild.getOwnerId());
this.response.appendString(this.guild.getOwnerName()); this.response.appendString(this.guild.getOwnerName());
this.response.appendBoolean(this.newWindow); this.response.appendBoolean(this.newWindow);
this.response.appendBoolean(this.guild.getRights() == 0); //User can place furni. this.response.appendBoolean(this.guild.getRights() == 0); //User can place furni. this.guild.getRights() == 0
this.response.appendInt((adminPermissions || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()) ? this.guild.getRequestCount() : 0); //Guild invites count. this.response.appendInt((adminPermissions || (this.member != null && (this.member.getRank().equals(GuildRank.MOD) || this.guild.getOwnerId() == this.client.getHabbo().getHabboInfo().getId()))) ? this.guild.getRequestCount() : 0); //Guild invites count.
this.response.appendBoolean(true); //Unknown this.response.appendBoolean(true); //Unknown
return this.response; return this.response;
} }

View File

@ -13,16 +13,18 @@ import java.util.TimeZone;
public class GuildMembersComposer extends MessageComposer public class GuildMembersComposer extends MessageComposer
{ {
private final ArrayList<GuildMember> members;
private final Guild guild; private final Guild guild;
private final int totalResults;
private final ArrayList<GuildMember> members;
private final int pageId; private final int pageId;
private final int level; private final int level;
private final String searchValue; private final String searchValue;
private final boolean isAdmin; private final boolean isAdmin;
public GuildMembersComposer(Guild guild, ArrayList<GuildMember> members, int pageId, int level, String searchValue, boolean isAdmin) public GuildMembersComposer(Guild guild, int totalResults, ArrayList<GuildMember> members, int pageId, int level, String searchValue, boolean isAdmin)
{ {
this.guild = guild; this.guild = guild;
this.totalResults = totalResults;
this.members = members; this.members = members;
this.pageId = pageId; this.pageId = pageId;
this.level = level; this.level = level;
@ -38,7 +40,7 @@ public class GuildMembersComposer extends MessageComposer
this.response.appendString(this.guild.getName()); this.response.appendString(this.guild.getName());
this.response.appendInt(this.guild.getRoomId()); this.response.appendInt(this.guild.getRoomId());
this.response.appendString(this.guild.getBadge()); this.response.appendString(this.guild.getBadge());
this.response.appendInt(this.guild.getMemberCount()); this.response.appendInt(this.totalResults);
this.response.appendInt(this.members.size()); this.response.appendInt(this.members.size());
Calendar cal = Calendar.getInstance(TimeZone.getDefault()); Calendar cal = Calendar.getInstance(TimeZone.getDefault());

View File

@ -11,10 +11,12 @@ public class ModToolReportReceivedAlertComposer extends MessageComposer
public static final int REPORT_ABUSIVE = 2; public static final int REPORT_ABUSIVE = 2;
private final int errorCode; private final int errorCode;
private final String message;
public ModToolReportReceivedAlertComposer(int errorCode) public ModToolReportReceivedAlertComposer(int errorCode, String message)
{ {
this.errorCode = errorCode; this.errorCode = errorCode;
this.message = message;
} }
@Override @Override
@ -22,6 +24,7 @@ public class ModToolReportReceivedAlertComposer extends MessageComposer
{ {
this.response.init(Outgoing.ModToolReportReceivedAlertComposer); this.response.init(Outgoing.ModToolReportReceivedAlertComposer);
this.response.appendInt(this.errorCode); this.response.appendInt(this.errorCode);
return null; this.response.appendString(this.message);
return this.response;
} }
} }

View File

@ -62,7 +62,7 @@ public class RoomDataComposer extends MessageComposer
this.response.appendInt(0); this.response.appendInt(0);
} }
int base = 32; int base = 0;
if(this.room.getGuildId() > 0) if(this.room.getGuildId() > 0)
{ {
@ -79,7 +79,7 @@ public class RoomDataComposer extends MessageComposer
base = base | 4; base = base | 4;
} }
if (this.room.isAllowPets()) if(this.room.isAllowPets())
{ {
base = base | 16; base = base | 16;
} }
@ -110,17 +110,16 @@ public class RoomDataComposer extends MessageComposer
this.response.appendInt((this.room.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60); this.response.appendInt((this.room.getPromotion().getEndTimestamp() - Emulator.getIntUnixTimestamp()) / 60);
} }
this.response.appendBoolean(true); //forwarded this.response.appendBoolean(this.publicRoom);
this.response.appendBoolean(false); //staffpick this.response.appendBoolean(this.room.isStaffPromotedRoom()); //staffpicked
this.response.appendBoolean(false); //_isGroupMember this.response.appendBoolean(this.room.isPublicRoom()); //ispublicroom
this.response.appendBoolean(this.room.isMuted()); //isroommuted this.response.appendBoolean(this.room.isMuted()); //isroommuted
this.response.appendInt(this.room.getMuteOption()); this.response.appendInt(this.room.getMuteOption());
this.response.appendInt(this.room.getKickOption()); this.response.appendInt(this.room.getKickOption());
this.response.appendInt(this.room.getBanOption()); this.response.appendInt(this.room.getBanOption());
this.response.appendBoolean(this.room.hasRights(this.habbo)); //canMute this.response.appendBoolean(this.room.hasRights(this.habbo)); //mute all button
this.response.appendInt(this.room.getChatMode()); this.response.appendInt(this.room.getChatMode());
this.response.appendInt(this.room.getChatWeight()); this.response.appendInt(this.room.getChatWeight());
@ -129,14 +128,6 @@ public class RoomDataComposer extends MessageComposer
this.response.appendInt(this.room.getChatProtection()); this.response.appendInt(this.room.getChatProtection());
//mute all button
return this.response; return this.response;
} }
} }

View File

@ -12,14 +12,31 @@ public class RoomUnitOnRollerComposer extends MessageComposer
{ {
private final RoomUnit roomUnit; private final RoomUnit roomUnit;
private final HabboItem roller; private final HabboItem roller;
private final RoomTile oldLocation;
private final double oldZ;
private final RoomTile newLocation; private final RoomTile newLocation;
private final double newZ;
private final Room room; private final Room room;
public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile newLocation, Room room) public RoomUnitOnRollerComposer(RoomUnit roomUnit, HabboItem roller, RoomTile oldLocation, double oldZ, RoomTile newLocation, double newZ, Room room)
{ {
this.roomUnit = roomUnit; this.roomUnit = roomUnit;
this.roller = roller; this.roller = roller;
this.oldLocation = oldLocation;
this.oldZ = oldZ;
this.newLocation = newLocation; this.newLocation = newLocation;
this.newZ = newZ;
this.room = room;
}
public RoomUnitOnRollerComposer(RoomUnit roomUnit, RoomTile newLocation, Room room)
{
this.roomUnit = roomUnit;
this.roller = null;
this.oldLocation = this.roomUnit.getCurrentLocation();
this.oldZ = this.roomUnit.getZ();
this.newLocation = newLocation;
this.newZ = this.newLocation.getStackHeight();
this.room = room; this.room = room;
} }
@ -38,23 +55,40 @@ public class RoomUnitOnRollerComposer extends MessageComposer
} }
this.response.init(Outgoing.ObjectOnRollerComposer); this.response.init(Outgoing.ObjectOnRollerComposer);
this.response.appendInt(this.roomUnit.getX()); this.response.appendInt(this.oldLocation.x);
this.response.appendInt(this.roomUnit.getY()); this.response.appendInt(this.oldLocation.y);
this.response.appendInt(this.newLocation.x); this.response.appendInt(this.newLocation.x);
this.response.appendInt(this.newLocation.y); this.response.appendInt(this.newLocation.y);
this.response.appendInt(0); this.response.appendInt(0);
this.response.appendInt(this.roller == null ? 0 : this.roller.getId()); this.response.appendInt(this.roller == null ? 0 : this.roller.getId());
this.response.appendInt(2); this.response.appendInt(2);
this.response.appendInt(this.roomUnit.getId()); this.response.appendInt(this.roomUnit.getId());
this.response.appendString(this.roomUnit.getZ() + ""); this.response.appendString(this.oldZ + "");
this.response.appendString(this.newLocation.getStackHeight() + ""); this.response.appendString(this.newZ + "");
this.roomUnit.setLocation(room.getLayout().getTile(newLocation.x, newLocation.y)); if (this.roller != null)
this.roomUnit.setPreviousLocationZ(this.newLocation.getStackHeight()); {
this.roomUnit.setZ(this.newLocation.getStackHeight()); RoomTile rollerTile = room.getLayout().getTile(this.roller.getX(), this.roller.getY());
this.roomUnit.sitUpdate = true;
if (RoomUnitOnRollerComposer.this.oldLocation == rollerTile && RoomUnitOnRollerComposer.this.roomUnit.getGoal() == rollerTile)
{
RoomUnitOnRollerComposer.this.roomUnit.setLocation(room.getLayout().getTile(newLocation.x, newLocation.y));
RoomUnitOnRollerComposer.this.roomUnit.setPreviousLocationZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight());
RoomUnitOnRollerComposer.this.roomUnit.setZ(RoomUnitOnRollerComposer.this.newLocation.getStackHeight());
RoomUnitOnRollerComposer.this.roomUnit.sitUpdate = true;
}
//});
}
else
{
this.roomUnit.setLocation(this.newLocation);
this.roomUnit.setZ(this.newZ);
}
return this.response; return this.response;
} }

View File

@ -10,6 +10,8 @@ import io.netty.channel.FixedRecvByteBufAllocator;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel;
import java.util.concurrent.TimeUnit;
public abstract class Server public abstract class Server
{ {
private final String name; private final String name;
@ -66,8 +68,8 @@ public abstract class Server
Emulator.getLogging().logShutdownLine("Stopping " + this.name); Emulator.getLogging().logShutdownLine("Stopping " + this.name);
try try
{ {
this.workerGroup.shutdownGracefully().sync(); this.workerGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync();
this.bossGroup.shutdownGracefully().sync(); this.bossGroup.shutdownGracefully(0, 0, TimeUnit.MILLISECONDS).sync();
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -55,8 +55,6 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter
ctx.channel().close(); ctx.channel().close();
} }
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
{ {

View File

@ -14,11 +14,10 @@ import io.netty.channel.socket.SocketChannel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map;
public class RCONServer extends Server public class RCONServer extends Server
{ {
public List<String> allowedAdresses = new ArrayList<>(); List<String> allowedAdresses = new ArrayList<>();
private final THashMap<String, Class<? extends RCONMessage>> messages; private final THashMap<String, Class<? extends RCONMessage>> messages;
@ -28,7 +27,6 @@ public class RCONServer extends Server
{ {
super("RCON Server", host, port, 1, 2); super("RCON Server", host, port, 1, 2);
this.allowedAdresses.add("5.196.70.224");
this.messages = new THashMap<>(); this.messages = new THashMap<>();
this.gsonBuilder = new GsonBuilder(); this.gsonBuilder = new GsonBuilder();

View File

@ -12,6 +12,7 @@ import com.eu.habbo.habbohotel.games.freeze.FreezeGame;
import com.eu.habbo.habbohotel.games.tag.TagGame; import com.eu.habbo.habbohotel.games.tag.TagGame;
import com.eu.habbo.habbohotel.items.ItemManager; import com.eu.habbo.habbohotel.items.ItemManager;
import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt; import com.eu.habbo.habbohotel.items.interactions.InteractionPostIt;
import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
import com.eu.habbo.habbohotel.items.interactions.games.football.InteractionFootballGate; import com.eu.habbo.habbohotel.items.interactions.games.football.InteractionFootballGate;
import com.eu.habbo.habbohotel.messenger.Messenger; import com.eu.habbo.habbohotel.messenger.Messenger;
import com.eu.habbo.habbohotel.modtool.WordFilter; import com.eu.habbo.habbohotel.modtool.WordFilter;
@ -338,6 +339,7 @@ public class PluginManager
BotManager.MAXIMUM_CHAT_SPEED = Emulator.getConfig().getInt("hotel.bot.max.chatdelay"); BotManager.MAXIMUM_CHAT_SPEED = Emulator.getConfig().getInt("hotel.bot.max.chatdelay");
HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items"); HabboInventory.MAXIMUM_ITEMS = Emulator.getConfig().getInt("hotel.inventory.max.items");
Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.max.friends"); Messenger.MAXIMUM_FRIENDS = Emulator.getConfig().getInt("hotel.max.friends");
Messenger.MAXIMUM_FRIENDS_HC = Emulator.getConfig().getInt("hotel.max.friends.hc");
Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room"); Room.MAXIMUM_BOTS = Emulator.getConfig().getInt("hotel.max.bots.room");
Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room"); Room.MAXIMUM_PETS = Emulator.getConfig().getInt("hotel.pets.max.room");
Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time"); Room.HAND_ITEM_TIME = Emulator.getConfig().getInt("hotel.rooms.handitem.time");
@ -380,5 +382,7 @@ public class PluginManager
CatalogManager.PURCHASE_COOLDOWN = Emulator.getConfig().getInt("hotel.catalog.purchase.cooldown"); CatalogManager.PURCHASE_COOLDOWN = Emulator.getConfig().getInt("hotel.catalog.purchase.cooldown");
CatalogManager.SORT_USING_ORDERNUM = Emulator.getConfig().getBoolean("hotel.catalog.items.display.ordernum"); CatalogManager.SORT_USING_ORDERNUM = Emulator.getConfig().getBoolean("hotel.catalog.items.display.ordernum");
AchievementManager.TALENTTRACK_ENABLED = Emulator.getConfig().getBoolean("hotel.talenttrack.enabled"); AchievementManager.TALENTTRACK_ENABLED = Emulator.getConfig().getBoolean("hotel.talenttrack.enabled");
InteractionRoller.NO_RULES = Emulator.getConfig().getBoolean("hotel.room.rollers.norules");
RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics");
} }
} }

View File

@ -29,6 +29,13 @@ public class ThreadPooling
{ {
return this.run(run, 0); return this.run(run, 0);
} }
else
{
if (Emulator.isShuttingDown)
{
run.run();
}
}
} }
catch (Exception e) catch (Exception e)
{ {
@ -72,13 +79,16 @@ public class ThreadPooling
public void shutDown() public void shutDown()
{ {
this.canAdd = false; this.canAdd = false;
this.scheduledPool.shutdownNow(); this.scheduledPool.shutdownNow();
while(!this.scheduledPool.isTerminated());
Emulator.getLogging().logShutdownLine("Threading -> Disposed!"); Emulator.getLogging().logShutdownLine("Threading -> Disposed!");
} }
public void setCanAdd(boolean canAdd)
{
this.canAdd = canAdd;
}
public ScheduledExecutorService getService() public ScheduledExecutorService getService()
{ {
return this.scheduledPool; return this.scheduledPool;

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit; import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus; import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUnitOnRollerComposer;
import java.util.LinkedList; import java.util.LinkedList;
@ -53,7 +54,9 @@ public class RoomUnitTeleport implements Runnable
this.roomUnit.setZ(this.z); this.roomUnit.setZ(this.z);
this.roomUnit.setPreviousLocationZ(this.z); this.roomUnit.setPreviousLocationZ(this.z);
this.roomUnit.removeStatus(RoomUnitStatus.MOVE); this.roomUnit.removeStatus(RoomUnitStatus.MOVE);
this.room.sendComposer(new RoomUnitOnRollerComposer(this.roomUnit, null, t, this.room).compose()); ServerMessage teleportMessage = new RoomUnitOnRollerComposer(this.roomUnit, t, this.room).compose();
this.roomUnit.setLocation(t);
this.room.sendComposer(teleportMessage);

View File

@ -40,6 +40,11 @@ class TeleportActionThree implements Runnable
if(targetRoom == null) if(targetRoom == null)
return; return;
if (targetRoom.isPreLoaded())
{
targetRoom.loadData();
}
targetTeleport = targetRoom.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId()); targetTeleport = targetRoom.getHabboItem(((InteractionTeleport) this.currentTeleport).getTargetId());
if(targetTeleport == null) if(targetTeleport == null)

View File

@ -67,11 +67,10 @@ class TeleportActionTwo implements Runnable
} }
if(((InteractionTeleport)this.currentTeleport).getTargetId() == 0) if(((InteractionTeleport)this.currentTeleport).getTargetId() == 0)
{ {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_teleports.*, A.room_id as a_room_id, A.id as a_id, B.room_id as b_room_id, B.id as b_id FROM items_teleports INNER JOIN items AS A ON items_teleports.teleport_one_id = A.id INNER JOIN items AS B ON items_teleports.teleport_two_id = B.id WHERE (teleport_one_id = ? OR teleport_two_id = ?) AND B.id != ? LIMIT 1")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT items_teleports.*, A.room_id as a_room_id, A.id as a_id, B.room_id as b_room_id, B.id as b_id FROM items_teleports INNER JOIN items AS A ON items_teleports.teleport_one_id = A.id INNER JOIN items AS B ON items_teleports.teleport_two_id = B.id WHERE (teleport_one_id = ? OR teleport_two_id = ?)"))
{ {
statement.setInt(1, this.currentTeleport.getId()); statement.setInt(1, this.currentTeleport.getId());
statement.setInt(2, this.currentTeleport.getId()); statement.setInt(2, this.currentTeleport.getId());
statement.setInt(3, this.currentTeleport.getId());
try (ResultSet set = statement.executeQuery()) try (ResultSet set = statement.executeQuery())
{ {
@ -96,7 +95,7 @@ class TeleportActionTwo implements Runnable
} }
} }
this.currentTeleport.setExtradata("1"); this.currentTeleport.setExtradata("0");
this.room.updateItem(this.currentTeleport); this.room.updateItem(this.currentTeleport);
if(((InteractionTeleport) this.currentTeleport).getTargetRoomId() == 0) if(((InteractionTeleport) this.currentTeleport).getTargetRoomId() == 0)