Updated to 1.15 decompiled.

This commit is contained in:
capheus 2018-12-22 10:39:00 +00:00
parent 35876a2596
commit 71acca7ebb
189 changed files with 4619 additions and 3579 deletions

View File

@ -5,7 +5,7 @@
## **To Get The Camera To Work Visit http://arcturus.wf and register.** ##
## **TUTORIAL FOR PLUGINS http://arcturus.wf/thread-2415.html** ##
# **DO NOT EDIT THE SOURCE. USE THE PLUGIN API.** #
## Current Stable Version: 1.14.0 ##
## Current Stable Version: 1.15.0 ##
Arcturus Morningstar is a Habbo emulator written in Java aiming to be an exact clone of the offical server, based on Arcturus Emulator by TheGeneral.
Targeting PRODUCTION-201611291003-338511768

View File

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

View File

@ -0,0 +1,70 @@
ALTER TABLE `pet_commands_data` ADD PRIMARY KEY(`command_id`);
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '1');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '2');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '3');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '4');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '5');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '6');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '1', '7');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '8');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '9');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '10');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '11');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '12');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '2', '13');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '3', '14');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '3', '15');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '3', '16');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '3', '17');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '4', '18');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '4', '19');
INSERT INTO `pet_breeding_races` (`pet_type`, `rarity_level`, `breed`) VALUES ('28', '4', '20');
ALTER TABLE `pet_actions` ADD `offspring_type` INT(3) NOT NULL DEFAULT '-1' AFTER `pet_name`;
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '1', '10', '0', '10', '1');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '2', '20', '0', '20', '10');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '3', '30', '0', '30', '30');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '4', '40', '0', '40', '60');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '5', '50', '0', '50', '120');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '6', '60', '0', '60', '240');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '7', '70', '0', '70', '600');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '8', '80', '0', '80', '1200');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '9', '90', '0', '90', '2400');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Trampolinist', 'games', '10', '100', '0', '100', '4800');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '1', '10', '0', '10', '1');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '2', '20', '0', '20', '10');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '3', '30', '0', '30', '30');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '4', '40', '0', '40', '60');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '5', '50', '0', '50', '120');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '6', '60', '0', '60', '240');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '7', '70', '0', '70', '600');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '8', '80', '0', '80', '1200');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '9', '90', '0', '90', '2400');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'CrossTrainer', 'games', '10', '100', '0', '100', '4800');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '1', '10', '0', '10', '1');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '2', '20', '0', '20', '10');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '3', '30', '0', '30', '30');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '4', '40', '0', '40', '60');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '5', '50', '0', '50', '120');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '6', '60', '0', '60', '240');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '7', '70', '0', '70', '600');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '8', '80', '0', '80', '1200');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '9', '90', '0', '90', '2400');
INSERT INTO `achievements` (`id`, `name`, `category`, `level`, `reward_amount`, `reward_type`, `points`, `progress_needed`) VALUES (NULL, 'Jogger', 'games', '10', '100', '0', '100', '4800');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.furni.gym.achievement.olympics_c16_trampoline', 'Trampolinist'), ('hotel.furni.gym.achievement.olympics_c16_crosstrainer', 'CrossTrainer'), ('hotel.furni.gym.achievement.olympics_c16_treadmill', 'Jogger');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.furni.gym.forcerot.olympics_c16_trampoline', '0'), ('hotel.furni.gym.forcerot.olympics_c16_crosstrainer', '1'), ('hotel.furni.gym.forcerot.olympics_c16_treadmill', '1');
UPDATE emulator_settings SET `key` = 'hotel.view.ltdcountdown.itemname' WHERE `key` = 'hotel.view.ltdcountdown.itename';
INSERT IGNORE INTO `emulator_texts` (`key`, `value`) VALUES ('commands.keys.cmd_empty_pets', 'emptypets;empty_pets');
INSERT IGNORE INTO `emulator_texts` (`key`, `value`) VALUES ('debug.show.headers', '');
ALTER TABLE `items_crackable` ADD PRIMARY KEY(`item_id`);
ALTER TABLE `items_crackable` ADD `required_effect` INT(3) NOT NULL DEFAULT '0' AFTER `achievement_cracked`;
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.tile.not.exists', 'Tile does not exist!');
ALTER TABLE `items` CHANGE `z` `z` DOUBLE(10,6) NOT NULL DEFAULT '0.000000';
ALTER TABLE `items_base` ADD `customparams` VARCHAR(256) NOT NULL DEFAULT '' AFTER `multiheight`;

View File

@ -33,7 +33,7 @@ public final class Emulator
public final static int MAJOR = 1;
public final static int MINOR = 14;
public final static int MINOR = 15;
public final static int BUILD = 0;
@ -70,7 +70,7 @@ public final class Emulator
private static PluginManager pluginManager;
private static Random random;
private static BadgeImager badgeImager;
static
{
Thread hook = new Thread(new Runnable()
@ -164,6 +164,7 @@ public final class Emulator
{
Emulator.getLogging().logStart("Thanks for using Arcturus. Contact: Skype: wesley.jabbo Discord: TheGeneral#0063");
Emulator.getLogging().logStart("-The General");
System.out.println("Waiting for command: ");
}
}, 3500);
@ -173,12 +174,14 @@ public final class Emulator
{
try
{
String line = reader.readLine();
if (line != null)
{
ConsoleCommand.handle(line);
}
System.out.println("Waiting for command: ");
}
catch (Exception e)
{
@ -355,12 +358,12 @@ public final class Emulator
{
cameraClient = client;
}
public static int getTimeStarted()
{
return timeStarted;
}
public static void prepareShutdown()
{
System.exit(0);
@ -393,7 +396,7 @@ public final class Emulator
}
return res;
}
public static Timestamp dateToTimeStamp(Date date)
{
return new Timestamp(date.getTime());
@ -408,12 +411,12 @@ public final class Emulator
{
return dateToUnixTimestamp(getDate());
}
public static int getIntUnixTimestamp()
{
return (int) (System.currentTimeMillis() / 1000);
}
public static boolean isNumeric(String string)
throws IllegalArgumentException
{

View File

@ -5,7 +5,7 @@ import gnu.trove.map.hash.THashMap;
public abstract class ConsoleCommand
{
public static THashMap<String, ConsoleCommand> commands = new THashMap<>();
private static THashMap<String, ConsoleCommand> commands = new THashMap<>();
public final String key;
@ -27,6 +27,7 @@ public abstract class ConsoleCommand
addCommand(new ConsoleInfoCommand());
addCommand(new ConsoleTestCommand());
addCommand(new ConsoleReconnectCameraCommand());
addCommand(new ShowInteractionsCommand());
}
@ -72,7 +73,7 @@ public abstract class ConsoleCommand
for (ConsoleCommand c : commands.values())
{
System.out.println(c.key + " " + c.usage);
System.out.println(c.key + " - " + c.usage);
}
}
}

View File

@ -9,7 +9,7 @@ public class ConsoleInfoCommand extends ConsoleCommand
{
public ConsoleInfoCommand()
{
super("info", "");
super("info", "Show current statistics.");
}
@Override

View File

@ -6,7 +6,7 @@ public class ConsoleReconnectCameraCommand extends ConsoleCommand
{
public ConsoleReconnectCameraCommand()
{
super("camera", "");
super("camera", "Attempt to reconnect to the camera server.");
}
@Override

View File

@ -6,7 +6,7 @@ public class ConsoleShutdownCommand extends ConsoleCommand
{
public ConsoleShutdownCommand()
{
super("stop", "");
super("stop", "Stop the emulator.");
}
@Override

View File

@ -8,19 +8,22 @@ public class ConsoleTestCommand extends ConsoleCommand
{
public ConsoleTestCommand()
{
super("test", "test");
super("test", "This is just a test.");
}
@Override
public void handle(String[] args) throws Exception
{
System.out.println("This is a test command for live debugging.");
if (Emulator.debugging)
{
System.out.println("This is a test command for live debugging.");
//AchievementManager.progressAchievement(4, Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"), 30);
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(1);
habbo.getHabboInfo().getMachineID();
//AchievementManager.progressAchievement(4, Emulator.getGameEnvironment().getAchievementManager().getAchievement("AllTimeHotelPresence"), 30);
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(1);
habbo.getHabboInfo().getMachineID();
}
}
}

View File

@ -0,0 +1,20 @@
package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
public class ShowInteractionsCommand extends ConsoleCommand
{
public ShowInteractionsCommand()
{
super("interactions", "Show a list of available furniture interactions.");
}
@Override
public void handle(String[] args) throws Exception
{
for (String interaction : Emulator.getGameEnvironment().getItemManager().getInteractionList())
{
System.out.println(interaction);
}
}
}

View File

@ -209,12 +209,12 @@ public class AchievementManager
AchievementLevel oldLevel = achievement.getLevelForProgress(currentProgress);
if(oldLevel == null)
{
oldLevel = achievement.firstLevel();
}
if(oldLevel.level == achievement.levels.size() && currentProgress >= oldLevel.progress) //Maximum achievement gotten.
if(oldLevel != null && (oldLevel.level == achievement.levels.size() && currentProgress >= oldLevel.progress)) //Maximum achievement gotten.
return;
habbo.getHabboStats().setProgress(achievement, currentProgress + amount);
@ -239,7 +239,8 @@ public class AchievementManager
}
}
if(newLevel == null || (oldLevel.level == newLevel.level && newLevel.level < achievement.levels.size()))
if(newLevel == null ||
(oldLevel != null &&(oldLevel.level == newLevel.level && newLevel.level < achievement.levels.size())))
{
habbo.getClient().sendResponse(new AchievementProgressComposer(habbo, achievement));
}
@ -261,13 +262,17 @@ public class AchievementManager
//The achievement is then progressed but the user is already disposed so fetching
//the badge would result in an nullpointer exception. This is normal behaviour.
HabboBadge badge = null;
try
if (oldLevel != null)
{
badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase());
}
catch (Exception e)
{
return;
try
{
badge = habbo.getInventory().getBadgesComponent().getBadge(("ACH_" + achievement.name + oldLevel.level).toLowerCase());
} catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
return;
}
}
if (badge != null)
@ -364,6 +369,28 @@ public class AchievementManager
}
}
public static int getAchievementProgressForHabbo(int userId, Achievement achievement)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT progress FROM users_achievements WHERE user_id = ? AND achievement_name = ? LIMIT 1"))
{
statement.setInt(1, userId);
statement.setString(2, achievement.name);
try (ResultSet set = statement.executeQuery())
{
if (set.next())
{
return set.getInt("progress");
}
}
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
return 0;
}
public LinkedHashMap<Integer, TalentTrackLevel> getTalenTrackLevels(TalentTrackType type)
{
return this.talentTrackLevels.get(type);
@ -420,30 +447,39 @@ public class AchievementManager
if (level != null)
{
for (Item item : level.items)
if (level.items != null && !level.items.isEmpty())
{
HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
habbo.getInventory().getItemsComponent().addItem(rewardItem);
habbo.getClient().sendResponse(new AddHabboItemComposer(rewardItem));
habbo.getClient().sendResponse(new InventoryRefreshComposer());
}
for (String badge : level.badges)
{
if (!badge.isEmpty())
for (Item item : level.items)
{
HabboBadge b = new HabboBadge(0, badge, 0, habbo);
Emulator.getThreading().run(b);
habbo.getInventory().getBadgesComponent().addBadge(b);
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
HabboItem rewardItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getHabboInfo().getId(), item, 0, 0, "");
habbo.getInventory().getItemsComponent().addItem(rewardItem);
habbo.getClient().sendResponse(new AddHabboItemComposer(rewardItem));
habbo.getClient().sendResponse(new InventoryRefreshComposer());
}
}
for (String perk : level.perks)
if (level.badges != null && level.badges.length > 0 )
{
if (perk.equalsIgnoreCase("TRADE"))
for (String badge : level.badges)
{
habbo.getHabboStats().perkTrade = true;
if (!badge.isEmpty())
{
HabboBadge b = new HabboBadge(0, badge, 0, habbo);
Emulator.getThreading().run(b);
habbo.getInventory().getBadgesComponent().addBadge(b);
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
}
}
}
if (level.perks != null && level.perks.length > 0 )
{
for (String perk : level.perks)
{
if (perk.equalsIgnoreCase("TRADE"))
{
habbo.getHabboStats().perkTrade = true;
}
}
}
habbo.getClient().sendResponse(new TalentLevelUpdateComposer(type, level));

View File

@ -72,7 +72,14 @@ public class TalentTrackLevel
}
}
this.perks = set.getString("reward_perks").split(",");
this.badges = set.getString("reward_badges").split(",");
if (!set.getString("reward_perks").isEmpty())
{
this.perks = set.getString("reward_perks").split(",");
}
if (!set.getString("reward_badges").isEmpty())
{
this.badges = set.getString("reward_badges").split(",");
}
}
}

View File

@ -1,9 +1,11 @@
package com.eu.habbo.habbohotel.bots;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.generic.alerts.BotErrorComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
@ -136,13 +138,18 @@ public class BotManager
return;
}
if (!room.tileWalkable(location.x, location.y))
if (!room.hasHabbosAt(location.x, location.y) && !location.isWalkable() && location.state != RoomTileState.SIT)
return;
RoomUnit roomUnit = new RoomUnit();
roomUnit.setRotation(RoomUserRotation.SOUTH);
roomUnit.setLocation(location);
roomUnit.setZ(room.getStackHeight(location.x, location.y, false));
HabboItem topItem = room.getTopItemAt(location.x, location.y);
if (topItem != null)
{
roomUnit.setZ(topItem.getZ() + Item.getCurrentHeight(topItem));
}
roomUnit.setPreviousLocationZ(roomUnit.getZ());
roomUnit.setPathFinderRoom(room);
roomUnit.setRoomUnitType(RoomUnitType.BOT);
roomUnit.setCanWalk(room.isAllowBotsWalk());
@ -155,11 +162,22 @@ public class BotManager
habbo.getInventory().getBotsComponent().removeBot(bot);
habbo.getClient().sendResponse(new RemoveBotComposer(bot));
bot.onPlace(habbo, room);
if (topItem != null)
{
try
{
topItem.onWalkOn(bot.getRoomUnit(), room, null);
} catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
bot.cycle(false);
}
else
{
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNI_PLACE_EMENT_ERROR.key, "cant_set_not_owner"));
habbo.getClient().sendResponse(new BubbleAlertComposer(BubbleAlertKeys.FURNITURE_PLACEMENT_ERROR.key, FurnitureMovementError.NO_RIGHTS.errorCode));
}
}
}

View File

@ -86,7 +86,7 @@ public class CatalogManager
public static int catalogItemAmount;
public static int PURCHASE_COOLDOWN = 3;
public static int PURCHASE_COOLDOWN = 1;
public static boolean SORT_USING_ORDERNUM = false;
@ -154,7 +154,7 @@ public class CatalogManager
this.giftFurnis = new THashMap<>();
this.clubItems = new THashSet<>();
this.clubOffers = new THashMap<>();
targetOffers = new THashMap<>();
this.targetOffers = new THashMap<>();
this.clothing = new THashMap<>();
this.offerDefs = new TIntIntHashMap();
this.vouchers = new ArrayList<>();
@ -396,22 +396,19 @@ public class CatalogManager
private void loadClubOffers() throws SQLException
{
synchronized (this.clubOffers)
{
this.clubOffers.clear();
this.clubOffers.clear();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_club_offers WHERE enabled = ?"))
{
statement.setString(1, "1");
try (ResultSet set = statement.executeQuery())
{
while (set.next())
{
this.clubOffers.put(set.getInt("id"), new ClubOffer(set));
}
}
}
}
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_club_offers WHERE enabled = ?"))
{
statement.setString(1, "1");
try (ResultSet set = statement.executeQuery())
{
while (set.next())
{
this.clubOffers.put(set.getInt("id"), new ClubOffer(set));
}
}
}
}
private void loadTargetOffers() throws SQLException
@ -1210,6 +1207,8 @@ public class CatalogManager
Emulator.getThreading().run(habboItem);
itemsList.add(habboItem);
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("MusicCollector"));
} else
{
HabboItem habboItem = Emulator.getGameEnvironment().getItemManager().createItem(habbo.getClient().getHabbo().getHabboInfo().getId(), baseItem, limitedStack, limitedNumber, extradata);

View File

@ -3,7 +3,7 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.events.calendar.AdventCalendarDataComposer;
import com.eu.habbo.messages.outgoing.unknown.NuxAlertComposer;
import com.eu.habbo.messages.outgoing.habboway.nux.NuxAlertComposer;
public class CalendarCommand extends Command
{

View File

@ -49,6 +49,10 @@ public class CoordsCommand extends Command {
"Tile Stack Height: " + tile.getStackHeight() + "\r" +
"Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r"));
}
else
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("generic.tile.not.exists"));
}
}
return true;
}

View File

