Updated to 1.15.2 decompiled.

This commit is contained in:
capheus 2019-03-18 01:22:00 +00:00
parent 71acca7ebb
commit bc572ce79a
680 changed files with 3805 additions and 4084 deletions

View File

@ -5,7 +5,7 @@
## **To Get The Camera To Work Visit http://arcturus.wf and register.** ## ## **To Get The Camera To Work Visit http://arcturus.wf and register.** ##
## **TUTORIAL FOR PLUGINS http://arcturus.wf/thread-2415.html** ## ## **TUTORIAL FOR PLUGINS http://arcturus.wf/thread-2415.html** ##
# **DO NOT EDIT THE SOURCE. USE THE PLUGIN API.** # # **DO NOT EDIT THE SOURCE. USE THE PLUGIN API.** #
## Current Stable Version: 1.15.0 ## ## Current Stable Version: 1.15.2 ##
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. 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 Targeting PRODUCTION-201611291003-338511768

View File

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

View File

@ -1,3 +1,5 @@
#DATABASE UPDATE: 1.14.0 -> 1.15.0
ALTER TABLE `pet_commands_data` ADD PRIMARY KEY(`command_id`); 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', '1');
@ -68,3 +70,5 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('generic.tile.not.exists',
ALTER TABLE `items` CHANGE `z` `z` DOUBLE(10,6) NOT NULL DEFAULT '0.000000'; 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`; ALTER TABLE `items_base` ADD `customparams` VARCHAR(256) NOT NULL DEFAULT '' AFTER `multiheight`;
#END DATABASE UPDATE: 1.14.0 -> 1.15.0

View File

@ -0,0 +1,5 @@
CREATE INDEX room_enter_log_room_id ON room_enter_log (room_id);
CREATE INDEX room_enter_log_user_entry ON room_enter_log (user_id, timestamp);
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.messenger.search.maxresults', '50');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.alert.oldstyle', '0');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.navigator.staffpicks.categoryid', '1'); #NOTE THIS IS navigator_publiccats

View File

@ -36,7 +36,7 @@ public final class Emulator
public final static int MINOR = 15; public final static int MINOR = 15;
public final static int BUILD = 0; public final static int BUILD = 2;
public static final String version = "Version: " + MAJOR + "." + MINOR + "." + BUILD; public static final String version = "Version: " + MAJOR + "." + MINOR + "." + BUILD;

View File

@ -72,7 +72,7 @@ public class CleanerThread implements Runnable {
public CleanerThread() public CleanerThread()
{ {
databaseCleanup(); this.databaseCleanup();
Emulator.getThreading().run(this, DELAY); Emulator.getThreading().run(this, DELAY);
Emulator.getThreading().run(new AchievementUpdater()); Emulator.getThreading().run(new AchievementUpdater());
@ -132,13 +132,13 @@ public class CleanerThread implements Runnable {
if (time - LAST_DAILY_REFILL > Emulator.getConfig().getInt("hotel.refill.daily")) if (time - LAST_DAILY_REFILL > Emulator.getConfig().getInt("hotel.refill.daily"))
{ {
refillDailyRespects(); this.refillDailyRespects();
LAST_DAILY_REFILL = time; LAST_DAILY_REFILL = time;
} }
if (time - LAST_HABBO_CACHE_CLEARED > CLEAR_CACHED_VALUES) if (time - LAST_HABBO_CACHE_CLEARED > CLEAR_CACHED_VALUES)
{ {
clearCachedValues(); this.clearCachedValues();
LAST_HABBO_CACHE_CLEARED = time; LAST_HABBO_CACHE_CLEARED = time;
} }
@ -149,7 +149,7 @@ public class CleanerThread implements Runnable {
void databaseCleanup() void databaseCleanup()
{ {
refillDailyRespects(); this.refillDailyRespects();
int time = Emulator.getIntUnixTimestamp(); int time = Emulator.getIntUnixTimestamp();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
@ -206,7 +206,7 @@ public class CleanerThread implements Runnable {
private void clearCachedValues() private void clearCachedValues()
{ {
Habbo habbo = null; Habbo habbo;
for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet())
{ {
habbo = map.getValue(); habbo = map.getValue();

View File

@ -8,7 +8,7 @@ import java.sql.SQLException;
public class CommandLog implements Loggable public class CommandLog implements Loggable
{ {
public static String insertQuery = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)"; public static final String insertQuery = "INSERT INTO commandlogs (`user_id`, `timestamp`, `command`, `params`, `succes`) VALUES (?, ?, ?, ?, ?)";
private final int userId; private final int userId;
private final int timestamp = Emulator.getIntUnixTimestamp(); private final int timestamp = Emulator.getIntUnixTimestamp();

View File

@ -22,39 +22,51 @@ public class ConfigurationManager
private final Properties properties; private final Properties properties;
public ConfigurationManager(String path) throws Exception private final String configurationPath;
public ConfigurationManager(String configurationPath) throws Exception
{ {
this.properties = new Properties(); this.properties = new Properties();
this.configurationPath = configurationPath;
this.reload(); this.reload();
} }
public void reload() throws Exception public void reload()
{ {
this.isLoading = true; this.isLoading = true;
this.properties.clear(); this.properties.clear();
InputStream input = null; InputStream input = null;
try { try
File f = new File("config.ini"); {
File f = new File(this.configurationPath);
input = new FileInputStream(f); input = new FileInputStream(f);
this.properties.load(input); this.properties.load(input);
} catch (IOException ex) { }
Emulator.getLogging().logErrorLine("[CRITICAL] FAILED TO LOAD CONFIG.INI FILE!"); catch (IOException ex)
} finally { {
if (input != null) { Emulator.getLogging().logErrorLine("[CRITICAL] FAILED TO LOAD CONFIG FILE! (" + this.configurationPath + ")");
try { ex.printStackTrace();
}
finally
{
if (input != null)
{
try
{
input.close(); input.close();
} catch (IOException e) { }
catch (IOException e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
if(loaded) if(this.loaded)
{ {
this.loadFromDatabase(); this.loadFromDatabase();
} }
@ -115,7 +127,7 @@ public class ConfigurationManager
public String getValue(String key) public String getValue(String key)
{ {
return getValue(key, ""); return this.getValue(key, "");
} }
@ -133,7 +145,7 @@ public class ConfigurationManager
public boolean getBoolean(String key) public boolean getBoolean(String key)
{ {
return getBoolean(key, false); return this.getBoolean(key, false);
} }
@ -144,11 +156,11 @@ public class ConfigurationManager
try try
{ {
return (getValue(key, "0").equals("1")) || (getValue(key, "false").equals("true")); return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true"));
} }
catch (Exception e) catch (Exception e)
{ {
Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + getValue(key) + " to type boolean."); Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type boolean.");
} }
return defaultValue; return defaultValue;
} }
@ -156,7 +168,7 @@ public class ConfigurationManager
public int getInt(String key) public int getInt(String key)
{ {
return getInt(key, 0); return this.getInt(key, 0);
} }
@ -167,10 +179,10 @@ public class ConfigurationManager
try try
{ {
return Integer.parseInt(getValue(key, defaultValue.toString())); return Integer.parseInt(this.getValue(key, defaultValue.toString()));
} catch (Exception e) } catch (Exception e)
{ {
Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + getValue(key) + " to type integer."); Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type integer.");
} }
return defaultValue; return defaultValue;
} }
@ -178,7 +190,7 @@ public class ConfigurationManager
public double getDouble(String key) public double getDouble(String key)
{ {
return getDouble(key, 0.0); return this.getDouble(key, 0.0);
} }
@ -189,11 +201,11 @@ public class ConfigurationManager
try try
{ {
return Double.parseDouble(getValue(key, defaultValue.toString())); return Double.parseDouble(this.getValue(key, defaultValue.toString()));
} }
catch (Exception e) catch (Exception e)
{ {
Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + getValue(key) + " to type double."); Emulator.getLogging().logErrorLine("Failed to parse key " + key + " with value " + this.getValue(key) + " to type double.");
} }
return defaultValue; return defaultValue;

View File

@ -65,7 +65,7 @@ public class CreditsScheduler extends Scheduler
public boolean isDisposed() public boolean isDisposed()
{ {
return disposed; return this.disposed;
} }
public void setDisposed(boolean disposed) public void setDisposed(boolean disposed)

View File

@ -2,6 +2,6 @@ package com.eu.habbo.core;
public interface Disposable public interface Disposable
{ {
public void dispose(); void dispose();
public boolean disposed(); boolean disposed();
} }

View File

@ -17,23 +17,6 @@ import java.sql.SQLException;
public class Logging public class Logging
{ {
private static File packets;
private static File packetsUndefined;
private static File errorsPackets;
private static File errorsSQL;
private static File errorsRuntime;
private static File debugFile;
private static PrintWriter packetsWriter; private static PrintWriter packetsWriter;
private static PrintWriter packetsUndefinedWriter; private static PrintWriter packetsUndefinedWriter;
private static PrintWriter errorsPacketsWriter; private static PrintWriter errorsPacketsWriter;
@ -63,21 +46,27 @@ public class Logging
public static final String ANSI_WHITE = "\u001B[37m"; public static final String ANSI_WHITE = "\u001B[37m";
private final THashSet<Loggable> errorLogs = new THashSet<>(); private final THashSet<Loggable> errorLogs = new THashSet<>(100);
private final THashSet<Loggable> commandLogs = new THashSet<>(); private final THashSet<Loggable> commandLogs = new THashSet<>(100);
private ConcurrentSet<Loggable> chatLogs = new ConcurrentSet<>(); private ConcurrentSet<Loggable> chatLogs = new ConcurrentSet<>();
public Logging() public Logging()
{ {
packets = new File("logging//packets//defined.txt");
packetsUndefined = new File("logging//packets//packets.txt"); File packets = new File("logging//packets//defined.txt");
errorsPackets = new File("logging//errors//packets.txt");
errorsSQL = new File("logging//errors//sql.txt"); File packetsUndefined = new File("logging//packets//packets.txt");
errorsRuntime = new File("logging//errors//runtime.txt");
debugFile = new File("logging//debug.txt"); File errorsPackets = new File("logging//errors//packets.txt");
File errorsSQL = new File("logging//errors//sql.txt");
File errorsRuntime = new File("logging//errors//runtime.txt");
File debugFile = new File("logging//debug.txt");
try try
{ {
@ -172,7 +161,7 @@ public class Logging
{ {
if(Emulator.getConfig().getBoolean("logging.debug")) if(Emulator.getConfig().getBoolean("logging.debug"))
{ {
write(debugFileWriter, line.toString()); this.write(debugFileWriter, line.toString());
} }
System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString()); System.out.println("[" + Logging.ANSI_BRIGHT + Logging.ANSI_GREEN + "SHUTDOWN" + Logging.ANSI_RESET + "] " + line.toString());
} }
@ -181,7 +170,7 @@ public class Logging
{ {
if(Emulator.getConfig().getBoolean("logging.debug")) if(Emulator.getConfig().getBoolean("logging.debug"))
{ {
write(debugFileWriter, line.toString()); this.write(debugFileWriter, line.toString());
} }
if (Emulator.getConfig().getBoolean("debug.show.users")) if (Emulator.getConfig().getBoolean("debug.show.users"))
@ -194,7 +183,7 @@ public class Logging
{ {
if (line instanceof Throwable) if (line instanceof Throwable)
{ {
logErrorLine(line); this.logErrorLine(line);
return; return;
} }
if (Emulator.getConfig().getBoolean("debug.mode")) { if (Emulator.getConfig().getBoolean("debug.mode")) {
@ -203,7 +192,7 @@ public class Logging
if(Emulator.getConfig().getBoolean("logging.debug")) if(Emulator.getConfig().getBoolean("logging.debug"))
{ {
write(debugFileWriter, line.toString()); this.write(debugFileWriter, line.toString());
} }
} }
@ -215,7 +204,7 @@ public class Logging
if(Emulator.getConfig().getBoolean("logging.packets")) if(Emulator.getConfig().getBoolean("logging.packets"))
{ {
write(packetsWriter, line.toString()); this.write(packetsWriter, line.toString());
} }
} }
@ -228,7 +217,7 @@ public class Logging
if (Emulator.getConfig().getBoolean("logging.packets.undefined")) if (Emulator.getConfig().getBoolean("logging.packets.undefined"))
{ {
write(packetsUndefinedWriter, line.toString()); this.write(packetsUndefinedWriter, line.toString());
} }
} }
@ -241,7 +230,7 @@ public class Logging
if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime")) if (Emulator.getConfig().loaded && Emulator.getConfig().getBoolean("logging.errors.runtime"))
{ {
write(errorsRuntimeWriter, line); this.write(errorsRuntimeWriter, line);
} }
if(line instanceof Throwable) if(line instanceof Throwable)
@ -267,7 +256,7 @@ public class Logging
if(Emulator.getConfig().getBoolean("logging.errors.sql")) if(Emulator.getConfig().getBoolean("logging.errors.sql"))
{ {
e.printStackTrace(); e.printStackTrace();
write(errorsSQLWriter, e); this.write(errorsSQLWriter, e);
Emulator.getThreading().run(new HTTPPostError(e)); Emulator.getThreading().run(new HTTPPostError(e));
} }
@ -280,7 +269,7 @@ public class Logging
if(e instanceof Throwable) if(e instanceof Throwable)
((Exception) e).printStackTrace(); ((Exception) e).printStackTrace();
write(errorsPacketsWriter, e); this.write(errorsPacketsWriter, e);
} }
if(e instanceof Throwable) if(e instanceof Throwable)

View File

@ -38,7 +38,7 @@ public class PixelScheduler extends Scheduler
{ {
super.run(); super.run();
Habbo habbo = null; Habbo habbo;
for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet())
{ {
habbo = map.getValue(); habbo = map.getValue();
@ -95,7 +95,7 @@ public class PixelScheduler extends Scheduler
public boolean isDisposed() public boolean isDisposed()
{ {
return disposed; return this.disposed;
} }
public void setDisposed(boolean disposed) public void setDisposed(boolean disposed)

View File

@ -38,7 +38,7 @@ public class PointsScheduler extends Scheduler
{ {
super.run(); super.run();
Habbo habbo = null; Habbo habbo;
for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) for(Map.Entry<Integer, Habbo> map : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet())
{ {
habbo = map.getValue(); habbo = map.getValue();
@ -95,7 +95,7 @@ public class PointsScheduler extends Scheduler
public boolean isDisposed() public boolean isDisposed()
{ {
return disposed; return this.disposed;
} }
public void setDisposed(boolean disposed) public void setDisposed(boolean disposed)

View File

@ -29,11 +29,11 @@ public class RoomUserPetComposer extends MessageComposer
this.response.appendString(this.habbo.getHabboInfo().getUsername()); this.response.appendString(this.habbo.getHabboInfo().getUsername());
this.response.appendString(""); this.response.appendString("");
this.response.appendString(this.petType + " " + this.race + " " + this.color + " 2 2 -1 0 3 -1 0"); this.response.appendString(this.petType + " " + this.race + " " + this.color + " 2 2 -1 0 3 -1 0");
this.response.appendInt(habbo.getRoomUnit().getId()); this.response.appendInt(this.habbo.getRoomUnit().getId());
this.response.appendInt(habbo.getRoomUnit().getX()); this.response.appendInt(this.habbo.getRoomUnit().getX());
this.response.appendInt(habbo.getRoomUnit().getY()); this.response.appendInt(this.habbo.getRoomUnit().getY());
this.response.appendString(habbo.getRoomUnit().getZ() + ""); this.response.appendString(this.habbo.getRoomUnit().getZ() + "");
this.response.appendInt(habbo.getRoomUnit().getBodyRotation().getValue()); this.response.appendInt(this.habbo.getRoomUnit().getBodyRotation().getValue());
this.response.appendInt(2); this.response.appendInt(2);
this.response.appendInt(this.petType); this.response.appendInt(this.petType);
this.response.appendInt(this.habbo.getHabboInfo().getId()); this.response.appendInt(this.habbo.getHabboInfo().getId());

View File

@ -55,7 +55,7 @@ public class TextsManager
public String getValue(String key) public String getValue(String key)
{ {
return getValue(key, ""); return this.getValue(key, "");
} }
@ -70,7 +70,7 @@ public class TextsManager
public boolean getBoolean(String key) public boolean getBoolean(String key)
{ {
return getBoolean(key, false); return this.getBoolean(key, false);
} }
@ -78,7 +78,7 @@ public class TextsManager
{ {
try try
{ {
return (getValue(key, "0").equals("1")) || (getValue(key, "false").equals("true")); return (this.getValue(key, "0").equals("1")) || (this.getValue(key, "false").equals("true"));
} }
catch (Exception e) catch (Exception e)
{ {
@ -90,7 +90,7 @@ public class TextsManager
public int getInt(String key) public int getInt(String key)
{ {
return getInt(key, 0); return this.getInt(key, 0);
} }
@ -98,7 +98,7 @@ public class TextsManager
{ {
try try
{ {
return Integer.parseInt(getValue(key, defaultValue.toString())); return Integer.parseInt(this.getValue(key, defaultValue.toString()));
} }
catch (Exception e) catch (Exception e)
{ {

View File

@ -1,11 +1,12 @@
package com.eu.habbo.core.consolecommands; package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.THashMap;
public abstract class ConsoleCommand public abstract class ConsoleCommand
{ {
private static THashMap<String, ConsoleCommand> commands = new THashMap<>(); private static final THashMap<String, ConsoleCommand> commands = new THashMap<>();
public final String key; public final String key;
@ -28,6 +29,7 @@ public abstract class ConsoleCommand
addCommand(new ConsoleTestCommand()); addCommand(new ConsoleTestCommand());
addCommand(new ConsoleReconnectCameraCommand()); addCommand(new ConsoleReconnectCameraCommand());
addCommand(new ShowInteractionsCommand()); addCommand(new ShowInteractionsCommand());
addCommand(new ShowRCONCommands());
} }
@ -63,7 +65,7 @@ public abstract class ConsoleCommand
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
} }
else else

View File

@ -0,0 +1,20 @@
package com.eu.habbo.core.consolecommands;
import com.eu.habbo.Emulator;
public class ShowRCONCommands extends ConsoleCommand
{
public ShowRCONCommands()
{
super("rconcommands", "Show a list of all RCON commands");
}
@Override
public void handle(String[] args) throws Exception
{
for (String command : Emulator.getRconServer().getCommands())
{
System.out.println(command);
}
}
}

View File

@ -48,7 +48,7 @@ public class GameEnvironment
public PixelScheduler pixelScheduler; public PixelScheduler pixelScheduler;
public PointsScheduler pointsScheduler; public PointsScheduler pointsScheduler;
public void load() public void load() throws Exception
{ {
Emulator.getLogging().logStart("GameEnvironment -> Loading..."); Emulator.getLogging().logStart("GameEnvironment -> Loading...");

View File

@ -22,9 +22,9 @@ public class Achievement
public Achievement(ResultSet set) throws SQLException public Achievement(ResultSet set) throws SQLException
{ {
levels = new THashMap<>(); this.levels = new THashMap<>();
id = set.getInt("id"); this.id = set.getInt("id");
this.name = set.getString("name"); this.name = set.getString("name");
this.category = AchievementCategories.valueOf(set.getString("category").toUpperCase()); this.category = AchievementCategories.valueOf(set.getString("category").toUpperCase());

View File

@ -189,13 +189,11 @@ public class AchievementManager
int currentProgress = habbo.getHabboStats().getAchievementProgress(achievement); int currentProgress = habbo.getHabboStats().getAchievementProgress(achievement);
boolean created = false;
if(currentProgress == -1) if(currentProgress == -1)
{ {
currentProgress = 0; currentProgress = 0;
createUserEntry(habbo, achievement); createUserEntry(habbo, achievement);
habbo.getHabboStats().setProgress(achievement, 0); habbo.getHabboStats().setProgress(achievement, 0);
created = true;
} }
if(Emulator.getPluginManager().isRegistered(UserAchievementProgressEvent.class, true)) if(Emulator.getPluginManager().isRegistered(UserAchievementProgressEvent.class, true))
@ -209,11 +207,6 @@ public class AchievementManager
AchievementLevel oldLevel = achievement.getLevelForProgress(currentProgress); AchievementLevel oldLevel = achievement.getLevelForProgress(currentProgress);
if(oldLevel != null && (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; return;
@ -325,12 +318,7 @@ public class AchievementManager
AchievementLevel nextLevel = achievement.levels.get(level.level + 1); AchievementLevel nextLevel = achievement.levels.get(level.level + 1);
if (nextLevel == null && currentProgress >= level.progress) return nextLevel == null && currentProgress >= level.progress;
{
return true;
}
return false;
} }

View File

@ -64,7 +64,7 @@ public class TalentTrackLevel
if (item != null) if (item != null)
{ {
items.add(item); this.items.add(item);
} }
else else
{ {

View File

@ -6,7 +6,10 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender; import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.*; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserShoutComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserTalkComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserWhisperComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUsersComposer;
import com.eu.habbo.plugin.events.bots.BotChatEvent; import com.eu.habbo.plugin.events.bots.BotChatEvent;
import com.eu.habbo.plugin.events.bots.BotShoutEvent; import com.eu.habbo.plugin.events.bots.BotShoutEvent;
import com.eu.habbo.plugin.events.bots.BotTalkEvent; import com.eu.habbo.plugin.events.bots.BotTalkEvent;
@ -24,7 +27,7 @@ public class Bot implements Runnable
{ {
public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}"; public static final String NO_CHAT_SET = "${bot.skill.chatter.configuration.text.placeholder}";
private int id; private transient int id;
private String name; private String name;
@ -63,6 +66,9 @@ public class Bot implements Runnable
private int chatTimeOut; private int chatTimeOut;
private int chatTimestamp;
private final ArrayList<String> chatLines; private final ArrayList<String> chatLines;
@ -74,13 +80,13 @@ public class Bot implements Runnable
private int effect; private int effect;
private boolean canWalk = true; private transient boolean canWalk = true;
private boolean needsUpdate; private boolean needsUpdate;
private int followingHabboId; private transient int followingHabboId;
public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName) public Bot(int id, String name, String motto, String figure, HabboGender gender, int ownerId, String ownerName)
{ {
@ -119,7 +125,6 @@ public class Bot implements Runnable
this.roomUnit = null; this.roomUnit = null;
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
this.needsUpdate = false; this.needsUpdate = false;
this.lastChatIndex = 0;
} }
public Bot(Bot bot) public Bot(Bot bot)
@ -134,12 +139,9 @@ public class Bot implements Runnable
this.chatRandom = false; this.chatRandom = false;
this.chatDelay = 10; this.chatDelay = 10;
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay; this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
this.chatLines = new ArrayList<>(Arrays.asList(new String[] {"Default Message :D"})); this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D"));
this.type = bot.getType(); this.type = bot.getType();
this.effect = bot.getEffect(); this.effect = bot.getEffect();
this.room = null;
this.roomUnit = null;
this.lastChatIndex = 0;
this.needsUpdate = false; this.needsUpdate = false;
} }
@ -175,12 +177,12 @@ public class Bot implements Runnable
statement.setInt(10, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue()); statement.setInt(10, this.roomUnit == null ? 0 : this.roomUnit.getBodyRotation().getValue());
statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType()); statement.setInt(11, this.roomUnit == null ? 0 : this.roomUnit.getDanceType().getType());
statement.setString(12, this.canWalk ? "1" : "0"); statement.setString(12, this.canWalk ? "1" : "0");
String text = ""; StringBuilder text = new StringBuilder();
for(String s : this.chatLines) for(String s : this.chatLines)
{ {
text += s + "\r"; text.append(s).append("\r");
} }
statement.setString(13, text); statement.setString(13, text.toString());
statement.setString(14, this.chatAuto ? "1" : "0"); statement.setString(14, this.chatAuto ? "1" : "0");
statement.setString(15, this.chatRandom ? "1" : "0"); statement.setString(15, this.chatRandom ? "1" : "0");
statement.setInt(16, this.chatDelay); statement.setInt(16, this.chatDelay);
@ -214,7 +216,7 @@ public class Bot implements Runnable
{ {
for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY()))) for (RoomTile t : this.room.getLayout().getTilesAround(this.room.getLayout().getTile(this.getRoomUnit().getX(), this.getRoomUnit().getY())))
{ {
WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, room.getItemsAt(t).toArray()); WiredHandler.handle(WiredTriggerType.BOT_REACHED_STF, this.roomUnit, this.room, this.room.getItemsAt(t).toArray());
} }
} }
} }
@ -252,6 +254,7 @@ public class Bot implements Runnable
if(Emulator.getPluginManager().fireEvent(event).isCancelled()) if(Emulator.getPluginManager().fireEvent(event).isCancelled())
return; return;
this.chatTimestamp = Emulator.getIntUnixTimestamp();
this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); this.room.botChat(new RoomUserTalkComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose());
} }
} }
@ -265,6 +268,7 @@ public class Bot implements Runnable
if(Emulator.getPluginManager().fireEvent(event).isCancelled()) if(Emulator.getPluginManager().fireEvent(event).isCancelled())
return; return;
this.chatTimestamp = Emulator.getIntUnixTimestamp();
this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose()); this.room.botChat(new RoomUserShoutComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)).compose());
} }
} }
@ -278,6 +282,7 @@ public class Bot implements Runnable
if(Emulator.getPluginManager().fireEvent(event).isCancelled()) if(Emulator.getPluginManager().fireEvent(event).isCancelled())
return; return;
this.chatTimestamp = Emulator.getIntUnixTimestamp();
event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE))); event.target.getClient().sendResponse(new RoomUserWhisperComposer(new RoomChatMessage(event.message, this.roomUnit, RoomChatMessageBubbles.BOT_RENTABLE)));
} }
} }
@ -476,6 +481,11 @@ public class Bot implements Runnable
} }
public int getChatTimestamp()
{
return this.chatTimestamp;
}
public void clearChat() public void clearChat()
{ {
synchronized (this.chatLines) synchronized (this.chatLines)
@ -498,18 +508,16 @@ public class Bot implements Runnable
} }
public void setEffect(int effect) public void setEffect(int effect, int duration)
{ {
this.effect = effect; this.effect = effect;
this.needsUpdate = true; this.needsUpdate = true;
if (this.roomUnit != null) if (this.roomUnit != null)
{ {
this.roomUnit.setEffectId(this.effect);
if (this.room != null) if (this.room != null)
{ {
this.room.sendComposer(new RoomUserEffectComposer(this.roomUnit).compose()); this.room.giveEffect(this.roomUnit, this.effect, duration);
} }
} }
} }

View File

@ -22,8 +22,6 @@ import java.util.Map;
public class BotManager public class BotManager
{ {
//Configuration. Loaded from database & updated accordingly.
public static int MINIMUM_CHAT_SPEED = 7; public static int MINIMUM_CHAT_SPEED = 7;
@ -33,18 +31,19 @@ public class BotManager
public static int MAXIMUM_CHAT_LENGTH = 120; public static int MAXIMUM_CHAT_LENGTH = 120;
public static int MAXIMUM_NAME_LENGTH = 15; public static int MAXIMUM_NAME_LENGTH = 15;
final private static THashMap<String, Class<? extends Bot>> botDefenitions = new THashMap<>(); final private static THashMap<String, Class<? extends Bot>> botDefenitions = new THashMap<>();
public BotManager() public BotManager() throws Exception
{ {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
botDefenitions.put("generic", Bot.class); addBotDefinition("generic", Bot.class);
botDefenitions.put("bartender", ButlerBot.class); addBotDefinition("bartender", ButlerBot.class);
botDefenitions.put("visitor_log", VisitorBot.class); addBotDefinition("visitor_log", VisitorBot.class);
this.reload(); this.reload();

View File

@ -14,6 +14,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -45,10 +46,7 @@ public class ButlerBot extends Bot
{ {
String[] keys = set.getString("keys").split(";"); String[] keys = set.getString("keys").split(";");
THashSet<String> ks = new THashSet<>(); THashSet<String> ks = new THashSet<>();
for(String key : keys) Collections.addAll(ks, keys);
{
ks.add(key);
}
serveItems.put(ks, set.getInt("item")); serveItems.put(ks, set.getInt("item"));
} }
} }

View File

@ -13,9 +13,9 @@ import java.util.Date;
public class VisitorBot extends Bot public class VisitorBot extends Bot
{ {
private static SimpleDateFormat formatDate; private static SimpleDateFormat DATE_FORMAT;
private boolean showedLog = false; private boolean showedLog = false;
private THashSet<ModToolRoomVisit> visits = new THashSet<>(); private THashSet<ModToolRoomVisit> visits = new THashSet<>(3);
public VisitorBot(ResultSet set) throws SQLException public VisitorBot(ResultSet set) throws SQLException
{ {
@ -38,16 +38,16 @@ public class VisitorBot extends Bot
String visitMessage = Emulator.getTexts().getValue("bots.visitor.list").replace("%count%", this.visits.size() + ""); String visitMessage = Emulator.getTexts().getValue("bots.visitor.list").replace("%count%", this.visits.size() + "");
String list = ""; StringBuilder list = new StringBuilder();
for(ModToolRoomVisit visit : this.visits) for(ModToolRoomVisit visit : this.visits)
{ {
list += "\r"; list.append("\r");
list += visit.roomName + " "; list.append(visit.roomName).append(" ");
list += Emulator.getTexts().getValue("generic.time.at") + " "; list.append(Emulator.getTexts().getValue("generic.time.at")).append(" ");
list += formatDate.format(new Date((visit.timestamp * 1000L))); list.append(DATE_FORMAT.format(new Date((visit.timestamp * 1000L))));
} }
visitMessage = visitMessage.replace("%list%", list); visitMessage = visitMessage.replace("%list%", list.toString());
this.talk(visitMessage); this.talk(visitMessage);
@ -78,7 +78,7 @@ public class VisitorBot extends Bot
public static void initialise() public static void initialise()
{ {
formatDate = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat")); DATE_FORMAT = new SimpleDateFormat(Emulator.getConfig().getValue("bots.visitor.dateformat"));
} }
} }

View File

@ -16,58 +16,58 @@ import java.util.HashMap;
public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem> public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem>
{ {
protected int id; int id;
protected int pageId; private int pageId;
protected String itemId; private String itemId;
protected String name; private String name;
protected int credits; private int credits;
protected int points; private int points;
protected short pointsType; private short pointsType;
protected int amount; private int amount;
protected boolean allowGift = false; private boolean allowGift = false;
protected int limitedStack; int limitedStack;
protected int limitedSells; private int limitedSells;
protected String extradata; private String extradata;
protected boolean clubOnly; private boolean clubOnly;
protected boolean haveOffer; private boolean haveOffer;
protected int offerId; private int offerId;
protected boolean needsUpdate; private boolean needsUpdate;
protected int orderNumber; private int orderNumber;
protected HashMap<Integer, Integer> bundle; private HashMap<Integer, Integer> bundle;
public CatalogItem(ResultSet set) throws SQLException public CatalogItem(ResultSet set) throws SQLException
{ {
@ -213,7 +213,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem
} }
public int getOrderNumber() private int getOrderNumber()
{ {
return this.orderNumber; return this.orderNumber;
} }
@ -252,7 +252,7 @@ public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem
itemId = itemId.split(":")[0]; itemId = itemId.split(":")[0];
} }
int identifier = 0; int identifier;
try try
{ {
@ -320,10 +320,11 @@ public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem
} }
} }
} }
} catch (Exception e) }
catch (Exception e)
{ {
Emulator.getLogging().logDebugLine("Failed to load " + itemId); Emulator.getLogging().logDebugLine("Failed to load " + this.itemId);
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
} }
else else
@ -482,9 +483,6 @@ public class CatalogItem implements ISerialize, Runnable, Comparable<CatalogItem
return false; return false;
} }
if(item.getName().toLowerCase().startsWith("rentable_bot_")) return !item.getName().toLowerCase().startsWith("rentable_bot_");
return false;
return true;
} }
} }

View File

@ -31,7 +31,7 @@ public class CatalogLimitedConfiguration implements Runnable
int num = this.limitedNumbers.pop(); int num = this.limitedNumbers.pop();
if(this.limitedNumbers.isEmpty()) if(this.limitedNumbers.isEmpty())
{ {
Emulator.getGameEnvironment().getCatalogManager().moveCatalogItem(Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(itemId), Emulator.getConfig().getInt("catalog.ltd.page.soldout")); Emulator.getGameEnvironment().getCatalogManager().moveCatalogItem(Emulator.getGameEnvironment().getCatalogManager().getCatalogItem(this.itemId), Emulator.getConfig().getInt("catalog.ltd.page.soldout"));
} }
return num; return num;
} }

View File

@ -94,51 +94,88 @@ public class CatalogManager
public final THashMap<Integer, CalendarRewardObject> calendarRewards; public final THashMap<Integer, CalendarRewardObject> calendarRewards;
public static final THashMap<String, Class<? extends CatalogPage>> pageDefinitions = new THashMap<String, Class<? extends CatalogPage>>() public static final THashMap<String, Class<? extends CatalogPage>> pageDefinitions = new THashMap<String, Class<? extends CatalogPage>>(CatalogPageLayouts.values().length)
{ {
{ {
for (CatalogPageLayouts layout : CatalogPageLayouts.values()) for (CatalogPageLayouts layout : CatalogPageLayouts.values())
{ {
switch(layout) switch(layout)
{ {
case frontpage: put(layout.name().toLowerCase(), FrontpageLayout.class); break; case frontpage:
case badge_display: put(layout.name().toLowerCase(), BadgeDisplayLayout.class); break; this.put(layout.name().toLowerCase(), FrontpageLayout.class); break;
case spaces_new: put(layout.name().toLowerCase(), SpacesLayout.class); break; case badge_display:
case trophies: put(layout.name().toLowerCase(), TrophiesLayout.class); break; this.put(layout.name().toLowerCase(), BadgeDisplayLayout.class); break;
case bots: put(layout.name().toLowerCase(), BotsLayout.class); break; case spaces_new:
case club_buy: put(layout.name().toLowerCase(), ClubBuyLayout.class); break; this.put(layout.name().toLowerCase(), SpacesLayout.class); break;
case club_gift: put(layout.name().toLowerCase(), ClubGiftsLayout.class); break; case trophies:
case sold_ltd_items: put(layout.name().toLowerCase(), SoldLTDItemsLayout.class); break; this.put(layout.name().toLowerCase(), TrophiesLayout.class); break;
case single_bundle: put(layout.name().toLowerCase(), SingleBundle.class); break; case bots:
case roomads: put(layout.name().toLowerCase(), RoomAdsLayout.class); break; this.put(layout.name().toLowerCase(), BotsLayout.class); break;
case recycler: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) put(layout.name().toLowerCase(), RecyclerLayout.class); break; case club_buy:
case recycler_info: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) put(layout.name().toLowerCase(), RecyclerInfoLayout.class); this.put(layout.name().toLowerCase(), ClubBuyLayout.class); break;
case recycler_prizes: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled")) put(layout.name().toLowerCase(), RecyclerPrizesLayout.class); break; case club_gift:
case marketplace: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) put(layout.name().toLowerCase(), MarketplaceLayout.class); break; this.put(layout.name().toLowerCase(), ClubGiftsLayout.class); break;
case marketplace_own_items: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled")) put(layout.name().toLowerCase(), MarketplaceOwnItems.class); break; case sold_ltd_items:
case info_duckets: put(layout.name().toLowerCase(), InfoDucketsLayout.class); break; this.put(layout.name().toLowerCase(), SoldLTDItemsLayout.class); break;
case info_pets: put(layout.name().toLowerCase(), InfoPetsLayout.class); break; case single_bundle:
case info_rentables: put(layout.name().toLowerCase(), InfoRentablesLayout.class); break; this.put(layout.name().toLowerCase(), SingleBundle.class); break;
case info_loyalty: put(layout.name().toLowerCase(), InfoLoyaltyLayout.class); break; case roomads:
case loyalty_vip_buy: put(layout.name().toLowerCase(), LoyaltyVipBuyLayout.class); break; this.put(layout.name().toLowerCase(), RoomAdsLayout.class); break;
case guilds: put(layout.name().toLowerCase(), GuildFrontpageLayout.class); break; case recycler: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled"))
case guild_furni: put(layout.name().toLowerCase(), GuildFurnitureLayout.class); break; this.put(layout.name().toLowerCase(), RecyclerLayout.class); break;
case guild_forum: put(layout.name().toLowerCase(), GuildForumLayout.class); break; case recycler_info: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled"))
case pets: put(layout.name().toLowerCase(), PetsLayout.class); break; this.put(layout.name().toLowerCase(), RecyclerInfoLayout.class);
case pets2: put(layout.name().toLowerCase(), Pets2Layout.class); break; case recycler_prizes: if (Emulator.getConfig().getBoolean("hotel.ecotron.enabled"))
case pets3: put(layout.name().toLowerCase(), Pets3Layout.class); break; this.put(layout.name().toLowerCase(), RecyclerPrizesLayout.class); break;
case soundmachine: put(layout.name().toLowerCase(), TraxLayout.class); break; case marketplace: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled"))
case default_3x3_color_grouping: put(layout.name().toLowerCase(), ColorGroupingLayout.class); break; this.put(layout.name().toLowerCase(), MarketplaceLayout.class); break;
case recent_purchases: put(layout.name().toLowerCase(), RecentPurchasesLayout.class); break; case marketplace_own_items: if (Emulator.getConfig().getBoolean("hotel.marketplace.enabled"))
case room_bundle: put(layout.name().toLowerCase(), RoomBundleLayout.class); break; this.put(layout.name().toLowerCase(), MarketplaceOwnItems.class); break;
case petcustomization: put(layout.name().toLowerCase(), PetCustomizationLayout.class); break; case info_duckets:
case vip_buy: put(layout.name().toLowerCase(), VipBuyLayout.class); break; this.put(layout.name().toLowerCase(), InfoDucketsLayout.class); break;
case frontpage_featured: put(layout.name().toLowerCase(), FrontPageFeaturedLayout.class); break; case info_pets:
case builders_club_addons: put(layout.name().toLowerCase(), BuildersClubAddonsLayout.class); break; this.put(layout.name().toLowerCase(), InfoPetsLayout.class); break;
case builders_club_frontpage: put(layout.name().toLowerCase(), BuildersClubFrontPageLayout.class); break; case info_rentables:
case builders_club_loyalty: put(layout.name().toLowerCase(), BuildersClubLoyaltyLayout.class); break; this.put(layout.name().toLowerCase(), InfoRentablesLayout.class); break;
case info_loyalty:
this.put(layout.name().toLowerCase(), InfoLoyaltyLayout.class); break;
case loyalty_vip_buy:
this.put(layout.name().toLowerCase(), LoyaltyVipBuyLayout.class); break;
case guilds:
this.put(layout.name().toLowerCase(), GuildFrontpageLayout.class); break;
case guild_furni:
this.put(layout.name().toLowerCase(), GuildFurnitureLayout.class); break;
case guild_forum:
this.put(layout.name().toLowerCase(), GuildForumLayout.class); break;
case pets:
this.put(layout.name().toLowerCase(), PetsLayout.class); break;
case pets2:
this.put(layout.name().toLowerCase(), Pets2Layout.class); break;
case pets3:
this.put(layout.name().toLowerCase(), Pets3Layout.class); break;
case soundmachine:
this.put(layout.name().toLowerCase(), TraxLayout.class); break;
case default_3x3_color_grouping:
this.put(layout.name().toLowerCase(), ColorGroupingLayout.class); break;
case recent_purchases:
this.put(layout.name().toLowerCase(), RecentPurchasesLayout.class); break;
case room_bundle:
this.put(layout.name().toLowerCase(), RoomBundleLayout.class); break;
case petcustomization:
this.put(layout.name().toLowerCase(), PetCustomizationLayout.class); break;
case vip_buy:
this.put(layout.name().toLowerCase(), VipBuyLayout.class); break;
case frontpage_featured:
this.put(layout.name().toLowerCase(), FrontPageFeaturedLayout.class); break;
case builders_club_addons:
this.put(layout.name().toLowerCase(), BuildersClubAddonsLayout.class); break;
case builders_club_frontpage:
this.put(layout.name().toLowerCase(), BuildersClubFrontPageLayout.class); break;
case builders_club_loyalty:
this.put(layout.name().toLowerCase(), BuildersClubLoyaltyLayout.class); break;
case default_3x3: case default_3x3:
default: put("default_3x3", Default_3x3Layout.class); break; default:
this.put("default_3x3", Default_3x3Layout.class); break;
} }
} }
} }
@ -175,17 +212,17 @@ public class CatalogManager
try try
{ {
loadLimitedNumbers(); this.loadLimitedNumbers();
loadCatalogPages(); this.loadCatalogPages();
loadCatalogFeaturedPages(); this.loadCatalogFeaturedPages();
loadCatalogItems(); this.loadCatalogItems();
loadClubOffers(); this.loadClubOffers();
loadTargetOffers(); this.loadTargetOffers();
loadVouchers(); this.loadVouchers();
loadClothing(); this.loadClothing();
loadRecycler(); this.loadRecycler();
loadGiftWrappers(); this.loadGiftWrappers();
loadCalendarRewards(); this.loadCalendarRewards();
} }
catch(SQLException e) catch(SQLException e)
{ {
@ -237,16 +274,10 @@ public class CatalogManager
final THashMap<Integer, CatalogPage> pages = new THashMap<>(); final THashMap<Integer, CatalogPage> pages = new THashMap<>();
pages.put(-1, new CatalogRootLayout(null)); pages.put(-1, new CatalogRootLayout(null));
ResultSet set = null;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_pages ORDER BY parent_id, id")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("SELECT * FROM catalog_pages ORDER BY parent_id, id"))
{ {
set = statement.executeQuery(); try (ResultSet set = statement.executeQuery())
}
catch (SQLException e)
{ {
Emulator.getLogging().logSQLException(e);
}
while(set.next()) while(set.next())
{ {
Class<? extends CatalogPage> pageClazz = pageDefinitions.get(set.getString("page_layout")); Class<? extends CatalogPage> pageClazz = pageDefinitions.get(set.getString("page_layout"));
@ -267,8 +298,12 @@ public class CatalogManager
Emulator.getLogging().logErrorLine("Failed to load layout: " + set.getString("page_layout")); Emulator.getLogging().logErrorLine("Failed to load layout: " + set.getString("page_layout"));
} }
} }
}
set.close(); }
catch (SQLException e)
{
Emulator.getLogging().logSQLException(e);
}
pages.forEachValue(new TObjectProcedure<CatalogPage>() pages.forEachValue(new TObjectProcedure<CatalogPage>()
{ {
@ -1001,7 +1036,7 @@ public class CatalogManager
{ {
if (amount * item.getAmount() > 100) if (amount * item.getAmount() > 100)
{ {
habbo.getClient().sendResponse(new GenericAlertComposer("Whoops! You tried to buy this " + (amount * item.getAmount()) + " times. This must've been a mistake.")); habbo.alert("Whoops! You tried to buy this " + (amount * item.getAmount()) + " times. This must've been a mistake.");
habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL)); habbo.getClient().sendResponse(new AlertPurchaseUnavailableComposer(AlertPurchaseUnavailableComposer.ILLEGAL));
return; return;
} }
@ -1059,11 +1094,11 @@ public class CatalogManager
{ {
for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++) for (int k = 0; k < item.getItemAmount(baseItem.getId()); k++)
{ {
cBaseItem = baseItem;
if (baseItem.getName().startsWith("rentable_bot_") || baseItem.getName().startsWith("bot_")) if (baseItem.getName().startsWith("rentable_bot_") || baseItem.getName().startsWith("bot_"))
{ {
String type = item.getName().replace("rentable_bot_", ""); String type = item.getName().replace("rentable_bot_", "");
type = type.replace("bot_", ""); type = type.replace("bot_", "");
type = type.replace("visitor_logger", "visitor_log");
THashMap<String, String> data = new THashMap<>(); THashMap<String, String> data = new THashMap<>();

View File

@ -34,10 +34,10 @@ public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize
protected String textTwo; protected String textTwo;
protected String textDetails; protected String textDetails;
protected String textTeaser; protected String textTeaser;
protected TIntArrayList offerIds = new TIntArrayList(); protected final TIntArrayList offerIds = new TIntArrayList();
protected THashMap<Integer, CatalogPage> childPages = new THashMap<>();; protected final THashMap<Integer, CatalogPage> childPages = new THashMap<>();
private TIntObjectMap<CatalogItem> catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>()); private final TIntObjectMap<CatalogItem> catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>());
private ArrayList<Integer> included = new ArrayList<>(); private final ArrayList<Integer> included = new ArrayList<>();
public CatalogPage(ResultSet set) throws SQLException public CatalogPage(ResultSet set) throws SQLException
{ {

View File

@ -6,7 +6,7 @@ import java.sql.SQLException;
public class Voucher public class Voucher
{ {
private final int id; public final int id;
public final String code; public final String code;

View File

@ -18,9 +18,9 @@ public class InfoDucketsLayout extends CatalogPage
{ {
message.appendString("info_duckets"); message.appendString("info_duckets");
message.appendInt(1); message.appendInt(1);
message.appendString(getHeaderImage()); message.appendString(this.getHeaderImage());
message.appendInt(1); message.appendInt(1);
message.appendString(getTextOne()); message.appendString(this.getTextOne());
message.appendInt(0); message.appendInt(0);
} }
} }

View File

@ -18,9 +18,9 @@ public class InfoLoyaltyLayout extends CatalogPage
{ {
message.appendString("info_loyalty"); message.appendString("info_loyalty");
message.appendInt(1); message.appendInt(1);
message.appendString(getHeaderImage()); message.appendString(this.getHeaderImage());
message.appendInt(1); message.appendInt(1);
message.appendString(getTextOne()); message.appendString(this.getTextOne());
message.appendInt(0); message.appendInt(0);
} }
} }

View File

@ -18,12 +18,12 @@ public class InfoPetsLayout extends CatalogPage
{ {
message.appendString("info_pets"); message.appendString("info_pets");
message.appendInt(2); message.appendInt(2);
message.appendString(getHeaderImage()); message.appendString(this.getHeaderImage());
message.appendString(getTeaserImage()); message.appendString(this.getTeaserImage());
message.appendInt(3); message.appendInt(3);
message.appendString(getTextOne()); message.appendString(this.getTextOne());
message.appendString(""); message.appendString("");
message.appendString(getTextTeaser()); message.appendString(this.getTextTeaser());
message.appendInt(0); message.appendInt(0);
} }
} }

View File

@ -16,10 +16,10 @@ public class InfoRentablesLayout extends CatalogPage
@Override @Override
public void serialize(ServerMessage message) public void serialize(ServerMessage message)
{ {
String[] data = getTextOne().split("\\|\\|"); String[] data = this.getTextOne().split("\\|\\|");
message.appendString("info_rentables"); message.appendString("info_rentables");
message.appendInt(1); message.appendInt(1);
message.appendString(getHeaderImage()); message.appendString(this.getHeaderImage());
message.appendInt(data.length); message.appendInt(data.length);
for (String d : data) { for (String d : data) {
message.appendString(d); message.appendString(d);

View File

@ -19,7 +19,7 @@ import java.util.Map;
public class RoomBundleLayout extends SingleBundle public class RoomBundleLayout extends SingleBundle
{ {
public int roomId = 0; public int roomId;
public Room room; public Room room;
private int lastUpdate = 0; private int lastUpdate = 0;
private boolean loaded = false; private boolean loaded = false;
@ -106,14 +106,14 @@ public class RoomBundleLayout extends SingleBundle
items.put(Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(item[0].getExtradata())), 1); items.put(Emulator.getGameEnvironment().getItemManager().getItem(Integer.valueOf(item[0].getExtradata())), 1);
} }
String data = ""; StringBuilder data = new StringBuilder();
for(Map.Entry<Item, Integer> set : items.entrySet()) for(Map.Entry<Item, Integer> set : items.entrySet())
{ {
data += set.getKey().getId() + ":" + set.getValue() + ";"; data.append(set.getKey().getId()).append(":").append(set.getValue()).append(";");
} }
item[0].setItemId(data); item[0].setItemId(data.toString());
item[0].loadBundle(); item[0].loadBundle();
} }
@ -237,12 +237,12 @@ public class RoomBundleLayout extends SingleBundle
statement.setInt(7, bot.getRoomUnit().getX()); statement.setInt(7, bot.getRoomUnit().getX());
statement.setInt(8, bot.getRoomUnit().getY()); statement.setInt(8, bot.getRoomUnit().getY());
statement.setDouble(9, bot.getRoomUnit().getZ()); statement.setDouble(9, bot.getRoomUnit().getZ());
String text = ""; StringBuilder text = new StringBuilder();
for (String s : bot.getChatLines()) for (String s : bot.getChatLines())
{ {
text += s + "\r"; text.append(s).append("\r");
} }
statement.setString(10, text); statement.setString(10, text.toString());
statement.setString(11, bot.isChatAuto() ? "1" : "0"); statement.setString(11, bot.isChatAuto() ? "1" : "0");
statement.setString(12, bot.isChatRandom() ? "1" : "0"); statement.setString(12, bot.isChatRandom() ? "1" : "0");
statement.setInt(13, bot.getChatDelay()); statement.setInt(13, bot.getChatDelay());

View File

@ -191,16 +191,6 @@ public class MarketPlace
query += " ORDER BY minPrice DESC"; query += " ORDER BY minPrice DESC";
break; break;
} }
if (sort == 3)
{
}
if (sort == 2)
{
}
else
{
}
query += ")"; query += ")";
@ -444,11 +434,7 @@ public class MarketPlace
try try
{ {
MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo()); MarketPlaceOffer offer = new MarketPlaceOffer(event.item, event.price, client.getHabbo());
if(offer != null)
{
client.getHabbo().getInventory().addMarketplaceOffer(offer); client.getHabbo().getInventory().addMarketplaceOffer(offer);
client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item); client.getHabbo().getInventory().getItemsComponent().removeHabboItem(event.item);
client.sendResponse(new RemoveHabboItemComposer(event.item.getId())); client.sendResponse(new RemoveHabboItemComposer(event.item.getId()));
client.sendResponse(new InventoryRefreshComposer()); client.sendResponse(new InventoryRefreshComposer());
@ -456,7 +442,6 @@ public class MarketPlace
item.needsUpdate(true); item.needsUpdate(true);
Emulator.getThreading().run(item); Emulator.getThreading().run(item);
} }
}
catch (SQLException e) catch (SQLException e)
{ {
Emulator.getLogging().logSQLException(e); Emulator.getLogging().logSQLException(e);

View File

@ -47,7 +47,7 @@ public class AboutCommand extends Command
"<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.pw \r\r" + "<b>Thanks for using Arcturus. Report issues on the forums. http://arcturus.pw \r\r" +
" - The General"; " - The General";
gameClient.sendResponse(new GenericAlertComposer(message)); gameClient.getHabbo().alert(message);
return true; return true;
} }

View File

@ -28,17 +28,17 @@ public class AlertCommand extends Command {
} }
String targetUsername = params[1]; String targetUsername = params[1];
String message = ""; StringBuilder message = new StringBuilder();
for(int i = 2; i < params.length; i++) for(int i = 2; i < params.length; i++)
{ {
message += (params[i] + " "); message.append(params[i]).append(" ");
} }
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(targetUsername); Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(targetUsername);
if (habbo != null) { if (habbo != null) {
habbo.getClient().sendResponse(new GenericAlertComposer(message + "\r\n -" + gameClient.getHabbo().getHabboInfo().getUsername())); habbo.alert(message + "\r\n -" + gameClient.getHabbo().getHabboInfo().getUsername());
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_alert.message_send").replace("%user%", targetUsername), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_alert.message_send").replace("%user%", targetUsername), RoomChatMessageBubbles.ALERT);
} else { } else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_alert.user_offline").replace("%user%", targetUsername), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_alert.user_offline").replace("%user%", targetUsername), RoomChatMessageBubbles.ALERT);

View File

@ -46,7 +46,7 @@ public class AllowTradingCommand extends Command
} }
else else
{ {
boolean found = false; boolean found;
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?")) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("UPDATE users_settings INNER JOIN users ON users.id = users_settings.id SET can_trade = ? WHERE users.username LIKE ?"))
{ {
statement.setString(1, enabled ? "1" : "0"); statement.setString(1, enabled ? "1" : "0");

View File

@ -68,7 +68,7 @@ public class BadgeCommand extends Command
{ {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection()) try (Connection connection = Emulator.getDatabase().getDataSource().getConnection())
{ {
boolean found = false; boolean found;
try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1")) try (PreparedStatement statement = connection.prepareStatement("SELECT COUNT(slot_id) FROM users_badges INNER JOIN users ON users.id = user_id WHERE users.username = ? AND badge_code = ? LIMIT 1"))
{ {

View File

@ -56,7 +56,7 @@ public class BanCommand extends Command
Habbo t = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); Habbo t = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
HabboInfo target = null; HabboInfo target;
if (t != null) if (t != null)
{ {
target = t.getHabboInfo(); target = t.getHabboInfo();
@ -79,17 +79,17 @@ public class BanCommand extends Command
} }
String reason = ""; StringBuilder reason = new StringBuilder();
if(params.length > 3) if(params.length > 3)
{ {
for(int i = 3; i < params.length; i++) for(int i = 3; i < params.length; i++)
{ {
reason += params[i] + " "; reason.append(params[i]).append(" ");
} }
} }
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().ban(target.getId(), gameClient.getHabbo(), reason, banTime, ModToolBanType.ACCOUNT, -1).get(0); ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().ban(target.getId(), gameClient.getHabbo(), reason.toString(), banTime, ModToolBanType.ACCOUNT, -1).get(0);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ban.ban_issued").replace("%user%", target.getUsername()).replace("%time%", ban.expireDate - Emulator.getIntUnixTimestamp() + "").replace("%reason%", ban.reason), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_ban.ban_issued").replace("%user%", target.getUsername()).replace("%time%", ban.expireDate - Emulator.getIntUnixTimestamp() + "").replace("%reason%", ban.reason), RoomChatMessageBubbles.ALERT);
return true; return true;

View File

@ -18,18 +18,18 @@ public class BotsCommand extends Command
if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo())) if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() == null || !gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasRights(gameClient.getHabbo()))
return false; return false;
String data = Emulator.getTexts().getValue("total") + ": " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values().length; StringBuilder data = new StringBuilder(Emulator.getTexts().getValue("total") + ": " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values().length);
for(Object bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values()) for(Object bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().values())
{ {
if(bot instanceof Bot) if(bot instanceof Bot)
{ {
data += "\r"; data.append("\r");
data += "<b>" + Emulator.getTexts().getValue("generic.bot.name") + "</b>: " + ((Bot) bot).getName() + " <b>" + Emulator.getTexts().getValue("generic.bot.id") + "</b>: " + ((Bot) bot).getId(); data.append("<b>").append(Emulator.getTexts().getValue("generic.bot.name")).append("</b>: ").append(((Bot) bot).getName()).append(" <b>").append(Emulator.getTexts().getValue("generic.bot.id")).append("</b>: ").append(((Bot) bot).getId());
} }
} }
gameClient.sendResponse(new GenericAlertComposer(data)); gameClient.getHabbo().alert(data.toString());
return true; return true;
} }

View File

@ -24,7 +24,7 @@ public class CommandHandler
public CommandHandler() public CommandHandler()
{ {
long millis = System.currentTimeMillis(); long millis = System.currentTimeMillis();
reloadCommands(); this.reloadCommands();
Emulator.getLogging().logStart("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)"); Emulator.getLogging().logStart("Command Handler -> Loaded! (" + (System.currentTimeMillis() - millis) + " MS)");
} }
@ -205,7 +205,7 @@ public class CommandHandler
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands()) if (gameClient.getHabbo().getHabboInfo().getRank().isLogCommands())
@ -249,22 +249,22 @@ public class CommandHandler
Pet pet = petIterator.value(); Pet pet = petIterator.value();
if (pet instanceof Pet) if (pet != null)
{ {
if (pet.getName().equalsIgnoreCase(args[0])) if (pet.getName().equalsIgnoreCase(args[0]))
{ {
String s = ""; StringBuilder s = new StringBuilder();
for (int i = 1; i < args.length; i++) for (int i = 1; i < args.length; i++)
{ {
s += args[i] + " "; s.append(args[i]).append(" ");
} }
s = s.substring(0, s.length() - 1); s = new StringBuilder(s.substring(0, s.length() - 1));
for (PetCommand command : pet.getPetData().getPetCommands()) for (PetCommand command : pet.getPetData().getPetCommands())
{ {
if (command.key.equalsIgnoreCase(s)) if (command.key.equalsIgnoreCase(s.toString()))
{ {
if (command.level <= pet.getLevel()) if (command.level <= pet.getLevel())
pet.handleCommand(command, gameClient.getHabbo(), args); pet.handleCommand(command, gameClient.getHabbo(), args);
@ -303,7 +303,7 @@ public class CommandHandler
} }
} }
Collections.sort(allowedCommands, CommandHandler.ALPHABETICAL_ORDER); allowedCommands.sort(CommandHandler.ALPHABETICAL_ORDER);
return allowedCommands; return allowedCommands;
} }

View File

@ -15,16 +15,16 @@ public class CommandsCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
String message = "Your Commands"; StringBuilder message = new StringBuilder("Your Commands");
List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId()); List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId());
message += "(" + commands.size() + "):\r\n"; message.append("(").append(commands.size()).append("):\r\n");
for(Command c : commands) for(Command c : commands)
{ {
message += Emulator.getTexts().getValue("commands.description." + c.permission, "commands.description." + c.permission) + "\r"; message.append(Emulator.getTexts().getValue("commands.description." + c.permission, "commands.description." + c.permission)).append("\r");
} }
gameClient.getHabbo().alert(new String[]{message}); gameClient.getHabbo().alert(new String[]{message.toString()});
return true; return true;
} }

View File

@ -21,7 +21,7 @@ public class CoordsCommand extends Command {
if (params.length == 1) if (params.length == 1)
{ {
gameClient.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" + gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" +
"x: " + gameClient.getHabbo().getRoomUnit().getX() + "\r" + "x: " + gameClient.getHabbo().getRoomUnit().getX() + "\r" +
"y: " + gameClient.getHabbo().getRoomUnit().getY() + "\r" + "y: " + gameClient.getHabbo().getRoomUnit().getY() + "\r" +
"z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getZ()) + "\r" + "z: " + (gameClient.getHabbo().getRoomUnit().hasStatus(RoomUnitStatus.SIT) ? gameClient.getHabbo().getRoomUnit().getStatus(RoomUnitStatus.SIT) : gameClient.getHabbo().getRoomUnit().getZ()) + "\r" +
@ -31,7 +31,7 @@ public class CoordsCommand extends Command {
"Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).state.name() + "\r" + "Tile State: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).state.name() + "\r" +
"Tile Walkable: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).isWalkable() + "\r" + "Tile Walkable: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).isWalkable() + "\r" +
"Tile relative height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).relativeHeight() + "\r" + "Tile relative height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).relativeHeight() + "\r" +
"Tile stack height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getStackHeight())); "Tile stack height: " + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getLayout().getTile(gameClient.getHabbo().getRoomUnit().getX(), gameClient.getHabbo().getRoomUnit().getY()).getStackHeight());
} }
else else
@ -40,14 +40,14 @@ public class CoordsCommand extends Command {
if (tile != null) if (tile != null)
{ {
gameClient.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" + gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.generic.cmd_coords.title") + "\r\n" +
"x: " + tile.x + "\r" + "x: " + tile.x + "\r" +
"y: " + tile.y + "\r" + "y: " + tile.y + "\r" +
"z: " + tile.z + "\r" + "z: " + tile.z + "\r" +
"Tile State: " + tile.state.name() + "\r" + "Tile State: " + tile.state.name() + "\r" +
"Tile Relative Height: " + tile.relativeHeight() + "\r" + "Tile Relative Height: " + tile.relativeHeight() + "\r" +
"Tile Stack Height: " + tile.getStackHeight() + "\r" + "Tile Stack Height: " + tile.getStackHeight() + "\r" +
"Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r")); "Tile Walkable: " + (tile.isWalkable() ? "Yes" : "No") + "\r");
} }
else else
{ {

View File

@ -25,7 +25,7 @@ public class CreditsCommand extends Command
{ {
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]); Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
int credits = 0; int credits;
try try
{ {
credits = Integer.parseInt(params[2]); credits = Integer.parseInt(params[2]);
@ -42,7 +42,7 @@ public class CreditsCommand extends Command
if (habbo.getHabboInfo().getCurrentRoom() != null) if (habbo.getHabboInfo().getCurrentRoom() != null)
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT); habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT);
else else
habbo.getClient().sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""))); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -27,7 +27,7 @@ public class EmptyBotsInventoryCommand extends Command
{ {
if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10)
{ {
gameClient.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")))); gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")));
} }
else else
{ {

View File

@ -29,7 +29,7 @@ public class EmptyInventoryCommand extends Command
{ {
if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10)
{ {
gameClient.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")))); gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")));
} }
else else
{ {

View File

@ -27,7 +27,7 @@ public class EmptyPetsInventoryCommand extends Command
{ {
if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10) if(gameClient.getHabbo().getHabboInfo().getCurrentRoom().getUserCount() > 10)
{ {
gameClient.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")))); gameClient.getHabbo().alert(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.verify").replace("%generic.yes%", Emulator.getTexts().getValue("generic.yes")));
} }
else else
{ {

View File

@ -17,7 +17,7 @@ public class EnableCommand extends Command
{ {
if(params.length >= 2) if(params.length >= 2)
{ {
int effectId = 0; int effectId;
try try
{ {
effectId = Integer.parseInt(params[1]); effectId = Integer.parseInt(params[1]);
@ -48,13 +48,13 @@ public class EnableCommand extends Command
return true; return true;
} }
target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId); target.getHabboInfo().getCurrentRoom().giveEffect(target, effectId, -1);
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
} }
} }

View File

@ -23,12 +23,12 @@ public class EventCommand extends Command
{ {
if (params.length >= 2) if (params.length >= 2)
{ {
String message = ""; StringBuilder message = new StringBuilder();
for (int i = 1; i < params.length; i++) for (int i = 1; i < params.length; i++)
{ {
message += params[i]; message.append(params[i]);
message += " "; message.append(" ");
} }
THashMap<String, String> codes = new THashMap<>(); THashMap<String, String> codes = new THashMap<>();
@ -37,7 +37,7 @@ public class EventCommand extends Command
codes.put("USERNAME", gameClient.getHabbo().getHabboInfo().getUsername()); codes.put("USERNAME", gameClient.getHabbo().getHabboInfo().getUsername());
codes.put("LOOK", gameClient.getHabbo().getHabboInfo().getLook()); codes.put("LOOK", gameClient.getHabbo().getHabboInfo().getLook());
codes.put("TIME", Emulator.getDate().toString()); codes.put("TIME", Emulator.getDate().toString());
codes.put("MESSAGE", message); codes.put("MESSAGE", message.toString());
ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose();

View File

@ -25,12 +25,20 @@ public class GiftCommand extends Command
{ {
if(params.length >= 3) if(params.length >= 3)
{ {
String username = params[1];
int itemId;
try try
{ {
String username = params[1]; itemId = Integer.valueOf(params[2]);
int itemId = Integer.valueOf(params[2]); }
catch (Exception e)
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
if(itemId < 0) if(itemId <= 0)
{ {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true; return true;
@ -52,17 +60,17 @@ public class GiftCommand extends Command
return true; return true;
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 3) if(params.length > 3)
{ {
for (int i = 3; i < params.length; i++) for (int i = 3; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
} }
final String finalMessage = message; final String finalMessage = message.toString();
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
@ -89,13 +97,6 @@ public class GiftCommand extends Command
} }
return true; return true;
} }
catch (Exception e)
{
e.printStackTrace();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
}
return false; return false;
} }

View File

@ -16,7 +16,7 @@ public class HabnamCommand extends Command
{ {
if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null)
{ {
gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), 140); gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), 140, 30);
return true; return true;
} }
} }

View File

@ -20,9 +20,9 @@ public class HotelAlertCommand extends Command {
public boolean handle(GameClient gameClient, String[] params) public boolean handle(GameClient gameClient, String[] params)
{ {
if(params.length > 1) { if(params.length > 1) {
String message = ""; StringBuilder message = new StringBuilder();
for (int i = 1; i < params.length; i++) { for (int i = 1; i < params.length; i++) {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose(); ServerMessage msg = new StaffAlertWithLinkComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername(), "").compose();

View File

@ -20,16 +20,16 @@ public class HotelAlertLinkCommand extends Command
} }
String url = params[1]; String url = params[1];
String message = ""; StringBuilder message = new StringBuilder();
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
message += params[i]; message.append(params[i]);
message += " "; message.append(" ");
} }
message += "\r\r-<b>" + gameClient.getHabbo().getHabboInfo().getUsername() + "</b>"; message.append("\r\r-<b>").append(gameClient.getHabbo().getHabboInfo().getUsername()).append("</b>");
Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new StaffAlertWithLinkComposer(message, url).compose()); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new StaffAlertWithLinkComposer(message.toString(), url).compose());
return true; return true;
} }
} }

View File

@ -19,8 +19,8 @@ public class IPBanCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
HabboInfo habbo = null; HabboInfo habbo;
String reason = ""; StringBuilder reason = new StringBuilder();
if (params.length >= 2) if (params.length >= 2)
{ {
Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
@ -43,8 +43,8 @@ public class IPBanCommand extends Command
{ {
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
reason += params[i]; reason.append(params[i]);
reason += " "; reason.append(" ");
} }
} }
@ -63,14 +63,14 @@ public class IPBanCommand extends Command
return true; return true;
} }
Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason, TEN_YEARS, ModToolBanType.IP, -1); Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1);
count++; count++;
for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(habbo.getIpLogin())) for (Habbo h : Emulator.getGameServer().getGameClientManager().getHabbosWithIP(habbo.getIpLogin()))
{ {
if (h != null) if (h != null)
{ {
count++; count++;
Emulator.getGameEnvironment().getModToolManager().ban(h.getHabboInfo().getId(), gameClient.getHabbo(), reason, TEN_YEARS, ModToolBanType.IP, -1); Emulator.getGameEnvironment().getModToolManager().ban(h.getHabboInfo().getId(), gameClient.getHabbo(), reason.toString(), TEN_YEARS, ModToolBanType.IP, -1);
} }
} }
} }

View File

@ -19,7 +19,7 @@ public class MachineBanCommand extends Command
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
HabboInfo habbo = null; HabboInfo habbo = null;
String reason = ""; StringBuilder reason = new StringBuilder();
if (params.length >= 2) if (params.length >= 2)
{ {
Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
@ -38,12 +38,12 @@ public class MachineBanCommand extends Command
{ {
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
reason += params[i]; reason.append(params[i]);
reason += " "; reason.append(" ");
} }
} }
int count = 0; int count;
if (habbo != null) if (habbo != null)
{ {
if (habbo == gameClient.getHabbo().getHabboInfo()) if (habbo == gameClient.getHabbo().getHabboInfo())
@ -58,7 +58,7 @@ public class MachineBanCommand extends Command
return true; return true;
} }
count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason, IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size(); count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size();

View File

@ -26,11 +26,19 @@ public class MassGiftCommand extends Command
{ {
if(params.length >= 2) if(params.length >= 2)
{ {
int itemId;
try try
{ {
int itemId = Integer.valueOf(params[1]); itemId = Integer.valueOf(params[1]);
}
catch (Exception e)
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
if(itemId < 0) if(itemId <= 0)
{ {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true; return true;
@ -44,17 +52,17 @@ public class MassGiftCommand extends Command
return true; return true;
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 2) if(params.length > 2)
{ {
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
} }
final String finalMessage = message; final String finalMessage = message.toString();
THashMap<String, String> keys = new THashMap<>(); THashMap<String, String> keys = new THashMap<>();
keys.put("display", "BUBBLE"); keys.put("display", "BUBBLE");
@ -89,13 +97,6 @@ public class MassGiftCommand extends Command
return true; return true;
} }
catch (Exception e)
{
e.printStackTrace();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
}
return false; return false;
} }

View File

@ -19,7 +19,7 @@ public class MassPointsCommand extends Command
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
int type = Emulator.getConfig().getInt("seasonal.primary.type"); int type = Emulator.getConfig().getInt("seasonal.primary.type");
String amountString = ""; String amountString;
if(params.length == 3) if(params.length == 3)
{ {
amountString = params[1]; amountString = params[1];
@ -83,7 +83,7 @@ public class MassPointsCommand extends Command
if(habbo.getHabboInfo().getCurrentRoom() != null) if(habbo.getHabboInfo().getCurrentRoom() != null)
habbo.whisper(message, RoomChatMessageBubbles.ALERT); habbo.whisper(message, RoomChatMessageBubbles.ALERT);
else else
habbo.getClient().sendResponse(new GenericAlertComposer(message)); habbo.alert(message);
} }
} }
return true; return true;

View File

@ -2,7 +2,6 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
public class MoonwalkCommand extends Command public class MoonwalkCommand extends Command
{ {
@ -16,16 +15,11 @@ public class MoonwalkCommand extends Command
{ {
if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub()) if(gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null && gameClient.getHabbo().getHabboStats().hasActiveClub())
{ {
if (gameClient.getHabbo().getRoomUnit().getEffectId() != 136) int effect = 136;
{ if (gameClient.getHabbo().getRoomUnit().getEffectId() == 136)
gameClient.getHabbo().getRoomUnit().setEffectId(136); effect = 0;
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserEffectComposer(gameClient.getHabbo().getRoomUnit()).compose());
} gameClient.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gameClient.getHabbo(), effect, -1);
else
{
gameClient.getHabbo().getRoomUnit().setEffectId(0);
gameClient.getHabbo().getHabboInfo().getCurrentRoom().sendComposer(new RoomUserEffectComposer(gameClient.getHabbo().getRoomUnit()).compose());
}
return true; return true;
} }

View File

@ -32,10 +32,7 @@ public class PetInfoCommand extends Command
{ {
if(pet.getName().equalsIgnoreCase(name)) if(pet.getName().equalsIgnoreCase(name))
{ {
if(!(pet instanceof Pet)) gameClient.getHabbo().alert("" +
return true;
gameClient.sendResponse(new GenericAlertComposer("" +
Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" + Emulator.getTexts().getValue("commands.generic.cmd_pet_info.title") + ": " + pet.getName() + "\r\n" +
Emulator.getTexts().getValue("generic.pet.id") + ": " + pet.getId() + "\r" + Emulator.getTexts().getValue("generic.pet.id") + ": " + pet.getId() + "\r" +
Emulator.getTexts().getValue("generic.pet.name") + ": " + pet.getName() + "\r" + Emulator.getTexts().getValue("generic.pet.name") + ": " + pet.getName() + "\r" +
@ -50,7 +47,7 @@ public class PetInfoCommand extends Command
Emulator.getTexts().getValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" + Emulator.getTexts().getValue("generic.pet.level.hunger") + ": " + pet.levelHunger + "\r" +
Emulator.getTexts().getValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? Emulator.getTexts().getValue("generic.nothing") : pet.getTask().name()) + "\r" + Emulator.getTexts().getValue("generic.pet.current_action") + ": " + (pet.getTask() == null ? Emulator.getTexts().getValue("generic.nothing") : pet.getTask().name()) + "\r" +
Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "" Emulator.getTexts().getValue("generic.can.walk") + ": " + (pet.getRoomUnit().canWalk() ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + ""
)); );
} }
return true; return true;

View File

@ -30,7 +30,7 @@ public class PixelCommand extends Command
if(habbo.getHabboInfo().getCurrentRoom() != null) if(habbo.getHabboInfo().getCurrentRoom() != null)
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""), RoomChatMessageBubbles.ALERT); habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""), RoomChatMessageBubbles.ALERT);
else else
habbo.getClient().sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""))); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", Integer.valueOf(params[2]) + ""));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.valueOf(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_duckets.send").replace("%amount%", Integer.valueOf(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);

View File

@ -15,14 +15,14 @@ public class PluginsCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
String message = "Plugins (" + Emulator.getPluginManager().getPlugins().size() + ")\r"; StringBuilder message = new StringBuilder("Plugins (" + Emulator.getPluginManager().getPlugins().size() + ")\r");
for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins()) for (HabboPlugin plugin : Emulator.getPluginManager().getPlugins())
{ {
message += "\r" + plugin.configuration.name + " By " + plugin.configuration.author; message.append("\r").append(plugin.configuration.name).append(" By ").append(plugin.configuration.author);
} }
gameClient.sendResponse(new GenericAlertComposer(message)); gameClient.getHabbo().alert(message.toString());
return true; return true;
} }

View File

@ -40,7 +40,7 @@ public class PointsCommand extends Command
} }
} }
int amount = 0; int amount;
try try
{ {
@ -59,7 +59,7 @@ public class PointsCommand extends Command
if(habbo.getHabboInfo().getCurrentRoom() != null) if(habbo.getHabboInfo().getCurrentRoom() != null)
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT); habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT);
else else
habbo.getClient().sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)))); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)));
habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(type), amount, type)); habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(type), amount, type));

View File

@ -5,7 +5,7 @@ import com.eu.habbo.habbohotel.catalog.TargetOffer;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer; import com.eu.habbo.messages.outgoing.generic.alerts.MessagesForYouComposer;
import com.eu.habbo.messages.outgoing.unknown.TargetedOfferComposer; import com.eu.habbo.messages.outgoing.catalog.TargetedOfferComposer;
import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.THashMap;
import java.util.ArrayList; import java.util.ArrayList;
@ -36,11 +36,11 @@ public class PromoteTargetOfferCommand extends Command
String[] textConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list").replace("%amount%", targetOffers.size() + "").split("<br>"); String[] textConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list").replace("%amount%", targetOffers.size() + "").split("<br>");
String entryConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list.entry"); String entryConfig = Emulator.getTexts().getValue("commands.cmd_promote_offer.list.entry");
List<String> message = new ArrayList<String>(); List<String> message = new ArrayList<>();
for (int i = 0; i < textConfig.length; i++) for (String pair : textConfig)
{ {
if (textConfig[i].contains("%list%")) if (pair.contains("%list%"))
{ {
for (TargetOffer offer : targetOffers.values()) for (TargetOffer offer : targetOffers.values())
{ {
@ -49,7 +49,7 @@ public class PromoteTargetOfferCommand extends Command
} }
else else
{ {
message.add(textConfig[i]); message.add(pair);
} }
} }

View File

@ -58,8 +58,8 @@ public class RedeemCommand extends Command
} }
} else if (item.getBaseItem().getName().startsWith("DF_")) } else if (item.getBaseItem().getName().startsWith("DF_"))
{ {
int pointsType = 0; int pointsType;
int pointsAmount = 0; int pointsAmount;
pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]); pointsType = Integer.valueOf(item.getBaseItem().getName().split("_")[1]);
pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]); pointsAmount = Integer.valueOf(item.getBaseItem().getName().split("_")[2]);

View File

@ -16,16 +16,16 @@ public class RoomAlertCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
String message = ""; StringBuilder message = new StringBuilder();
if (params.length >= 2) if (params.length >= 2)
{ {
for (int i = 1; i < params.length; i++) for (int i = 1; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
if (message.isEmpty()) if (message.length() == 0)
{ {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomalert.empty"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roomalert.empty"), RoomChatMessageBubbles.ALERT);
return true; return true;
@ -35,7 +35,7 @@ public class RoomAlertCommand extends Command
if (room != null) if (room != null)
{ {
room.sendComposer(new ModToolIssueHandledComposer(message).compose()); room.sendComposer(new ModToolIssueHandledComposer(message.toString()).compose());
return true; return true;
} }
} }

View File

@ -32,10 +32,9 @@ public class RoomCreditsCommand extends Command
if(amount != 0) if(amount != 0)
{ {
final String message = Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + ""); final String message = Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", amount + "");
final int finalAmount = amount;
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
habbo.giveCredits(finalAmount); habbo.giveCredits(amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT); habbo.whisper(message, RoomChatMessageBubbles.ALERT);
} }
} }

View File

@ -2,9 +2,9 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient; import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserEffectComposer;
public class RoomEffectCommand extends Command public class RoomEffectCommand extends Command
{ {
@ -28,10 +28,10 @@ public class RoomEffectCommand extends Command
if(effectId >= 0) if(effectId >= 0)
{ {
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
for (Habbo habbo : room.getHabbos())
{ {
habbo.getRoomUnit().setEffectId(effectId); room.giveEffect(habbo, effectId, -1);
habbo.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserEffectComposer(habbo.getRoomUnit()).compose());
} }
return true; return true;

View File

@ -6,7 +6,7 @@ import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles; import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.generic.alerts.WiredRewardAlertComposer; import com.eu.habbo.messages.outgoing.wired.WiredRewardAlertComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer; import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
public class RoomGiftCommand extends Command public class RoomGiftCommand extends Command
@ -21,11 +21,19 @@ public class RoomGiftCommand extends Command
{ {
if(params.length >= 2) if(params.length >= 2)
{ {
int itemId;
try try
{ {
int itemId = Integer.valueOf(params[1]); itemId = Integer.valueOf(params[1]);
}
catch (Exception e)
{
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
if(itemId < 0) if(itemId <= 0)
{ {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true; return true;
@ -39,17 +47,17 @@ public class RoomGiftCommand extends Command
return true; return true;
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 2) if(params.length > 2)
{ {
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
} }
final String finalMessage = message; final String finalMessage = message.toString();
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
@ -69,13 +77,6 @@ public class RoomGiftCommand extends Command
return true; return true;
} }
catch (Exception e)
{
e.printStackTrace();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
return true;
}
}
return false; return false;
} }

View File

@ -22,10 +22,10 @@ public class RoomKickCommand extends Command
{ {
if(params.length > 1) if(params.length > 1)
{ {
String message = ""; StringBuilder message = new StringBuilder();
for (int i = 1; i < params.length; i++) for (int i = 1; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
room.sendComposer(new GenericAlertComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose()); room.sendComposer(new GenericAlertComposer(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()).compose());
} }

View File

@ -32,10 +32,9 @@ public class RoomPixelsCommand extends Command
if(amount != 0) if(amount != 0)
{ {
final String message = Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", amount + ""); final String message = Emulator.getTexts().getValue("commands.generic.cmd_duckets.received").replace("%amount%", amount + "");
final int finalAmount = amount;
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
habbo.givePixels(finalAmount); habbo.givePixels(amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT); habbo.whisper(message, RoomChatMessageBubbles.ALERT);
} }
} }

View File

@ -16,7 +16,7 @@ public class RoomPointsCommand extends Command
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
int type = Emulator.getConfig().getInt("seasonal.primary.type"); int type = Emulator.getConfig().getInt("seasonal.primary.type");
String amountString = ""; String amountString;
if(params.length == 3) if(params.length == 3)
{ {
try try
@ -72,11 +72,9 @@ public class RoomPointsCommand extends Command
{ {
final String message = Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)); final String message = Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type));
final int finalType = type;
final int finalAmount = amount;
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
habbo.givePoints(finalType, finalAmount); habbo.givePoints(type, amount);
habbo.whisper(message, RoomChatMessageBubbles.ALERT); habbo.whisper(message, RoomChatMessageBubbles.ALERT);
} }
} }

View File

@ -21,18 +21,15 @@ public class SayAllCommand extends Command
return true; return true;
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 1)
{
for(int i = 1; i < params.length; i++) for(int i = 1; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
}
} }
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
habbo.talk(message); habbo.talk(message.toString());
} }
return true; return true;

View File

@ -39,17 +39,17 @@ public class SayCommand extends Command
} }
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 2) if(params.length > 2)
{ {
for(int i = 2; i < params.length; i++) for(int i = 2; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
} }
target.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTalkComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); target.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserTalkComposer(new RoomChatMessage(message.toString(), target, RoomChatMessageBubbles.NORMAL)).compose());
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_say").replace("%user%", params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_say").replace("%user%", params[1]).replace("%message%", message.toString()), RoomChatMessageBubbles.ALERT);
return true; return true;
} }
} }

View File

@ -16,7 +16,7 @@ public class SetMaxCommand extends Command
{ {
if (params.length >= 2) if (params.length >= 2)
{ {
int max = 0; int max;
try try
{ {
max = Integer.valueOf(params[1]); max = Integer.valueOf(params[1]);

View File

@ -21,18 +21,15 @@ public class ShoutAllCommand extends Command
return true; return true;
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 1)
{
for(int i = 1; i < params.length; i++) for(int i = 1; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
}
} }
for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
habbo.shout(message); habbo.shout(message.toString());
} }
return true; return true;

View File

@ -41,17 +41,17 @@ public class ShoutCommand extends Command
} }
} }
String message = ""; StringBuilder message = new StringBuilder();
if(params.length > 2) if(params.length > 2)
{ {
for(int i = 2; i < params.length; i++) for(int i = 2; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
} }
target.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserShoutComposer(new RoomChatMessage(message, target, RoomChatMessageBubbles.NORMAL)).compose()); target.getHabboInfo().getCurrentRoom().sendComposer(new RoomUserShoutComposer(new RoomChatMessage(message.toString(), target, RoomChatMessageBubbles.NORMAL)).compose());
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_shout").replace("%user%", params[1]).replace("%message%", message), RoomChatMessageBubbles.ALERT); gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_shout").replace("%user%", params[1]).replace("%message%", message.toString()), RoomChatMessageBubbles.ALERT);
return true; return true;
} }
} }

View File

@ -18,14 +18,14 @@ public class ShutdownCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
String reason = "-"; StringBuilder reason = new StringBuilder("-");
int minutes = 0; int minutes = 0;
if(params.length > 2) if(params.length > 2)
{ {
reason = ""; reason = new StringBuilder();
for(int i = 1; i < params.length; i++) for(int i = 1; i < params.length; i++)
{ {
reason += params[i] + " "; reason.append(params[i]).append(" ");
} }
} }
else else
@ -38,13 +38,13 @@ public class ShutdownCommand extends Command
} }
catch (Exception e) catch (Exception e)
{ {
reason = params[1]; reason = new StringBuilder(params[1]);
} }
} }
} }
ServerMessage message = null; ServerMessage message;
if (!reason.equals("-")) if (!reason.toString().equals("-"))
{ {
message = new GenericAlertComposer("<b>" + Emulator.getTexts().getValue("generic.warning") + "</b> \r\n" + message = new GenericAlertComposer("<b>" + Emulator.getTexts().getValue("generic.warning") + "</b> \r\n" +
Emulator.getTexts().getValue("generic.shutdown").replace("%minutes%", minutes + "") + "\r\n" + Emulator.getTexts().getValue("generic.shutdown").replace("%minutes%", minutes + "") + "\r\n" +

View File

@ -18,14 +18,14 @@ public class StaffAlertCommand extends Command
{ {
if(params.length > 1) if(params.length > 1)
{ {
String message = ""; StringBuilder message = new StringBuilder();
for (int i = 1; i < params.length; i++) for (int i = 1; i < params.length; i++)
{ {
message += params[i] + " "; message.append(params[i]).append(" ");
} }
Emulator.getGameEnvironment().getHabboManager().staffAlert(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername()); Emulator.getGameEnvironment().getHabboManager().staffAlert(message + "\r\n-" + gameClient.getHabbo().getHabboInfo().getUsername());
Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new FriendChatMessageComposer(new Message(gameClient.getHabbo().getHabboInfo().getId(), -1, message)).compose(), "acc_staff_chat", gameClient); Emulator.getGameServer().getGameClientManager().sendBroadcastResponse(new FriendChatMessageComposer(new Message(gameClient.getHabbo().getHabboInfo().getId(), -1, message.toString())).compose(), "acc_staff_chat", gameClient);
} }
else else
{ {

View File

@ -58,7 +58,7 @@ public class StaffOnlineCommand extends Command
} }
} }
Collections.sort(staffs, new Comparator<Habbo>() staffs.sort(new Comparator<Habbo>()
{ {
@Override @Override
public int compare(Habbo o1, Habbo o2) public int compare(Habbo o1, Habbo o2)
@ -67,18 +67,18 @@ public class StaffOnlineCommand extends Command
} }
}); });
String message = Emulator.getTexts().getValue("commands.generic.cmd_staffonline.staffs"); StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("commands.generic.cmd_staffonline.staffs"));
message += "\r\n"; message.append("\r\n");
for(Habbo habbo : staffs) for(Habbo habbo : staffs)
{ {
message += habbo.getHabboInfo().getUsername(); message.append(habbo.getHabboInfo().getUsername());
message += ": "; message.append(": ");
message += habbo.getHabboInfo().getRank().getName(); message.append(habbo.getHabboInfo().getRank().getName());
message += "\r"; message.append("\r");
} }
gameClient.sendResponse(new GenericAlertComposer(message)); gameClient.getHabbo().alert(message.toString());
} }
return true; return true;

View File

@ -61,7 +61,7 @@ public class SummonCommand extends Command
habbo.getRoomUnit().setGoalLocation(t); habbo.getRoomUnit().setGoalLocation(t);
} }
habbo.getClient().sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername()))); habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_summon.been_summoned").replace("%user%", gameClient.getHabbo().getHabboInfo().getUsername()));
return true; return true;
} }

View File

@ -18,7 +18,7 @@ public class SummonRankCommand extends Command
@Override @Override
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
int minRank = 1; int minRank;
if(params.length >= 2) if(params.length >= 2)
{ {

View File

@ -19,7 +19,7 @@ public class SuperbanCommand extends Command
public boolean handle(GameClient gameClient, String[] params) throws Exception public boolean handle(GameClient gameClient, String[] params) throws Exception
{ {
HabboInfo habbo = null; HabboInfo habbo = null;
String reason = ""; StringBuilder reason = new StringBuilder();
if (params.length >= 2) if (params.length >= 2)
{ {
Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]); Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
@ -38,12 +38,12 @@ public class SuperbanCommand extends Command
{ {
for (int i = 2; i < params.length; i++) for (int i = 2; i < params.length; i++)
{ {
reason += params[i]; reason.append(params[i]);
reason += " "; reason.append(" ");
} }
} }
int count = 0; int count;
if (habbo != null) if (habbo != null)
{ {
if (habbo == gameClient.getHabbo().getHabboInfo()) if (habbo == gameClient.getHabbo().getHabboInfo())
@ -58,7 +58,7 @@ public class SuperbanCommand extends Command
return true; return true;
} }
count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason, IPBanCommand.TEN_YEARS, ModToolBanType.SUPER, -1).size(); count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.SUPER, -1).size();
} }
else else
{ {

View File

@ -91,7 +91,7 @@ public class TestCommand extends Command
if (params[1].equals("ach")) if (params[1].equals("ach"))
{ {
AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Jogger"), 1); AchievementManager.progressAchievement(gameClient.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("Jogger"), 1000);
return true; return true;
} }
@ -125,28 +125,26 @@ public class TestCommand extends Command
if(params[1].equals("units")) if(params[1].equals("units"))
{ {
String s = ""; StringBuilder s = new StringBuilder();
for(Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) for(Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos())
{ {
s += "Habbo ID: " + habbo.getHabboInfo().getId() + ", RoomUnit ID: " + habbo.getRoomUnit().getId() + "\r"; s.append("Habbo ID: ").append(habbo.getHabboInfo().getId()).append(", RoomUnit ID: ").append(habbo.getRoomUnit().getId()).append("\r");
} }
for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection()) for (Pet pet : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentPets().valueCollection())
{ {
s += "Pet ID: " + pet.getId() + ", RoomUnit ID: " + pet.getRoomUnit().getId() + ", Name: " + pet.getName(); s.append("Pet ID: ").append(pet.getId()).append(", RoomUnit ID: ").append(pet.getRoomUnit().getId()).append(", Name: ").append(pet.getName());
if (pet instanceof MonsterplantPet) if (pet instanceof MonsterplantPet)
{ {
s += ", B:" + (((MonsterplantPet) pet).canBreed() ? "Y" : "N") + s.append(", B:").append(((MonsterplantPet) pet).canBreed() ? "Y" : "N").append(", PB: ").append(((MonsterplantPet) pet).isPubliclyBreedable() ? "Y" : "N").append(", D: ").append(((MonsterplantPet) pet).isDead() ? "Y" : "N");
", PB: " + (((MonsterplantPet)pet).isPubliclyBreedable() ? "Y" : "N" ) +
", D: " + (((MonsterplantPet) pet).isDead() ? "Y" : "N");
} }
s += "\r"; s.append("\r");
} }
gameClient.sendResponse(new MessagesForYouComposer(new String[]{s})); gameClient.sendResponse(new MessagesForYouComposer(new String[]{s.toString()}));
return true; return true;
} }
@ -168,14 +166,14 @@ public class TestCommand extends Command
if (params[1].equalsIgnoreCase("bots")) if (params[1].equalsIgnoreCase("bots"))
{ {
String message = ""; StringBuilder message = new StringBuilder();
for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection()) for (Bot bot : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getCurrentBots().valueCollection())
{ {
message += "Name: " + bot.getName() + ", ID: " + bot.getId() + ", RID: " + bot.getRoomUnit().getId() + ", Rot: " + bot.getRoomUnit().getBodyRotation() + "\r"; message.append("Name: ").append(bot.getName()).append(", ID: ").append(bot.getId()).append(", RID: ").append(bot.getRoomUnit().getId()).append(", Rot: ").append(bot.getRoomUnit().getBodyRotation()).append("\r");
} }
gameClient.sendResponse(new MessagesForYouComposer(new String[]{message})); gameClient.sendResponse(new MessagesForYouComposer(new String[]{message.toString()}));
return true; return true;
} }
@ -220,9 +218,9 @@ public class TestCommand extends Command
{ {
Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2])); Pet pet = gameClient.getHabbo().getHabboInfo().getCurrentRoom().getPet(Integer.valueOf(params[2]));
if(pet instanceof Pet) if(pet != null)
{ {
String a = ""; String a;
String b = ""; String b = "";
String c = ""; String c = "";
if(params[3] != null) if(params[3] != null)
@ -267,14 +265,14 @@ public class TestCommand extends Command
results.put(random, results.get(random) + 1); results.put(random, results.get(random) + 1);
} }
String result = "Results : " + params[2] + "<br/><br/>"; StringBuilder result = new StringBuilder("Results : " + params[2] + "<br/><br/>");
for (Map.Entry<Integer, Integer> set : results.entrySet()) for (Map.Entry<Integer, Integer> set : results.entrySet())
{ {
result += set.getKey() + " -> " + set.getValue() + "<br/>"; result.append(set.getKey()).append(" -> ").append(set.getValue()).append("<br/>");
} }
gameClient.sendResponse(new GenericAlertComposer(result)); gameClient.sendResponse(new GenericAlertComposer(result.toString()));
} }
else if (params[1].equalsIgnoreCase("threads")) else if (params[1].equalsIgnoreCase("threads"))
{ {
@ -403,7 +401,7 @@ public class TestCommand extends Command
} }
else if (params[1].equals("datb")) else if (params[1].equals("datb"))
{ {
long millis = 1; long millis;
long diff = 1; long diff = 1;
try(Connection conn = Emulator.getDatabase().getDataSource().getConnection()) try(Connection conn = Emulator.getDatabase().getDataSource().getConnection())
{ {

View File

@ -24,18 +24,18 @@ public class TransformCommand extends Command
{ {
if (params.length == 1) if (params.length == 1)
{ {
String petNames = ""; StringBuilder petNames = new StringBuilder();
petNames += (Emulator.getTexts().getValue("commands.generic.cmd_transform.title")); petNames.append(Emulator.getTexts().getValue("commands.generic.cmd_transform.title"));
petNames += "\r------------------------------------------------------------------------------\r"; petNames.append("\r------------------------------------------------------------------------------\r");
ArrayList<PetData> petData = new ArrayList<>(Emulator.getGameEnvironment().getPetManager().getPetData()); ArrayList<PetData> petData = new ArrayList<>(Emulator.getGameEnvironment().getPetManager().getPetData());
Collections.sort(petData); Collections.sort(petData);
String line = Emulator.getTexts().getValue("commands.generic.cmd_transform.line"); String line = Emulator.getTexts().getValue("commands.generic.cmd_transform.line");
for (PetData p : petData) for (PetData p : petData)
{ {
petNames += (line.replace("%id%", p.getType() + "").replace("%name%", p.getName())) + "\r"; petNames.append(line.replace("%id%", p.getType() + "").replace("%name%", p.getName())).append("\r");
} }
gameClient.sendResponse(new MessagesForYouComposer(new String[]{petNames})); gameClient.sendResponse(new MessagesForYouComposer(new String[]{petNames.toString()}));
return true; return true;
} }
else else

View File

@ -43,29 +43,29 @@ public class UserInfoCommand extends Command
return true; return true;
} }
String message = Emulator.getTexts().getValue("command.cmd_userinfo.userinfo") + ": " + " <b>" + habbo.getUsername() + "</b> (<b>" + habbo.getId() + "</b>)\r" + StringBuilder message = new StringBuilder(Emulator.getTexts().getValue("command.cmd_userinfo.userinfo") + ": " + " <b>" + habbo.getUsername() + "</b> (<b>" + habbo.getId() + "</b>)\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.user_id") + ": " + habbo.getId() + "\r" + Emulator.getTexts().getValue("command.cmd_userinfo.user_id") + ": " + habbo.getId() + "\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.user_name") + ": " + habbo.getUsername() + "\r" + Emulator.getTexts().getValue("command.cmd_userinfo.user_name") + ": " + habbo.getUsername() + "\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" + Emulator.getTexts().getValue("command.cmd_userinfo.motto") + ": " + habbo.getMotto().replace("<", "[").replace(">", "]") + "\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.rank") + ": " +habbo.getRank().getName() + " (" + habbo.getRank().getId() + ") \r" + Emulator.getTexts().getValue("command.cmd_userinfo.rank") + ": " + habbo.getRank().getName() + " (" + habbo.getRank().getId() + ") \r" +
Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" + Emulator.getTexts().getValue("command.cmd_userinfo.online") + ": " + (onlineHabbo == null ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" +
Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r" + Emulator.getTexts().getValue("command.cmd_userinfo.email") + ": " + habbo.getMail() + "\r" +
((habbo.getRank().hasPermission("acc_hide_ip", true))?"" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": "+ habbo.getIpRegister() + "\r") + ((habbo.getRank().hasPermission("acc_hide_ip", true)) ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_register") + ": " + habbo.getIpRegister() + "\r") +
((habbo.getRank().hasPermission("acc_hide_ip", true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") + ((habbo.getRank().hasPermission("acc_hide_ip", true)) || onlineHabbo == null ? "" : Emulator.getTexts().getValue("command.cmd_userinfo.ip_current") + ": " + onlineHabbo.getClient().getChannel().remoteAddress().toString() + "\r") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r": ""); (onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.achievement_score") + ": " + onlineHabbo.getHabboStats().achievementScore + "\r" : ""));
ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId()); ModToolBan ban = Emulator.getGameEnvironment().getModToolManager().checkForBan(habbo.getId());
message += Emulator.getTexts().getValue("command.cmd_userinfo.total_bans") + ": " + Emulator.getGameEnvironment().getModToolManager().totalBans(habbo.getId()) + "\r"; message.append(Emulator.getTexts().getValue("command.cmd_userinfo.total_bans")).append(": ").append(Emulator.getGameEnvironment().getModToolManager().totalBans(habbo.getId())).append("\r");
message += Emulator.getTexts().getValue("command.cmd_userinfo.banned") + ": " + Emulator.getTexts().getValue(ban != null ? "generic.yes" : "generic.no") + "\r\r"; message.append(Emulator.getTexts().getValue("command.cmd_userinfo.banned")).append(": ").append(Emulator.getTexts().getValue(ban != null ? "generic.yes" : "generic.no")).append("\r\r");
if (ban != null) if (ban != null)
{ {
message += "<b>" + Emulator.getTexts().getValue("command.cmd_userinfo.ban_info") + "</b>\r"; message.append("<b>").append(Emulator.getTexts().getValue("command.cmd_userinfo.ban_info")).append("</b>\r");
message += ban.listInfo() + "\r"; message.append(ban.listInfo()).append("\r");
} }
message += "<b>" + Emulator.getTexts().getValue("command.cmd_userinfo.currencies") + "</b>\r"; message.append("<b>").append(Emulator.getTexts().getValue("command.cmd_userinfo.currencies")).append("</b>\r");
message += Emulator.getTexts().getValue("command.cmd_userinfo.credits") + ": " + habbo.getCredits() + "\r"; message.append(Emulator.getTexts().getValue("command.cmd_userinfo.credits")).append(": ").append(habbo.getCredits()).append("\r");
TIntIntIterator iterator = habbo.getCurrencies().iterator(); TIntIntIterator iterator = habbo.getCurrencies().iterator();
for(int i = habbo.getCurrencies().size(); i-- > 0;) for(int i = habbo.getCurrencies().size(); i-- > 0;)
@ -79,36 +79,27 @@ public class UserInfoCommand extends Command
break; break;
} }
message += (Emulator.getTexts().getValue("seasonal.name." + iterator.key()) + ": " + iterator.value() + "\r"); message.append(Emulator.getTexts().getValue("seasonal.name." + iterator.key())).append(": ").append(iterator.value()).append("\r");
} }
message += "\r" + message.append("\r").append(onlineHabbo != null ? "<b>" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "</b>\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-") : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "").append(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "");
(onlineHabbo != null ? "<b>" + Emulator.getTexts().getValue("command.cmd_userinfo.current_activity") + "</b>\r" : "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.room") + ": " + (onlineHabbo.getHabboInfo().getCurrentRoom() != null ? onlineHabbo.getHabboInfo().getCurrentRoom().getName() + "(" + onlineHabbo.getHabboInfo().getCurrentRoom().getId() + ")\r" : "-" ): "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.respect_left") + ": " + onlineHabbo.getHabboStats().respectPointsToGive + "\r" : "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.pet_respect_left") + ": " + onlineHabbo.getHabboStats().petRespectPointsToGive + "\r" : "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_trade") + ": " + ((onlineHabbo.getHabboStats().allowTrade()) ? Emulator.getTexts().getValue("generic.yes") : Emulator.getTexts().getValue("generic.no")) + "\r" : "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_follow") + ": " + ((onlineHabbo.getHabboStats().blockFollowing) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "") +
(onlineHabbo != null ? Emulator.getTexts().getValue("command.cmd_userinfo.allow_friend_request") + ": " + ((onlineHabbo.getHabboStats().blockFriendRequests) ? Emulator.getTexts().getValue("generic.no") : Emulator.getTexts().getValue("generic.yes")) + "\r" : "");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<Map.Entry<Integer, String>> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3); List<Map.Entry<Integer, String>> nameChanges = Emulator.getGameEnvironment().getHabboManager().getNameChanges(habbo.getId(), 3);
if (!nameChanges.isEmpty()) if (!nameChanges.isEmpty())
{ {
message += "\r<b>Latest name changes:<b><br/>"; message.append("\r<b>Latest name changes:<b><br/>");
for (Map.Entry<Integer, String> entry : nameChanges) for (Map.Entry<Integer, String> entry : nameChanges)
{ {
message += format.format(new Date((long)entry.getKey() * 1000L)) + " : " + entry.getValue() + "<br/>"; message.append(format.format(new Date((long) entry.getKey() * 1000L))).append(" : ").append(entry.getValue()).append("<br/>");
} }
} }
if(onlineHabbo != null) if(onlineHabbo != null)
{ {
message += "\r" + message.append("\r" + "<b>Other accounts (");
"<b>Other accounts (";
ArrayList<HabboInfo> users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10); ArrayList<HabboInfo> users = Emulator.getGameEnvironment().getHabboManager().getCloneAccounts(onlineHabbo, 10);
Collections.sort(users, new Comparator<HabboInfo>() users.sort(new Comparator<HabboInfo>()
{ {
@Override @Override
public int compare(HabboInfo o1, HabboInfo o2) public int compare(HabboInfo o1, HabboInfo o2)
@ -117,17 +108,17 @@ public class UserInfoCommand extends Command
} }
}); });
message += users.size() + "):</b>\r"; message.append(users.size()).append("):</b>\r");
message += "<b>Username,\tID,\tDate register,\tDate last online</b>\r"; message.append("<b>Username,\tID,\tDate register,\tDate last online</b>\r");
for(HabboInfo info : users) for(HabboInfo info : users)
{ {
message += info.getUsername() + ",\t" + info.getId() + ",\t" + format.format(new Date((long)info.getAccountCreated() * 1000L)) + ",\t" + format.format(new Date((long)info.getLastOnline() * 1000L)) + "\r"; message.append(info.getUsername()).append(",\t").append(info.getId()).append(",\t").append(format.format(new Date((long) info.getAccountCreated() * 1000L))).append(",\t").append(format.format(new Date((long) info.getLastOnline() * 1000L))).append("\r");
} }
} }
gameClient.sendResponse(new GenericAlertComposer(message)); gameClient.getHabbo().alert(message.toString());
return true; return true;
} }

View File

@ -15,14 +15,14 @@ public class WordQuizCommand extends Command
{ {
if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz())
{ {
String question = ""; StringBuilder question = new StringBuilder();
int duration = 60; int duration = 60;
if (params.length > 2) if (params.length > 2)
{ {
for (int i = 1; i < params.length - 1; i++) for (int i = 1; i < params.length - 1; i++)
{ {
question += " " + params[i]; question.append(" ").append(params[i]);
} }
try try
@ -31,15 +31,15 @@ public class WordQuizCommand extends Command
} }
catch (Exception e) catch (Exception e)
{ {
question += " " + params[params.length -1]; question.append(" ").append(params[params.length - 1]);
} }
} }
else else
{ {
question = params[1]; question = new StringBuilder(params[1]);
} }
gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question, duration * 1000); gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000);
} }
return true; return true;
} }

View File

@ -20,8 +20,8 @@ public class CraftingAltar
{ {
this.baseItem = baseItem; this.baseItem = baseItem;
this.ingredients = new THashSet<>(); this.ingredients = new THashSet<>(1);
this.recipes = new THashMap<>(); this.recipes = new THashMap<>(1);
} }
public void addIngredient(Item item) public void addIngredient(Item item)
@ -36,12 +36,12 @@ public class CraftingAltar
public Map<CraftingRecipe, Boolean> matchRecipes(Map<Item, Integer> amountMap) public Map<CraftingRecipe, Boolean> matchRecipes(Map<Item, Integer> amountMap)
{ {
THashMap<CraftingRecipe, Boolean> foundRecepies = new THashMap<>(); THashMap<CraftingRecipe, Boolean> foundRecepies = new THashMap<>(Math.max(1, this.recipes.size() / 3));
for (Map.Entry<Integer, CraftingRecipe> set : this.recipes.entrySet()) for (Map.Entry<Integer, CraftingRecipe> set : this.recipes.entrySet())
{ {
boolean contains = true; boolean contains = true;
boolean equals = true; boolean equals;
if (set.getValue().isLimited() && !set.getValue().canBeCrafted()) if (set.getValue().isLimited() && !set.getValue().canBeCrafted())
{ {
@ -73,38 +73,6 @@ public class CraftingAltar
} }
} }
//
//
if (contains) if (contains)
{ {
foundRecepies.put(set.getValue(), equals); foundRecepies.put(set.getValue(), equals);

View File

@ -105,7 +105,7 @@ public class CraftingManager
public CraftingRecipe getRecipe(String recipeName) public CraftingRecipe getRecipe(String recipeName)
{ {
CraftingRecipe recipe = null; CraftingRecipe recipe;
for (CraftingAltar altar : this.altars.values()) for (CraftingAltar altar : this.altars.values())
{ {
recipe = altar.getRecipe(recipeName); recipe = altar.getRecipe(recipeName);

View File

@ -27,7 +27,7 @@ public class GameClient
private String machineId = ""; private String machineId = "";
public ConcurrentHashMap<Integer, Integer> incomingPacketCounter = new ConcurrentHashMap<>(25); public final ConcurrentHashMap<Integer, Integer> incomingPacketCounter = new ConcurrentHashMap<>(25);
public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp(); public long lastPacketCounterCleared = Emulator.getIntUnixTimestamp();
public GameClient(Channel channel) public GameClient(Channel channel)
@ -43,7 +43,7 @@ public class GameClient
try try
{ {
ServerMessage msg = composer.compose(); ServerMessage msg = composer.compose();
sendResponse(msg); this.sendResponse(msg);
} catch (Exception e) } catch (Exception e)
{ {
Emulator.getLogging().logPacketError(e); Emulator.getLogging().logPacketError(e);

View File

@ -22,34 +22,12 @@ public class GameClientManager
this.clients = new ConcurrentHashMap<>(); this.clients = new ConcurrentHashMap<>();
} }
public ConcurrentMap<ChannelId, GameClient> getSessions() public ConcurrentMap<ChannelId, GameClient> getSessions()
{ {
return this.clients; return this.clients;
} }
public boolean containsClient(Channel channel)
{
return this.clients.containsKey(channel.id());
}
public GameClient getClient(Channel channel)
{
if (this.clients.containsKey(channel.id())) {
return this.clients.get(channel.id());
}
return null;
}
public GameClient getClient(Habbo habbo)
{
for(GameClient client : this.clients.values())
{
if(client.getHabbo() == habbo)
return client;
}
return null;
}
public boolean addClient(ChannelHandlerContext ctx) public boolean addClient(ChannelHandlerContext ctx)
{ {
@ -59,19 +37,20 @@ public class GameClientManager
@Override @Override
public void operationComplete(ChannelFuture channelFuture) throws Exception public void operationComplete(ChannelFuture channelFuture) throws Exception
{ {
disposeClient(ctx.channel()); GameClientManager.this.disposeClient(ctx.channel());
} }
}); });
ctx.attr(CLIENT).set(client); ctx.channel().attr(CLIENT).set(client);
ctx.fireChannelRegistered(); ctx.fireChannelRegistered();
return this.clients.putIfAbsent(ctx.channel().id(), client) == null; return this.clients.putIfAbsent(ctx.channel().id(), client) == null;
} }
public void disposeClient(GameClient client) public void disposeClient(GameClient client)
{ {
client.getChannel().close(); this.disposeClient(client.getChannel());
} }
private void disposeClient(Channel channel) private void disposeClient(Channel channel)
@ -89,6 +68,7 @@ public class GameClientManager
this.clients.remove(channel.id()); this.clients.remove(channel.id());
} }
public boolean containsHabbo(Integer id) public boolean containsHabbo(Integer id)
{ {
if (!this.clients.isEmpty()) if (!this.clients.isEmpty())
@ -108,6 +88,7 @@ public class GameClientManager
return false; return false;
} }
public Habbo getHabbo(int id) public Habbo getHabbo(int id)
{ {
for(GameClient client : this.clients.values()) for(GameClient client : this.clients.values())
@ -122,6 +103,7 @@ public class GameClientManager
return null; return null;
} }
public Habbo getHabbo(String username) public Habbo getHabbo(String username)
{ {
for(GameClient client : this.clients.values()) for(GameClient client : this.clients.values())
@ -136,6 +118,7 @@ public class GameClientManager
return null; return null;
} }
public List<Habbo> getHabbosWithIP(String ip) public List<Habbo> getHabbosWithIP(String ip)
{ {
List<Habbo> habbos = new ArrayList<>(); List<Habbo> habbos = new ArrayList<>();
@ -154,6 +137,7 @@ public class GameClientManager
return habbos; return habbos;
} }
public List<Habbo> getHabbosWithMachineId(String machineId) public List<Habbo> getHabbosWithMachineId(String machineId)
{ {
List<Habbo> habbos = new ArrayList<>(); List<Habbo> habbos = new ArrayList<>();
@ -169,28 +153,35 @@ public class GameClientManager
return habbos; return habbos;
} }
public void sendBroadcastResponse(MessageComposer composer) public void sendBroadcastResponse(MessageComposer composer)
{ {
sendBroadcastResponse(composer.compose()); this.sendBroadcastResponse(composer.compose());
} }
public void sendBroadcastResponse(ServerMessage msg)
public void sendBroadcastResponse(ServerMessage message)
{ {
for (GameClient client : this.clients.values()) { for (GameClient client : this.clients.values())
client.sendResponse(msg); {
client.sendResponse(message);
} }
} }
public void sendBroadcastResponse(ServerMessage msg, GameClient exclude)
public void sendBroadcastResponse(ServerMessage message, GameClient exclude)
{
for (GameClient client : this.clients.values())
{ {
for (GameClient client : this.clients.values()) {
if(client.equals(exclude)) if(client.equals(exclude))
continue; continue;
client.sendResponse(msg); client.sendResponse(message);
} }
} }
public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude) public void sendBroadcastResponse(ServerMessage message, String minPermission, GameClient exclude)
{ {
for (GameClient client : this.clients.values()) for (GameClient client : this.clients.values())

View File

@ -31,19 +31,22 @@ public abstract class Game implements Runnable
protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>(); protected final THashMap<GameTeamColors, GameTeam> teams = new THashMap<>();
protected Room room; protected final Room room;
protected boolean countsAchievements; protected final boolean countsAchievements;
protected int startTime; protected int startTime;
protected int pauseTime;
protected int endTime; protected int endTime;
public boolean isRunning; public GameState state = GameState.IDLE;
public Game(Class<? extends GameTeam> gameTeamClazz, Class<? extends GamePlayer> gamePlayerClazz, Room room, boolean countsAchievements) public Game(Class<? extends GameTeam> gameTeamClazz, Class<? extends GamePlayer> gamePlayerClazz, Room room, boolean countsAchievements)
{ {
@ -137,14 +140,14 @@ public abstract class Game implements Runnable
if (deleteGame) if (deleteGame)
{ {
room.deleteGame(this); this.room.deleteGame(this);
} }
} }
public void start() public void start()
{ {
this.isRunning = true; this.state = GameState.RUNNING;
this.startTime = Emulator.getIntUnixTimestamp(); this.startTime = Emulator.getIntUnixTimestamp();
if(Emulator.getPluginManager().isRegistered(GameStartedEvent.class, true)) if(Emulator.getPluginManager().isRegistered(GameStartedEvent.class, true))
@ -158,17 +161,34 @@ public abstract class Game implements Runnable
for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class)) for (HabboItem item : this.room.getRoomSpecialTypes().getItemsOfType(WiredBlob.class))
{ {
item.setExtradata("0"); item.setExtradata("0");
room.updateItem(item); this.room.updateItem(item);
} }
} }
public abstract void run(); public abstract void run();
public void pause()
{
if (this.state.equals(GameState.RUNNING))
{
this.state = GameState.PAUSED;
this.pauseTime = Emulator.getIntUnixTimestamp();
}
}
public void unpause()
{
if (this.state.equals(GameState.PAUSED))
{
this.state = GameState.RUNNING;
this.endTime = Emulator.getIntUnixTimestamp() + (this.endTime - this.pauseTime);
}
}
public void stop() public void stop()
{ {
this.isRunning = false; this.state = GameState.IDLE;
this.endTime = Emulator.getIntUnixTimestamp(); this.endTime = Emulator.getIntUnixTimestamp();
this.saveScores(); this.saveScores();

View File

@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.wired.WiredTriggerType;
public class GamePlayer public class GamePlayer
{ {
private Habbo habbo; private final Habbo habbo;
private GameTeamColors teamColor; private GameTeamColors teamColor;

View File

@ -0,0 +1,8 @@
package com.eu.habbo.habbohotel.games;
public enum GameState
{
IDLE,
RUNNING,
PAUSED
}

View File

@ -2,10 +2,7 @@ package com.eu.habbo.habbohotel.games.battlebanzai;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.*;
import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiSphere;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTile;
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.InteractionBattleBanzaiTimer;
@ -13,19 +10,15 @@ import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.gates.Inter
import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards.InteractionBattleBanzaiScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.battlebanzai.scoreboards.InteractionBattleBanzaiScoreboard;
import com.eu.habbo.habbohotel.rooms.Room; import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile; import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.rooms.RoomUserAction; import com.eu.habbo.habbohotel.rooms.RoomUserAction;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.EventPriority;
import com.eu.habbo.plugin.events.users.UserTakeStepEvent;
import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker; import com.eu.habbo.threading.runnables.BattleBanzaiTilesFlicker;
import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.THashMap;
import gnu.trove.set.hash.THashSet; import gnu.trove.set.hash.THashSet;
import java.util.Collection;
import java.util.Map; import java.util.Map;
public class BattleBanzaiGame extends Game public class BattleBanzaiGame extends Game
@ -51,11 +44,14 @@ public class BattleBanzaiGame extends Game
private final THashMap<GameTeamColors, THashSet<HabboItem>> lockedTiles; private final THashMap<GameTeamColors, THashSet<HabboItem>> lockedTiles;
private final THashMap<Integer, HabboItem> gameTiles;
public BattleBanzaiGame(Room room) public BattleBanzaiGame(Room room)
{ {
super(BattleBanzaiGameTeam.class, BattleBanzaiGamePlayer.class, room, true); super(BattleBanzaiGameTeam.class, BattleBanzaiGamePlayer.class, room, true);
this.lockedTiles = new THashMap<>(); this.lockedTiles = new THashMap<>();
this.gameTiles = new THashMap<>();
room.setAllowEffects(true); room.setAllowEffects(true);
} }
@ -63,7 +59,7 @@ public class BattleBanzaiGame extends Game
@Override @Override
public void initialise() public void initialise()
{ {
if(this.isRunning) if(!this.state.equals(GameState.IDLE))
return; return;
int highestTime = 0; int highestTime = 0;
@ -115,7 +111,7 @@ public class BattleBanzaiGame extends Game
@Override @Override
public void start() public void start()
{ {
if(this.isRunning) if(!this.state.equals(GameState.IDLE))
return; return;
super.start(); super.start();
@ -130,7 +126,7 @@ public class BattleBanzaiGame extends Game
{ {
try try
{ {
if (!this.isRunning) if (this.state.equals(GameState.IDLE))
return; return;
if(this.countDown > 0) if(this.countDown > 0)
@ -158,11 +154,13 @@ public class BattleBanzaiGame extends Game
{ {
Emulator.getThreading().run(this, 1000); Emulator.getThreading().run(this, 1000);
if (this.state.equals(GameState.PAUSED)) return;
this.timeLeft--; this.timeLeft--;
for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet()) for (Map.Entry<Integer, InteractionBattleBanzaiTimer> set : this.room.getRoomSpecialTypes().getBattleBanzaiTimers().entrySet())
{ {
set.getValue().setExtradata(timeLeft + ""); set.getValue().setExtradata(this.timeLeft + "");
this.room.updateItemState(set.getValue()); this.room.updateItemState(set.getValue());
} }
@ -225,8 +223,6 @@ public class BattleBanzaiGame extends Game
} }
if (winningTeam != null) if (winningTeam != null)
{
synchronized (winningTeam)
{ {
for (GamePlayer player : winningTeam.getMembers()) for (GamePlayer player : winningTeam.getMembers())
{ {
@ -245,16 +241,13 @@ public class BattleBanzaiGame extends Game
Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room)); Emulator.getThreading().run(new BattleBanzaiTilesFlicker(this.lockedTiles.get(winningTeam.teamColor), winningTeam.teamColor, this.room));
} }
}
this.stop(); this.stop();
this.isRunning = false;
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
} }
@ -265,23 +258,21 @@ public class BattleBanzaiGame extends Game
this.timeLeft = 0; this.timeLeft = 0;
//Think on Habbo the counters and tiles stay as is untill the game restarts.
this.refreshGates(); this.refreshGates();
for (HabboItem tile : this.gameTiles.values())
{
if (tile.getExtradata().equals("1"))
{
tile.setExtradata("0");
this.room.updateItemState(tile);
}
}
this.lockedTiles.clear(); this.lockedTiles.clear();
} }
protected synchronized void resetMap() private synchronized void resetMap()
{ {
for (HabboItem item : this.room.getFloorItems()) for (HabboItem item : this.room.getFloorItems())
{ {
@ -290,6 +281,7 @@ public class BattleBanzaiGame extends Game
item.setExtradata("1"); item.setExtradata("1");
this.room.updateItemState(item); this.room.updateItemState(item);
this.tileCount++; this.tileCount++;
this.gameTiles.put(item.getId(), item);
} }
if (item instanceof InteractionBattleBanzaiScoreboard) if (item instanceof InteractionBattleBanzaiScoreboard)
@ -316,25 +308,6 @@ public class BattleBanzaiGame extends Game
} }
} }
@EventHandler(priority = EventPriority.HIGH)
public static void onUserWalkEvent(UserTakeStepEvent event)
{
if(event.habbo.getHabboInfo().getCurrentGame() == BattleBanzaiGame.class)
{
BattleBanzaiGame game = (BattleBanzaiGame) event.habbo.getHabboInfo().getCurrentRoom().getGame(BattleBanzaiGame.class);
if (game != null && game.isRunning)
{
if(!event.habbo.getHabboInfo().getCurrentRoom().hasObjectTypeAt(InteractionBattleBanzaiTile.class, event.toLocation.x, event.toLocation.y))
{
event.setCancelled(true);
event.habbo.getRoomUnit().setGoalLocation(event.habbo.getRoomUnit().getCurrentLocation());
event.habbo.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
game.room.sendComposer(new RoomUserStatusComposer(event.habbo.getRoomUnit()).compose());
}
}
}
}
public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo) public void tileLocked(GameTeamColors teamColor, HabboItem item, Habbo habbo)
{ {
@ -392,12 +365,44 @@ public class BattleBanzaiGame extends Game
private void refreshGates() private void refreshGates()
{ {
THashSet<RoomTile> tilesToUpdate = new THashSet<>(); Collection<InteractionBattleBanzaiGate> gates = this.room.getRoomSpecialTypes().getBattleBanzaiGates().values();
for (HabboItem item : this.room.getRoomSpecialTypes().getBattleBanzaiGates().values()) THashSet<RoomTile> tilesToUpdate = new THashSet<>(gates.size());
for (HabboItem item : gates)
{ {
tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY())); tilesToUpdate.add(this.room.getLayout().getTile(item.getX(), item.getY()));
} }
this.room.updateTiles(tilesToUpdate); this.room.updateTiles(tilesToUpdate);
} }
public void markTile(Habbo habbo, InteractionBattleBanzaiTile tile, int state)
{
if (!this.gameTiles.contains(tile.getId())) return;
int check = state - (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3);
if(check == 3 || check == 4)
{
state++;
if(state % 3 == 2)
{
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_LOCK_TILE);
this.tileLocked(habbo.getHabboInfo().getGamePlayer().getTeamColor(), tile, habbo);
}
else
{
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_FILL_TILE);
}
}
else
{
state = (habbo.getHabboInfo().getGamePlayer().getTeamColor().type * 3) + 3;
habbo.getHabboInfo().getGamePlayer().addScore(BattleBanzaiGame.POINTS_HIJACK_TILE);
}
this.refreshCounters(habbo.getHabboInfo().getGamePlayer().getTeamColor());
tile.setExtradata(state + "");
this.room.updateItem(tile);
}
} }

View File

@ -17,19 +17,19 @@ public class BattleBanzaiGameTeam extends GameTeam
{ {
super.addMember(gamePlayer); super.addMember(gamePlayer);
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), BattleBanzaiGame.effectId + this.teamColor.type, -1);
} }
@Override @Override
public void removeMember(GamePlayer gamePlayer) public void removeMember(GamePlayer gamePlayer)
{ {
Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame()); Game game = gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().getGame(gamePlayer.getHabbo().getHabboInfo().getCurrentGame());
if(game != null && game instanceof BattleBanzaiGame) if(game instanceof BattleBanzaiGame)
{ {
((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor()); ((BattleBanzaiGame) game).addPositionToGate(gamePlayer.getTeamColor());
} }
gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0); gamePlayer.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(gamePlayer.getHabbo(), 0, -1);
gamePlayer.getHabbo().getRoomUnit().setCanWalk(true); gamePlayer.getHabbo().getRoomUnit().setCanWalk(true);
super.removeMember(gamePlayer); super.removeMember(gamePlayer);

View File

@ -40,16 +40,15 @@ public class FootballGame extends Game
if(this.room == null || !this.room.isLoaded()) if(this.room == null || !this.room.isLoaded())
return; return;
Habbo habbo = room.getHabbo(kicker); Habbo habbo = this.room.getHabbo(kicker);
if(habbo != null) if(habbo != null)
{ {
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored")); AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScored"));
}
if (habbo.getHabboInfo().getId() != this.room.getOwnerId()) if (habbo.getHabboInfo().getId() != this.room.getOwnerId())
{ {
AchievementManager.progressAchievement(this.room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom")); AchievementManager.progressAchievement(this.room.getOwnerId(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FootballGoalScoredInRoom"));
} }
}
this.room.sendComposer(new RoomUserActionComposer(kicker, RoomUserAction.WAVE).compose()); this.room.sendComposer(new RoomUserActionComposer(kicker, RoomUserAction.WAVE).compose());
@ -58,5 +57,4 @@ public class FootballGame extends Game
scoreBoard.getValue().changeScore(1); scoreBoard.getValue().changeScore(1);
} }
} }
} }

View File

@ -2,26 +2,24 @@ package com.eu.habbo.habbohotel.games.freeze;
import com.eu.habbo.Emulator; import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager; import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.games.Game; import com.eu.habbo.habbohotel.games.*;
import com.eu.habbo.habbohotel.games.GamePlayer;
import com.eu.habbo.habbohotel.games.GameTeam;
import com.eu.habbo.habbohotel.games.GameTeamColors;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeBlock;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeExitTile;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTile;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer; import com.eu.habbo.habbohotel.items.interactions.games.freeze.InteractionFreezeTimer;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate; import com.eu.habbo.habbohotel.items.interactions.games.freeze.gates.InteractionFreezeGate;
import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard; import com.eu.habbo.habbohotel.items.interactions.games.freeze.scoreboards.InteractionFreezeScoreboard;
import com.eu.habbo.habbohotel.rooms.*; 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.RoomUserAction;
import com.eu.habbo.habbohotel.users.Habbo; import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem; import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType; import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer; import com.eu.habbo.messages.outgoing.rooms.users.RoomUserActionComposer;
import com.eu.habbo.messages.outgoing.rooms.users.RoomUserStatusComposer;
import com.eu.habbo.plugin.EventHandler; import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent;
import com.eu.habbo.plugin.events.users.UserTakeStepEvent;
import com.eu.habbo.threading.runnables.freeze.FreezeClearEffects; import com.eu.habbo.threading.runnables.freeze.FreezeClearEffects;
import com.eu.habbo.threading.runnables.freeze.FreezeThrowSnowball; import com.eu.habbo.threading.runnables.freeze.FreezeThrowSnowball;
import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.THashMap;
@ -34,6 +32,7 @@ import java.util.Map;
public class FreezeGame extends Game public class FreezeGame extends Game
{ {
public static final int effectId = 40; public static final int effectId = 40;
public static int POWER_UP_POINTS; public static int POWER_UP_POINTS;
public static int POWER_UP_CHANCE; public static int POWER_UP_CHANCE;
public static int POWER_UP_PROTECT_TIME; public static int POWER_UP_PROTECT_TIME;
@ -57,7 +56,7 @@ public class FreezeGame extends Game
@Override @Override
public synchronized void initialise() public synchronized void initialise()
{ {
if(this.isRunning) if(this.state == GameState.RUNNING)
return; return;
int highestTime = 0; int highestTime = 0;
@ -86,7 +85,7 @@ public class FreezeGame extends Game
{ {
if (this.getTeamForHabbo(habbo) == null) if (this.getTeamForHabbo(habbo) == null)
{ {
for (HabboItem item : room.getItemsAt(habbo.getRoomUnit().getCurrentLocation())) for (HabboItem item : this.room.getItemsAt(habbo.getRoomUnit().getCurrentLocation()))
{ {
if (item instanceof InteractionFreezeTile) if (item instanceof InteractionFreezeTile)
{ {
@ -136,13 +135,13 @@ public class FreezeGame extends Game
public void throwBall(Habbo habbo, InteractionFreezeTile item) public void throwBall(Habbo habbo, InteractionFreezeTile item)
{ {
if (!this.isRunning || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass()) if (!this.state.equals(GameState.RUNNING) || !habbo.getHabboInfo().isInGame() || habbo.getHabboInfo().getCurrentGame() != this.getClass())
return; return;
if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty()) if (!item.getExtradata().equalsIgnoreCase("0") && !item.getExtradata().isEmpty())
return; return;
if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), room.getLayout().getTile(item.getX(), item.getY()))) if (RoomLayout.tilesAdjecent(habbo.getRoomUnit().getCurrentLocation(), this.room.getLayout().getTile(item.getX(), item.getY())))
{ {
if(((FreezeGamePlayer)habbo.getHabboInfo().getGamePlayer()).canThrowSnowball()) if(((FreezeGamePlayer)habbo.getHabboInfo().getGamePlayer()).canThrowSnowball())
{ {
@ -158,14 +157,15 @@ public class FreezeGame extends Game
RoomTile t = this.room.getLayout().getTile(x, y); RoomTile t = this.room.getLayout().getTile(x, y);
tiles.add(t); tiles.add(t);
for(int i = 0; i < 4; i++) for(int rotatation = 0; rotatation < 8; rotatation += 2)
{ {
for(int j = 0; j < radius; j++) for(int j = 0; j < radius; j++)
{ {
t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), i * 2, (short) radius); t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), rotatation, j);
if(t == null || t.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY()) if(t == null || t.x < 0 || t.y < 0 || t.x >= this.room.getLayout().getMapSizeX() || t.y >= this.room.getLayout().getMapSizeY())
continue; continue;
tiles.add(t); tiles.add(t);
} }
} }
@ -177,13 +177,13 @@ public class FreezeGame extends Game
{ {
THashSet<RoomTile> tiles = new THashSet<>(); THashSet<RoomTile> tiles = new THashSet<>();
for(int i = 0; i < 4; i++) for(int rotation = 1; rotation < 9; rotation += 2)
{ {
RoomTile t = room.getLayout().getTile(x, y); RoomTile t = this.room.getLayout().getTile(x, y);
for(int j = 0; j < radius; j++) for(int j = 0; j < radius; j++)
{ {
t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), (i * 2) + 1, (short) radius); t = this.room.getLayout().getTileInFront(this.room.getLayout().getTile(x, y), rotation, j);
if (t != null) if (t != null)
{ {
@ -198,7 +198,7 @@ public class FreezeGame extends Game
return tiles; return tiles;
} }
public synchronized void explodeBox(InteractionFreezeBlock block) public synchronized void explodeBox(InteractionFreezeBlock block, int delay)
{ {
int powerUp = 0; int powerUp = 0;
if(Emulator.getRandom().nextInt(100) + 1 <= FreezeGame.POWER_UP_CHANCE) if(Emulator.getRandom().nextInt(100) + 1 <= FreezeGame.POWER_UP_CHANCE)
@ -206,7 +206,7 @@ public class FreezeGame extends Game
powerUp += Emulator.getRandom().nextInt(6) + 1; powerUp += Emulator.getRandom().nextInt(6) + 1;
} }
block.setExtradata((powerUp + 1) * 1000 + ""); block.setExtradata((powerUp + 1) + String.format("%3d", delay));
this.room.updateItemState(block); this.room.updateItemState(block);
} }
@ -273,7 +273,7 @@ public class FreezeGame extends Game
@Override @Override
public void start() public void start()
{ {
if (this.isRunning) if (this.state != GameState.IDLE)
{ {
return; return;
} }
@ -292,13 +292,15 @@ public class FreezeGame extends Game
{ {
try try
{ {
if (!this.isRunning) if (this.state.equals(GameState.IDLE))
return; return;
if (timeLeft > 0) if (this.timeLeft > 0)
{ {
Emulator.getThreading().run(this, 1000); Emulator.getThreading().run(this, 1000);
if (this.state.equals(GameState.PAUSED)) return;
this.timeLeft--; this.timeLeft--;
for (GameTeam team : this.teams.values()) for (GameTeam team : this.teams.values())
@ -331,7 +333,7 @@ public class FreezeGame extends Game
for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet()) for (Map.Entry<Integer, InteractionFreezeTimer> set : this.room.getRoomSpecialTypes().getFreezeTimers().entrySet())
{ {
set.getValue().setExtradata(timeLeft + ""); set.getValue().setExtradata(this.timeLeft + "");
this.room.updateItemState(set.getValue()); this.room.updateItemState(set.getValue());
} }
} else } else
@ -341,7 +343,7 @@ public class FreezeGame extends Game
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); Emulator.getLogging().logErrorLine(e);
} }
} }
@ -391,7 +393,7 @@ public class FreezeGame extends Game
for (Map.Entry<Integer, InteractionFreezeGate> set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet()) for (Map.Entry<Integer, InteractionFreezeGate> set : this.room.getRoomSpecialTypes().getFreezeGates().entrySet())
{ {
if (teamMemberCount.containsKey(set.getValue())) if (teamMemberCount.containsKey(set.getValue().teamColor))
{ {
int amount = Math.min(teamMemberCount.get(set.getValue().teamColor), 5); int amount = Math.min(teamMemberCount.get(set.getValue().teamColor), 5);
set.getValue().setExtradata(amount + ""); set.getValue().setExtradata(amount + "");
@ -413,32 +415,13 @@ public class FreezeGame extends Game
public boolean execute(InteractionFreezeExitTile object) public boolean execute(InteractionFreezeExitTile object)
{ {
object.setExtradata(state); object.setExtradata(state);
room.updateItemState(object); FreezeGame.this.room.updateItemState(object);
return true; return true;
} }
}); });
} }
@EventHandler
public static void onUserWalkEvent(UserTakeStepEvent event)
{
if(event.habbo.getHabboInfo().getCurrentGame() == FreezeGame.class)
{
FreezeGame game = (FreezeGame) event.habbo.getHabboInfo().getCurrentRoom().getGame(FreezeGame.class);
if (game != null && game.isRunning)
{
if (!game.room.hasObjectTypeAt(InteractionFreezeTile.class, event.toLocation.x, event.toLocation.y))
{
event.setCancelled(true);
event.habbo.getRoomUnit().setGoalLocation(event.habbo.getRoomUnit().getCurrentLocation());
event.habbo.getRoomUnit().removeStatus(RoomUnitStatus.MOVE);
game.room.sendComposer(new RoomUserStatusComposer(event.habbo.getRoomUnit()).compose());
}
}
}
}
@EventHandler @EventHandler
public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event) public static void onConfigurationUpdated(EmulatorConfigUpdatedEvent event)
{ {

View File

@ -74,7 +74,6 @@ public class FreezeGamePlayer extends GamePlayer
{ {
game.playerDies(this); game.playerDies(this);
} }
return;
} }
else else
{ {
@ -114,13 +113,7 @@ public class FreezeGamePlayer extends GamePlayer
public boolean canThrowSnowball() public boolean canThrowSnowball()
{ {
if(this.snowBalls > 0) return this.snowBalls > 0 && !this.isFrozen();
{
if(!this.isFrozen())
return true;
}
return false;
} }
public void freeze() public void freeze()
@ -220,7 +213,7 @@ public class FreezeGamePlayer extends GamePlayer
{ {
this.frozenTime--; this.frozenTime--;
if(frozenTime <= 0) if(this.frozenTime <= 0)
{ {
super.getHabbo().getRoomUnit().setCanWalk(true); super.getHabbo().getRoomUnit().setCanWalk(true);
needsEffectUpdate = true; needsEffectUpdate = true;
@ -260,6 +253,6 @@ public class FreezeGamePlayer extends GamePlayer
if(this.dead) if(this.dead)
return; return;
super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId()); super.getHabbo().getHabboInfo().getCurrentRoom().giveEffect(super.getHabbo(), this.correctEffectId(), -1);
} }
} }

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