@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.StaffAlertWithLinkComposer;
import java.util.Map;
@ -25,7 +25,7 @@ public class HotelAlertCommand extends Command {
message += params[i] + " ";
}
ServerMessage msg = new GenericAlertComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose();
ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose();
for(Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet())
{

View File

@ -4,7 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.modtool.ModToolIssueHandledComposer;
public class RoomAlertCommand extends Command
{
@ -35,7 +35,7 @@ public class RoomAlertCommand extends Command
if (room != null)
{
room.sendComposer(new GenericAlertComposer(message).compose());
room.sendComposer(new ModToolIssueHandledComposer(message).compose());
return true;
}
}

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.outgoing.inventory.InventoryBadgesComposer;
import com.eu.habbo.messages.outgoing.users.UserBadgesComposer;
public class TakeBadgeCommand extends Command
{
@ -47,6 +48,10 @@ public class TakeBadgeCommand extends Command
}
habbo.getClient().sendResponse(new InventoryBadgesComposer(habbo));
if (habbo.getHabboInfo().getCurrentRoom() != null)
{
habbo.getHabboInfo().getCurrentRoom().sendComposer(new UserBadgesComposer(habbo.getInventory().getBadgesComponent().getWearingBadges(), habbo.getHabboInfo().getId()).compose());
}
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_take_badge"), RoomChatMessageBubbles.ALERT);

View File

@ -22,6 +22,7 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
import com.eu.habbo.messages.outgoing.rooms.RoomQueueStatusMessage;
import com.eu.habbo.messages.outgoing.rooms.pets.PetInformationComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.PetStatusUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserDataComposer;
@ -56,9 +57,41 @@ public class TestCommand extends Command
public boolean handle(GameClient gameClient, String[] params) throws Exception
{
if (params[1].equalsIgnoreCase("ut"))
{
RoomTile tile = gameClient.getHabbo().getRoomUnit().getCurrentLocation();
gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateTile(tile);
return true;
}
if (params[1].equalsIgnoreCase("clients"))
{
System.out.println(Emulator.getGameServer().getGameClientManager().getSessions().size());
}
if (params[1].equalsIgnoreCase("queue"))
{
gameClient.sendResponse(new RoomQueueStatusMessage());
return true;
}
if (params[1].equalsIgnoreCase("public"))
{
gameClient.getHabbo().getHabboInfo().getCurrentRoom().setPublicRoom(true);
return true;
}
if (params[1].equalsIgnoreCase("randtel"))
{
RoomTile tile = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getRandomWalkableTile();
gameClient.getHabbo().getRoomUnit().setCurrentLocation(tile);
gameClient.getHabbo().getHabboInfo().getCurrentRoom().updateHabbo(gameClient.getHabbo());
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserStatusComposer(gameClient.getHabbo().getRoomUnit()).compose());
return true;
}
if (params[1].equals("ach"))
{
AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("GiftGiver"), 100);
AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Jogger"), 1);
return true;
}

View File

@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserIgnoredComposer;
public class UnmuteCommand extends Command
{
@ -43,11 +42,6 @@ public class UnmuteCommand extends Command
habbo.getHabboInfo().getCurrentRoom().muteHabbo(habbo, 1);
}
if (habbo.getHabboInfo().getCurrentRoom() != null)
{
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserIgnoredComposer(habbo, RoomUserIgnoredComposer.UNIGNORED).compose());
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_unmute").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
}
else

View File

@ -26,61 +26,57 @@ public class CraftingManager
{
this.dispose();
synchronized (this.altars)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM crafting_altars_recipes " +
"INNER JOIN crafting_recipes ON crafting_altars_recipes.recipe_id = crafting_recipes.id " +
"INNER JOIN crafting_recipes_ingredients ON crafting_recipes.id = crafting_recipes_ingredients.recipe_id " +
"WHERE crafting_recipes.enabled = ? ORDER BY altar_id ASC"))
{
statement.setString(1, "1");
try (ResultSet set = statement.executeQuery())
{
while (set.next())
{
Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("altar_id"));
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM crafting_altars_recipes " +
"INNER JOIN crafting_recipes ON crafting_altars_recipes.recipe_id = crafting_recipes.id " +
"INNER JOIN crafting_recipes_ingredients ON crafting_recipes.id = crafting_recipes_ingredients.recipe_id " +
"WHERE crafting_recipes.enabled = ? ORDER BY altar_id ASC"))
{
statement.setString(1, "1");
try (ResultSet set = statement.executeQuery())
{
while (set.next())
{
Item item = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("altar_id"));
if (item != null)
{
if (!this.altars.containsKey(item))
{
this.altars.put(item, new CraftingAltar(item));
}
if (item != null)
{
if (!this.altars.containsKey(item))
{
this.altars.put(item, new CraftingAltar(item));
}
CraftingAltar altar = this.altars.get(item);
CraftingAltar altar = this.altars.get(item);
if (altar != null)
{
CraftingRecipe recipe = altar.getRecipe(set.getInt("crafting_recipes_ingredients.recipe_id"));
if (altar != null)
{
CraftingRecipe recipe = altar.getRecipe(set.getInt("crafting_recipes_ingredients.recipe_id"));
if (recipe == null)
{
recipe = new CraftingRecipe(set);
altar.addRecipe(recipe);
}
if (recipe == null)
{
recipe = new CraftingRecipe(set);
altar.addRecipe(recipe);
}
Item ingredientItem = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("crafting_recipes_ingredients.item_id"));
Item ingredientItem = Emulator.getGameEnvironment().getItemManager().getItem(set.getInt("crafting_recipes_ingredients.item_id"));
if (ingredientItem != null)
{
recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount"));
altar.addIngredient(ingredientItem);
}
else
{
Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id"));
}
}
}
}
}
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
}
if (ingredientItem != null)
{
recipe.addIngredient(ingredientItem, set.getInt("crafting_recipes_ingredients.amount"));
altar.addIngredient(ingredientItem);
}
else
{
Emulator.getLogging().logErrorLine("Unknown ingredient item " + set.getInt("crafting_recipes_ingredients.item_id"));
}
}
}
}
}
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
}
public int getRecipesWithItemCount(final Item item)
@ -109,57 +105,48 @@ public class CraftingManager
public CraftingRecipe getRecipe(String recipeName)
{
synchronized (this.altars)
{
CraftingRecipe recipe = null;
for (CraftingAltar altar : this.altars.values())
{
recipe = altar.getRecipe(recipeName);
CraftingRecipe recipe = null;
for (CraftingAltar altar : this.altars.values())
{
recipe = altar.getRecipe(recipeName);
if (recipe != null)
{
return recipe;
}
}
}
if (recipe != null)
{
return recipe;
}
}
return null;
}
public CraftingAltar getAltar(Item item)
{
synchronized (this.altars)
{
return this.altars.get(item);
}
return this.altars.get(item);
}
public void dispose()
{
synchronized (this.altars)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE crafting_recipes SET remaining = ? WHERE id = ? LIMIT 1"))
{
for (CraftingAltar altar : this.altars.values())
{
for (CraftingRecipe recipe : altar.getRecipes())
{
if (recipe.isLimited())
{
statement.setInt(1, recipe.getRemaining());
statement.setInt(2, recipe.getId());
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE crafting_recipes SET remaining = ? WHERE id = ? LIMIT 1"))
{
for (CraftingAltar altar : this.altars.values())
{
for (CraftingRecipe recipe : altar.getRecipes())
{
if (recipe.isLimited())
{
statement.setInt(1, recipe.getRemaining());
statement.setInt(2, recipe.getId());
statement.addBatch();
}
}
}
statement.executeBatch();
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
}
statement.addBatch();
}
}
}
statement.executeBatch();
}
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
this.altars.clear();
}

View File

@ -68,18 +68,22 @@ public class GameClientManager
return this.clients.putIfAbsent(ctx.channel().id(), client) == null;
}
public void disposeClient(Channel channel)
public void disposeClient(GameClient client)
{
GameClient client = this.getClient(channel);
client.getChannel().close();
}
private void disposeClient(Channel channel)
{
GameClient client = channel.attr(CLIENT).get();
if (client != null)
{
client.dispose();
}
channel.attr(CLIENT).set(null);
channel.deregister();
channel.attr(CLIENT).set(null);
channel.closeFuture();
channel.close();
this.clients.remove(channel.id());

View File

@ -5,7 +5,9 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.interactions.InteractionGuildFurni;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.guilds.GuildJoinErrorComposer;
import com.eu.habbo.messages.outgoing.unknown.GuildMembershipRequestedComposer;
import gnu.trove.TCollections;
import gnu.trove.iterator.TIntObjectIterator;
import gnu.trove.map.TIntObjectMap;
@ -317,7 +319,18 @@ public class GuildManager
if(userId == 0 && !error)
{
if (guild.getState() == GuildState.LOCKED)
{
guild.increaseRequestCount();
ServerMessage membershipRequestMessage = new GuildMembershipRequestedComposer(guild.getId(), client.getHabbo().getHabboInfo().getId()).compose();
for (GuildMember member : this.getOnlyAdmins(guild).values())
{
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(member.getUserId());
if (habbo != null)
{
habbo.getClient().sendResponse(membershipRequestMessage);
}
}
}
else
{
guild.increaseMemberCount();

View File

@ -16,6 +16,7 @@ public class CrackableReward
public int totalChance;
public final String achievementTick;
public final String achievementCracked;
public final int requiredEffect;
public CrackableReward(ResultSet set) throws SQLException
{
@ -23,6 +24,7 @@ public class CrackableReward
this.count = set.getInt("count");
this.achievementTick = set.getString("achievement_tick");
this.achievementCracked = set.getString("achievement_cracked");
this.requiredEffect = set.getInt("required_effect");
String[] data = set.getString("prizes").split(";");
this.prizes = new HashMap<>();

View File

@ -32,6 +32,7 @@ public class Item {
private short effectF;
private TIntArrayList vendingItems;
private double[] multiHeights;
private String customParams;
private ItemInteraction interactionType;
@ -55,6 +56,10 @@ public class Item {
this.width = set.getShort("width");
this.length = set.getShort("length");
this.height = set.getDouble("stack_height");
if (this.height == 0)
{
this.height = 1e-6;
}
this.allowStack = set.getBoolean("allow_stack");
this.allowWalk = set.getBoolean("allow_walk");
this.allowSit = set.getBoolean("allow_sit");
@ -70,7 +75,7 @@ public class Item {
this.stateCount = set.getShort("interaction_modes_count");
this.effectM = set.getShort("effect_id_male");
this.effectF = set.getShort("effect_id_female");
this.customParams = set.getString("customparams");
if(!set.getString("vending_ids").isEmpty())
{
this.vendingItems = new TIntArrayList();
@ -81,7 +86,7 @@ public class Item {
}
}
if(this.interactionType.getType() == InteractionMultiHeight.class)
//if(this.interactionType.getType() == InteractionMultiHeight.class || this.interactionType.getType().isAssignableFrom(InteractionMultiHeight.class))
{
if(set.getString("multiheight").contains(";"))
{
@ -100,15 +105,18 @@ public class Item {
}
}
public int getId() {
public int getId()
{
return this.id;
}
public int getSpriteId() {
public int getSpriteId()
{
return this.spriteId;
}
public String getName() {
public String getName()
{
return this.name;
}
@ -122,47 +130,58 @@ public class Item {
return this.type;
}
public int getWidth() {
public int getWidth()
{
return this.width;
}
public int getLength() {
public int getLength()
{
return this.length;
}
public double getHeight() {
public double getHeight()
{
return this.height;
}
public boolean allowStack() {
public boolean allowStack()
{
return this.allowStack;
}
public boolean allowWalk() {
public boolean allowWalk()
{
return this.allowWalk;
}
public boolean allowSit() {
public boolean allowSit()
{
return this.allowSit;
}
public boolean allowLay() {
public boolean allowLay()
{
return this.allowLay;
}
public boolean allowRecyle() {
public boolean allowRecyle()
{
return this.allowRecyle;
}
public boolean allowTrade() {
public boolean allowTrade()
{
return this.allowTrade;
}
public boolean allowMarketplace() {
public boolean allowMarketplace()
{
return this.allowMarketplace;
}
public boolean allowGift() {
public boolean allowGift()
{
return this.allowGift;
}
@ -171,15 +190,18 @@ public class Item {
return this.allowInventoryStack;
}
public int getStateCount() {
public int getStateCount()
{
return this.stateCount;
}
public int getEffectM() {
public int getEffectM()
{
return this.effectM;
}
public int getEffectF() {
public int getEffectF()
{
return this.effectF;
}

View File

@ -164,6 +164,13 @@ public class ItemManager
this.interactionsList.add(new ItemInteraction("sticky_pole", InteractionStickyPole.class));
this.interactionsList.add(new ItemInteraction("trap", InteractionTrap.class));
this.interactionsList.add(new ItemInteraction("tent", InteractionTent.class));
this.interactionsList.add(new ItemInteraction("gym_equipment", InteractionGymEquipment.class));
this.interactionsList.add(new ItemInteraction("handitem", InteractionHanditem.class));
this.interactionsList.add(new ItemInteraction("handitem_tile", InteractionHanditemTile.class));
this.interactionsList.add(new ItemInteraction("effect_giver", InteractionEffectGiver.class));
this.interactionsList.add(new ItemInteraction("effect_vendingmachine", InteractionEffectVendingMachine.class));
this.interactionsList.add(new ItemInteraction("crackable_monster", InteractionMonsterCrackable.class));
this.interactionsList.add(new ItemInteraction("snowboard_slope", InteractionSnowboardSlope.class));
@ -183,6 +190,8 @@ public class ItemManager
this.interactionsList.add(new ItemInteraction("wf_trg_bot_reached_avtr", WiredTriggerBotReachedHabbo.class));
this.interactionsList.add(new ItemInteraction("wf_trg_says_command", WiredTriggerHabboSaysCommand.class));
this.interactionsList.add(new ItemInteraction("wf_trg_score_achieved", WiredTriggerScoreAchieved.class));
this.interactionsList.add(new ItemInteraction("wf_trg_idles", WiredTriggerHabboIdle.class));
this.interactionsList.add(new ItemInteraction("wf_trg_unidles", WiredTriggerHabboUnidle.class));
this.interactionsList.add(new ItemInteraction("wf_act_toggle_state", WiredEffectToggleFurni.class));
@ -422,14 +431,17 @@ public class ItemManager
{
while(set.next())
{
CrackableReward reward = null;
try
{
this.crackableRewards.put(set.getInt("item_id"), new CrackableReward(set));
reward = new CrackableReward(set);
}
catch (Exception e)
{
Emulator.getLogging().logErrorLine("Failed to load items_crackable item_id = " + set.getInt("ïtem_id"));
continue;
}
this.crackableRewards.put(set.getInt("item_id"), reward);
}
}
catch (SQLException e)
@ -913,4 +925,16 @@ public class ItemManager
Emulator.getLogging().logShutdownLine("Item Manager -> Disposed!");
}
public List<String> getInteractionList()
{
List<String> interactions = new ArrayList<>();
for (ItemInteraction interaction : this.interactionsList)
{
interactions.add(interaction.getName());
}
Collections.sort(interactions);
return interactions;
}
}

View File

@ -1,6 +1,11 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -16,4 +21,36 @@ public class InteractionBlackHole extends InteractionGate
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void onPlace(Room room)
{
Achievement holeCountAchievement = Emulator.getGameEnvironment().getAchievementManager().getAchievement("RoomDecoHoleFurniCount");
int holesCountProgress = 0;
Habbo owner = room.getHabbo(this.getUserId());
int furniCollecterProgress = 0;
if (owner == null)
{
furniCollecterProgress = AchievementManager.getAchievementProgressForHabbo(this.getUserId(), holeCountAchievement);
}
else
{
furniCollecterProgress = owner.getHabboStats().getAchievementProgress(holeCountAchievement);
}
int holeDifference = room.getRoomSpecialTypes().getItemsOfType(InteractionBlackHole.class).size() - holesCountProgress;
if (holeDifference > 0)
{
if (owner != null)
{
AchievementManager.progressAchievement(owner, holeCountAchievement, holeDifference);
}
else
{
AchievementManager.progressAchievement(this.getUserId(), holeCountAchievement, holeDifference);
}
}
}
}

View File

@ -20,6 +20,7 @@ import java.sql.SQLException;
public class InteractionCrackable extends HabboItem
{
public boolean cracked = false;
protected int ticks = 0;
private final Object lock = new Object();
public InteractionCrackable(ResultSet set, Item baseItem) throws SQLException
@ -102,26 +103,34 @@ public class InteractionCrackable extends HabboItem
public void onTick(Habbo habbo, Room room)
{
if (this.cracked) return;
if (this.allowAnyone() || this.getUserId() == habbo.getHabboInfo().getId())
{
this.setExtradata(Integer.valueOf(this.getExtradata()) + 1 + "");
CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId());
if (rewardData.requiredEffect > 0 && habbo.getRoomUnit().getEffectId() != rewardData.requiredEffect) return;
this.ticks++;
this.setExtradata("" + (this.ticks));
this.needsUpdate(true);
room.updateItem(this);
CrackableReward rewardData = Emulator.getGameEnvironment().getItemManager().getCrackableData(this.getBaseItem().getId());
if (rewardData != null && !rewardData.achievementTick.isEmpty())
if (rewardData != null)
{
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementTick));
}
if (!this.cracked && Integer.valueOf(this.getExtradata()) == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()))
{
this.cracked = true;
Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom()), 1500);
if (rewardData != null && !rewardData.achievementCracked.isEmpty())
if (!rewardData.achievementTick.isEmpty())
{
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked));
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementTick));
}
if (!this.cracked && this.ticks == Emulator.getGameEnvironment().getItemManager().getCrackableCount(this.getBaseItem().getId()))
{
this.cracked = true;
Emulator.getThreading().run(new CrackableExplode(room, this, habbo, !this.placeInRoom(), this.getX(), this.getY()), 1500);
if (!rewardData.achievementCracked.isEmpty())
{
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked));
}
}
}
}
@ -163,6 +172,7 @@ public class InteractionCrackable extends HabboItem
public void reset(Room room)
{
this.cracked = false;
this.ticks = 0;
this.setExtradata("0");
room.updateItem(this);
}

View File

@ -1,9 +1,11 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
import com.eu.habbo.habbohotel.users.Habbo;
@ -119,6 +121,24 @@ public class InteractionDefault extends HabboItem
}
}
}
else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT))
{
Bot bot = room.getBot(roomUnit);
if (bot != null)
{
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectM())
{
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectM());
return;
}
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0 && roomUnit.getEffectId() != this.getBaseItem().getEffectF())
{
room.giveEffect(bot.getRoomUnit(), this.getBaseItem().getEffectF());
return;
}
}
}
}
}
}
@ -132,12 +152,27 @@ public class InteractionDefault extends HabboItem
{
if (this.getBaseItem().getEffectF() > 0 || this.getBaseItem().getEffectM() > 0)
{
if (objects != null && objects.length == 2)
{
if (objects[0] instanceof RoomTile && objects[1] instanceof RoomTile)
{
RoomTile goalTile = (RoomTile) objects[1];
HabboItem topItem = room.getTopItemAt(goalTile.x, goalTile.y);
if (topItem != null && (topItem.getBaseItem().getEffectM() == this.getBaseItem().getEffectM() || topItem.getBaseItem().getEffectF() == this.getBaseItem().getEffectF()))
{
return;
}
}
}
if (roomUnit.getRoomUnitType().equals(RoomUnitType.USER))
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
if (habbo.getHabboInfo().getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0)
{
room.giveEffect(habbo, 0);
@ -151,6 +186,25 @@ public class InteractionDefault extends HabboItem
}
}
}
else if (roomUnit.getRoomUnitType().equals(RoomUnitType.BOT))
{
Bot bot = room.getBot(roomUnit);
if (bot != null)
{
if (bot.getGender().equals(HabboGender.M) && this.getBaseItem().getEffectM() > 0)
{
room.giveEffect(roomUnit, 0);
return;
}
if (bot.getGender().equals(HabboGender.F) && this.getBaseItem().getEffectF() > 0)
{
room.giveEffect(roomUnit, 0);
return;
}
}
}
}
}
}

View File

@ -0,0 +1,63 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionEffectGiver extends InteractionDefault
{
public InteractionEffectGiver(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionEffectGiver(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
{
super.onClick(client, room, objects);
if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) ||
(client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY()))
{
this.handle(room, client.getHabbo().getRoomUnit());
}
}
protected void handle(Room room, RoomUnit roomUnit)
{
if (this.getExtradata().isEmpty()) this.setExtradata("0");
if (!this.getExtradata().equals("0")) return;
HabboItem instance = this;
room.giveEffect(roomUnit, this.getBaseItem().getRandomVendingItem());
if (this.getBaseItem().getStateCount() > 1)
{
this.setExtradata("1");
room.updateItem(this);
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
setExtradata("0");
room.updateItem(instance);
}
}, 500);
}
}
}

View File

@ -1,8 +1,10 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.bots.Bot;
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.rooms.RoomUnitType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
@ -49,14 +51,35 @@ public class InteractionEffectTile extends InteractionPressurePlate
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
super.onWalkOn(roomUnit, room, objects);
Habbo habbo = room.getHabbo(roomUnit);
if (habbo.getHabboInfo().getGender().equals(HabboGender.M))
if (roomUnit.getRoomUnitType() == RoomUnitType.USER)
{
room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getEffectM());
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
giveEffect(room, roomUnit, habbo.getHabboInfo().getGender());
}
}
else if (roomUnit.getRoomUnitType() == RoomUnitType.BOT)
{
Bot bot = room.getBot(roomUnit);
if (bot != null)
{
giveEffect(room, roomUnit, bot.getGender());
}
}
}
private void giveEffect(Room room, RoomUnit roomUnit, HabboGender gender)
{
if (gender.equals(HabboGender.M))
{
room.giveEffect(roomUnit, this.getBaseItem().getEffectM());
} else
{
room.giveEffect(habbo.getRoomUnit(), this.getBaseItem().getEffectF());
room.giveEffect(roomUnit, this.getBaseItem().getEffectF());
}
}

View File

@ -0,0 +1,89 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.RoomUserRotation;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.threading.runnables.RoomUnitVendingMachineAction;
import com.eu.habbo.util.pathfinding.Rotation;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionEffectVendingMachine extends InteractionDefault
{
public InteractionEffectVendingMachine(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
this.setExtradata("0");
}
public InteractionEffectVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
{
super.onClick(client, room, objects);
if (client != null)
{
RoomTile tile = getSquareInFront(room.getLayout(), this);
if (tile != null)
{
if (tile.equals(client.getHabbo().getRoomUnit().getCurrentLocation()))
{
if (this.getExtradata().equals("0") || this.getExtradata().length() == 0)
{
room.updateHabbo(client.getHabbo());
if (!client.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT))
{
client.getHabbo().getRoomUnit().setRotation(RoomUserRotation.values()[Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())]);
client.getHabbo().getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
room.scheduledComposers.add(new RoomUserStatusComposer(client.getHabbo().getRoomUnit()).compose());
}
this.setExtradata("1");
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
Emulator.getThreading().run(this, 1000);
HabboItem instance = this;
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
room.giveEffect(client.getHabbo().getRoomUnit(), instance.getBaseItem().getRandomVendingItem());
}
});
}
}
else
{
if (!tile.isWalkable())
{
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY())))
{
if (t != null && t.isWalkable())
{
tile = t;
break;
}
}
}
client.getHabbo().getRoomUnit().setGoalLocation(tile);
Emulator.getThreading().run(new RoomUnitVendingMachineAction(client.getHabbo(), this, room), client.getHabbo().getRoomUnit().getPath().size() + 2 * 510);
}
}
}
}
}

View File

@ -54,5 +54,5 @@ public class InteractionExternalImage extends HabboItem
{
}
//{"t":10000000, "u":"http://arcturus.wf/camera/", "m":"idk", "s":1, "w":"http://arcturus.wf/camera/image.png"}
//{"t":10000000, "u":"http://arcturus.pw/camera/", "m":"idk", "s":1, "w":"http://arcturus.pw/camera/image.png"}
}

View File

@ -47,10 +47,11 @@ public class InteractionGate extends HabboItem
{
super.onClick(client, room, objects);
if (client != null && !room.hasRights(client.getHabbo()) && !(objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE))
boolean isWired = (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE);
if (client != null && !room.hasRights(client.getHabbo()) && !isWired)
return;
if(!room.getHabbosAt(this.getX(), this.getY()).isEmpty())
if(!isWired && !room.getHabbosAt(this.getX(), this.getY()).isEmpty())
return;
if(this.getExtradata().length() == 0)

View File

@ -0,0 +1,191 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionGymEquipment extends InteractionEffectTile implements ICycleable
{
private int startTime = 0;
private int roomUnitId = -1;
public InteractionGymEquipment(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionGymEquipment(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects)
{
return this.roomUnitId == -1 && super.canWalkOn(roomUnit, room, objects) && (roomUnit.getRoomUnitType().equals(RoomUnitType.USER) || roomUnit.getRoomUnitType().equals(RoomUnitType.BOT));
}
@Override
public boolean isWalkable()
{
return this.roomUnitId == -1;
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
super.onWalkOn(roomUnit, room, objects);
if (this.forceRotation())
{
roomUnit.setRotation(RoomUserRotation.fromValue(this.getRotation()));
roomUnit.canRotate = false;
}
this.roomUnitId = roomUnit.getId();
if (roomUnit.getRoomUnitType() == RoomUnitType.USER)
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
{
this.startTime = Emulator.getIntUnixTimestamp();
}
}
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
super.onWalkOff(roomUnit, room, objects);
room.giveEffect(roomUnit, 0);
if (this.forceRotation())
{
roomUnit.canRotate = true;
}
this.reset(room);
}
public String achievementName()
{
return Emulator.getConfig().getValue("hotel.furni.gym.achievement." + this.getBaseItem().getName(), "");
}
public boolean forceRotation()
{
return Emulator.getConfig().getBoolean("hotel.furni.gym.forcerot." + this.getBaseItem().getName(), true);
}
@Override
public void cycle(Room room)
{
if (this.roomUnitId != -1)
{
Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId);
if (habbo != null)
{
int timestamp = Emulator.getIntUnixTimestamp();
if (timestamp - this.startTime >= 120)
{
String achievement = achievementName();
if (!achievement.isEmpty())
{
AchievementManager.progressAchievement(habbo.getHabboInfo().getId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement));
}
this.startTime = timestamp;
}
}
}
}
@Override
public void setRotation(int rotation)
{
super.setRotation(rotation);
if (this.forceRotation() && this.roomUnitId != -1)
{
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if (room != null)
{
RoomUnit roomUnit = getCurrentRoomUnit(room);
if (roomUnit != null)
{
roomUnit.setRotation(RoomUserRotation.fromValue(rotation));
room.updateRoomUnit(roomUnit);
}
}
}
}
@Override
public void onPickUp(Room room)
{
super.onPickUp(room);
if (this.roomUnitId != -1)
{
this.setEffect(room, 0);
}
this.reset(room);
}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
{
super.onMove(room, oldLocation, newLocation);
if (!oldLocation.equals(newLocation))
{
this.setEffect(room, 0);
this.reset(room);
}
}
private void setEffect(Room room, int effectId)
{
if (this.roomUnitId == -1) return;
room.giveEffect(getCurrentRoomUnit(room), effectId);
}
private void reset(Room room)
{
this.roomUnitId = -1;
this.startTime = 0;
this.setExtradata("0");
room.updateItem(this);
}
private RoomUnit getCurrentRoomUnit(Room room)
{
Habbo habbo = room.getHabboByRoomUnitId(this.roomUnitId);
if (habbo != null)
{
return habbo.getRoomUnit();
}
else
{
Bot bot = room.getBotByRoomUnitId(this.roomUnitId);
if (bot != null)
{
return bot.getRoomUnit();
}
}
return null;
}
}

View File

@ -0,0 +1,63 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionHanditem extends InteractionDefault
{
public InteractionHanditem(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionHanditem(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
{
super.onClick(client, room, objects);
if (RoomLayout.tilesAdjecent(client.getHabbo().getRoomUnit().getCurrentLocation(), room.getLayout().getTile(this.getX(), this.getY())) ||
(client.getHabbo().getRoomUnit().getCurrentLocation().x == this.getX() && client.getHabbo().getRoomUnit().getCurrentLocation().y == this.getY()))
{
this.handle(room, client.getHabbo().getRoomUnit());
}
}
protected void handle(Room room, RoomUnit roomUnit)
{
if (this.getExtradata().isEmpty()) this.setExtradata("0");
if (!this.getExtradata().equals("0")) return;
HabboItem instance = this;
room.giveHandItem(roomUnit, this.getBaseItem().getRandomVendingItem());
if (this.getBaseItem().getStateCount() > 1)
{
this.setExtradata("1");
room.updateItem(this);
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
setExtradata("0");
room.updateItem(instance);
}
}, 500);
}
}
}

View File

@ -0,0 +1,39 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionHanditemTile extends InteractionHanditem
{
public InteractionHanditemTile(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionHanditemTile(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
InteractionHanditemTile instance = this;
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
if (roomUnit.getCurrentLocation().x == instance.getX() && roomUnit.getCurrentLocation().y == instance.getY())
{
instance.handle(room, roomUnit);
}
}
}, 3000);
}
}

View File

@ -11,7 +11,7 @@ public class InteractionInformationTerminal extends InteractionCustomValues
{
public static THashMap<String, String> defaultValues = new THashMap<String, String>()
{
{put("internalLink", "http://arcturus.wf");}
{put("internalLink", "http://arcturus.pw");}
};
public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException

View File

@ -0,0 +1,79 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionMonsterCrackable extends InteractionCrackable implements ICycleable
{
private int lastHealthChange = 0;
private boolean respawn = false;
public InteractionMonsterCrackable(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public InteractionMonsterCrackable(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
@Override
public void cycle(Room room)
{
if (this.ticks > 0 && Emulator.getIntUnixTimestamp() - lastHealthChange > 30)
{
lastHealthChange = Emulator.getIntUnixTimestamp();
this.ticks--;
room.updateItem(this);
}
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
{
if (room.isPublicRoom()) respawn = true;
super.onClick(client, room, objects);
}
@Override
public boolean resetable()
{
return this.respawn;
}
@Override
public void reset(Room room)
{
RoomTile tile = room.getRandomWalkableTile();
this.setX(tile.x);
this.setY(tile.y);
this.setZ(room.getStackHeight(tile.x, tile.y, false));
super.reset(room);
}
@Override
public boolean allowAnyone()
{
return this.respawn;
}
@Override
public boolean isUsable()
{
return true;
}
@Override
protected boolean placeInRoom()
{
return this.respawn;
}
}

View File

@ -11,7 +11,6 @@ import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.UpdateStackHeightComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import gnu.trove.set.hash.THashSet;
@ -77,7 +76,7 @@ public class InteractionMultiHeight extends HabboItem
this.needsUpdate(true);
room.updateTiles(room.getLayout().getTilesAt(room.getLayout().getTile(this.getX(), this.getY()), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation()));
room.updateItemState(this);
room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.valueOf(this.getExtradata())] * 256.0D).compose());
//room.sendComposer(new UpdateStackHeightComposer(this.getX(), this.getY(), this.getBaseItem().getMultiHeights()[Integer.valueOf(this.getExtradata())] * 256.0D).compose());
}
if(this.isWalkable())
@ -100,7 +99,7 @@ public class InteractionMultiHeight extends HabboItem
}
else
{
habbo.getRoomUnit().setZ(this.getZ() + this.getBaseItem().getMultiHeights()[(this.getExtradata().isEmpty() ? 0 : Integer.valueOf(this.getExtradata()) % (this.getBaseItem().getMultiHeights().length))]);
habbo.getRoomUnit().setZ(habbo.getRoomUnit().getCurrentLocation().getStackHeight());
habbo.getRoomUnit().setPreviousLocationZ(habbo.getRoomUnit().getZ());
}
}

View File

@ -1,13 +1,20 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.pets.PetManager;
import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.pets.PetPackageNameValidationComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.breeding.PetBreedingCompleted;
import com.eu.habbo.messages.outgoing.rooms.pets.breeding.PetBreedingResultComposer;
import com.eu.habbo.threading.runnables.QueryDeleteHabboItem;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -68,12 +75,14 @@ public class InteractionPetBreedingNest extends HabboItem
if (boxFull())
{
Habbo ownerPetOne = room.getHabbo(petOne.getUserId());
Habbo ownerPetTwo = room.getHabbo(petTwo.getUserId());
Habbo ownerPetOne = room.getHabbo(this.petOne.getUserId());
Habbo ownerPetTwo = room.getHabbo(this.petTwo.getUserId());
if (ownerPetOne != null && ownerPetTwo != null)
if (ownerPetOne != null && ownerPetTwo != null && this.petOne.getPetData().getType() == this.petTwo.getPetData().getType() && this.petOne.getPetData().getOffspringType() != -1)
{
ownerPetTwo.getClient().sendResponse(new PetBreedingResultComposer(0, this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername()));
ownerPetTwo.getClient().sendResponse(new PetBreedingResultComposer(this.getId(), this.petOne.getPetData().getOffspringType(), this.petOne, ownerPetOne.getHabboInfo().getUsername(), this.petTwo, ownerPetTwo.getHabboInfo().getUsername()));
this.setExtradata("1");
room.updateItem(this);
}
}
}
@ -85,11 +94,13 @@ public class InteractionPetBreedingNest extends HabboItem
if (this.petOne == null)
{
this.petOne = pet;
this.petOne.getRoomUnit().setCanWalk(false);
return true;
}
else if (this.petTwo == null && this.petOne != pet)
{
this.petTwo = pet;
this.petTwo.getRoomUnit().setCanWalk(false);
return true;
}
@ -101,9 +112,94 @@ public class InteractionPetBreedingNest extends HabboItem
return this.petOne != null && this.petTwo != null;
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
if (this.petOne != null && this.petOne.getRoomUnit() == roomUnit) this.petOne = null;
if (this.petTwo != null && this.petTwo.getRoomUnit() == roomUnit) this.petTwo = null;
this.setExtradata("0");
room.updateItem(this);
}
@Override
public boolean allowWiredResetState()
{
return false;
}
public void stopBreeding(Habbo habbo)
{
this.setExtradata("0");
habbo.getHabboInfo().getCurrentRoom().updateItem(this);
if (this.petOne != null)
{
habbo.getClient().sendResponse(new PetPackageNameValidationComposer(this.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
}
if (this.petTwo.getUserId() != habbo.getHabboInfo().getId())
{
Habbo owner = this.petTwo.getRoom().getHabbo(this.petTwo.getUserId());
if (owner != null)
{
owner.getClient().sendResponse(new PetPackageNameValidationComposer(this.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
}
}
this.freePets();
}
private void freePets()
{
if (this.petOne != null)
{
this.petOne.getRoomUnit().setCanWalk(true);
this.petOne.setTask(PetTasks.FREE);
this.petOne = null;
}
if (this.petTwo != null)
{
this.petTwo.getRoomUnit().setCanWalk(true);
this.petTwo.setTask(PetTasks.FREE);
this.petTwo = null;
}
}
public void breed(Habbo habbo, String name, int petOneId, int petTwoId)
{
Emulator.getThreading().run(new QueryDeleteHabboItem(this));
this.setExtradata("2");
habbo.getHabboInfo().getCurrentRoom().updateItem(this);
HabboItem box = this;
Pet petOne = this.petOne;
Pet petTwo = this.petTwo;
Emulator.getThreading().run(new Runnable()
{
@Override
public void run()
{
Pet offspring = Emulator.getGameEnvironment().getPetManager().createPet(petOne.getPetData().getOffspringType(), (int) Math.min(Math.round(Math.max(1d, PetManager.getNormalDistributionForBreeding(petOne.getLevel(), petTwo.getLevel()).sample())), 20), name, habbo.getClient());
//habbo.getClient().sendResponse(new PetPackageNameValidationComposer(box.getId(), PetPackageNameValidationComposer.CLOSE_WIDGET, ""));
habbo.getHabboInfo().getCurrentRoom().placePet(offspring, box.getX(), box.getY(), box.getZ(), box.getRotation());
offspring.needsUpdate = true;
offspring.run();
freePets();
habbo.getHabboInfo().getCurrentRoom().removeHabboItem(box);
habbo.getClient().sendResponse(new PetBreedingCompleted(offspring.getId(), Emulator.getGameEnvironment().getPetManager().getRarityForOffspring(offspring)));
if (box.getBaseItem().getName().startsWith("pet_breeding_"))
{
String boxType = box.getBaseItem().getName().replace("pet_breeding_", "");
String achievement = boxType.substring(0, 1).toUpperCase() + boxType.substring(1) + "Breeder";
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(achievement));
}
}
}, 2000);
}
}

View File

@ -90,8 +90,13 @@ public class InteractionPressurePlate extends HabboItem
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
{
this.setExtradata("0");
room.updateItemState(this);
super.onMove(room, oldLocation, newLocation);
if (oldLocation != newLocation && oldLocation.getStackHeight() != newLocation.getStackHeight() && !room.hasHabbosAt(newLocation.x, newLocation.y))
{
this.setExtradata("0");
room.updateItemState(this);
}
}
@Override
@ -99,4 +104,6 @@ public class InteractionPressurePlate extends HabboItem
{
return true;
}
}

View File

@ -3,12 +3,16 @@ package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class InteractionRoller extends HabboItem
{
@ -66,4 +70,28 @@ public class InteractionRoller extends HabboItem
{
super.onWalkOff(roomUnit, room, objects);
}
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation)
{
if (itemsAtLocation.isEmpty()) return false;
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation)
{
if (!set.getValue().isEmpty())
{
if (set.getValue().size() > 1)
{
return false;
}
else if (!set.getValue().contains(this))
{
return false;
}
}
}
return true;
}
}

View File

@ -12,8 +12,8 @@ public class InteractionRoomAds extends InteractionCustomValues
{
public final static THashMap<String, String> defaultValues = new THashMap<String, String>()
{
{put("imageUrl", "http://arcturus.wf/ads_background.png");}
{put("clickUrl", "http://arcturus.wf");}
{put("imageUrl", "http://arcturus.pw/ads_background.png");}
{put("clickUrl", "http://arcturus.pw");}
{put("offsetX", "0");}
{put("offsetY", "0");}
{put("offsetZ", "0");}

View File

@ -0,0 +1,104 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.Achievement;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.set.hash.THashSet;
import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionSnowboardSlope extends InteractionMultiHeight
{
public InteractionSnowboardSlope(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
}
public InteractionSnowboardSlope(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
@Override
public void onWalkOn(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
room.giveEffect(roomUnit, 97);
}
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception
{
super.onWalkOff(roomUnit, room, objects);
if (roomUnit.getEffectId() == 97)
{
room.giveEffect(roomUnit, 0);
}
}
@Override
public void onPlace(Room room)
{
super.onPlace(room);
THashSet<HabboItem> items = room.getRoomSpecialTypes().getItemsOfType(InteractionSnowboardSlope.class);
Achievement snowboardBuild = Emulator.getGameEnvironment().getAchievementManager().getAchievement("snowBoardBuild");
if (snowboardBuild == null) return;
int progress = 0;
Habbo habbo = room.getHabbo(room.getOwnerId());
if (habbo != null)
{
progress = habbo.getHabboStats().getAchievementProgress(snowboardBuild);
}
else
{
progress = AchievementManager.getAchievementProgressForHabbo(room.getOwnerId(), snowboardBuild);
}
progress = Math.max(items.size() - progress, 0);
if (progress > 0)
{
AchievementManager.progressAchievement(room.getOwnerId(), snowboardBuild);
}
}
@Override
public void onPickUp(Room room)
{
for (Habbo habbo : room.getHabbosOnItem(this))
{
if (habbo.getRoomUnit().getEffectId() == 97)
{
room.giveEffect(habbo, 0);
}
}
}
@Override
public void onMove(Room room, RoomTile oldLocation, RoomTile newLocation)
{
Rectangle newRect = RoomLayout.getRectangle(newLocation.x, newLocation.y, this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
for (Habbo habbo : room.getHabbosOnItem(this))
{
if (habbo.getRoomUnit().getEffectId() == 97 && !newRect.contains(habbo.getRoomUnit().getCurrentLocation().x, habbo.getRoomUnit().getCurrentLocation().y))
{
room.giveEffect(habbo, 0);
}
}
}
}

View File

@ -24,13 +24,13 @@ public class InteractionStackHelper extends HabboItem
@Override
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects)
{
return true;
return false;
}
@Override
public boolean isWalkable()
{
return true;
return false;
}
@Override

View File

@ -1,8 +1,10 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
import java.sql.ResultSet;
@ -37,4 +39,27 @@ public class InteractionSwitch extends InteractionDefault
{
return true;
}
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception
{
if (!this.canToggle(client.getHabbo(), room))
{
RoomTile closestTile = null;
for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY())))
{
if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation())))
{
closestTile = client.getHabbo().getRoomUnit().getCurrentLocation();
}
}
if (closestTile != null)
{
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
}
}
super.onClick(client, room, objects);
}
}

View File

@ -79,7 +79,7 @@ public class InteractionTeleport extends HabboItem
});
}
}
else if (teleportPosition.equals(client.getHabbo().getRoomUnit().getCurrentLocation()))
else if (teleportPosition.equals(client.getHabbo().getRoomUnit().getCurrentLocation()) && tile != null && tile.isWalkable())
{
startTeleport(room, client.getHabbo());
}

View File

@ -4,6 +4,7 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.FloorItemUpdateComposer;
@ -20,11 +21,13 @@ public class InteractionVendingMachine extends HabboItem
public InteractionVendingMachine(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
this.setExtradata("0");
}
public InteractionVendingMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
this.setExtradata("0");
}
@Override
@ -65,11 +68,14 @@ public class InteractionVendingMachine extends HabboItem
room.scheduledComposers.add(new FloorItemUpdateComposer(this).compose());
Emulator.getThreading().run(this, 1000);
Emulator.getThreading().run(new RoomUnitGiveHanditem(client.getHabbo().getRoomUnit(), room, this.getBaseItem().getRandomVendingItem()));
if (this.getBaseItem().getEffectM() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.M) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectM());
if (this.getBaseItem().getEffectF() > 0 && client.getHabbo().getHabboInfo().getGender() == HabboGender.F) room.giveEffect(client.getHabbo(), this.getBaseItem().getEffectF());
}
}
else
{
if (!tile.isWalkable())
if (!tile.isWalkable() && tile.state != RoomTileState.SIT && tile.state != RoomTileState.LAY)
{
for (RoomTile t : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY())))
{

View File

@ -1,18 +1,23 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.util.Pair;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class InteractionWater extends InteractionDefault
{
@ -36,6 +41,28 @@ public class InteractionWater extends InteractionDefault
public void onPickUp(Room room)
{
this.recalculate(room);
Object[] empty = new Object[]{};
for (Habbo habbo : room.getHabbosOnItem(this))
{
try
{
this.onWalkOff(habbo.getRoomUnit(), room, empty);
} catch (Exception e)
{
}
}
for (Bot bot : room.getBotsOnItem(this))
{
try
{
this.onWalkOff(bot.getRoomUnit(), room, empty);
}
catch (Exception e)
{}
}
}
@Override
@ -69,27 +96,46 @@ public class InteractionWater extends InteractionDefault
((InteractionWaterItem) item).update();
}
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() - 1)) _1 = 1;
if (room.waterTiles.containsKey(this.getX() ) && room.waterTiles.get(this.getX() ).contains(this.getY() - 1)) _2 = 1;
if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() - 1)) _3 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() - 1)) _4 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() )) _5 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() )) _6 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 1)) _7 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 1)) _8 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 2)) _9 = 1;
if (room.waterTiles.containsKey(this.getX() ) && room.waterTiles.get(this.getX() ).contains(this.getY() + 2)) _10 = 1;
if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() + 2)) _11 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 2)) _12 = 1;
if (!this.getBaseItem().getName().equalsIgnoreCase("bw_water_2"))
{
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() - 1))
_1 = 1;
if (room.waterTiles.containsKey(this.getX()) && room.waterTiles.get(this.getX()).contains(this.getY() - 1))
_2 = 1;
if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() - 1))
_3 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() - 1))
_4 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY()))
_5 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY()))
_6 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 1))
_7 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 1))
_8 = 1;
if (room.waterTiles.containsKey(this.getX() - 1) && room.waterTiles.get(this.getX() - 1).contains(this.getY() + 2))
_9 = 1;
if (room.waterTiles.containsKey(this.getX()) && room.waterTiles.get(this.getX()).contains(this.getY() + 2))
_10 = 1;
if (room.waterTiles.containsKey(this.getX() + 1) && room.waterTiles.get(this.getX() + 1).contains(this.getY() + 2))
_11 = 1;
if (room.waterTiles.containsKey(this.getX() + 2) && room.waterTiles.get(this.getX() + 2).contains(this.getY() + 2))
_12 = 1;
}
if (_2 == 0 && !room.getLayout().tileWalkable(this.getX() , (short) (this.getY() - 1))) _2 = 1;
if (_3 == 0 && !room.getLayout().tileWalkable((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1;
if (_5 == 0 && !room.getLayout().tileWalkable((short) (this.getX() - 1), this.getY() )) _5 = 1;
if (_6 == 0 && !room.getLayout().tileWalkable((short) (this.getX() + 2), this.getY() )) _6 = 1;
if (_7 == 0 && !room.getLayout().tileWalkable((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1;
if (_8 == 0 && !room.getLayout().tileWalkable((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1;
if (_10 == 0 && !room.getLayout().tileWalkable(this.getX() , (short) (this.getY() + 2))) _10 = 1;
if (_11 == 0 && !room.getLayout().tileWalkable((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1;
//if (_1 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() -1))) _1 = 1;
if (_2 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() - 1))) _2 = 1;
if (_3 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() - 1))) _3 = 1;
//if (_4 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() - 1))) _4 = 1;
if (_5 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), this.getY())) _5 = 1;
if (_6 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), this.getY())) _6 = 1;
if (_7 == 0 && room.getLayout().isVoidTile((short) (this.getX() - 1), (short) (this.getY() + 1))) _7 = 1;
if (_8 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 1))) _8 = 1;
//if (_9 == 0 && room.getLayout().isVoidTile((short)(this.getX() -1), (short) (this.getY() + 2))) _9 = 1;
if (_10 == 0 && room.getLayout().isVoidTile(this.getX(), (short) (this.getY() + 2))) _10 = 1;
if (_11 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 1), (short) (this.getY() + 2))) _11 = 1;
//if (_12 == 0 && room.getLayout().isVoidTile((short) (this.getX() + 2), (short) (this.getY() + 2))) _12 = 1;
int result = 0;
result |= _1 << 11;
@ -157,4 +203,27 @@ public class InteractionWater extends InteractionDefault
{
return false;
}
@Override
public boolean canToggle(Habbo habbo, Room room)
{
return false;
}
@Override
public boolean canStackAt(Room room, List<Pair<RoomTile, THashSet<HabboItem>>> itemsAtLocation)
{
for (Pair<RoomTile, THashSet<HabboItem>> set : itemsAtLocation)
{
for (HabboItem item : set.getValue())
{
if (!(item instanceof InteractionWater))
{
return false;
}
}
}
return super.canStackAt(room, itemsAtLocation);
}
}

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import gnu.trove.set.hash.THashSet;
@ -52,25 +53,40 @@ public class InteractionWaterItem extends InteractionDefault
Rectangle rectangle = RoomLayout.getRectangle(this.getX(), this.getY(), this.getBaseItem().getWidth(), this.getBaseItem().getLength(), this.getRotation());
for(int x = rectangle.x; x < rectangle.getWidth() + rectangle.x; x++)
boolean foundWater = true;
for(short x = (short)rectangle.x; x < rectangle.getWidth() + rectangle.x && foundWater; x++)
{
for(int y = rectangle.y; y < rectangle.getHeight() + rectangle.y; y++)
for(short y = (short)rectangle.y; y < rectangle.getHeight() + rectangle.y && foundWater; y++)
{
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(this.getX(), this.getY()));
boolean tile = false;
THashSet<HabboItem> items = room.getItemsAt(room.getLayout().getTile(x, y));
for(HabboItem item : items)
{
if(item instanceof InteractionWater)
if (item instanceof InteractionWater)
{
this.setExtradata("1");
room.updateItem(this);
return;
tile = true;
break;
}
}
if (!tile)
{
foundWater = false;
}
}
}
if (foundWater)
{
this.setExtradata("1");
this.needsUpdate(true);
room.updateItem(this);
return;
}
this.setExtradata("0");
this.needsUpdate(true);
room.updateItem(this);
}
@ -79,4 +95,10 @@ public class InteractionWaterItem extends InteractionDefault
{
return false;
}
@Override
public boolean canToggle(Habbo habbo, Room room)
{
return false;
}
}

View File

@ -118,11 +118,13 @@ public abstract class InteractionWired extends HabboItem
{
return false;
}
this.cooldown = newMillis;
return true;
}
public void setCooldown(long newMillis)
{
this.cooldown = newMillis;
}
@Override
public boolean allowWiredResetState()
{

View File

@ -4,6 +4,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.outgoing.wired.WiredConditionDataComposer;
@ -70,4 +71,9 @@ public abstract class InteractionWiredCondition extends InteractionWired
public abstract boolean saveData(ClientMessage packet);
public WiredConditionOperator operator()
{
return WiredConditionOperator.AND;
}
}

View File

@ -41,7 +41,7 @@ public class InteractionBattleBanzaiTile extends HabboItem
@Override
public boolean isWalkable()
{
return false;
return true;
}
@Override

View File

@ -1,9 +1,12 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -11,17 +14,20 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;
public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition
{
public static final WiredConditionType type = WiredConditionType.FURNI_HAVE_HABBO;
private boolean all;
private THashSet<HabboItem> items;
protected boolean all;
protected THashSet<HabboItem> items;
public WiredConditionFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException
{
@ -50,14 +56,50 @@ public class WiredConditionFurniHaveHabbo extends InteractionWiredCondition
if(this.items.isEmpty())
return true;
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
for(HabboItem item : this.items)
{
THashSet<Habbo> habbos = room.getHabbosOnItem(item);
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
}
if(habbos.isEmpty())
Collection<Habbo> habbos = room.getHabbos();
Collection<Bot> bots = room.getCurrentBots().valueCollection();
Collection<Pet> pets = room.getCurrentPets().valueCollection();
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet())
{
boolean found = false;
for (Habbo habbo : habbos)
{
return false;
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation()))
{
found = true;
}
}
if (!found)
{
for (Bot bot : bots)
{
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation()))
{
found = true;
}
}
}
if (!found)
{
for (Pet pet : pets)
{
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation()))
{
found = true;
}
}
}
if (!found) return false;
}
return true;

View File

@ -4,6 +4,7 @@ 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.habbohotel.wired.WiredConditionOperator;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -29,7 +30,7 @@ public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge
{
try
{
return habbo.getHabboInfo().getRank().getId() >= Integer.valueOf(this.badge);
return habbo.getHabboInfo().getRank().getId() == Integer.valueOf(this.badge);
}
catch (Exception e)
{
@ -39,4 +40,10 @@ public class WiredConditionHabboHasRank extends WiredConditionHabboWearsBadge
return false;
}
@Override
public WiredConditionOperator operator()
{
return WiredConditionOperator.OR;
}
}

View File

@ -4,6 +4,7 @@ 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.habbohotel.wired.WiredConditionOperator;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -29,7 +30,7 @@ public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge
{
try
{
return habbo.getHabboInfo().getRank().getId() < Integer.valueOf(this.badge);
return habbo.getHabboInfo().getRank().getId() != Integer.valueOf(this.badge);
}
catch (Exception e)
{
@ -39,4 +40,10 @@ public class WiredConditionHabboNotRank extends WiredConditionHabboWearsBadge
return false;
}
@Override
public WiredConditionOperator operator()
{
return WiredConditionOperator.OR;
}
}

View File

@ -97,7 +97,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
HabboItem item = room.getHabboItem(itemId);
if (item != null)
this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY(), item.getZ()));
this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()));
}
return true;
@ -125,7 +125,7 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
if(this.position)
{
if(!(setting.x == item.getX() && setting.y == item.getY() && setting.z == item.getZ()))
if(!(setting.x == item.getX() && setting.y == item.getY()))
return false;
}
@ -185,8 +185,8 @@ public class WiredConditionMatchStatePosition extends InteractionWiredCondition
{
String[] stuff = items[i].split("-");
if(stuff.length == 6)
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]), Double.valueOf(stuff[5])));
if(stuff.length >= 5)
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
}
this.state = data[2].equals("1");

View File

@ -5,6 +5,7 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
@ -91,4 +92,10 @@ public class WiredConditionMottoContains extends InteractionWiredCondition
return true;
}
@Override
public WiredConditionOperator operator()
{
return WiredConditionOperator.OR;
}
}

View File

@ -1,9 +1,12 @@
package com.eu.habbo.habbohotel.items.interactions.wired.conditions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
@ -11,28 +14,38 @@ import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;
public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition
{
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_HABBO;
private boolean all;
private THashSet<HabboItem> items;
protected boolean all;
protected THashSet<HabboItem> items;
public WiredConditionNotFurniHaveHabbo(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
this.items = new THashSet<>();
items = new THashSet<>();
}
public WiredConditionNotFurniHaveHabbo(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells)
{
super(id, userId, item, extradata, limitedStack, limitedSells);
this.items = new THashSet<>();
items = new THashSet<>();
}
@Override
public void onPickUp()
{
this.items.clear();
this.all = false;
}
@Override
@ -43,15 +56,54 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition
if(this.items.isEmpty())
return true;
THashMap<HabboItem, THashSet<RoomTile>> tiles = new THashMap<>();
for(HabboItem item : this.items)
{
THashSet<Habbo> habbos = room.getHabbosOnItem(item);
if(habbos.isEmpty())
return true;
tiles.put(item, room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
}
return false;
Collection<Habbo> habbos = room.getHabbos();
Collection<Bot> bots = room.getCurrentBots().valueCollection();
Collection<Pet> pets = room.getCurrentPets().valueCollection();
for (Map.Entry<HabboItem, THashSet<RoomTile>> set : tiles.entrySet())
{
if (!habbos.isEmpty())
{
for (Habbo habbo : habbos)
{
if (set.getValue().contains(habbo.getRoomUnit().getCurrentLocation()))
{
return false;
}
}
}
if (!bots.isEmpty())
{
for (Bot bot : bots)
{
if (set.getValue().contains(bot.getRoomUnit().getCurrentLocation()))
{
return false;
}
}
}
if (!pets.isEmpty())
{
for (Pet pet : pets)
{
if (set.getValue().contains(pet.getRoomUnit().getCurrentLocation()))
{
return false;
}
}
}
}
return true;
}
@Override
@ -95,13 +147,6 @@ public class WiredConditionNotFurniHaveHabbo extends InteractionWiredCondition
}
}
@Override
public void onPickUp()
{
this.items.clear();
this.all = false;
}
@Override
public WiredConditionType getType()
{

View File

@ -60,7 +60,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
if(this.position)
{
if((setting.x == item.getX() && setting.y == item.getY() && setting.z == item.getZ()))
if((setting.x == item.getX() && setting.y == item.getY()))
return false;
}
@ -120,8 +120,8 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
{
String[] stuff = items[i].split("-");
if(stuff.length == 6)
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]), Double.valueOf(stuff[5])));
if(stuff.length >= 5)
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
}
this.state = data[2].equals("1");
@ -197,7 +197,7 @@ public class WiredConditionNotMatchStatePosition extends InteractionWiredConditi
HabboItem item = room.getHabboItem(itemId);
if (item != null)
this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY(), item.getZ()));
this.settings.add(new WiredMatchFurniSetting(item.getId(), item.getExtradata(), item.getRotation(), item.getX(), item.getY()));
}
return true;

View File

@ -6,7 +6,6 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@ -41,11 +40,6 @@ public class WiredConditionNotTriggerOnFurni extends InteractionWiredCondition
if(this.items.isEmpty())
return true;
Habbo habbo = room.getHabbo(roomUnit);
if(habbo == null)
return true;
for(HabboItem item : this.items)
{
if(RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))

View File

@ -6,8 +6,8 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredCondition;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredConditionOperator;
import com.eu.habbo.habbohotel.wired.WiredConditionType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ClientMessage;
@ -41,11 +41,6 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition
if(this.items.isEmpty())
return true;
Habbo habbo = room.getHabbo(roomUnit);
if(habbo == null)
return true;
for(HabboItem item : this.items)
{
if(RoomLayout.getRectangle(item.getX(), item.getY(), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()).contains(roomUnit.getX(), roomUnit.getY()))
@ -170,4 +165,10 @@ public class WiredConditionTriggerOnFurni extends InteractionWiredCondition
this.items.removeAll(items);
}
@Override
public WiredConditionOperator operator()
{
return WiredConditionOperator.OR;
}
}

View File

@ -120,7 +120,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect
int currentEffect = bot.getRoomUnit().getEffectId();
room.giveEffect(bot.getRoomUnit(), 4);
Emulator.getThreading().run(new RoomUnitTeleport(bot.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + (item.getBaseItem().allowSit() ? item.getBaseItem().getHeight() - 0.50 : 0D), currentEffect));
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? - 0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
break;
} else
{

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
@ -77,16 +78,45 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect
{
RoomTile t = room.getLayout().getTile((short) setting.x, (short) setting.y);
if (t.state == RoomTileState.OPEN)
if (t != null)
{
if (!room.hasHabbosAt(t.x, t.y))
if (t.state != RoomTileState.INVALID)
{
tilesToUpdate.addAll(room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
if (!room.hasHabbosAt(t.x, t.y))
{
THashSet<RoomTile> tiles = room.getLayout().getTilesAt(t, item.getBaseItem().getWidth(), item.getBaseItem().getLength(), setting.rotation);
double highestZ = -1d;
for (RoomTile tile : tiles)
{
if (tile.state == RoomTileState.INVALID)
{
highestZ = -1d;
break;
}
double offsetZ = setting.z - item.getZ();
if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y))
{
highestZ = -1d;
break;
}
room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
double stackHeight = room.getStackHeight(tile.x, tile.y, false, item);
if (stackHeight > highestZ)
{
highestZ = stackHeight;
}
}
if (highestZ != -1d)
{
tilesToUpdate.addAll(tiles);
double offsetZ = highestZ - item.getZ();
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), oldRotation));
room.sendComposer(new FloorItemOnRollerComposer(item, null, t, offsetZ, room).compose());
}
}
}
}
}
@ -152,8 +182,10 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect
String[] stuff = items[i].split("-");
if (stuff.length == 6)
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4]), Double.valueOf(stuff[5])));
if (stuff.length >= 5)
{
this.settings.add(new WiredMatchFurniSetting(Integer.valueOf(stuff[0]), stuff[1], Integer.valueOf(stuff[2]), Integer.valueOf(stuff[3]), Integer.valueOf(stuff[4])));
}
}
catch (Exception e)
@ -239,7 +271,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect
HabboItem item = room.getHabboItem(itemId);
if (item != null)
this.settings.add(new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY(), item.getZ()));
this.settings.add(new WiredMatchFurniSetting(item.getId(), this.checkForWiredResetPermission && item.allowWiredResetState() ? item.getExtradata() : " ", item.getRotation(), item.getX(), item.getY()));
}
this.setDelay(packet.readInt());
@ -251,7 +283,7 @@ public class WiredEffectMatchFurni extends InteractionWiredEffect
{
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
if(room != null)
if(room != null && room.isLoaded())
{
THashSet<WiredMatchFurniSetting> remove = new THashSet<>();

View File

@ -79,65 +79,62 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect
{
List<HabboItem> items = new ArrayList<>();
synchronized (this.items)
{
for (HabboItem item : this.items)
{
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : this.items)
{
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
if (this.items.isEmpty())
return false;
if (this.items.isEmpty())
return false;
if (stuff != null && stuff.length > 0)
{
for (Object object : stuff)
{
if (object instanceof HabboItem)
{
HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size()));
if (stuff != null && stuff.length > 0)
{
for (Object object : stuff)
{
if (object instanceof HabboItem)
{
HabboItem targetItem = this.items.get(Emulator.getRandom().nextInt(this.items.size()));
if (targetItem != null)
{
int indexOffset = 0;
if (!this.indexOffset.containsKey(targetItem.getId()))
{
this.indexOffset.put(targetItem.getId(), indexOffset);
}
else
{
indexOffset = this.indexOffset.get(targetItem.getId()) + spacing;
}
if (targetItem != null)
{
int indexOffset = 0;
if (!this.indexOffset.containsKey(targetItem.getId()))
{
this.indexOffset.put(targetItem.getId(), indexOffset);
}
else
{
indexOffset = this.indexOffset.get(targetItem.getId()) + spacing;
}
RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY());
RoomTile objectTile = room.getLayout().getTile(targetItem.getX(), targetItem.getY());
if (objectTile != null)
{
THashSet<RoomTile> refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation());
if (objectTile != null)
{
THashSet<RoomTile> refreshTiles = room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation());
RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
if (tile == null || !tile.getAllowStack())
{
indexOffset = 0;
tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
}
RoomTile tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
if (tile == null || !tile.getAllowStack())
{
indexOffset = 0;
tile = room.getLayout().getTileInFront(objectTile, this.direction, indexOffset);
}
room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose());
refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()));
room.updateTiles(refreshTiles);
this.indexOffset.put(targetItem.getId(), indexOffset);
}
}
}
}
}
}
room.sendComposer(new FloorItemOnRollerComposer((HabboItem) object, null, tile, tile.getStackHeight() - ((HabboItem) object).getZ(), room).compose());
refreshTiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(((HabboItem) object).getX(), ((HabboItem) object).getY()), ((HabboItem) object).getBaseItem().getWidth(), ((HabboItem) object).getBaseItem().getLength(), ((HabboItem) object).getRotation()));
room.updateTiles(refreshTiles);
this.indexOffset.put(targetItem.getId(), indexOffset);
}
}
}
}
}
return true;
}
@ -173,67 +170,61 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect
{
THashSet<HabboItem> items = new THashSet<>();
synchronized (this.items)
{
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
message.appendInt(item.getId());
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(2);
message.appendInt(this.direction);
message.appendInt(this.spacing);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(this.getDelay());
message.appendInt(0);
}
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
message.appendInt(item.getId());
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(2);
message.appendInt(this.direction);
message.appendInt(this.spacing);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(this.getDelay());
message.appendInt(0);
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
synchronized (this.items)
{
this.items.clear();
this.items.clear();
String[] data = set.getString("wired_data").split("\t");
String[] data = set.getString("wired_data").split("\t");
if (data.length == 4)
{
try
{
this.direction = Integer.valueOf(data[0]);
this.spacing = Integer.valueOf(data[1]);
this.setDelay(Integer.valueOf(data[2]));
}
catch (Exception e)
{
}
if (data.length == 4)
{
try
{
this.direction = Integer.valueOf(data[0]);
this.spacing = Integer.valueOf(data[1]);
this.setDelay(Integer.valueOf(data[2]));
}
catch (Exception e)
{
}
for (String s : data[3].split("\r"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
for (String s : data[3].split("\r"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
if (item != null)
this.items.add(item);
}
}
}
if (item != null)
this.items.add(item);
}
}
}
@Override

View File

@ -3,6 +3,7 @@ package com.eu.habbo.habbohotel.items.interactions.wired.effects;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionRoller;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.rooms.*;
import com.eu.habbo.habbohotel.users.Habbo;
@ -42,142 +43,166 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
THashSet<HabboItem> items = new THashSet<>();
THashSet<RoomTile> tilesToUpdate = new THashSet<>();
for (HabboItem item : this.items)
{
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
synchronized (this.items)
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : this.items)
{
if (this.rotation > 0)
{
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
if (this.rotation == 1)
{
item.setRotation(item.getRotation() + 2);
}
else if (this.rotation == 2)
{
item.setRotation(item.getRotation() + 6);
}
else if (this.rotation == 3)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
item.setRotation(item.getRotation() + 2);
}
else
{
item.setRotation(item.getRotation() + 6);
}
}
if (this.direction == 0)
{
tilesToUpdate.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
room.sendComposer(new FloorItemUpdateComposer(item).compose());
}
}
if (this.direction > 0)
{
RoomUserRotation moveDirection = RoomUserRotation.NORTH;
if (this.direction == 1)
{
moveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length)];
}
else if (this.direction == 2)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
moveDirection = RoomUserRotation.EAST;
}
else
{
moveDirection = RoomUserRotation.WEST;
}
}
else if (this.direction == 3)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
moveDirection = RoomUserRotation.NORTH;
}
else
{
moveDirection = RoomUserRotation.SOUTH;
}
}
else if (this.direction == 4)
{
moveDirection = RoomUserRotation.SOUTH;
}
else if (this.direction == 5)
{
moveDirection = RoomUserRotation.EAST;
}
else if (this.direction == 6)
{
moveDirection = RoomUserRotation.NORTH;
}
else if (this.direction == 7)
{
moveDirection = RoomUserRotation.WEST;
}
RoomTile newTile = room.getLayout().getTile(
(short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))),
(short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0)))
);
if (newTile != null)
{
boolean hasHabbos = false;
for (Habbo habbo : room.getHabbosAt(newTile))
{
hasHabbos = true;
WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item});
}
if (!hasHabbos && room.getStackHeight(newTile.x, newTile.y, true, item) != Short.MAX_VALUE)
{
Rectangle rectangle = new Rectangle(newTile.x,
newTile.y,
item.getBaseItem().getWidth(),
item.getBaseItem().getLength());
double offset = -Short.MAX_VALUE;
boolean validMove = true;
for (short x = (short)rectangle.x; x < rectangle.x + rectangle.getWidth(); x++)
{
for (short y = (short)rectangle.y; y < rectangle.y + rectangle.getHeight(); y++)
{
RoomTile tile = room.getLayout().getTile(x, y);
if (tile.state == RoomTileState.INVALID || !tile.getAllowStack())
{
validMove = false;
break;
}
if (item instanceof InteractionRoller && room.hasItemsAt(tile.x, tile.y))
{
validMove = false;
break;
}
HabboItem i = room.getTopItemAt(x, y, item);
if (i == null || i == item || i.getBaseItem().allowStack())
{
offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
}
tilesToUpdate.add(tile);
}
}
if (item.getZ() + offset > 40)
{
offset = 40 - item.getZ();
}
if (validMove)
{
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose());
}
}
}
}
}
if (!tilesToUpdate.isEmpty())
{
for (HabboItem item : this.items)
{
if (Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : this.items)
{
if (this.rotation > 0)
{
THashSet<RoomTile> tiles = room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation());
if (this.rotation == 1)
{
item.setRotation(item.getRotation() + 2);
}
else if (this.rotation == 2)
{
item.setRotation(item.getRotation() + 6);
}
else if (this.rotation == 3)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
item.setRotation(item.getRotation() + 2);
}
else
{
item.setRotation(item.getRotation() + 6);
}
}
if (this.direction == 0)
{
tiles.addAll(room.getLayout().getTilesAt(room.getLayout().getTile(item.getX(), item.getY()), item.getBaseItem().getWidth(), item.getBaseItem().getLength(), item.getRotation()));
room.updateTiles(tiles);
room.sendComposer(new FloorItemUpdateComposer(item).compose());
}
}
if (this.direction > 0)
{
RoomUserRotation moveDirection = RoomUserRotation.NORTH;
if (this.direction == 1)
{
moveDirection = RoomUserRotation.values()[Emulator.getRandom().nextInt(RoomUserRotation.values().length)];
}
else if (this.direction == 2)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
moveDirection = RoomUserRotation.EAST;
}
else
{
moveDirection = RoomUserRotation.WEST;
}
}
else if (this.direction == 3)
{
if (Emulator.getRandom().nextInt(2) == 1)
{
moveDirection = RoomUserRotation.NORTH;
}
else
{
moveDirection = RoomUserRotation.SOUTH;
}
}
else if (this.direction == 4)
{
moveDirection = RoomUserRotation.SOUTH;
}
else if (this.direction == 5)
{
moveDirection = RoomUserRotation.EAST;
}
else if (this.direction == 6)
{
moveDirection = RoomUserRotation.NORTH;
}
else if (this.direction == 7)
{
moveDirection = RoomUserRotation.WEST;
}
RoomTile newTile = room.getLayout().getTile(
(short) (item.getX() + ((moveDirection == RoomUserRotation.WEST || moveDirection == RoomUserRotation.NORTH_WEST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : (((moveDirection == RoomUserRotation.EAST || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.NORTH_EAST) ? 1 : 0)))),
(short) (item.getY() + ((moveDirection == RoomUserRotation.NORTH || moveDirection == RoomUserRotation.NORTH_EAST || moveDirection == RoomUserRotation.NORTH_WEST) ? 1 : ((moveDirection == RoomUserRotation.SOUTH || moveDirection == RoomUserRotation.SOUTH_EAST || moveDirection == RoomUserRotation.SOUTH_WEST) ? -1 : 0)))
);
if (newTile != null)
{
boolean hasHabbos = false;
for (Habbo habbo : room.getHabbosAt(newTile))
{
hasHabbos = true;
WiredHandler.handle(WiredTriggerType.COLLISION, habbo.getRoomUnit(), room, new Object[]{item});
}
if (!hasHabbos && room.tileWalkable(newTile))
{
Rectangle rectangle = new Rectangle(newTile.x,
newTile.y,
item.getBaseItem().getWidth(),
item.getBaseItem().getLength());
double offset = 0;
for (short x = (short)rectangle.x; x < rectangle.x + rectangle.getWidth(); x++)
{
for (short y = (short)rectangle.y; y < rectangle.y + rectangle.getHeight(); y++)
{
RoomTile tile = room.getLayout().getTile(x, y);
if (tile.state == RoomTileState.INVALID) continue;
HabboItem i = room.getTopItemAt(x, y, item);
if (i == null || i == item || i.getBaseItem().allowStack())
{
offset = Math.max(room.getStackHeight(newTile.x, newTile.y, false, item) - item.getZ(), offset);
}
}
}
room.sendComposer(new FloorItemOnRollerComposer(item, null, newTile, offset, room).compose());
}
}
}
}
room.updateTiles(tilesToUpdate);
}
return true;
@ -188,7 +213,6 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
{
THashSet<HabboItem> items = new THashSet<>();
this.items.remove(null);
Room room = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId());
for(HabboItem item : this.items)
@ -217,33 +241,30 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
synchronized (this.items)
{
this.items.clear();
this.items.clear();
String[] data = set.getString("wired_data").split("\t");
String[] data = set.getString("wired_data").split("\t");
if (data.length == 4)
{
try
{
this.direction = Integer.valueOf(data[0]);
this.rotation = Integer.valueOf(data[1]);
this.setDelay(Integer.valueOf(data[2]));
}
catch (Exception e)
{
}
if (data.length == 4)
{
try
{
this.direction = Integer.valueOf(data[0]);
this.rotation = Integer.valueOf(data[1]);
this.setDelay(Integer.valueOf(data[2]));
}
catch (Exception e)
{
}
for (String s : data[3].split("\r"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
for (String s : data[3].split("\r"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
if (item != null)
this.items.add(item);
}
}
}
if (item != null)
this.items.add(item);
}
}
}
@Override
@ -266,35 +287,32 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
{
THashSet<HabboItem> items = new THashSet<>();
synchronized (this.items)
{
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
message.appendInt(item.getId());
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(2);
message.appendInt(this.direction);
message.appendInt(this.rotation);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(this.getDelay());
message.appendInt(0);
}
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
message.appendInt(item.getId());
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(2);
message.appendInt(this.direction);
message.appendInt(this.rotation);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(this.getDelay());
message.appendInt(0);
}
@Override
@ -314,14 +332,11 @@ public class WiredEffectMoveRotateFurni extends InteractionWiredEffect
int count = packet.readInt();
synchronized (this.items)
{
this.items.clear();
for (int i = 0; i < count; i++)
{
this.items.add(room.getHabboItem(packet.readInt()));
}
}
this.items.clear();
for (int i = 0; i < count; i++)
{
this.items.add(room.getHabboItem(packet.readInt()));
}
this.setDelay(packet.readInt());

View File

@ -7,7 +7,6 @@ import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
@ -118,11 +117,17 @@ public class WiredEffectTeleport extends InteractionWiredEffect
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
Habbo habbo = room.getHabbo(roomUnit);
THashSet<HabboItem> items = new THashSet<>();
if(habbo == null)
for(HabboItem item : this.items)
{
return false;
if(item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for(HabboItem item : items)
{
this.items.remove(item);
}
if(!this.items.isEmpty())
@ -134,11 +139,11 @@ public class WiredEffectTeleport extends InteractionWiredEffect
{
if (i == j)
{
int currentEffect = habbo.getRoomUnit().getEffectId();
int currentEffect = roomUnit.getEffectId();
room.giveEffect(habbo, 4);
room.giveEffect(roomUnit, 4);
final WiredEffectTeleport teleportWired = this;
Emulator.getThreading().run(new RoomUnitTeleport(habbo.getRoomUnit(), room, item.getX(), item.getY(), item.getZ() + (item.getBaseItem().allowSit() ? item.getBaseItem().getHeight() - 0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, item.getX(), item.getY(), item.getZ() + item.getBaseItem().getHeight() + (item.getBaseItem().allowSit() ? - 0.50 : 0D), currentEffect), WiredHandler.TELEPORT_DELAY);
Emulator.getThreading().run(new Runnable()
{
@Override
@ -146,7 +151,7 @@ public class WiredEffectTeleport extends InteractionWiredEffect
{
try
{
item.onWalkOn(habbo.getRoomUnit(), room, new Object[]{teleportWired});
item.onWalkOn(roomUnit, room, new Object[]{teleportWired});
}
catch (Exception e)
{}

View File

@ -47,62 +47,59 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
@Override
public void serializeWiredData(ServerMessage message, Room room)
{
synchronized (this.items)
{
THashSet<HabboItem> items = new THashSet<>();
THashSet<HabboItem> items = new THashSet<>();
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : this.items)
{
if (item.getRoomId() != this.getRoomId() || Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(item.getId()) == null)
items.add(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
for (HabboItem item : items)
{
this.items.remove(item);
}
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
{
message.appendInt(item.getId());
}
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getType().code);
message.appendInt(this.getDelay());
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(this.items.size());
for (HabboItem item : this.items)
{
message.appendInt(item.getId());
}
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(0);
message.appendInt(0);
message.appendInt(this.getType().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);
}
}
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
@ -111,22 +108,19 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
packet.readInt();
packet.readString();
synchronized (this.items)
{
this.items.clear();
this.items.clear();
int count = packet.readInt();
int count = packet.readInt();
for (int i = 0; i < count; i++)
{
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
for (int i = 0; i < count; i++)
{
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
continue;
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
continue;
this.items.add(item);
}
}
this.items.add(item);
}
this.setDelay(packet.readInt());
@ -136,58 +130,51 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
@Override
public boolean execute(RoomUnit roomUnit, Room room, Object[] stuff)
{
synchronized (this.items)
{
Habbo habbo = room.getHabbo(roomUnit);
Habbo habbo = room.getHabbo(roomUnit);
HabboItem triggerItem = null;
HabboItem triggerItem = null;
if (stuff != null && stuff.length > 0)
{
if (stuff[0] instanceof HabboItem)
{
triggerItem = (HabboItem) stuff[0];
}
}
if (stuff != null && stuff.length > 0)
{
if (stuff[0] instanceof HabboItem)
{
triggerItem = (HabboItem) stuff[0];
}
}
THashSet<HabboItem> itemsToRemove = new THashSet<>();
for (HabboItem item : this.items)
{
if (item == null || item.getRoomId() == 0 || item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile)
{
itemsToRemove.add(item);
continue;
}
THashSet<HabboItem> itemsToRemove = new THashSet<>();
for (HabboItem item : this.items)
{
if (item == null || item.getRoomId() == 0 || item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile)
{
itemsToRemove.add(item);
continue;
}
if (triggerItem == null && roomUnit == null)
{
continue;
}
try
{
if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer)
{
if (item instanceof InteractionGameTimer)
{
Game game = room.getGame(((InteractionGameTimer)item).getGameType());
if (game == null || game.isRunning)
{
continue;
}
}
try
{
if (item.getBaseItem().getStateCount() > 1 || item instanceof InteractionGameTimer)
{
if (item instanceof InteractionGameTimer)
{
Game game = room.getGame(((InteractionGameTimer)item).getGameType());
if (game == null || game.isRunning)
{
continue;
}
}
item.onClick(habbo != null ? habbo.getClient() : null, room, new Object[]{item.getExtradata().length() == 0 ? 0 : Integer.valueOf(item.getExtradata()), this.getType()});
}
}
catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
item.onClick(habbo != null ? habbo.getClient() : null, room, new Object[]{item.getExtradata().length() == 0 ? 0 : Integer.valueOf(item.getExtradata()), this.getType()});
}
}
catch (Exception e)
{
Emulator.getLogging().logErrorLine(e);
}
}
this.items.removeAll(itemsToRemove);
}
this.items.removeAll(itemsToRemove);
return true;
}
@ -196,16 +183,13 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
{
String wiredData = this.getDelay() + "\t";
synchronized (this.items)
{
if(items != null && !items.isEmpty())
{
for (HabboItem item : this.items)
{
wiredData += item.getId() + ";";
}
}
}
if(items != null && !items.isEmpty())
{
for (HabboItem item : this.items)
{
wiredData += item.getId() + ";";
}
}
return wiredData;
}
@ -213,32 +197,29 @@ public class WiredEffectToggleFurni extends InteractionWiredEffect
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
synchronized (this.items)
{
this.items.clear();
String[] wiredData = set.getString("wired_data").split("\t");
this.items.clear();
String[] wiredData = set.getString("wired_data").split("\t");
if (wiredData.length >= 1)
{
this.setDelay(Integer.valueOf(wiredData[0]));
}
if (wiredData.length == 2)
{
if (wiredData[1].contains(";"))
{
for (String s : wiredData[1].split(";"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
if (wiredData.length >= 1)
{
this.setDelay(Integer.valueOf(wiredData[0]));
}
if (wiredData.length == 2)
{
if (wiredData[1].contains(";"))
{
for (String s : wiredData[1].split(";"))
{
HabboItem item = room.getHabboItem(Integer.valueOf(s));
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
continue;
if (item instanceof InteractionFreezeBlock || item instanceof InteractionFreezeTile || item instanceof InteractionCrackable)
continue;
if (item != null)
this.items.add(item);
}
}
}
}
if (item != null)
this.items.add(item);
}
}
}
}
@Override

View File

@ -100,27 +100,24 @@ public class WiredEffectToggleRandom extends InteractionWiredEffect
@Override
public boolean saveData(ClientMessage packet, GameClient gameClient)
{
synchronized (this.items)
{
packet.readInt();
packet.readString();
packet.readInt();
packet.readString();
this.items.clear();
this.items.clear();
int count = packet.readInt();
int count = packet.readInt();
for (int i = 0; i < count; i++)
{
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
for (int i = 0; i < count; i++)
{
HabboItem item = Emulator.getGameEnvironment().getRoomManager().getRoom(this.getRoomId()).getHabboItem(packet.readInt());
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
continue;
if (item instanceof InteractionFreezeBlock || item instanceof InteractionGameTimer || item instanceof InteractionCrackable)
continue;
this.items.add(item);
}
this.items.add(item);
}
this.setDelay(packet.readInt());
}
this.setDelay(packet.readInt());
return true;
}

View File

@ -84,6 +84,10 @@ public class WiredEffectWhisper extends InteractionWiredEffect
packet.readInt();
this.message = Emulator.getGameEnvironment().getWordFilter().filter(packet.readString(), null);
if (this.message.length() > 100)
{
this.message = "";
}
packet.readInt();
this.setDelay(packet.readInt());
return true;

View File

@ -0,0 +1,87 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredTriggerHabboIdle extends InteractionWiredTrigger
{
private static final WiredTriggerType type = WiredTriggerType.IDLES;
public WiredTriggerHabboIdle(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredTriggerHabboIdle(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)
{
return stuff.length > 0 && stuff[0] instanceof Habbo;
}
@Override
public String getWiredData()
{
return "";
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
}
@Override
public void onPickUp()
{
}
@Override
public WiredTriggerType getType()
{
return type;
}
@Override
public void serializeWiredData(ServerMessage message, Room room)
{
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(0);
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(0);
message.appendInt(0);
message.appendInt(type.code);
message.appendInt(0);
message.appendInt(0);
}
@Override
public boolean saveData(ClientMessage packet)
{
return true;
}
@Override
public boolean isTriggeredByRoomUnit()
{
return true;
}
}

View File

@ -0,0 +1,87 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ClientMessage;
import com.eu.habbo.messages.ServerMessage;
import java.sql.ResultSet;
import java.sql.SQLException;
public class WiredTriggerHabboUnidle extends InteractionWiredTrigger
{
private static final WiredTriggerType type = WiredTriggerType.IDLES;
public WiredTriggerHabboUnidle(ResultSet set, Item baseItem) throws SQLException
{
super(set, baseItem);
}
public WiredTriggerHabboUnidle(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)
{
return stuff.length > 0 && stuff[0] instanceof Habbo;
}
@Override
public String getWiredData()
{
return "";
}
@Override
public void loadWiredData(ResultSet set, Room room) throws SQLException
{
}
@Override
public void onPickUp()
{
}
@Override
public WiredTriggerType getType()
{
return type;
}
@Override
public void serializeWiredData(ServerMessage message, Room room)
{
message.appendBoolean(false);
message.appendInt(WiredHandler.MAXIMUM_FURNI_SELECTION);
message.appendInt(0);
message.appendInt(this.getBaseItem().getSpriteId());
message.appendInt(this.getId());
message.appendString("");
message.appendInt(0);
message.appendInt(0);
message.appendInt(type.code);
message.appendInt(0);
message.appendInt(0);
}
@Override
public boolean saveData(ClientMessage packet)
{
return true;
}
@Override
public boolean isTriggeredByRoomUnit()
{
return true;
}
}

View File

@ -5,7 +5,6 @@ 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.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger
{
@ -40,16 +41,11 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger
{
if(stuff.length >= 1)
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
if (stuff[0] instanceof HabboItem)
{
if (stuff[0] instanceof HabboItem)
if(items.contains(stuff[0]))
{
if(items.contains(stuff[0]))
{
return true;
}
return true;
}
}
}
@ -63,10 +59,20 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger
if(!items.isEmpty())
{
List<HabboItem> toRemove = new ArrayList<>(0);
for (HabboItem item : this.items)
{
wiredData += item.getId() + ";";
if (item.getRoomId() == this.getRoomId())
{
wiredData += item.getId() + ";";
}
else
{
toRemove.add(item);
}
}
this.items.removeAll(toRemove);
}
else
wiredData += "\t";

View File

@ -5,7 +5,6 @@ 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.RoomUnit;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
@ -15,6 +14,8 @@ import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger
{
@ -40,16 +41,11 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger
{
if(stuff.length >= 1)
{
Habbo habbo = room.getHabbo(roomUnit);
if (habbo != null)
if (stuff[0] instanceof HabboItem)
{
if (stuff[0] instanceof HabboItem)
if(items.contains(stuff[0]))
{
if(items.contains(stuff[0]))
{
return true;
}
return true;
}
}
}
@ -127,10 +123,20 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger
if(!items.isEmpty())
{
List<HabboItem> toRemove = new ArrayList<>(0);
for (HabboItem item : this.items)
{
wiredData += item.getId() + ";";
if (item.getRoomId() == this.getRoomId())
{
wiredData += item.getId() + ";";
}
else
{
toRemove.add(item);
}
}
this.items.removeAll(toRemove);
}
else
wiredData += "\t";

View File

@ -198,7 +198,7 @@ public class ModToolManager
if(userId <= 0)
return;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM users INNER JOIN users_settings ON users.id = users_settings.user_id WHERE users.id = ? LIMIT 1"))
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT users.*, users_settings.*, permissions.rank_name, permissions.id as rank_id FROM users INNER JOIN users_settings ON users.id = users_settings.user_id INNER JOIN permissions ON permissions.id = users.rank WHERE users.id = ? LIMIT 1"))
{
statement.setInt(1, userId);
try (ResultSet set = statement.executeQuery())
@ -516,18 +516,20 @@ public class ModToolManager
if (target != null)
{
Emulator.getGameServer().getGameClientManager().disposeClient(target.getClient().getChannel());
Emulator.getGameServer().getGameClientManager().disposeClient(target.getClient());
}
if ((type == ModToolBanType.IP || type == ModToolBanType.SUPER) && target != null && !ban.ip.equals("offline"))
{
for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(ban.ip))
{
if (h.getHabboInfo().getRank().getId() >= moderator.getHabboInfo().getRank().getId()) continue;
ban = new ModToolBan(h.getHabboInfo().getId(), h != null ? h.getHabboInfo().getIpLogin() : "offline", h != null ? h.getClient().getMachineId() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic);
Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, h, ban));
Emulator.getThreading().run(ban);
bans.add(ban);
Emulator.getGameServer().getGameClientManager().disposeClient(h.getClient().getChannel());
Emulator.getGameServer().getGameClientManager().disposeClient(h.getClient());
}
}
@ -535,11 +537,13 @@ public class ModToolManager
{
for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithMachineId(ban.machineId))
{
if (h.getHabboInfo().getRank().getId() >= moderator.getHabboInfo().getRank().getId()) continue;
ban = new ModToolBan(h.getHabboInfo().getId(), h != null ? h.getHabboInfo().getIpLogin() : "offline", h != null ? h.getClient().getMachineId() : "offline", moderator.getHabboInfo().getId(), Emulator.getIntUnixTimestamp() + duration, reason, type, cfhTopic);
Emulator.getPluginManager().fireEvent(new SupportUserBannedEvent(moderator, h, ban));
Emulator.getThreading().run(ban);
bans.add(ban);
Emulator.getGameServer().getGameClientManager().disposeClient(h.getClient().getChannel());
Emulator.getGameServer().getGameClientManager().disposeClient(h.getClient());
}
}
@ -662,7 +666,7 @@ public class ModToolManager
public boolean unban(String username)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bans INNER JOIN users ON bans.user_id = users.id SET ban_expire = ?, ban_reason = CONCAT('" + Emulator.getTexts().getValue("unbanned") + ": ', ban_reason) WHERE users.username = ? AND ban_expire > ?"))
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE bans INNER JOIN users ON bans.user_id = users.id SET ban_expire = ?, ban_reason = CONCAT('" + Emulator.getTexts().getValue("unbanned") + ": ', ban_reason) WHERE users.username LIKE ? AND ban_expire > ?"))
{
statement.setInt(1, Emulator.getIntUnixTimestamp());
statement.setString(2, username);

View File

@ -33,7 +33,10 @@ public class NavigatorHotelFilter extends NavigatorFilter
if (!set.getValue().isEmpty())
{
RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getKey());
resultLists.add(new SearchResultList(i, category.getCaption(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ORDER_NUM, category.getOrder()));
if (category != null)
{
resultLists.add(new SearchResultList(i, category.getCaption(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ORDER_NUM, category.getOrder()));
}
i++;
}
}
@ -55,7 +58,11 @@ public class NavigatorHotelFilter extends NavigatorFilter
if (!set.getValue().isEmpty())
{
RoomCategory category = Emulator.getGameEnvironment().getRoomManager().getCategory(set.getKey());
resultLists.add(new SearchResultList(i, category.getCaptionSave(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ACTIVITY, category.getOrder()));
if (category != null)
{
resultLists.add(new SearchResultList(i, category.getCaptionSave(), category.getCaption(), SearchAction.MORE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory(category.getCaptionSave()), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory(category.getCaptionSave()), set.getValue(), true, showInvisible, DisplayOrder.ACTIVITY, category.getOrder()));
}
i++;
}
}

View File

@ -74,7 +74,7 @@ public class NavigatorManager
}
else
{
Emulator.getLogging().logErrorLine("Public room defined in navigator_publics does not exist!");
Emulator.getLogging().logErrorLine("Public room (ID: " + set.getInt("room_id") + " defined in navigator_publics does not exist!");
}
}
}

View File

@ -24,7 +24,7 @@ public class NavigatorUserFilter extends NavigatorFilter
List<SearchResultList> resultLists = new ArrayList<>();
List<Room> rooms = Emulator.getGameEnvironment().getRoomManager().getRoomsForHabbo(habbo);
Collections.sort(rooms);
resultLists.add(new SearchResultList(i, "my", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my"), rooms, true, true, DisplayOrder.ACTIVITY, -1));
resultLists.add(new SearchResultList(i, "my", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my"), rooms, true, true, DisplayOrder.ORDER_NUM, i));
i++;
List<Room> favoriteRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsFavourite(habbo);
@ -32,28 +32,28 @@ public class NavigatorUserFilter extends NavigatorFilter
if (!favoriteRooms.isEmpty())
{
Collections.sort(favoriteRooms);
resultLists.add(new SearchResultList(1, "favorites", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("favorites"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("favorites"), favoriteRooms, true, true, DisplayOrder.ACTIVITY, -1));
resultLists.add(new SearchResultList(i, "favorites", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("favorites"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("favorites"), favoriteRooms, true, true, DisplayOrder.ORDER_NUM, i));
i++;
}
List<Room> frequentlyVisited = Emulator.getGameEnvironment().getRoomManager().getRoomsVisited(habbo, false, 10);
if (!frequentlyVisited.isEmpty())
{
resultLists.add(new SearchResultList(1, "history_freq", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("history_freq"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("history_freq"), frequentlyVisited, true, true, DisplayOrder.ACTIVITY, -1));
resultLists.add(new SearchResultList(i, "history_freq", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("history_freq"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("history_freq"), frequentlyVisited, true, true, DisplayOrder.ORDER_NUM, i));
i++;
}
List<Room> groupRooms = Emulator.getGameEnvironment().getRoomManager().getGroupRooms(habbo, 25);
if (!groupRooms.isEmpty())
{
resultLists.add(new SearchResultList(1, "my_groups", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my_groups"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my_groups"), groupRooms, true, true, DisplayOrder.ACTIVITY, -1));
resultLists.add(new SearchResultList(i, "my_groups", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("my_groups"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("my_groups"), groupRooms, true, true, DisplayOrder.ORDER_NUM, i));
i++;
}
List<Room> rightRooms = Emulator.getGameEnvironment().getRoomManager().getRoomsWithRights(habbo);
if (!rightRooms.isEmpty())
{
resultLists.add(new SearchResultList(1, "with_rights", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_rights"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_rights"), rightRooms, true, true, DisplayOrder.ACTIVITY, -1));
resultLists.add(new SearchResultList(i, "with_rights", "", SearchAction.NONE, habbo.getHabboStats().navigatorWindowSettings.getListModeForCategory("with_rights"), habbo.getHabboStats().navigatorWindowSettings.getDisplayModeForCategory("with_rights"), rightRooms, true, true, DisplayOrder.ORDER_NUM, i));
i++;
}

View File

@ -219,6 +219,8 @@ public class MonsterplantPet extends Pet implements IPetLook
}
}
}
super.cycle();
}
public int getType()
@ -428,4 +430,10 @@ public class MonsterplantPet extends Pet implements IPetLook
this.room.sendComposer(new PetStatusUpdateComposer(this).compose());
this.room.sendComposer(new RoomPetRespectComposer(this, RoomPetRespectComposer.PET_TREATED).compose());
}
@Override
public boolean canWalk()
{
return false;
}
}

View File

@ -8,6 +8,7 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ISerialize;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.pets.PetLevelUpdatedComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetExperienceComposer;
import com.eu.habbo.messages.outgoing.rooms.pets.RoomPetRespectComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
@ -21,25 +22,55 @@ import java.util.TimeZone;
public class Pet implements ISerialize, Runnable
{
protected int id;
protected int userId;
protected Room room;
protected String name;
protected PetData petData;
protected int race;
protected String color;
protected int happyness;
public int levelThirst;
public int levelHunger;
protected int experience;
protected int energy;
protected int respect;
protected int created;
protected int level;
public boolean needsUpdate = false;
private int chatTimeout;
RoomUnit roomUnit;
public int levelThirst;
public int levelHunger;
public boolean packetUpdate = false;
@ -105,7 +136,8 @@ public class Pet implements ISerialize, Runnable
this.level = 1;
}
void say(String message)
protected void say(String message)
{
if(this.roomUnit != null && this.room != null && !message.isEmpty())
{
@ -118,13 +150,15 @@ public class Pet implements ISerialize, Runnable
}
}
public void say(PetVocal vocal)
{
if(vocal != null)
this.say(vocal.message);
}
public synchronized void addEnergy(int amount)
public void addEnergy(int amount)
{
this.energy += amount;
@ -135,7 +169,8 @@ public class Pet implements ISerialize, Runnable
this.energy = 0;
}
public synchronized void addHappyness(int amount)
public void addHappyness(int amount)
{
this.happyness += amount;
@ -156,11 +191,13 @@ public class Pet implements ISerialize, Runnable
this.respect++;
}
public int daysAlive()
{
return (Emulator.getIntUnixTimestamp() - this.created) / 86400;
}
public String bornDate()
{
@ -250,7 +287,7 @@ public class Pet implements ISerialize, Runnable
if(time - this.postureTimeout > 1 && this.task == null)
{
this.clearPosture();
this.postureTimeout = time;
this.postureTimeout = time + 120;
}
if (this.freeCommandTicks > 0)
@ -376,6 +413,7 @@ public class Pet implements ISerialize, Runnable
}
}
public void handleCommand(PetCommand command, Habbo habbo, String[] data)
{
this.idleCommandTicks = 0;
@ -430,7 +468,13 @@ public class Pet implements ISerialize, Runnable
if(this.task == null)
{
boolean isDead = false;
if (this.roomUnit.hasStatus(RoomUnitStatus.RIP))
isDead = true;
this.roomUnit.clearStatus();
if (isDead) this.roomUnit.setStatus(RoomUnitStatus.RIP, "");
for (Map.Entry<RoomUnitStatus, String> entry : keys.entrySet())
{
this.roomUnit.setStatus(entry.getKey(), entry.getValue());
@ -495,6 +539,7 @@ public class Pet implements ISerialize, Runnable
message.appendInt(0);
}
public void findNest()
{
HabboItem item = this.petData.randomNest(this.room.getRoomSpecialTypes().getNests());
@ -511,6 +556,7 @@ public class Pet implements ISerialize, Runnable
}
}
public void drink()
{
HabboItem item = this.petData.randomDrinkItem(this.room.getRoomSpecialTypes().getPetDrinks());
@ -521,6 +567,7 @@ public class Pet implements ISerialize, Runnable
}
}
public void eat()
{
HabboItem item = this.petData.randomFoodItem(this.room.getRoomSpecialTypes().getPetFoods());
@ -533,6 +580,7 @@ public class Pet implements ISerialize, Runnable
}
}
public void findToy()
{
HabboItem item = this.petData.randomToyItem(this.room.getRoomSpecialTypes().getPetToys());
@ -545,21 +593,25 @@ public class Pet implements ISerialize, Runnable
}
}
public void randomHappyAction()
{
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsHappy[Emulator.getRandom().nextInt(this.petData.actionsHappy.length)]), "");
}
public void randomSadAction()
{
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsTired[Emulator.getRandom().nextInt(this.petData.actionsTired.length)]), "");
}
public void randomAction()
{
this.roomUnit.setStatus(RoomUnitStatus.fromString(this.petData.actionsRandom[Emulator.getRandom().nextInt(this.petData.actionsRandom.length)]), "");
}
public void addExperience(int amount)
{
this.experience += amount;
@ -575,16 +627,26 @@ public class Pet implements ISerialize, Runnable
}
}
protected void levelUp()
{
if (this.level >= PetManager.experiences.length)
return;
this.level++;
if (this.experience < PetManager.experiences[this.level])
{
this.experience = PetManager.experiences[this.level];
}
this.say(this.petData.randomVocal(PetVocalsType.LEVEL_UP));
this.addHappyness(100);
this.roomUnit.setStatus(RoomUnitStatus.GESTURE, "exp");
this.gestureTickTimeout = Emulator.getIntUnixTimestamp();
AchievementManager.progressAchievement(Emulator.getGameEnvironment().getHabboManager().getHabbo(this.userId), Emulator.getGameEnvironment().getAchievementManager().getAchievement("PetLevelUp"));
this.room.sendComposer(new PetLevelUpdatedComposer(this).compose());
}
public void addThirst(int amount)
{
this.levelThirst += amount;
@ -596,6 +658,7 @@ public class Pet implements ISerialize, Runnable
this.levelThirst = 0;
}
public void addHunger(int amount)
{
this.levelHunger += amount;
@ -607,6 +670,7 @@ public class Pet implements ISerialize, Runnable
this.levelHunger = 0;
}
public void freeCommand()
{
this.task = null;
@ -616,6 +680,7 @@ public class Pet implements ISerialize, Runnable
this.say(this.petData.randomVocal(PetVocalsType.GENERIC_NEUTRAL));
}
public void scratched(Habbo habbo)
{
this.addExperience(10);

View File

@ -8,12 +8,22 @@ import java.util.List;
public abstract class PetAction
{
public int minimumActionDuration = 500;
public final PetTasks petTask;
public final boolean stopsPetWalking;
public final List<RoomUnitStatus> statusToRemove = new ArrayList<>();
public String gestureToSet = null;
public final List<RoomUnitStatus> statusToSet = new ArrayList<>();
protected PetAction(PetTasks petTask, boolean stopsPetWalking)
@ -22,5 +32,6 @@ public abstract class PetAction
this.stopsPetWalking = stopsPetWalking;
}
public abstract boolean apply(Pet pet, Habbo habbo, String[] data);
}

View File

@ -5,8 +5,13 @@ import java.sql.SQLException;
public class PetBreedingReward
{
public final int petType;
public final int rarityLevel;
public final int breed;
public PetBreedingReward(ResultSet set) throws SQLException

View File

@ -9,12 +9,25 @@ import java.sql.SQLException;
public class PetCommand implements Comparable<PetCommand>
{
public final int id;
public final String key;
public final int level;
public final int xp;
public final int energyCost;
public final int happynessCost;
public final PetAction action;
public PetCommand(ResultSet set, PetAction action) throws SQLException

View File

@ -18,33 +18,67 @@ import java.util.List;
public class PetData implements Comparable<PetData>
{
private int type;
private String name;
public static final String BLINK = "eyb";
public static final String SPEAK = "spk";
public static final String EAT = "eat";
public static final String PLAYFUL = "pla";
public String[] actionsHappy;
public String[] actionsTired;
public String[] actionsRandom;
private List<PetCommand> petCommands;
private List<Item> nestItems;
private List<Item> foodItems;
private List<Item> drinkItems;
private List<Item> toyItems;
public static final List<Item> generalDrinkItems = new ArrayList<>();
public static final List<Item> generalFoodItems = new ArrayList<>();
public static final List<Item> generalNestItems = new ArrayList<>();
public static final List<Item> generalToyItems = new ArrayList<>();
public THashMap<PetVocalsType, THashSet<PetVocal>> petVocals;
public static final THashMap<PetVocalsType, THashSet<PetVocal>> generalPetVocals = new THashMap<>();
private int offspringType;
public PetData(ResultSet set) throws SQLException
{
this.load(set);
@ -54,6 +88,7 @@ public class PetData implements Comparable<PetData>
{
this.type = set.getInt("pet_type");
this.name = set.getString("pet_name");
this.offspringType = set.getInt("offspring_type");
this.actionsHappy = set.getString("happy_actions").split(";");
this.actionsTired = set.getString("tired_actions").split(";");
this.actionsRandom = set.getString("random_actions").split(";");
@ -90,37 +125,50 @@ public class PetData implements Comparable<PetData>
return this.petCommands;
}
public int getType()
{
return this.type;
}
public String getName()
{
return this.name;
}
public void addNest(Item item)
public int getOffspringType()
{
if(item != null)
this.nestItems.add(item);
return this.offspringType;
}
public void addNest(Item nest)
{
if(nest != null)
this.nestItems.add(nest);
}
public List<Item> getNests()
{
return this.nestItems;
}
public boolean haveNest(HabboItem item)
public boolean haveNest(HabboItem nest)
{
return this.haveNest(item.getBaseItem());
return this.haveNest(nest.getBaseItem());
}
boolean haveNest(Item item)
boolean haveNest(Item nest)
{
return PetData.generalNestItems.contains(item) || this.nestItems.contains(item);
return PetData.generalNestItems.contains(nest) || this.nestItems.contains(nest);
}
public HabboItem randomNest(THashSet<InteractionNest> items)
{
List<HabboItem> nestList = new ArrayList<>();
@ -143,26 +191,31 @@ public class PetData implements Comparable<PetData>
return null;
}
public void addFoodItem(Item item)
public void addFoodItem(Item food)
{
this.foodItems.add(item);
this.foodItems.add(food);
}
public List<Item> getFoodItems()
{
return this.foodItems;
}
public boolean haveFoodItem(HabboItem item)
public boolean haveFoodItem(HabboItem food)
{
return this.haveFoodItem(item.getBaseItem());
return this.haveFoodItem(food.getBaseItem());
}
boolean haveFoodItem(Item item)
boolean haveFoodItem(Item food)
{
return this.foodItems.contains(item) || PetData.generalFoodItems.contains(item);
return this.foodItems.contains(food) || PetData.generalFoodItems.contains(food);
}
public HabboItem randomFoodItem(THashSet<InteractionPetFood> items)
{
List<HabboItem> foodList = new ArrayList<>();
@ -184,26 +237,31 @@ public class PetData implements Comparable<PetData>
return null;
}
public void addDrinkItem(Item item)
{
this.drinkItems.add(item);
}
public List<Item> getDrinkItems()
{
return this.drinkItems;
}
public boolean haveDrinkItem(HabboItem item)
{
return this.haveDrinkItem(item.getBaseItem());
}
boolean haveDrinkItem(Item item)
{
return this.drinkItems.contains(item) || PetData.generalDrinkItems.contains(item);
}
public HabboItem randomDrinkItem(THashSet<InteractionPetDrink> items)
{
List<HabboItem> drinkList = new ArrayList<>();
@ -225,31 +283,36 @@ public class PetData implements Comparable<PetData>
return null;
}
public void addToyItem(Item item)
public void addToyItem(Item toy)
{
this.toyItems.add(item);
this.toyItems.add(toy);
}
public List<Item> getToyItems()
{
return this.toyItems;
}
public boolean haveToyItem(HabboItem item)
public boolean haveToyItem(HabboItem toy)
{
return this.haveToyItem(item.getBaseItem());
return this.haveToyItem(toy.getBaseItem());
}
public boolean haveToyItem(Item item)
public boolean haveToyItem(Item toy)
{
return this.toyItems.contains(item) || PetData.generalToyItems.contains(item);
return this.toyItems.contains(toy) || PetData.generalToyItems.contains(toy);
}
public HabboItem randomToyItem(THashSet<InteractionPetToy> items)
public HabboItem randomToyItem(THashSet<InteractionPetToy> toys)
{
List<HabboItem> toyList = new ArrayList<>();
for(InteractionPetToy toy : items)
for(InteractionPetToy toy : toys)
{
if(this.haveToyItem(toy))
{
@ -266,6 +329,7 @@ public class PetData implements Comparable<PetData>
return null;
}
public PetVocal randomVocal(PetVocalsType type)
{
//TODO: Remove this useless copying.

View File

@ -16,7 +16,9 @@ import gnu.trove.map.TIntIntMap;
import gnu.trove.map.hash.THashMap;
import gnu.trove.map.hash.TIntIntHashMap;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TIntObjectProcedure;
import gnu.trove.set.hash.THashSet;
import org.apache.commons.math3.distribution.NormalDistribution;
import java.sql.*;
import java.util.ArrayList;
@ -63,6 +65,7 @@ public class PetManager
put(36, new ActionBreatheFire());
put(38, new ActionTorch());
put(43, new ActionEat());
put(46, new ActionBreed());
}
};
@ -81,6 +84,7 @@ public class PetManager
this.loadRaces(connection);
this.loadPetData(connection);
this.loadPetCommands(connection);
this.loadPetBreeding(connection);
}
catch (SQLException e)
{
@ -92,6 +96,7 @@ public class PetManager
Emulator.getLogging().logStart("Pet Manager -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
}
public void reloadPetData()
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
@ -319,6 +324,35 @@ public class PetManager
return null;
}
public TIntObjectHashMap<ArrayList<PetBreedingReward>> getBreedingRewards(int petType)
{
return this.breedingReward.get(petType);
}
public int getRarityForOffspring(Pet pet)
{
final int[] rarityLevel = {0};
TIntObjectHashMap<ArrayList<PetBreedingReward>> offspringList = this.breedingReward.get(pet.getPetData().getType());
offspringList.forEachEntry(new TIntObjectProcedure<ArrayList<PetBreedingReward>>()
{
@Override
public boolean execute(int i, ArrayList<PetBreedingReward> petBreedingRewards)
{
if (petBreedingRewards.contains(pet.getRace()))
{
rarityLevel[0] = i;
return false;
}
return true;
}
});
return 4 - rarityLevel[0];
}
public static int getLevel(int experience)
{
int index = 0;
@ -433,10 +467,15 @@ public class PetManager
}
public Pet createPet(int type, String name, GameClient client)
{
return this.createPet(type, Emulator.getRandom().nextInt(this.petRaces.get(type).size() + 1), name, client);
}
public Pet createPet(int type, int race, String name, GameClient client)
{
if (this.petData.containsKey(type))
{
Pet pet = new Pet(type, Emulator.getRandom().nextInt(this.petRaces.get(type).size() + 1), "FFFFFF", name, client.getHabbo().getHabboInfo().getId());
Pet pet = new Pet(type, race, "FFFFFF", name, client.getHabbo().getHabboInfo().getId());
pet.needsUpdate = true;
pet.run();
return pet;
@ -594,4 +633,14 @@ public class PetManager
return false;
}
}
public static NormalDistribution getNormalDistributionForBreeding(int levelOne, int levelTwo)
{
return getNormalDistributionForBreeding((levelOne + levelTwo) / 2);
}
public static NormalDistribution getNormalDistributionForBreeding(double avgLevel)
{
return new NormalDistribution(avgLevel, (20 - (avgLevel / 2)) / 2);
}
}

View File

@ -5,10 +5,19 @@ import java.sql.SQLException;
public class PetRace
{
public final int race;
public final int colorOne;
public final int colorTwo;
public final boolean hasColorOne;
public final boolean hasColorTwo;
public PetRace(ResultSet set) throws SQLException

View File

@ -7,6 +7,7 @@ import com.eu.habbo.habbohotel.pets.PetTasks;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.pets.breeding.PetBreedingStartFailedComposer;
import org.apache.commons.lang3.StringUtils;
public class ActionBreed extends PetAction
{
@ -21,7 +22,7 @@ public class ActionBreed extends PetAction
InteractionPetBreedingNest nest = null;
for (HabboItem item : pet.getRoom().getRoomSpecialTypes().getItemsOfType(InteractionPetBreedingNest.class))
{
if (item.getBaseItem().getName().contains(pet.getPetData().getName()))
if (StringUtils.containsIgnoreCase(item.getBaseItem().getName(), pet.getPetData().getName()))
{
if (!((InteractionPetBreedingNest)item).boxFull())
{

View File

@ -7,10 +7,18 @@ import java.util.Collections;
public class Poll
{
private int id;
private String title;
private String thanksMessage;
private String badgeReward;
public final int id;
public final String title;
public final String thanksMessage;
public final String badgeReward;
public int lastQuestionId;
private ArrayList<PollQuestion> questions;
@ -24,26 +32,6 @@ public class Poll
this.questions = new ArrayList<>();
}
public int getId()
{
return this.id;
}
public String getTitle()
{
return this.title;
}
public String getThanksMessage()
{
return this.thanksMessage;
}
public String getBadgeReward()
{
return this.badgeReward;
}
public ArrayList<PollQuestion> getQuestions()
{
return this.questions;
@ -53,7 +41,7 @@ public class Poll
{
for (PollQuestion q : this.questions)
{
if (q.getId() == id)
if (q.id == id)
{
return q;
}

View File

@ -15,6 +15,7 @@ public class PollManager
this.loadPolls();
}
public void loadPolls()
{
synchronized (this.activePolls)
@ -57,7 +58,7 @@ public class PollManager
}
}
poll.lastQuestionId = question.getId();
poll.lastQuestionId = question.id;
}
}
}
@ -70,11 +71,13 @@ public class PollManager
}
}
public Poll getPoll(int pollId)
{
return this.activePolls.get(pollId);
}
public static boolean donePoll(Habbo habbo, int pollId)
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT NULL FROM polls_answers WHERE poll_id = ? AND user_id = ? LIMIT 1"))

View File

@ -12,14 +12,28 @@ import java.util.Map;
public class PollQuestion implements ISerialize, Comparable<PollQuestion>
{
private int id;
private int parentId;
private int type;
private String question;
private THashMap<Integer, String[]> options;
public final int id;
public final int parentId;
public final int type;
public final String question;
public final THashMap<Integer, String[]> options;
public final int minSelections;
public final int order;
private ArrayList<PollQuestion> subQuestions;
private int minSelections;
private int order;
public PollQuestion(ResultSet set) throws SQLException
{
@ -44,31 +58,6 @@ public class PollQuestion implements ISerialize, Comparable<PollQuestion>
}
}
public int getId()
{
return this.id;
}
public int getType()
{
return this.type;
}
public String getQuestion()
{
return this.question;
}
public THashMap<Integer, String[]> getOptions()
{
return this.options;
}
public int getMinSelections()
{
return this.minSelections;
}
public void addSubQuestion(PollQuestion pollQuestion)
{
this.subQuestions.add(pollQuestion);

View File

@ -10,13 +10,13 @@ import java.sql.SQLException;
public class CustomRoomLayout extends RoomLayout implements Runnable
{
private boolean needsUpdate;
private Room room;
private final int roomId;
public CustomRoomLayout(ResultSet set, Room room) throws SQLException
{
super(set, room);
this.room = room;
this.roomId = room.getId();
}
@Override
@ -32,7 +32,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable
statement.setInt(2, this.getDoorY());
statement.setInt(3, this.getDoorDirection());
statement.setString(4, this.getHeightmap());
statement.setInt(5, this.room.getId());
statement.setInt(5, this.roomId);
statement.execute();
}
catch (SQLException e)

View File

@ -0,0 +1,24 @@
package com.eu.habbo.habbohotel.rooms;
public enum FurnitureMovementError
{
NONE(""),
NO_RIGHTS("${room.error.cant_set_not_owner}"),
INVALID_MOVE("${room.error.cant_set_item}"),
CANT_STACK("${room.error.cant_set_item}"),
CANCEL_PLUGIN_PLACE("${room.error.plugin_place}"),
CANCEL_PLUGIN_MOVE("${room.error.plugin_move}"),
CANCEL_PLUGIN_ROTATE("${room.error.plugin_rotate}"),
TILE_HAS_HABBOS("${room.error.cant_set_item}"),
TILE_HAS_PETS("${room.error.cant_set_item}"),
TILE_HAS_BOTS("${room.error.cant_set_item}"),
MAX_DIMMERS("${room.error.max_dimmers}"),
MAX_SOUNDFURNI("${room.errors.max_soundfurni}");
FurnitureMovementError(String errorCode)
{
this.errorCode = errorCode;
}
public final String errorCode;
}

File diff suppressed because it is too large Load Diff

View File

@ -9,9 +9,16 @@ import java.sql.SQLException;
public class RoomBan
{
public final int roomId;
public final int userId;
public final String username;
public final int endTimestamp;
public RoomBan(int roomId, int userId, String username, int endTimestamp)
@ -30,6 +37,7 @@ public class RoomBan
this.endTimestamp = set.getInt("ends");
}
public void insert()
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO room_bans (room_id, user_id, ends) VALUES (?, ?, ?)"))
@ -45,6 +53,7 @@ public class RoomBan
}
}
public void delete()
{
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("DELETE FROM room_bans WHERE room_id = ? AND user_id = ?"))

View File

@ -146,7 +146,7 @@ public class RoomChatMessage implements Runnable, ISerialize, Loggable
}
@Override
public synchronized void run()
public void run()
{
if(habbo == null)
return;

View File

@ -2,62 +2,64 @@ package com.eu.habbo.habbohotel.rooms;
public enum RoomChatMessageBubbles
{
NORMAL(0, "", true),
ALERT(1, "", true),
BOT(2, "", true),
RED(3, "", true),
BLUE(4, "", true),
YELLOW(5, "", true),
GREEN(6, "", true),
BLACK(7, "", true),
FORTUNE_TELLER(8, "", false),
ZOMBIE_ARM(9, "", true),
SKELETON(10, "", true),
LIGHT_BLUE(11, "", true),
PINK(12, "", true),
PURPLE(13, "", true),
DARK_YEWLLOW(14, "", true),
DARK_BLUE(15, "", true),
HEARTS(16, "", true),
ROSES(17, "", true),
UNUSED(18, "", true), //?
PIG(19, "", true),
DOG(20, "", true),
BLAZE_IT(21, "", true),
DRAGON(22, "", true),
STAFF(23, "", false),
BATS(24, "", true),
MESSENGER(25, "", true),
STEAMPUNK(26, "", true),
THUNDER(27, "", true),
PARROT(28, "", false),
PIRATE(29, "", false),
BOT_GUIDE(30, "", true),
BOT_RENTABLE(31, "", true),
SCARY_THING(32, "", true),
FRANK(33, "", true),
WIRED(34, "", false),
GOAT(35, "", true),
SANTA(36, "", true),
AMBASSADOR(37, "acc_ambassador", false),
RADIO(38, "", true),
UNKNOWN_39(39, "", true),
UNKNOWN_40(40, "", true),
UNKNOWN_41(41, "", true),
UNKNOWN_42(42, "", true),
UNKNOWN_43(43, "", true),
UNKNOWN_44(44, "", true),
UNKNOWN_45(45, "", true);
NORMAL(0, "", true, true),
ALERT(1, "", true, true),
BOT(2, "", true, true),
RED(3, "", true, true),
BLUE(4, "", true, true),
YELLOW(5, "", true, true),
GREEN(6, "", true, true),
BLACK(7, "", true, true),
FORTUNE_TELLER(8, "", false, false),
ZOMBIE_ARM(9, "", true, false),
SKELETON(10, "", true, false),
LIGHT_BLUE(11, "", true, true),
PINK(12, "", true, true),
PURPLE(13, "", true, true),
DARK_YEWLLOW(14, "", true, true),
DARK_BLUE(15, "", true, true),
HEARTS(16, "", true, true),
ROSES(17, "", true, true),
UNUSED(18, "", true, true), //?
PIG(19, "", true, true),
DOG(20, "", true, true),
BLAZE_IT(21, "", true, true),
DRAGON(22, "", true, true),
STAFF(23, "", false, true),
BATS(24, "", true, false),
MESSENGER(25, "", true, false),
STEAMPUNK(26, "", true, false),
THUNDER(27, "", true, true),
PARROT(28, "", false, false),
PIRATE(29, "", false, false),
BOT_GUIDE(30, "", true, true),
BOT_RENTABLE(31, "", true, true),
SCARY_THING(32, "", true, false),
FRANK(33, "", true, false),
WIRED(34, "", false, true),
GOAT(35, "", true, false),
SANTA(36, "", true, false),
AMBASSADOR(37, "acc_ambassador", false, true),
RADIO(38, "", true, false),
UNKNOWN_39(39, "", true, false),
UNKNOWN_40(40, "", true, false),
UNKNOWN_41(41, "", true, false),
UNKNOWN_42(42, "", true, false),
UNKNOWN_43(43, "", true, false),
UNKNOWN_44(44, "", true, false),
UNKNOWN_45(45, "", true, false);
private final int type;
private final String permission;
private final boolean overridable;
private final boolean triggersTalkingFurniture;
RoomChatMessageBubbles(int type, String permission, boolean overridable)
RoomChatMessageBubbles(int type, String permission, boolean overridable, boolean triggersTalkingFurniture)
{
this.type = type;
this.permission = permission;
this.overridable = overridable;
this.triggersTalkingFurniture = triggersTalkingFurniture;
}
public int getType()
@ -75,6 +77,10 @@ public enum RoomChatMessageBubbles
return this.overridable;
}
public boolean triggersTalkingFurniture()
{
return this.triggersTalkingFurniture;
}
public static RoomChatMessageBubbles getBubble(int bubbleId)
{
try

View File

@ -246,6 +246,12 @@ public class RoomLayout
return this.tileExists(x, y) && this.roomTiles[x][y].state == RoomTileState.OPEN && this.roomTiles[x][y].isWalkable();
}
public boolean isVoidTile(short x, short y)
{
if (!tileExists(x, y)) return true;
return this.roomTiles[x][y].state == RoomTileState.INVALID;
}
public RoomTileState getStateAt(short x, short y)
{
return this.roomTiles[x][y].state;
@ -307,7 +313,7 @@ public class RoomLayout
if (!ALLOW_FALLING && height < - MAXIMUM_STEP_HEIGHT) continue;
//If the step difference is bigger than the maximum step height, continue.
if (height > MAXIMUM_STEP_HEIGHT) continue;
if (height > MAXIMUM_STEP_HEIGHT && currentAdj.state == RoomTileState.OPEN) continue;
//Check if the tile has habbos.
if (!this.room.isAllowWalkthrough() && room.hasHabbosAt(currentAdj.x, currentAdj.y)) { closedList.add(currentAdj); openList.remove(currentAdj); continue;}
@ -393,83 +399,135 @@ public class RoomLayout
return cheapest;
}
private List<RoomTile> getAdjacent(List<RoomTile> closedList, RoomTile node, RoomTile nextTile)
private List<RoomTile> getAdjacent(List<RoomTile> openList, RoomTile node, RoomTile nextTile)
{
short x = node.x;
short y = node.y;
List<RoomTile> adj = new LinkedList<>();
if (x > 0)
{
RoomTile temp = findTile(adj, (short) (x - 1), y);
RoomTile temp = findTile(openList, (short) (x - 1), y);
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
temp.isDiagonally(false);
adj.add(temp);
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(false);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
if (x < this.mapSizeX)
{
RoomTile temp = findTile(closedList, (short) (x + 1), y);
RoomTile temp = findTile(openList, (short) (x + 1), y);
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
temp.isDiagonally(false);
adj.add(temp);
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(false);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
if (y > 0)
{
RoomTile temp = findTile(closedList, x, (short) (y - 1));
RoomTile temp = findTile(openList, x, (short) (y - 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
temp.isDiagonally(false);
adj.add(temp);
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(false);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
if (y < this.mapSizeY)
{
RoomTile temp = findTile(closedList, x, (short) (y + 1));
RoomTile temp = findTile(openList, x, (short) (y + 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
temp.isDiagonally(false);
adj.add(temp);
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(false);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
if (CANMOVEDIAGONALY)
{
if ((x < this.mapSizeX) && (y < this.mapSizeY))
{
RoomTile temp = findTile(closedList, (short) (x + 1), (short) (y + 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
RoomTile offX = findTile(openList, (short) (x + 1), y);
RoomTile offY = findTile(openList, x, (short) (y+1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable()))
{
temp.isDiagonally(true);
adj.add(temp);
RoomTile temp = findTile(openList, (short) (x + 1), (short) (y + 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(true);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
}
if ((x > 0) && (y > 0))
{
RoomTile temp = findTile(closedList, (short) (x - 1), (short) (y - 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
RoomTile offX = findTile(openList, (short) (x - 1), y);
RoomTile offY = findTile(openList, x, (short) (y - 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable()))
{
temp.isDiagonally(true);
adj.add(temp);
RoomTile temp = findTile(openList, (short) (x - 1), (short) (y - 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(true);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
}
if ((x > 0) && (y < this.mapSizeY))
{
RoomTile temp = findTile(closedList, (short) (x - 1), (short) (y + 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
RoomTile offX = findTile(openList, (short) (x - 1), y);
RoomTile offY = findTile(openList, x, (short) (y+1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable()))
{
temp.isDiagonally(true);
adj.add(temp);
RoomTile temp = findTile(openList, (short) (x - 1), (short) (y + 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(true);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
}
if ((x < this.mapSizeX) && (y > 0))
{
RoomTile temp = findTile(closedList, (short) (x + 1), (short) (y - 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
RoomTile offX = findTile(openList, (short) (x + 1), y);
RoomTile offY = findTile(openList, x, (short) (y - 1));
if (offX != null && offY != null && (offX.isWalkable() || offY.isWalkable()))
{
temp.isDiagonally(true);
adj.add(temp);
RoomTile temp = findTile(openList, (short) (x + 1), (short) (y - 1));
if (temp != null && temp.state != RoomTileState.BLOCKED && temp.state != RoomTileState.INVALID)
{
if (temp.state != RoomTileState.SIT || nextTile.getStackHeight() - node.getStackHeight() <= 2.0)
{
temp.isDiagonally(true);
if (!adj.contains(temp))
adj.add(temp);
}
}
}
}
}

View File

@ -453,9 +453,9 @@ public class RoomManager
for(Room room : roomsToDispose)
{
room.dispose();
if(room.getUserCount() == 0)
this.activeRooms.remove(room.getId());
room.dispose();
}
}
@ -1464,7 +1464,7 @@ public class RoomManager
{
if (guild.getOwnerId() != habbo.getHabboInfo().getId())
{
Room room = this.loadRoom(guild.getRoomId());
Room room = this.getRoom(guild.getRoomId());
if (room != null)
{

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