diff --git a/pom.xml b/pom.xml
index d55e42fb..a6886220 100644
--- a/pom.xml
+++ b/pom.xml
@@ -36,6 +36,7 @@
18
+ --enable-preview
diff --git a/src/main/java/com/eu/habbo/Emulator.java b/src/main/java/com/eu/habbo/Emulator.java
index 7e59f956..695d6b11 100644
--- a/src/main/java/com/eu/habbo/Emulator.java
+++ b/src/main/java/com/eu/habbo/Emulator.java
@@ -217,13 +217,14 @@ public final class Emulator {
try {
String filepath = new File(Emulator.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getAbsolutePath();
MessageDigest md = MessageDigest.getInstance("MD5");// MD5
- FileInputStream fis = new FileInputStream(filepath);
- byte[] dataBytes = new byte[1024];
- int nread;
- while ((nread = fis.read(dataBytes)) != -1)
- md.update(dataBytes, 0, nread);
- byte[] mdbytes = md.digest();
- for (byte mdbyte : mdbytes) sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
+ try(FileInputStream fis = new FileInputStream(filepath)) {
+ byte[] dataBytes = new byte[1024];
+ int nread;
+ while ((nread = fis.read(dataBytes)) != -1)
+ md.update(dataBytes, 0, nread);
+ byte[] mdbytes = md.digest();
+ for (byte mdbyte : mdbytes) sb.append(Integer.toString((mdbyte & 0xff) + 0x100, 16).substring(1));
+ }
} catch (Exception e) {
build = "4.0 Developer Preview Branch";
return;
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
index 96cb775d..6ecaa49c 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleCommand.java
@@ -59,6 +59,6 @@ public abstract class ConsoleCommand {
return false;
}
- public abstract void handle(String[] args) throws Exception;
+ public abstract void handle(String[] args);
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
index f1fc9836..b0001ee2 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleInfoCommand.java
@@ -17,7 +17,7 @@ public class ConsoleInfoCommand extends ConsoleCommand {
public void handle(String[] args) {
int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
int day = (int) TimeUnit.SECONDS.toDays(seconds);
- long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24);
+ long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24L);
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
diff --git a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java
index 1b033e70..06c9f341 100644
--- a/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java
+++ b/src/main/java/com/eu/habbo/core/consolecommands/ConsoleShutdownCommand.java
@@ -8,7 +8,7 @@ public class ConsoleShutdownCommand extends ConsoleCommand {
}
@Override
- public void handle(String[] args) throws Exception {
+ public void handle(String[] args) {
new ShutdownCommand().handle(null, args);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java
index 50790239..6a387e67 100644
--- a/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java
+++ b/src/main/java/com/eu/habbo/crypto/HabboDiffieHellman.java
@@ -88,11 +88,11 @@ public class HabboDiffieHellman {
}
if (this.DHPrime.compareTo(BigInteger.valueOf(2)) < 1) {
- throw new HabboCryptoException("Prime cannot be <= 2!\nPrime: " + this.DHPrime.toString());
+ throw new HabboCryptoException("Prime cannot be <= 2!\nPrime: " + this.DHPrime);
}
if (this.DHGenerator.compareTo(this.DHPrime) > -1) {
- throw new HabboCryptoException("Generator cannot be >= Prime!\nPrime: " + this.DHPrime.toString() + "\nGenerator: " + this.DHGenerator.toString());
+ throw new HabboCryptoException("Generator cannot be >= Prime!\nPrime: " + this.DHPrime + "\nGenerator: " + this.DHGenerator);
}
generateDHKeys();
diff --git a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
index 2b657c4e..1e8b91b4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
+++ b/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java
@@ -20,6 +20,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
@Slf4j
public class Bot implements Runnable {
@@ -42,7 +43,7 @@ public class Bot implements Runnable {
private int chatTimeOut;
private int chatTimestamp;
private short lastChatIndex;
- private int bubble;
+ private final int bubble;
private final String type;
@@ -108,7 +109,7 @@ public class Bot implements Runnable {
this.chatRandom = false;
this.chatDelay = 10;
this.chatTimeOut = Emulator.getIntUnixTimestamp() + this.chatDelay;
- this.chatLines = new ArrayList<>(Arrays.asList("Default Message :D"));
+ this.chatLines = new ArrayList<>(List.of("Default Message :D"));
this.type = bot.getType();
this.effect = bot.getEffect();
this.bubble = bot.getBubbleId();
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
index 18ce8684..babec10e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogLimitedConfiguration.java
@@ -26,14 +26,14 @@ public class CatalogLimitedConfiguration implements Runnable {
public CatalogLimitedConfiguration(int itemId, LinkedList availableNumbers, int totalSet) {
this.itemId = itemId;
this.totalSet = totalSet;
- LinkedList numbers = new LinkedList(availableNumbers);
+ LinkedList numbers = new LinkedList<>(availableNumbers);
if (Emulator.getConfig().getBoolean("catalog.ltd.random", true)) {
Collections.shuffle(numbers);
} else {
Collections.reverse(numbers);
}
- limitedNumbers = new LinkedBlockingQueue(numbers);
+ limitedNumbers = new LinkedBlockingQueue<>(numbers);
}
public int getNumber() {
@@ -70,7 +70,7 @@ public class CatalogLimitedConfiguration implements Runnable {
public void generateNumbers(int starting, int amount) {
synchronized (lock) {
- LinkedList numbers = new LinkedList();
+ LinkedList numbers = new LinkedList<>();
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection(); PreparedStatement statement = connection.prepareStatement("INSERT INTO catalog_items_limited (catalog_item_id, number) VALUES (?, ?)")) {
statement.setInt(1, this.itemId);
@@ -93,7 +93,7 @@ public class CatalogLimitedConfiguration implements Runnable {
Collections.reverse(numbers);
}
- limitedNumbers = new LinkedBlockingQueue(numbers);
+ limitedNumbers = new LinkedBlockingQueue<>(numbers);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
index 39ec532f..6c5333db 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/CatalogPage.java
@@ -125,6 +125,37 @@ public abstract class CatalogPage implements Comparable, ISerialize
}
}
+ protected void appendImagesAndText(ServerMessage message) {
+ message.appendInt(3);
+ message.appendString(getHeaderImage());
+ message.appendString(getTeaserImage());
+ message.appendString(getSpecialImage());
+ message.appendInt(3);
+ message.appendString(getTextOne());
+ message.appendString(getTextDetails());
+ message.appendString(getTextTeaser());
+ }
+
+ protected void appendGuildImagesAndText(ServerMessage message) {
+ message.appendInt(2);
+ message.appendString(getHeaderImage());
+ message.appendString(getTeaserImage());
+ message.appendInt(3);
+ message.appendString(getTextOne());
+ message.appendString(getTextDetails());
+ message.appendString(getTextTeaser());
+ }
+
+ protected void appendPetImagesAndText(ServerMessage message){
+ message.appendInt(2);
+ message.appendString(getHeaderImage());
+ message.appendString(getTeaserImage());
+ message.appendInt(4);
+ message.appendString(getTextOne());
+ message.appendString(getTextTwo());
+ message.appendString(getTextDetails());
+ message.appendString(getTextTeaser());
+ }
@Override
public int compareTo(CatalogPage page) {
return this.getOrderNum() - page.getOrderNum();
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java
index de8cf5e8..62f86359 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BadgeDisplayLayout.java
@@ -15,13 +15,6 @@ public class BadgeDisplayLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("badge_display");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java
index d3f64dab..8648e7bc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubAddonsLayout.java
@@ -15,13 +15,8 @@ public class BuildersClubAddonsLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("builders_club_addons");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
+
+
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java
index cdedbf07..b9005e65 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/BuildersClubLoyaltyLayout.java
@@ -15,13 +15,6 @@ public class BuildersClubLoyaltyLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("builders_club_loyalty");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java
index 1cfbe354..41b6d595 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ColorGroupingLayout.java
@@ -14,13 +14,6 @@ public class ColorGroupingLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("default_3x3_color_grouping");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java
index 2846ce2d..0c70773f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Default_3x3Layout.java
@@ -15,13 +15,6 @@ public class Default_3x3Layout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("default_3x3");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java
index 40de36aa..09d3483e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildForumLayout.java
@@ -14,12 +14,6 @@ public class GuildForumLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("guild_forum");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendGuildImagesAndText(message);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java
index a2adeb2d..859b08b3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFrontpageLayout.java
@@ -14,12 +14,6 @@ public class GuildFrontpageLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("guild_frontpage");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendGuildImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java
index e6c3c85e..5beb9fcf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/GuildFurnitureLayout.java
@@ -14,12 +14,6 @@ public class GuildFurnitureLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("guild_custom_furni");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendGuildImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoMonkeyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoMonkeyLayout.java
index 1de28f58..0edc1d51 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoMonkeyLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoMonkeyLayout.java
@@ -15,13 +15,6 @@ public class InfoMonkeyLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("monkey");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoNikoLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoNikoLayout.java
index f6cd5160..3449a9e2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoNikoLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/InfoNikoLayout.java
@@ -15,13 +15,6 @@ public class InfoNikoLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("monkey");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java
index fbcd15fe..436773b8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/LoyaltyVipBuyLayout.java
@@ -14,13 +14,6 @@ public class LoyaltyVipBuyLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("loyalty_vip_buy");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java
index 5474a423..8bfd3649 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetCustomizationLayout.java
@@ -14,13 +14,6 @@ public class PetCustomizationLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("petcustomization");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java
index 7ebbf45a..d76e59e6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets2Layout.java
@@ -14,13 +14,6 @@ public class Pets2Layout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("pets2");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(4);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextTwo());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendPetImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java
index 0c430519..43a8cc63 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/Pets3Layout.java
@@ -14,13 +14,6 @@ public class Pets3Layout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("pets3");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(4);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextTwo());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendPetImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java
index d708b013..5895850f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/PetsLayout.java
@@ -14,13 +14,6 @@ public class PetsLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("pets");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(4);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextTwo());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendPetImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java
index b8cfe136..59e9837d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/ProductPage1Layout.java
@@ -14,13 +14,6 @@ public class ProductPage1Layout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("productpage1");
- message.appendInt(2);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendInt(4);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextTwo());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendPetImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java
index 11485a12..cd73e7ea 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecentPurchasesLayout.java
@@ -14,13 +14,7 @@ public class RecentPurchasesLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("default_3x3");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
+
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java
index 9d923b53..ca1f2826 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerInfoLayout.java
@@ -14,13 +14,7 @@ public class RecyclerInfoLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("recycler_info");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
+
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java
index fe5693b2..b4cadcc5 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/RecyclerPrizesLayout.java
@@ -14,13 +14,6 @@ public class RecyclerPrizesLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("recycler_prizes");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java
index 752673d0..3b7c5e08 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/SpacesLayout.java
@@ -15,13 +15,6 @@ public class SpacesLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("spaces_new");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java
index 48234910..f3c3dfe6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/TrophiesLayout.java
@@ -15,13 +15,6 @@ public class TrophiesLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("trophies");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java
index ce963413..01735d59 100644
--- a/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/catalog/layouts/VipBuyLayout.java
@@ -14,13 +14,6 @@ public class VipBuyLayout extends CatalogPage {
@Override
public void serialize(ServerMessage message) {
message.appendString("vip_buy");
- message.appendInt(3);
- message.appendString(super.getHeaderImage());
- message.appendString(super.getTeaserImage());
- message.appendString(super.getSpecialImage());
- message.appendInt(3);
- message.appendString(super.getTextOne());
- message.appendString(super.getTextDetails());
- message.appendString(super.getTextTeaser());
+ appendImagesAndText(message);
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java
index b1a137ad..64be09e6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/AboutCommand.java
@@ -13,9 +13,40 @@ public class AboutCommand extends Command {
public AboutCommand() {
super(null, new String[]{"about", "info", "online", "server"});
}
- public static final String credits = "Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral \n" +
- "The Following people have all contributed to this emulator:\n" +
- " TheGeneral\n Beny\n Alejandro\n Capheus\n Skeletor\n Harmonic\n Mike\n Remco\n zGrav \n Quadral \n Harmony\n Swirny\n ArpyAge\n Mikkel\n Rodolfo\n Rasmus\n Kitt Mustang\n Snaiker\n nttzx\n necmi\n Dome\n Jose Flores\n Cam\n Oliver\n Narzo\n Tenshie\n MartenM\n Ridge\n SenpaiDipper\n Snaiker\n Thijmen";
+ public static final String credits = """
+ Arcturus Morningstar is an opensource project based on Arcturus By TheGeneral\s
+ The Following people have all contributed to this emulator:
+ TheGeneral
+ Beny
+ Alejandro
+ Capheus
+ Skeletor
+ Harmonic
+ Mike
+ Remco
+ zGrav\s
+ Quadral\s
+ Harmony
+ Swirny
+ ArpyAge
+ Mikkel
+ Rodolfo
+ Rasmus
+ Kitt Mustang
+ Snaiker
+ nttzx
+ necmi
+ Dome
+ Jose Flores
+ Cam
+ Oliver
+ Narzo
+ Tenshie
+ MartenM
+ Ridge
+ SenpaiDipper
+ Snaiker
+ Thijmen""";
@Override
public boolean handle(GameClient gameClient, String[] params) {
@@ -23,7 +54,7 @@ public class AboutCommand extends Command {
int seconds = Emulator.getIntUnixTimestamp() - Emulator.getTimeStarted();
int day = (int) TimeUnit.SECONDS.toDays(seconds);
- long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24);
+ long hours = TimeUnit.SECONDS.toHours(seconds) - (day * 24L);
long minute = TimeUnit.SECONDS.toMinutes(seconds) - (TimeUnit.SECONDS.toHours(seconds) * 60);
long second = TimeUnit.SECONDS.toSeconds(seconds) - (TimeUnit.SECONDS.toMinutes(seconds) * 60);
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
index bce43f15..bbaea77d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/CommandHandler.java
@@ -2,6 +2,17 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.CommandLog;
+import com.eu.habbo.habbohotel.commands.badge.BadgeCommand;
+import com.eu.habbo.habbohotel.commands.badge.MassBadgeCommand;
+import com.eu.habbo.habbohotel.commands.badge.RoomBadgeCommand;
+import com.eu.habbo.habbohotel.commands.bans.BanCommand;
+import com.eu.habbo.habbohotel.commands.bans.MachineBanCommand;
+import com.eu.habbo.habbohotel.commands.bans.SuperbanCommand;
+import com.eu.habbo.habbohotel.commands.gift.GiftCommand;
+import com.eu.habbo.habbohotel.commands.gift.MassGiftCommand;
+import com.eu.habbo.habbohotel.commands.points.MassPointsCommand;
+import com.eu.habbo.habbohotel.commands.points.PointsCommand;
+import com.eu.habbo.habbohotel.commands.points.RoomPointsCommand;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.permissions.PermissionSetting;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java
index 3cab9d9a..0786dd42 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/FreezeCommand.java
@@ -17,7 +17,6 @@ public class FreezeCommand extends Command {
if (habbo == null) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_freeze.not_found").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
- return true;
} else {
if (habbo.getRoomUnit().canWalk()) {
habbo.getRoomUnit().setCanWalk(false);
@@ -28,8 +27,8 @@ public class FreezeCommand extends Command {
habbo.whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.unfrozen"), RoomChatMessageBubbles.ALERT);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_freeze.user_unfrozen").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
}
- return true;
}
+ return true;
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_freeze.not_found").replace("%user%", ""), RoomChatMessageBubbles.ALERT);
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java
deleted file mode 100644
index 30825c47..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MassGiftCommand.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.eu.habbo.habbohotel.commands;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.messages.ServerMessage;
-import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
-import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
-import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
-import gnu.trove.map.hash.THashMap;
-
-import java.util.Map;
-
-public class MassGiftCommand extends Command {
- public MassGiftCommand() {
- super("cmd_massgift", Emulator.getTexts().getValue("commands.keys.cmd_massgift").split(";"));
- }
-
- @Override
- public boolean handle(final GameClient gameClient, String[] params) {
- if (params.length >= 2) {
- int itemId;
-
- try {
- itemId = Integer.parseInt(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) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
- return true;
- }
-
- final Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(itemId);
-
- if (baseItem == null) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT);
- return true;
- }
-
- StringBuilder message = new StringBuilder();
-
- if (params.length > 2) {
- for (int i = 2; i < params.length; i++) {
- message.append(params[i]).append(" ");
- }
- }
-
- final String finalMessage = message.toString();
-
- THashMap keys = new THashMap<>();
- keys.put("display", "BUBBLE");
- keys.put("image", "${image.library.url}notifications/gift.gif");
- keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous"));
- ServerMessage giftNotificiationMessage = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose();
-
- Emulator.getThreading().run(() -> {
- for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
- Habbo habbo = set.getValue();
-
- HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
-
- Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
-
- String extraData = "1\t" + item.getId();
- extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
-
- Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
-
- habbo.getClient().sendResponse(new FurniListInvalidateComposer());
- habbo.getClient().sendResponse(giftNotificiationMessage);
- }
- });
-
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java
deleted file mode 100644
index 63cd9c2c..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/commands/PointsCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.eu.habbo.habbohotel.commands;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.Habbo;
-
-public class PointsCommand extends Command {
- public PointsCommand() {
- super("cmd_points", Emulator.getTexts().getValue("commands.keys.cmd_points").split(";"));
- }
-
- @Override
- public boolean handle(GameClient gameClient, String[] params) {
- if (params.length >= 3) {
- Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
-
- if (habbo != null) {
- try {
- int type = Emulator.getConfig().getInt("seasonal.primary.type");
-
- if (params.length == 4) {
- try {
- type = Integer.parseInt(params[3]);
- } catch (Exception e) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT);
- return true;
- }
- }
-
- int amount;
-
- try {
- amount = Integer.parseInt(params[2]);
- } catch (Exception e) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
- return true;
- }
-
- if (amount != 0) {
- habbo.givePoints(type, amount);
-
- 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);
- else
- 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));
-
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_points.send").replace("%amount%", amount + "").replace("%user%", params[1]).replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT);
-
- } else {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
- }
- } catch (NumberFormatException e) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
- }
- } else {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.user_offline").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
- }
- } else {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
- }
- return true;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java
deleted file mode 100644
index c00465eb..00000000
--- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomGiftCommand.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.eu.habbo.habbohotel.commands;
-
-import com.eu.habbo.Emulator;
-import com.eu.habbo.habbohotel.gameclients.GameClient;
-import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboItem;
-import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
-import com.eu.habbo.messages.outgoing.wired.WiredRewardResultMessageComposer;
-
-public class RoomGiftCommand extends Command {
- public RoomGiftCommand() {
- super("cmd_roomgift", Emulator.getTexts().getValue("commands.keys.cmd_roomgift").split(";"));
- }
-
- @Override
- public boolean handle(final GameClient gameClient, String[] params) {
- if (params.length >= 2) {
- int itemId;
-
- try {
- itemId = Integer.parseInt(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) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
- return true;
- }
-
- final Item baseItem = Emulator.getGameEnvironment().getItemManager().getItem(itemId);
-
- if (baseItem == null) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT);
- return true;
- }
-
- StringBuilder message = new StringBuilder();
-
- if (params.length > 2) {
- for (int i = 2; i < params.length; i++) {
- message.append(params[i]).append(" ");
- }
- }
-
- final String finalMessage = message.toString();
-
- for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) {
- HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
-
- Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
-
- String extraData = "1\t" + item.getId();
- extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
-
- Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
-
- habbo.getClient().sendResponse(new FurniListInvalidateComposer());
-
- habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_ITEM));
- }
-
- return true;
- }
-
- return false;
- }
-}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java
index ff57f21f..688ae9c1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/SetMaxCommand.java
@@ -25,10 +25,9 @@ public class SetMaxCommand extends Command {
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setmax.invalid_number"), RoomChatMessageBubbles.ALERT);
}
- return true;
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_setmax.forgot_number"), RoomChatMessageBubbles.ALERT);
- return true;
}
+ return true;
}
}
\ No newline at end of file
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/badge/BadgeCommand.java
similarity index 96%
rename from src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/badge/BadgeCommand.java
index 40e715f5..ea1bfdec 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/BadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/badge/BadgeCommand.java
@@ -1,6 +1,7 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.badge;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -14,7 +15,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
@Slf4j
-public class BadgeCommand extends Command {
+public class BadgeCommand extends BaseBadgeCommand {
public BadgeCommand() {
super("cmd_badge", Emulator.getTexts().getValue("commands.keys.cmd_badge").split(";"));
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/badge/BaseBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/badge/BaseBadgeCommand.java
new file mode 100644
index 00000000..d1269729
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/badge/BaseBadgeCommand.java
@@ -0,0 +1,37 @@
+package com.eu.habbo.habbohotel.commands.badge;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboBadge;
+import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
+import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
+import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
+import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer;
+import gnu.trove.map.hash.THashMap;
+
+public abstract class BaseBadgeCommand extends Command {
+ public BaseBadgeCommand(String permission, String[] keys) {
+ super(permission, keys);
+ }
+
+ protected ServerMessage createServerMessage(String badge) {
+ THashMap keys = new THashMap<>();
+ keys.put("display", "BUBBLE");
+ keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
+ keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
+ return new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose();
+ }
+
+ protected void sendBadgeToClient(String badge, ServerMessage message, Habbo habbo) {
+ if (habbo.isOnline()) {
+ if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
+ HabboBadge b = BadgesComponent.createBadge(badge, habbo);
+
+ habbo.getClient().sendResponse(new BadgeReceivedComposer(b));
+ habbo.getClient().sendResponse(message);
+ }
+ }
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/badge/MassBadgeCommand.java
similarity index 57%
rename from src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/badge/MassBadgeCommand.java
index 3fdd1b89..ff93d9d8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MassBadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/badge/MassBadgeCommand.java
@@ -1,6 +1,7 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.badge;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -14,7 +15,7 @@ import gnu.trove.map.hash.THashMap;
import java.util.Map;
-public class MassBadgeCommand extends Command {
+public class MassBadgeCommand extends BaseBadgeCommand {
public MassBadgeCommand() {
super("cmd_massbadge", Emulator.getTexts().getValue("commands.keys.cmd_massbadge").split(";"));
}
@@ -27,23 +28,12 @@ public class MassBadgeCommand extends Command {
badge = params[1];
if (!badge.isEmpty()) {
- THashMap keys = new THashMap<>();
- keys.put("display", "BUBBLE");
- keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
- keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
- ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose();
+ ServerMessage message = createServerMessage(badge);
for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
- if (habbo.isOnline()) {
- if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
- HabboBadge b = BadgesComponent.createBadge(badge, habbo);
-
- habbo.getClient().sendResponse(new BadgeReceivedComposer(b));
- habbo.getClient().sendResponse(message);
- }
- }
+ sendBadgeToClient(badge, message, habbo);
}
return true;
}
@@ -53,4 +43,6 @@ public class MassBadgeCommand extends Command {
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/badge/RoomBadgeCommand.java
similarity index 56%
rename from src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/badge/RoomBadgeCommand.java
index 7cf20315..d5b8e3c1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomBadgeCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/badge/RoomBadgeCommand.java
@@ -1,6 +1,7 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.badge;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
@@ -12,7 +13,7 @@ import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageCo
import com.eu.habbo.messages.outgoing.users.BadgeReceivedComposer;
import gnu.trove.map.hash.THashMap;
-public class RoomBadgeCommand extends Command {
+public class RoomBadgeCommand extends BaseBadgeCommand {
public RoomBadgeCommand() {
super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";"));
}
@@ -28,21 +29,10 @@ public class RoomBadgeCommand extends Command {
badge = params[1];
if (!badge.isEmpty()) {
- THashMap keys = new THashMap<>();
- keys.put("display", "BUBBLE");
- keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
- keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
- ServerMessage message = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose();
+ ServerMessage message = createServerMessage(badge);
for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) {
- if (habbo.isOnline()) {
- if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
- HabboBadge b = BadgesComponent.createBadge(badge, habbo);
-
- habbo.getClient().sendResponse(new BadgeReceivedComposer(b));
- habbo.getClient().sendResponse(message);
- }
- }
+ sendBadgeToClient(badge, message, habbo);
}
}
return true;
@@ -51,4 +41,6 @@ public class RoomBadgeCommand extends Command {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT);
return true;
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/bans/BanCommand.java
similarity index 97%
rename from src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/bans/BanCommand.java
index b37dbbf0..97570ce1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/BanCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/bans/BanCommand.java
@@ -1,6 +1,7 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.bans;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.ModToolBan;
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/bans/BaseBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/bans/BaseBanCommand.java
new file mode 100644
index 00000000..710f3650
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/bans/BaseBanCommand.java
@@ -0,0 +1,53 @@
+package com.eu.habbo.habbohotel.commands.bans;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboInfo;
+import com.eu.habbo.habbohotel.users.HabboManager;
+
+
+public abstract class BaseBanCommand extends Command {
+ protected HabboInfo habboInfo;
+ protected String reason;
+ protected int count;
+
+ public BaseBanCommand(String permission, String[] keys) {
+ super(permission, keys);
+ }
+
+
+ @Override
+ public boolean handle(GameClient gameClient, String[] params) throws Exception {
+ this.reason = getReason(params);
+ this.habboInfo = getHabboInfo(params);
+ return false;
+ }
+
+ private String getReason(String[] params) {
+ StringBuilder reason = new StringBuilder();
+
+ if (params.length > 2) {
+ for (int i = 2; i < params.length; i++) {
+ reason.append(params[i]);
+ reason.append(" ");
+ }
+ }
+
+ return reason.toString();
+ }
+
+ protected HabboInfo getHabboInfo(String[] params) {
+ if (params.length >= 2) {
+ Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
+
+ if (h != null) {
+ return h.getHabboInfo();
+ } else {
+ return HabboManager.getOfflineHabboInfo(params[1]);
+ }
+ }
+ return null;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/bans/MachineBanCommand.java
similarity index 52%
rename from src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/bans/MachineBanCommand.java
index 12e6460e..c67d5a59 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MachineBanCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/bans/MachineBanCommand.java
@@ -1,54 +1,32 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.bans;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.IPBanCommand;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
-public class MachineBanCommand extends Command {
+public class MachineBanCommand extends BaseBanCommand {
public MachineBanCommand() {
super("cmd_machine_ban", Emulator.getTexts().getValue("commands.keys.cmd_machine_ban").split(";"));
}
@Override
- public boolean handle(GameClient gameClient, String[] params) {
- HabboInfo habbo = null;
- StringBuilder reason = new StringBuilder();
- if (params.length >= 2) {
- Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
+ public boolean handle(GameClient gameClient, String[] params) throws Exception {
+ super.handle(gameClient, params);
- if (h != null) {
- habbo = h.getHabboInfo();
- } else {
- habbo = HabboManager.getOfflineHabboInfo(params[1]);
- }
- }
-
- if (params.length > 2) {
- for (int i = 2; i < params.length; i++) {
- reason.append(params[i]);
- reason.append(" ");
- }
- }
-
- int count;
- if (habbo != null) {
- if (habbo == gameClient.getHabbo().getHabboInfo()) {
+ if (habboInfo != null) {
+ if (habboInfo == gameClient.getHabbo().getHabboInfo()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_machine_ban.ban_self"), RoomChatMessageBubbles.ALERT);
return true;
}
- if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
+ if (habboInfo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT);
return true;
}
- count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size();
-
-
+ count = Emulator.getGameEnvironment().getModToolManager().ban(habboInfo.getId(), gameClient.getHabbo(), reason, IPBanCommand.TEN_YEARS, ModToolBanType.MACHINE, -1).size();
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT);
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/bans/SuperbanCommand.java
similarity index 52%
rename from src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/bans/SuperbanCommand.java
index d4c9ee6e..b75f363c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/SuperbanCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/bans/SuperbanCommand.java
@@ -1,52 +1,32 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.bans;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.IPBanCommand;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.modtool.ModToolBanType;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
-import com.eu.habbo.habbohotel.users.Habbo;
-import com.eu.habbo.habbohotel.users.HabboInfo;
-import com.eu.habbo.habbohotel.users.HabboManager;
-public class SuperbanCommand extends Command {
+public class SuperbanCommand extends BaseBanCommand {
public SuperbanCommand() {
super("cmd_super_ban", Emulator.getTexts().getValue("commands.keys.cmd_super_ban").split(";"));
}
@Override
- public boolean handle(GameClient gameClient, String[] params) {
- HabboInfo habbo = null;
- StringBuilder reason = new StringBuilder();
- if (params.length >= 2) {
- Habbo h = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[1]);
+ public boolean handle(GameClient gameClient, String[] params) throws Exception {
+ super.handle(gameClient, params);
- if (h != null) {
- habbo = h.getHabboInfo();
- } else {
- habbo = HabboManager.getOfflineHabboInfo(params[1]);
- }
- }
-
- if (params.length > 2) {
- for (int i = 2; i < params.length; i++) {
- reason.append(params[i]);
- reason.append(" ");
- }
- }
-
- int count;
- if (habbo != null) {
- if (habbo == gameClient.getHabbo().getHabboInfo()) {
+ if (habboInfo != null) {
+ if (habboInfo == gameClient.getHabbo().getHabboInfo()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_super_ban.ban_self"), RoomChatMessageBubbles.ALERT);
return true;
}
- if (habbo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
+ if (habboInfo.getRank().getId() >= gameClient.getHabbo().getHabboInfo().getRank().getId()) {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.target_rank_higher"), RoomChatMessageBubbles.ALERT);
return true;
}
- count = Emulator.getGameEnvironment().getModToolManager().ban(habbo.getId(), gameClient.getHabbo(), reason.toString(), IPBanCommand.TEN_YEARS, ModToolBanType.SUPER, -1).size();
+ count = Emulator.getGameEnvironment().getModToolManager().ban(habboInfo.getId(), gameClient.getHabbo(), reason, IPBanCommand.TEN_YEARS, ModToolBanType.SUPER, -1).size();
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_ban.user_offline"), RoomChatMessageBubbles.ALERT);
return true;
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/gift/BaseGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/gift/BaseGiftCommand.java
new file mode 100644
index 00000000..8447807b
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/gift/BaseGiftCommand.java
@@ -0,0 +1,81 @@
+package com.eu.habbo.habbohotel.commands.gift;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
+
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+public abstract class BaseGiftCommand extends Command {
+ public BaseGiftCommand(String permission, String[] keys) {
+ super(permission, keys);
+ }
+
+ protected boolean validateGiftCommand(GameClient gameClient, String[] params) {
+ Integer itemId = getItemId(params);
+ if (itemId == null) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
+ return false;
+ }
+
+ if (itemId <= 0) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_a_number"), RoomChatMessageBubbles.ALERT);
+ return false;
+ }
+
+ final Item baseItem = getBaseItem(itemId);
+
+ if (baseItem == null) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_gift.not_found").replace("%itemid%", itemId + ""), RoomChatMessageBubbles.ALERT);
+ return false;
+ }
+
+ return true;
+ }
+
+ protected String getFinalMessage(String[] params) {
+ String message = "";
+
+ if (params.length > 2) {
+ message = IntStream.range(2, params.length).mapToObj(i -> params[i] + " ").collect(Collectors.joining());
+ }
+
+ return message;
+ }
+
+ protected void createGift(String finalMessage, Habbo habbo, String[] params) {
+ HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, getBaseItem(params), 0, 0, "");
+
+ Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
+
+ String extraData = "1\t" + item.getId();
+ extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
+
+ Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
+
+ habbo.getClient().sendResponse(new FurniListInvalidateComposer());
+ }
+
+
+ protected Item getBaseItem(String[] params) {
+ return Emulator.getGameEnvironment().getItemManager().getItem(getItemId(params));
+ }
+
+ protected Item getBaseItem(Integer itemId) {
+ return Emulator.getGameEnvironment().getItemManager().getItem(itemId);
+ }
+
+ protected Integer getItemId(String[] params) {
+ try {
+ return Integer.parseInt(params[1]);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/gift/GiftCommand.java
similarity index 96%
rename from src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/gift/GiftCommand.java
index 85f1d2e5..2c44f9ee 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/GiftCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/gift/GiftCommand.java
@@ -1,6 +1,7 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.gift;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
@@ -13,7 +14,7 @@ import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageCo
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import gnu.trove.map.hash.THashMap;
-public class GiftCommand extends Command {
+public class GiftCommand extends BaseGiftCommand {
public GiftCommand() {
super("cmd_gift", Emulator.getTexts().getValue("commands.keys.cmd_gift").split(";"));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/gift/MassGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/gift/MassGiftCommand.java
new file mode 100644
index 00000000..703c911d
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/gift/MassGiftCommand.java
@@ -0,0 +1,53 @@
+package com.eu.habbo.habbohotel.commands.gift;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.ServerMessage;
+import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
+import com.eu.habbo.messages.outgoing.generic.alerts.NotificationDialogMessageComposer;
+import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
+import gnu.trove.map.hash.THashMap;
+
+import java.util.Map;
+
+public class MassGiftCommand extends BaseGiftCommand {
+ public MassGiftCommand() {
+ super("cmd_massgift", Emulator.getTexts().getValue("commands.keys.cmd_massgift").split(";"));
+ }
+
+ @Override
+ public boolean handle(final GameClient gameClient, String[] params) {
+ if (params.length >= 2) {
+ if(!validateGiftCommand(gameClient, params)){
+ return true;
+ }
+
+ final String finalMessage = getFinalMessage(params);
+
+ THashMap keys = new THashMap<>();
+ keys.put("display", "BUBBLE");
+ keys.put("image", "${image.library.url}notifications/gift.gif");
+ keys.put("message", Emulator.getTexts().getValue("generic.gift.received.anonymous"));
+ ServerMessage giftNotificationMessage = new NotificationDialogMessageComposer(BubbleAlertKeys.RECEIVED_BADGE.getKey(), keys).compose();
+
+ Emulator.getThreading().run(() -> {
+ for (Map.Entry set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
+ Habbo habbo = set.getValue();
+
+ createGift(finalMessage, habbo, params);
+ habbo.getClient().sendResponse(giftNotificationMessage);
+ }
+ });
+
+
+ return true;
+ }
+
+ return false;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/gift/RoomGiftCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/gift/RoomGiftCommand.java
new file mode 100644
index 00000000..a234d20f
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/gift/RoomGiftCommand.java
@@ -0,0 +1,40 @@
+package com.eu.habbo.habbohotel.commands.gift;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.items.Item;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.habbohotel.users.HabboItem;
+import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
+import com.eu.habbo.messages.outgoing.wired.WiredRewardResultMessageComposer;
+
+public class RoomGiftCommand extends BaseGiftCommand {
+ public RoomGiftCommand() {
+ super("cmd_roomgift", Emulator.getTexts().getValue("commands.keys.cmd_roomgift").split(";"));
+ }
+
+ @Override
+ public boolean handle(final GameClient gameClient, String[] params) {
+ if (params.length >= 2) {
+ if (!validateGiftCommand(gameClient, params)) {
+ return true;
+ }
+
+ final String finalMessage = getFinalMessage(params);
+
+ for (Habbo habbo : gameClient.getHabbo().getHabboInfo().getCurrentRoom().getHabbos()) {
+ createGift(finalMessage, habbo, params);
+
+ habbo.getClient().sendResponse(new WiredRewardResultMessageComposer(WiredRewardResultMessageComposer.REWARD_RECEIVED_ITEM));
+ }
+
+ return true;
+ }
+
+ return false;
+ }
+
+
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/points/BasePointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/points/BasePointsCommand.java
new file mode 100644
index 00000000..b3c6fb2d
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/points/BasePointsCommand.java
@@ -0,0 +1,9 @@
+package com.eu.habbo.habbohotel.commands.points;
+
+import com.eu.habbo.habbohotel.commands.Command;
+
+public abstract class BasePointsCommand extends Command {
+ public BasePointsCommand(String permission, String[] keys) {
+ super(permission, keys);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/points/MassPointsCommand.java
similarity index 94%
rename from src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/points/MassPointsCommand.java
index 510e2baa..9300805e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/MassPointsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/points/MassPointsCommand.java
@@ -1,13 +1,14 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.points;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import java.util.Map;
-public class MassPointsCommand extends Command {
+public class MassPointsCommand extends BasePointsCommand {
public MassPointsCommand() {
super("cmd_masspoints", Emulator.getTexts().getValue("commands.keys.cmd_masspoints").split(";"));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/points/PointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/points/PointsCommand.java
new file mode 100644
index 00000000..9ab11d83
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/points/PointsCommand.java
@@ -0,0 +1,68 @@
+package com.eu.habbo.habbohotel.commands.points;
+
+import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
+import com.eu.habbo.habbohotel.gameclients.GameClient;
+import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
+import com.eu.habbo.habbohotel.users.Habbo;
+
+public class PointsCommand extends BasePointsCommand {
+ public PointsCommand() {
+ super("cmd_points", Emulator.getTexts().getValue("commands.keys.cmd_points").split(";"));
+ }
+
+ @Override
+ public boolean handle(GameClient gameClient, String[] params) {
+ if (params.length < 3) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
+ Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
+
+ if (habbo == null) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.user_offline").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
+ try {
+ int type = Emulator.getConfig().getInt("seasonal.primary.type");
+ int amount;
+ if (params.length == 4) {
+ try {
+ type = Integer.parseInt(params[3]);
+ } catch (NumberFormatException e) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+ }
+
+ try {
+ amount = Integer.parseInt(params[2]);
+ } catch (NumberFormatException e) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
+ return true;
+ }
+
+ if (amount != 0) {
+ habbo.givePoints(type, amount);
+
+ 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);
+ else
+ 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));
+
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_points.send").replace("%amount%", amount + "").replace("%user%", params[1]).replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT);
+
+ } else {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
+ }
+ } catch (NumberFormatException e) {
+ gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
+ }
+
+ return true;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java b/src/main/java/com/eu/habbo/habbohotel/commands/points/RoomPointsCommand.java
similarity index 94%
rename from src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java
rename to src/main/java/com/eu/habbo/habbohotel/commands/points/RoomPointsCommand.java
index 6ae63460..c241c299 100644
--- a/src/main/java/com/eu/habbo/habbohotel/commands/RoomPointsCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/commands/points/RoomPointsCommand.java
@@ -1,11 +1,12 @@
-package com.eu.habbo.habbohotel.commands;
+package com.eu.habbo.habbohotel.commands.points;
import com.eu.habbo.Emulator;
+import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
-public class RoomPointsCommand extends Command {
+public class RoomPointsCommand extends BasePointsCommand {
public RoomPointsCommand() {
super("cmd_roompoints", Emulator.getTexts().getValue("commands.keys.cmd_roompoints").split(";"));
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java
index 2dffae90..2389e762 100644
--- a/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java
+++ b/src/main/java/com/eu/habbo/habbohotel/crafting/CraftingRecipe.java
@@ -39,7 +39,7 @@ public class CraftingRecipe {
}
public boolean canBeCrafted() {
- return this.limited && this.remaining <= 0;
+ return !this.limited || this.remaining > 0;
}
public synchronized boolean decrease() {
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
index 89b003b0..03737687 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThread.java
@@ -98,7 +98,7 @@ public class ForumThread implements Runnable, ISerialize {
this.commentIndex = 0;
}
- public static ForumThread create(Guild guild, Habbo opener, String subject, String message) throws Exception {
+ public static ForumThread create(Guild guild, Habbo opener, String subject, String message) {
ForumThread createdThread = null;
if (Emulator.getPluginManager().fireEvent(new GuildForumThreadBeforeCreated(guild, opener, subject, message)).isCancelled())
diff --git a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java
index a089209f..f8c35139 100644
--- a/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java
+++ b/src/main/java/com/eu/habbo/habbohotel/guilds/forums/ForumThreadState.java
@@ -11,7 +11,7 @@ public enum ForumThreadState {
HIDDEN_BY_GUILD_ADMIN(20);
@Getter
- private int stateId;
+ private final int stateId;
public static ForumThreadState fromValue(int value) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
index 020c43df..f6877649 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionBuildArea.java
@@ -24,7 +24,7 @@ import java.util.ArrayList;
import java.util.Arrays;
public class InteractionBuildArea extends InteractionCustomValues {
- protected static final THashMap defaultValues = new THashMap();
+ protected static final THashMap defaultValues = new THashMap<>();
private final THashSet tiles;
@@ -110,7 +110,6 @@ public class InteractionBuildArea extends InteractionCustomValues {
}
}
- THashSet oldTiles = this.tiles;
THashSet newTiles = new THashSet<>();
int minX = Math.max(0, newLocation.getX() - Integer.parseInt(this.values.get("tilesBack")));
@@ -127,7 +126,7 @@ public class InteractionBuildArea extends InteractionCustomValues {
}
if (!canBuild.isEmpty()) {
- for (RoomTile tile : oldTiles) {
+ for (RoomTile tile : this.tiles) {
THashSet tileItems = room.getItemsAt(tile);
if (newTiles.contains(tile)) continue;
for (HabboItem tileItem : tileItems) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
index 42948536..896cf046 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionDice.java
@@ -48,7 +48,7 @@ public class InteractionDice extends HabboItem {
if (client != null) {
if (RoomLayout.tilesAdjecent(room.getLayout().getTile(this.getX(), this.getY()), client.getHabbo().getRoomUnit().getCurrentLocation())) {
if (!this.getExtradata().equalsIgnoreCase("-1")) {
- FurnitureDiceRolledEvent event = (FurnitureDiceRolledEvent) Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1));
+ FurnitureDiceRolledEvent event = Emulator.getPluginManager().fireEvent(new FurnitureDiceRolledEvent(this, client.getHabbo(), -1));
if (event.isCancelled())
return;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
index 067405a6..3ba1afc6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionGuildFurni.java
@@ -10,14 +10,13 @@ import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.List;
public class InteractionGuildFurni extends InteractionDefault {
private int guildId;
- private static final THashSet ROTATION_8_ITEMS = new THashSet<>() {
- {
- this.add("gld_wall_tall");
- }
- };
+ private static final THashSet ROTATION_8_ITEMS = new THashSet<>(
+ List.of("gld_wall_tall")
+ );
public InteractionGuildFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
index 86b73483..d8e5fa5c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionInformationTerminal.java
@@ -9,13 +9,14 @@ import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
public class InteractionInformationTerminal extends InteractionCustomValues {
- public static final THashMap defaultValues = new THashMap<>() {
- {
- this.put("internalLink", "habbopages/chat/commands");
- }
- };
+ public static final THashMap defaultValues = new THashMap<>(
+ Map.of(
+ "internalLink", "habbopages/chat/commands"
+ )
+ );
public InteractionInformationTerminal(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem, defaultValues);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
index e7d6fc43..e5fbd80b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionMuteArea.java
@@ -19,29 +19,18 @@ import gnu.trove.set.hash.THashSet;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
public class InteractionMuteArea extends InteractionCustomValues {
- public static final THashMap defaultValues = new THashMap<>() {
- {
- this.put("tilesLeft", "0");
- }
-
- {
- this.put("tilesRight", "0");
- }
-
- {
- this.put("tilesFront", "0");
- }
-
- {
- this.put("tilesBack", "0");
- }
-
- {
- this.put("state", "0");
- }
- };
+ public static final THashMap defaultValues = new THashMap<>(
+ Map.of(
+ "tilesLeft", "0",
+ "tilesRight", "0",
+ "tilesFront", "0",
+ "tilesBack", "0",
+ "state", "0"
+ )
+ );
private final THashSet tiles;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
index 688d6fdc..3a977194 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionRoomAds.java
@@ -7,29 +7,16 @@ import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
public class InteractionRoomAds extends InteractionCustomValues {
- public final static THashMap defaultValues = new THashMap<>() {
- {
- this.put("imageUrl", "");
- }
-
- {
- this.put("clickUrl", "");
- }
-
- {
- this.put("offsetX", "0");
- }
-
- {
- this.put("offsetY", "0");
- }
-
- {
- this.put("offsetZ", "0");
- }
- };
+ public final static THashMap defaultValues = new THashMap<>(Map.of(
+ "imageUrl", "" ,
+ "clickUrl", "",
+ "offsetX", "0",
+ "offsetY", "0",
+ "offsetZ", "0")
+ );
public InteractionRoomAds(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem, defaultValues);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
index 0a988e15..ae286472 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTeleport.java
@@ -128,9 +128,7 @@ public class InteractionTeleport extends HabboItem {
List onSuccess = new ArrayList<>();
List onFail = new ArrayList<>();
- onSuccess.add(() -> {
- tryTeleport(client, room);
- });
+ onSuccess.add(() -> tryTeleport(client, room));
unit.setGoalLocation(infrontTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(unit, infrontTile, room, onSuccess, onFail));
@@ -202,10 +200,7 @@ public class InteractionTeleport extends HabboItem {
if (unit == null)
return false;
- if (habbo.getHabboInfo().getRiding() != null)
- return false;
-
- return true;
+ return habbo.getHabboInfo().getRiding() == null;
}
public void startTeleport(Room room, Habbo habbo) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
index dd9fba6b..b8c1d313 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionTileEffectProvider.java
@@ -8,13 +8,12 @@ import gnu.trove.map.hash.THashMap;
import java.sql.ResultSet;
import java.sql.SQLException;
+import java.util.Map;
public class InteractionTileEffectProvider extends InteractionCustomValues {
- public static final THashMap defaultValues = new THashMap<>() {
- {
- this.put("effectId", "0");
- }
- };
+ public static final THashMap defaultValues = new THashMap<>(
+ Map.of("effectId", "0")
+ );
public InteractionTileEffectProvider(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem, defaultValues);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
index 6f2ff036..4da6bb8f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/InteractionYoutubeTV.java
@@ -9,6 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.rooms.items.youtube.YoutubeDisplayVideoMessageComposer;
+import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo;
import java.sql.ResultSet;
import java.sql.SQLException;
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
index 3f1b06cb..58eea046 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/interfaces/ConditionalGate.java
@@ -4,5 +4,5 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
public interface ConditionalGate {
- public void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
+ void onRejected(RoomUnit roomUnit, Room room, Object[] objects);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
index 3e08adc6..b9ad3607 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetDrink.java
@@ -50,9 +50,7 @@ public class InteractionPetDrink extends InteractionDefault {
if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
List onSuccess = new ArrayList<>();
- onSuccess.add(() -> {
- this.change(room, this.getBaseItem().getStateCount() - 1);
- });
+ onSuccess.add(() -> this.change(room, this.getBaseItem().getStateCount() - 1));
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
index 5e5aa06c..f50ac58d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/pets/InteractionPetTree.java
@@ -40,12 +40,12 @@ public class InteractionPetTree extends InteractionDefault {
Pet pet = room.getPet(roomUnit);
if (pet != null && pet.getPetData().haveToyItem(this.getBaseItem()) && this.getOccupyingTiles(room.getLayout()).contains(pet.getRoomUnit().getGoal())) {
- RoomUnitStatus task = RoomUnitStatus.HANG;
- switch(pet.getTask()){
- case RING_OF_FIRE: task = RoomUnitStatus.RINGOFFIRE; break;
- case SWING: task = RoomUnitStatus.SWING; break;
- case ROLL: task = RoomUnitStatus.ROLL; break;
- }
+ RoomUnitStatus task = switch (pet.getTask()) {
+ case RING_OF_FIRE -> RoomUnitStatus.RINGOFFIRE;
+ case SWING -> RoomUnitStatus.SWING;
+ case ROLL -> RoomUnitStatus.ROLL;
+ default -> RoomUnitStatus.HANG;
+ };
if (pet.getEnergy() >= 35 && task != RoomUnitStatus.HANG) {
pet.getRoomUnit().setCanWalk(false);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
index 83838e76..38b06c51 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionFurniTypeMatch.java
@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.STUFF_IS;
- private THashSet items = new THashSet<>();
+ private final THashSet items = new THashSet<>();
public WiredConditionFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -44,8 +44,7 @@ public class WiredConditionFurniTypeMatch extends InteractionWiredCondition {
if (stuff != null) {
if (stuff.length >= 1) {
- if (stuff[0] instanceof HabboItem) {
- HabboItem triggeringItem = (HabboItem)stuff[0];
+ if (stuff[0] instanceof HabboItem triggeringItem) {
return this.items.stream().anyMatch(item -> item == triggeringItem);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
index bd357437..9c75f4f3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionLessTimeElapsed.java
@@ -50,7 +50,7 @@ public class WiredConditionLessTimeElapsed extends InteractionWiredCondition {
if (!wiredData.equals(""))
this.cycles = Integer.parseInt(wiredData);
}
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
index f2473726..ea0b85f8 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionMoreTimeElapsed.java
@@ -50,7 +50,7 @@ public class WiredConditionMoreTimeElapsed extends InteractionWiredCondition {
if (!wiredData.equals(""))
this.cycles = Integer.parseInt(wiredData);
}
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
index b0bf441a..05feda6b 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniHaveFurni.java
@@ -23,7 +23,7 @@ public class WiredConditionNotFurniHaveFurni extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.NOT_FURNI_HAVE_FURNI;
private boolean all;
- private THashSet items;
+ private final THashSet items;
public WiredConditionNotFurniHaveFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
index d2a09c8b..36966574 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/conditions/WiredConditionNotFurniTypeMatch.java
@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
public static final WiredConditionType type = WiredConditionType.NOT_STUFF_IS;
- private THashSet items = new THashSet<>();
+ private final THashSet items = new THashSet<>();
public WiredConditionNotFurniTypeMatch(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -39,8 +39,7 @@ public class WiredConditionNotFurniTypeMatch extends InteractionWiredCondition {
if (stuff != null) {
if (stuff.length >= 1) {
- if (stuff[0] instanceof HabboItem) {
- HabboItem triggeringItem = (HabboItem)stuff[0];
+ if (stuff[0] instanceof HabboItem triggeringItem) {
return this.items.stream().noneMatch(item -> item == triggeringItem);
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
index cea716c7..4071236c 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectBotTeleport.java
@@ -79,7 +79,7 @@ public class WiredEffectBotTeleport extends InteractionWiredEffect {
}
}
- Emulator.getThreading().run(() -> { roomUnit.isWiredTeleporting = true; }, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
+ Emulator.getThreading().run(() -> roomUnit.isWiredTeleporting = true, Math.max(0, WiredHandler.TELEPORT_DELAY - 500));
Emulator.getThreading().run(new RoomUnitTeleport(roomUnit, room, tile.getX(), tile.getY(), tile.getStackHeight() + (tile.getState() == RoomTileState.SIT ? -0.5 : 0), roomUnit.getEffectId()), WiredHandler.TELEPORT_DELAY);
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
index d3111df6..733718d2 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectChangeFurniDirection.java
@@ -263,23 +263,16 @@ public class WiredEffectChangeFurniDirection extends InteractionWiredEffect {
}
private RoomUserRotation nextRotation(RoomUserRotation currentRotation) {
- switch (this.blockedAction) {
- case ACTION_TURN_BACK:
- return RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite();
- case ACTION_TURN_LEFT_45:
- return RoomUserRotation.counterClockwise(currentRotation);
- case ACTION_TURN_LEFT_90:
- return RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentRotation));
- case ACTION_TURN_RIGHT_45:
- return RoomUserRotation.clockwise(currentRotation);
- case ACTION_TURN_RIGHT_90:
- return RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentRotation));
- case ACTION_TURN_RANDOM:
- return RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8));
- case ACTION_WAIT:
- default:
- return currentRotation;
- }
+ return switch (this.blockedAction) {
+ case ACTION_TURN_BACK -> RoomUserRotation.fromValue(currentRotation.getValue()).getOpposite();
+ case ACTION_TURN_LEFT_45 -> RoomUserRotation.counterClockwise(currentRotation);
+ case ACTION_TURN_LEFT_90 ->
+ RoomUserRotation.counterClockwise(RoomUserRotation.counterClockwise(currentRotation));
+ case ACTION_TURN_RIGHT_45 -> RoomUserRotation.clockwise(currentRotation);
+ case ACTION_TURN_RIGHT_90 -> RoomUserRotation.clockwise(RoomUserRotation.clockwise(currentRotation));
+ case ACTION_TURN_RANDOM -> RoomUserRotation.fromValue(Emulator.getRandom().nextInt(8));
+ case ACTION_WAIT, default -> currentRotation;
+ };
}
@Override
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java
index 468cadaa..df98240e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHandItem.java
@@ -27,7 +27,7 @@ public class WiredEffectGiveHandItem extends WiredEffectWhisper {
if (habbo != null) {
room.giveHandItem(habbo, itemId);
}
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
return false;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java
index 5903e1d3..5ba1cda4 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveHotelviewBonusRarePoints.java
@@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
@@ -13,7 +12,6 @@ import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.hotelview.BonusRareInfoMessageComposer;
-import gnu.trove.procedure.TObjectProcedure;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -48,14 +46,11 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
if (this.requiresTriggeringUser()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
+ if (!object.isTriggeredByRoomUnit()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
@@ -119,7 +114,7 @@ public class WiredEffectGiveHotelviewBonusRarePoints extends InteractionWiredEff
try {
this.amount = Integer.parseInt(wiredData.split("\t")[1]);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java
index e25ab19a..9d80cc4d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectGiveRespect.java
@@ -115,7 +115,7 @@ public class WiredEffectGiveRespect extends InteractionWiredEffect {
try {
this.respects = Integer.parseInt(data[1]);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java
index 09512ff8..28673eaf 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectKickHabbo.java
@@ -4,7 +4,6 @@ import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.Room;
@@ -18,7 +17,6 @@ import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.incoming.wired.WiredSaveException;
import com.eu.habbo.messages.outgoing.rooms.users.WhisperMessageComposer;
import com.eu.habbo.threading.runnables.RoomUnitKick;
-import gnu.trove.procedure.TObjectProcedure;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -129,14 +127,11 @@ public class WiredEffectKickHabbo extends InteractionWiredEffect {
if (this.requiresTriggeringUser()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
+ if (!object.isTriggeredByRoomUnit()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java
index e22eee70..cd052fe7 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMoveFurniTo.java
@@ -197,7 +197,7 @@ public class WiredEffectMoveFurniTo extends InteractionWiredEffect {
this.direction = Integer.parseInt(data[0]);
this.spacing = Integer.parseInt(data[1]);
this.setDelay(Integer.parseInt(data[2]));
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
for (String s : data[3].split("\r")) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java
index ba939604..34afbb2f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectMuteHabbo.java
@@ -106,7 +106,7 @@ public class WiredEffectMuteHabbo extends InteractionWiredEffect {
this.setDelay(Integer.parseInt(data[0]));
this.length = Integer.parseInt(data[1]);
this.message = data[2];
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java
index cef4072a..032471ac 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectResetTimers.java
@@ -48,14 +48,11 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
if (this.requiresTriggeringUser()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
+ if (!object.isTriggeredByRoomUnit()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
@@ -98,7 +95,7 @@ public class WiredEffectResetTimers extends InteractionWiredEffect {
if (!wiredData.equals("")) {
this.delay = Integer.parseInt(wiredData);
}
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java
index 7225fb29..780157ca 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/effects/WiredEffectWhisper.java
@@ -53,14 +53,11 @@ public class WiredEffectWhisper extends InteractionWiredEffect {
if (this.requiresTriggeringUser()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredTrigger object) {
- if (!object.isTriggeredByRoomUnit()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getTriggers(this.getX(), this.getY()).forEach(object -> {
+ if (!object.isTriggeredByRoomUnit()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java
index 6db447f7..9f631c9d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/interfaces/InteractionWiredMatchFurniSettings.java
@@ -4,8 +4,8 @@ import com.eu.habbo.habbohotel.wired.WiredMatchFurniSetting;
import gnu.trove.set.hash.THashSet;
public interface InteractionWiredMatchFurniSettings {
- public THashSet getMatchFurniSettings();
- public boolean shouldMatchState();
- public boolean shouldMatchRotation();
- public boolean shouldMatchPosition();
+ THashSet getMatchFurniSettings();
+ boolean shouldMatchState();
+ boolean shouldMatchRotation();
+ boolean shouldMatchPosition();
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java
index 22ad69fe..922e5f3f 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerGameStarts.java
@@ -1,14 +1,12 @@
package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.procedure.TObjectProcedure;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -60,18 +58,15 @@ public class WiredTriggerGameStarts extends InteractionWiredTrigger {
message.appendString("");
message.appendInt(0);
message.appendInt(0);
- message.appendInt(this.type.getCode());
+ message.appendInt(type.getCode());
if (!this.isTriggeredByRoomUnit()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredEffect object) {
- if (object.requiresTriggeringUser()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> {
+ if (object.requiresTriggeringUser()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java
index 2cf1458b..02623288 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOffFurni.java
@@ -20,7 +20,7 @@ import java.util.stream.Collectors;
public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
public static final WiredTriggerType type = WiredTriggerType.WALKS_OFF_FURNI;
- private THashSet items;
+ private final THashSet items;
public WiredTriggerHabboWalkOffFurni(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
@@ -76,7 +76,7 @@ public class WiredTriggerHabboWalkOffFurni extends InteractionWiredTrigger {
if (item != null)
this.items.add(item);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java
index b6ba23d7..4c779ca6 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerHabboWalkOnFurni.java
@@ -127,7 +127,7 @@ public class WiredTriggerHabboWalkOnFurni extends InteractionWiredTrigger {
if (item != null)
this.items.add(item);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
index cafe8779..8984c313 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerRepeaterLong.java
@@ -3,7 +3,6 @@ package com.eu.habbo.habbohotel.items.interactions.wired.triggers;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.items.ICycleable;
import com.eu.habbo.habbohotel.items.Item;
-import com.eu.habbo.habbohotel.items.interactions.InteractionWiredEffect;
import com.eu.habbo.habbohotel.items.interactions.InteractionWiredTrigger;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredSettings;
import com.eu.habbo.habbohotel.items.interactions.wired.WiredTriggerReset;
@@ -12,7 +11,6 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import com.eu.habbo.messages.ServerMessage;
-import gnu.trove.procedure.TObjectProcedure;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -88,14 +86,11 @@ public class WiredTriggerRepeaterLong extends InteractionWiredTrigger implements
if (!this.isTriggeredByRoomUnit()) {
List invalidTriggers = new ArrayList<>();
- room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(new TObjectProcedure() {
- @Override
- public boolean execute(InteractionWiredEffect object) {
- if (object.requiresTriggeringUser()) {
- invalidTriggers.add(object.getBaseItem().getSpriteId());
- }
- return true;
+ room.getRoomSpecialTypes().getEffects(this.getX(), this.getY()).forEach(object -> {
+ if (object.requiresTriggeringUser()) {
+ invalidTriggers.add(object.getBaseItem().getSpriteId());
}
+ return true;
});
message.appendInt(invalidTriggers.size());
for (Integer i : invalidTriggers) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java
index 24cd112e..449e165e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java
+++ b/src/main/java/com/eu/habbo/habbohotel/items/interactions/wired/triggers/WiredTriggerScoreAchieved.java
@@ -53,7 +53,7 @@ public class WiredTriggerScoreAchieved extends InteractionWiredTrigger {
} else {
try {
this.score = Integer.parseInt(wiredData);
- } catch (Exception e) {
+ } catch (Exception ignored) {
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java
index b96c360f..319654a1 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/PetCommand.java
@@ -85,7 +85,6 @@ public class PetCommand implements Comparable {
}
pet.say(pet.petData.randomVocal(PetVocalsType.DISOBEY));
- return;
}
}
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java
index e9d54c8b..1301d7e3 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionCroak.java
@@ -9,7 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.threading.runnables.PetClearPosture;
-public class ActionCroak extends PetAction {
+public class ActionCroak extends ActionVocals {
public ActionCroak() {
super(PetTasks.SPEAK, false);
this.minimumActionDuration = 2000;
@@ -21,19 +21,10 @@ public class ActionCroak extends PetAction {
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.CROAK, null, false), this.minimumActionDuration);
- if (pet.getHappiness() > 70)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY));
- else if (pet.getHappiness() < 30)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD));
- else if (pet.getLevelHunger() > 65)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY));
- else if (pet.getLevelThirst() > 65)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY));
- else if (pet.getEnergy() < 25)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED));
- else if (pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.SLEEPING));
+ petSay(pet);
return true;
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java
index ed3207b4..f720655e 100644
--- a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionSpeak.java
@@ -9,7 +9,7 @@ import com.eu.habbo.habbohotel.rooms.RoomUnitStatus;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.threading.runnables.PetClearPosture;
-public class ActionSpeak extends PetAction {
+public class ActionSpeak extends ActionVocals {
public ActionSpeak() {
super(PetTasks.SPEAK, false);
@@ -21,18 +21,7 @@ public class ActionSpeak extends PetAction {
pet.setMuted(false);
Emulator.getThreading().run(new PetClearPosture(pet, RoomUnitStatus.SPEAK, null, false), 2000);
- if (pet.getHappiness() > 70)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY));
- else if (pet.getHappiness() < 30)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD));
- else if (pet.getLevelHunger() > 65)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY));
- else if (pet.getLevelThirst() > 65)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY));
- else if (pet.getEnergy() < 25)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED));
- else if (pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN)
- pet.say(pet.getPetData().randomVocal(PetVocalsType.SLEEPING));
+ petSay(pet);
return true;
}
diff --git a/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionVocals.java b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionVocals.java
new file mode 100644
index 00000000..675c9550
--- /dev/null
+++ b/src/main/java/com/eu/habbo/habbohotel/pets/actions/ActionVocals.java
@@ -0,0 +1,28 @@
+package com.eu.habbo.habbohotel.pets.actions;
+
+import com.eu.habbo.habbohotel.pets.Pet;
+import com.eu.habbo.habbohotel.pets.PetAction;
+import com.eu.habbo.habbohotel.pets.PetTasks;
+import com.eu.habbo.habbohotel.pets.PetVocalsType;
+
+public abstract class ActionVocals extends PetAction {
+
+ protected ActionVocals(PetTasks petTask, boolean stopsPetWalking) {
+ super(petTask, stopsPetWalking);
+ }
+
+ protected void petSay(Pet pet) {
+ if (pet.getHappiness() > 70)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_HAPPY));
+ else if (pet.getHappiness() < 30)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.GENERIC_SAD));
+ else if (pet.getLevelHunger() > 65)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.HUNGRY));
+ else if (pet.getLevelThirst() > 65)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.THIRSTY));
+ else if (pet.getEnergy() < 25)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.TIRED));
+ else if (pet.getTask() == PetTasks.NEST || pet.getTask() == PetTasks.DOWN)
+ pet.say(pet.getPetData().randomVocal(PetVocalsType.SLEEPING));
+ }
+}
diff --git a/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java b/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java
index fc1dff48..0571fbdc 100644
--- a/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java
+++ b/src/main/java/com/eu/habbo/habbohotel/polls/Poll.java
@@ -18,7 +18,7 @@ public class Poll {
@Setter
private int lastQuestionId;
- private ArrayList questions;
+ private final ArrayList questions;
public Poll(ResultSet set) throws SQLException {
this.id = set.getInt("id");
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
index 351269ae..0399ff1a 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/CustomRoomLayout.java
@@ -14,7 +14,7 @@ public class CustomRoomLayout extends RoomLayout implements Runnable {
private final int roomId;
private boolean needsUpdate;
- public CustomRoomLayout(ResultSet set, Room room) throws SQLException {
+ public CustomRoomLayout(ResultSet set, Room room) {
super(set, room);
this.roomId = room.getId();
diff --git a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
index 0511771d..fc25eb0d 100644
--- a/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
+++ b/src/main/java/com/eu/habbo/habbohotel/rooms/RoomChatMessage.java
@@ -85,7 +85,7 @@ public class RoomChatMessage implements Runnable, ISerialize, DatabaseLoggable {
this.targetHabbo = chatMessage.getTargetHabbo();
this.bubble = chatMessage.getBubble();
this.roomUnitId = chatMessage.roomUnitId;
- this.emotion = (byte) chatMessage.getEmotion();
+ this.emotion = chatMessage.getEmotion();
}
public RoomChatMessage(String message, RoomUnit roomUnit, RoomChatMessageBubbles bubble) {
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
index 92cd5932..d41f6c29 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboInfo.java
@@ -330,7 +330,8 @@ public class HabboInfo implements Runnable {
roomUnit.setPreviousLocationZ(riding.getRoomUnit().getZ());
roomUnit.stopWalking();
if (room != null)
- room.sendComposer(new UserUpdateComposer(roomUnit).compose());
+ room.sendComposer(new UserUpdateComposer(roomUnit).compose());
+
List availableTiles = isRemoving ? new ArrayList<>() : this.getCurrentRoom().getLayout().getWalkableTilesAround(roomUnit.getCurrentLocation());
RoomTile tile = availableTiles.isEmpty() ? roomUnit.getCurrentLocation() : availableTiles.get(0);
diff --git a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
index 21e727bd..5bb26eb9 100644
--- a/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
+++ b/src/main/java/com/eu/habbo/habbohotel/users/HabboItem.java
@@ -37,6 +37,7 @@ import java.util.List;
@Slf4j
public abstract class HabboItem implements Runnable, IEventTriggers {
+ @SuppressWarnings("rawtypes")
private static final Class[] TOGGLING_INTERACTIONS = new Class[]{
InteractionGameTimer.class,
InteractionWired.class,
diff --git a/src/main/java/com/eu/habbo/messages/PacketManager.java b/src/main/java/com/eu/habbo/messages/PacketManager.java
index a4dfcb55..157f98dc 100644
--- a/src/main/java/com/eu/habbo/messages/PacketManager.java
+++ b/src/main/java/com/eu/habbo/messages/PacketManager.java
@@ -176,7 +176,7 @@ public class PacketManager {
return;
}
- final MessageHandler handler = handlerClass.newInstance();
+ final MessageHandler handler = handlerClass.getDeclaredConstructor().newInstance();
if (handler.getRatelimit() > 0) {
if (client.messageTimestamps.containsKey(handlerClass) && System.currentTimeMillis() - client.messageTimestamps.get(handlerClass) < handler.getRatelimit()) {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java
index fa13813c..cca9502b 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/BuildersClubPlaceWallItemEvent.java
@@ -6,8 +6,6 @@ import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
import com.eu.habbo.habbohotel.users.subscriptions.SubscriptionHabboClub;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.unknown.HabboClubExtendOfferMessageComposer;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class BuildersClubPlaceWallItemEvent extends MessageHandler {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java
new file mode 100644
index 00000000..1657e79c
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseEvent.java
@@ -0,0 +1,46 @@
+package com.eu.habbo.messages.incoming.catalog;
+
+import com.eu.habbo.habbohotel.catalog.ClubOffer;
+import com.eu.habbo.habbohotel.permissions.Permission;
+import com.eu.habbo.habbohotel.users.subscriptions.Subscription;
+import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.catalog.PurchaseErrorMessageComposer;
+import com.eu.habbo.messages.outgoing.catalog.PurchaseOKMessageComposer;
+import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
+import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer;
+import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer;
+
+public abstract class PurchaseEvent extends MessageHandler {
+ protected void purchase(ClubOffer deal, int totalDays, int totalCredits, int totalDuckets) throws Exception {
+ if (totalDays > 0) {
+ if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(deal.getPointsType()) < totalDuckets)
+ return;
+
+ if (this.client.getHabbo().getHabboInfo().getCredits() < totalCredits)
+ return;
+
+ if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS))
+ this.client.getHabbo().giveCredits(-totalCredits);
+
+ if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
+ this.client.getHabbo().givePoints(deal.getPointsType(), -totalDuckets);
+
+
+ if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
+ this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose());
+ throw new Exception("Unable to create or extend subscription");
+ }
+
+ if (totalCredits > 0)
+ this.client.sendResponse(new CreditBalanceComposer(this.client.getHabbo()));
+
+ if (totalDuckets > 0)
+ this.client.sendResponse(new ActivityPointsMessageComposer(this.client.getHabbo()));
+
+ this.client.sendResponse(new PurchaseOKMessageComposer(null));
+ this.client.sendResponse(new FurniListInvalidateComposer());
+
+ this.client.getHabbo().getHabboStats().run();
+ }
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java
index ce67f7ab..cada42a7 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseFromCatalogEvent.java
@@ -30,7 +30,7 @@ import org.apache.commons.lang3.StringUtils;
import static com.eu.habbo.messages.incoming.catalog.ApproveNameEvent.PET_NAME_LENGTH_MAXIMUM;
import static com.eu.habbo.messages.incoming.catalog.ApproveNameEvent.PET_NAME_LENGTH_MINIMUM;
-public class PurchaseFromCatalogEvent extends MessageHandler {
+public class PurchaseFromCatalogEvent extends PurchaseEvent {
@Override
@@ -166,44 +166,7 @@ public class PurchaseFromCatalogEvent extends MessageHandler {
totalDuckets += item.getPoints();
}
- if (totalDays > 0) {
- if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(item.getPointsType()) < totalDuckets)
- return;
-
- if (this.client.getHabbo().getHabboInfo().getCredits() < totalCredits)
- return;
-
- if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS))
- this.client.getHabbo().giveCredits(-totalCredits);
-
- if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
- this.client.getHabbo().givePoints(item.getPointsType(), -totalDuckets);
-
-
- if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
- this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose());
- throw new Exception("Unable to create or extend subscription");
- }
-
- /*if (this.client.getHabbo().getHabboStats().getClubExpireTimestamp() <= Emulator.getIntUnixTimestamp())
- this.client.getHabbo().getHabboStats().setClubExpireTimestamp(Emulator.getIntUnixTimestamp());
-
- this.client.getHabbo().getHabboStats().setClubExpireTimestamp(this.client.getHabbo().getHabboStats().getClubExpireTimestamp() + (totalDays * 86400));
-
- this.client.sendResponse(new UserPermissionsComposer(this.client.getHabbo()));
- this.client.sendResponse(new UserClubComposer(this.client.getHabbo()));*/
-
- if (totalCredits > 0)
- this.client.sendResponse(new CreditBalanceComposer(this.client.getHabbo()));
-
- if (totalDuckets > 0)
- this.client.sendResponse(new ActivityPointsMessageComposer(this.client.getHabbo()));
-
- this.client.sendResponse(new PurchaseOKMessageComposer(null));
- this.client.sendResponse(new FurniListInvalidateComposer());
-
- this.client.getHabbo().getHabboStats().run();
- }
+ purchase(item, totalDays, totalCredits, totalDuckets);
return;
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java
index 903e4c31..70065f99 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/catalog/PurchaseVipMembershipExtensionEvent.java
@@ -12,7 +12,7 @@ import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
import com.eu.habbo.messages.outgoing.users.ActivityPointsMessageComposer;
import com.eu.habbo.messages.outgoing.users.CreditBalanceComposer;
-public class PurchaseVipMembershipExtensionEvent extends MessageHandler {
+public class PurchaseVipMembershipExtensionEvent extends PurchaseEvent {
@Override
public void handle() throws Exception {
@@ -43,39 +43,12 @@ public class PurchaseVipMembershipExtensionEvent extends MessageHandler {
int totalCredits = deal.getCredits();
int totalDuckets = deal.getPoints();
- if (totalDays > 0) {
- if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(deal.getPointsType()) < totalDuckets)
- return;
-
- if (this.client.getHabbo().getHabboInfo().getCredits() < totalCredits)
- return;
-
- if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_CREDITS))
- this.client.getHabbo().giveCredits(-totalCredits);
-
- if (!this.client.getHabbo().hasPermission(Permission.ACC_INFINITE_POINTS))
- this.client.getHabbo().givePoints(deal.getPointsType(), -totalDuckets);
-
-
- if(this.client.getHabbo().getHabboStats().createSubscription(Subscription.HABBO_CLUB, (totalDays * 86400)) == null) {
- this.client.sendResponse(new PurchaseErrorMessageComposer(PurchaseErrorMessageComposer.SERVER_ERROR).compose());
- throw new Exception("Unable to create or extend subscription");
- }
-
- if (totalCredits > 0)
- this.client.sendResponse(new CreditBalanceComposer(this.client.getHabbo()));
-
- if (totalDuckets > 0)
- this.client.sendResponse(new ActivityPointsMessageComposer(this.client.getHabbo()));
-
- this.client.sendResponse(new PurchaseOKMessageComposer(null));
- this.client.sendResponse(new FurniListInvalidateComposer());
-
- this.client.getHabbo().getHabboStats().run();
- }
+ purchase(deal, totalDays, totalCredits, totalDuckets);
}
}
}
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java
index 0727336a..26736ce1 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/CreateGuildEvent.java
@@ -16,7 +16,7 @@ import com.eu.habbo.plugin.events.guilds.GuildPurchasedEvent;
import lombok.extern.slf4j.Slf4j;
@Slf4j
-public class CreateGuildEvent extends MessageHandler {
+public class CreateGuildEvent extends GuildBadgeEvent {
@Override
public void handle() {
@@ -58,25 +58,7 @@ public class CreateGuildEvent extends MessageHandler {
int count = this.packet.readInt();
- StringBuilder badge = new StringBuilder();
-
- byte base = 1;
-
- while (base < count) {
- int id = this.packet.readInt();
- int color = this.packet.readInt();
- int pos = this.packet.readInt();
-
- if (base == 1) {
- badge.append("b");
- } else {
- badge.append("s");
- }
-
- badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos);
-
- base += 3;
- }
+ StringBuilder badge = createBadge(count);
Guild guild = Emulator.getGameEnvironment().getGuildManager().createGuild(this.client.getHabbo(), roomId, r.getName(), name, description, badge.toString(), colorOne, colorTwo);
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildBadgeEvent.java
new file mode 100644
index 00000000..27d84a8c
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/GuildBadgeEvent.java
@@ -0,0 +1,28 @@
+package com.eu.habbo.messages.incoming.guilds;
+
+import com.eu.habbo.messages.incoming.MessageHandler;
+
+public abstract class GuildBadgeEvent extends MessageHandler {
+ protected StringBuilder createBadge(int count) {
+ StringBuilder badge = new StringBuilder();
+
+ byte base = 1;
+
+ while (base < count) {
+ int id = this.packet.readInt();
+ int color = this.packet.readInt();
+ int pos = this.packet.readInt();
+
+ if (base == 1) {
+ badge.append("b");
+ } else {
+ badge.append("s");
+ }
+
+ badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos);
+
+ base += 3;
+ }
+ return badge;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java
index 0a1f0c4e..713ed406 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/UpdateGuildBadgeEvent.java
@@ -7,7 +7,7 @@ import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.events.guilds.GuildChangedBadgeEvent;
-public class UpdateGuildBadgeEvent extends MessageHandler {
+public class UpdateGuildBadgeEvent extends GuildBadgeEvent {
@Override
public void handle() {
int guildId = this.packet.readInt();
@@ -22,25 +22,7 @@ public class UpdateGuildBadgeEvent extends MessageHandler {
int count = this.packet.readInt();
- StringBuilder badge = new StringBuilder();
-
- byte base = 1;
-
- while (base < count) {
- int id = this.packet.readInt();
- int color = this.packet.readInt();
- int pos = this.packet.readInt();
-
- if (base == 1) {
- badge.append("b");
- } else {
- badge.append("s");
- }
-
- badge.append(id < 100 ? "0" : "").append(id < 10 ? "0" : "").append(id).append(color < 10 ? "0" : "").append(color).append(pos);
-
- base += 3;
- }
+ StringBuilder badge = createBadge(count);
if (guild.getBadge().equalsIgnoreCase(badge.toString()))
return;
@@ -63,4 +45,6 @@ public class UpdateGuildBadgeEvent extends MessageHandler {
}
}
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java
index 2b70f354..ade09389 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/GetMessagesEvent.java
@@ -18,7 +18,7 @@ import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer;
public class GetMessagesEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int guildId = packet.readInt();
int threadId = packet.readInt();
int index = packet.readInt(); // 40
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java
index 5696c418..a92b5c88 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateMessageEvent.java
@@ -17,7 +17,7 @@ import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer;
public class ModerateMessageEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int guildId = packet.readInt();
int threadId = packet.readInt();
int messageId = packet.readInt();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java
index 75001eee..77dd0e52 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/ModerateThreadEvent.java
@@ -17,7 +17,7 @@ import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer;
public class ModerateThreadEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int guildId = packet.readInt();
int threadId = packet.readInt();
int state = packet.readInt();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java
index 32b95f60..1e6d1fd8 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/guilds/forums/UpdateThreadEvent.java
@@ -16,7 +16,7 @@ import com.eu.habbo.messages.outgoing.handshake.ErrorReportComposer;
public class UpdateThreadEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int guildId = this.packet.readInt();
int threadId = this.packet.readInt();
boolean isPinned = this.packet.readBoolean();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumMessageEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumMessageEvent.java
index e2f10afd..94eef632 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumMessageEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumMessageEvent.java
@@ -12,7 +12,7 @@ import com.eu.habbo.threading.runnables.InsertModToolIssue;
public class CallForHelpFromForumMessageEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int groupId = this.packet.readInt();
int threadId = this.packet.readInt();
int commentId = this.packet.readInt();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumThreadEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumThreadEvent.java
index 2273090c..5281e27e 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumThreadEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/CallForHelpFromForumThreadEvent.java
@@ -12,7 +12,7 @@ import com.eu.habbo.threading.runnables.InsertModToolIssue;
public class CallForHelpFromForumThreadEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
int groupId = this.packet.readInt();
int threadId = this.packet.readInt();
int topicId = this.packet.readInt();
diff --git a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java
index fe3698a7..987aeb43 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/modtool/GetCfhChatlogEvent.java
@@ -14,7 +14,7 @@ import java.util.stream.Collectors;
public class GetCfhChatlogEvent extends MessageHandler {
@Override
- public void handle() throws Exception {
+ public void handle() {
if (this.client.getHabbo().hasPermission(Permission.ACC_SUPPORTTOOL)) {
ModToolIssue issue = Emulator.getGameEnvironment().getModToolManager().getTicket(this.packet.readInt());
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java
index f9053c63..6368a05e 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetJukeboxPlayListEvent.java
@@ -5,12 +5,9 @@ import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer;
-public class GetJukeboxPlayListEvent extends MessageHandler {
+public class GetJukeboxPlayListEvent extends JukeboxEvent {
@Override
public void handle() {
- TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
- this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo())));
- this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
+ updateHabboWithCurrentPlaying();
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java
index 124ec4fe..4659c61d 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/GetNowPlayingEvent.java
@@ -5,12 +5,9 @@ import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer;
-public class GetNowPlayingEvent extends MessageHandler {
+public class GetNowPlayingEvent extends JukeboxEvent {
@Override
public void handle() {
- TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
- this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo())));
- this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
+ updateHabboWithCurrentPlaying();
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
index edd83c1b..8d2ada31 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeBoxEventOne.java
@@ -5,12 +5,11 @@ import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer;
import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer;
-public class JukeBoxEventOne extends MessageHandler {
+public class JukeBoxEventOne extends JukeboxEvent {
@Override
public void handle() {
- TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
- this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength()));
- this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo())));
- this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
+ updateHabboWithCurrentPlaying();
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java
new file mode 100644
index 00000000..bef71287
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/jukebox/JukeboxEvent.java
@@ -0,0 +1,15 @@
+package com.eu.habbo.messages.incoming.rooms.items.jukebox;
+
+import com.eu.habbo.habbohotel.rooms.TraxManager;
+import com.eu.habbo.messages.incoming.MessageHandler;
+import com.eu.habbo.messages.outgoing.rooms.items.jukebox.JukeboxSongDisksMessageComposer;
+import com.eu.habbo.messages.outgoing.rooms.items.jukebox.UserSongDisksInventoryMessageComposer;
+
+public abstract class JukeboxEvent extends MessageHandler {
+ protected void updateHabboWithCurrentPlaying() {
+ TraxManager traxManager = this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager();
+ this.client.sendResponse(new JukeboxSongDisksMessageComposer(traxManager.getSongs(), traxManager.totalLength()));
+ this.client.sendResponse(new UserSongDisksInventoryMessageComposer(traxManager.myList(this.client.getHabbo())));
+ this.client.getHabbo().getHabboInfo().getCurrentRoom().getTraxManager().updateCurrentPlayingSong(this.client.getHabbo());
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java
index 3556a332..b6b5805a 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/ControlYoutubeDisplayPlaybackEvent.java
@@ -14,7 +14,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
-public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler {
+public class ControlYoutubeDisplayPlaybackEvent extends YoutubeEvent {
@Getter
@AllArgsConstructor
public enum YoutubeState {
@@ -45,15 +45,9 @@ public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler {
Habbo habbo = this.client.getHabbo();
- if (habbo == null) return;
-
+ if(!validate(habbo)) return;
Room room = habbo.getHabboInfo().getCurrentRoom();
-
- if (room == null) return;
- if (!room.isOwner(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) return;
-
-
HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId);
if (!(item instanceof InteractionYoutubeTV tv)) return;
@@ -70,7 +64,7 @@ public class ControlYoutubeDisplayPlaybackEvent extends MessageHandler {
case RESUME -> {
tv.playing = true;
tv.startedWatchingAt = Emulator.getIntUnixTimestamp();
- tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), (tv.currentVideo.getDuration() - tv.offset) * 1000);
+ tv.autoAdvance = Emulator.getThreading().run(new YoutubeAdvanceVideo(tv), (tv.currentVideo.getDuration() - tv.offset) * 1000L);
room.sendComposer(new YoutubeControlVideoMessageComposer(tv.getId(), 1).compose());
}
case PREVIOUS -> {
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java
index 7c09d967..7f9fbeca 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/SetYoutubeDisplayPlaylistEvent.java
@@ -13,7 +13,7 @@ import com.eu.habbo.threading.runnables.YoutubeAdvanceVideo;
import java.util.Optional;
-public class SetYoutubeDisplayPlaylistEvent extends MessageHandler {
+public class SetYoutubeDisplayPlaylistEvent extends YoutubeEvent {
@Override
public void handle() {
int itemId = this.packet.readInt();
@@ -21,14 +21,10 @@ public class SetYoutubeDisplayPlaylistEvent extends MessageHandler {
Habbo habbo = this.client.getHabbo();
- if (habbo == null) return;
-
+ if (!validate(habbo)) return;
Room room = habbo.getHabboInfo().getCurrentRoom();
- if (room == null) return;
- if (!room.isOwner(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) return;
-
HabboItem item = this.client.getHabbo().getHabboInfo().getCurrentRoom().getHabboItem(itemId);
diff --git a/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java
new file mode 100644
index 00000000..dfea8959
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/rooms/items/youtube/YoutubeEvent.java
@@ -0,0 +1,26 @@
+package com.eu.habbo.messages.incoming.rooms.items.youtube;
+
+import com.eu.habbo.habbohotel.permissions.Permission;
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.messages.incoming.MessageHandler;
+
+public abstract class YoutubeEvent extends MessageHandler {
+
+ protected boolean validate(Habbo habbo) {
+ if (habbo == null) {
+ return false;
+ }
+
+ Room room = habbo.getHabboInfo().getCurrentRoom();
+
+ if (room == null) {
+ return false;
+ }
+ if (!room.isOwner(habbo) && !habbo.hasPermission(Permission.ACC_ANYROOMOWNER)) {
+ return false;
+ }
+
+ return true;
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java
index 0c064546..3005e9b3 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/trading/CloseTradingEvent.java
@@ -5,21 +5,9 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
-public class CloseTradingEvent extends MessageHandler {
+public class CloseTradingEvent extends TradingEvent {
@Override
public void handle() {
- Habbo habbo = this.client.getHabbo();
- Room room = habbo.getHabboInfo().getCurrentRoom();
-
- if (room == null)
- return;
-
- RoomTrade trade = room.getActiveTradeForHabbo(habbo);
-
- if (trade == null)
- return;
-
- trade.stopTrade(habbo);
- room.stopTrade(trade);
+ stopTrade(this.client.getHabbo());
}
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java
index 2762db99..5b88197f 100644
--- a/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java
+++ b/src/main/java/com/eu/habbo/messages/incoming/trading/ConfirmDeclineTradingEvent.java
@@ -5,21 +5,11 @@ import com.eu.habbo.habbohotel.rooms.RoomTrade;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.incoming.MessageHandler;
-public class ConfirmDeclineTradingEvent extends MessageHandler {
+public class ConfirmDeclineTradingEvent extends TradingEvent {
@Override
public void handle() {
- Habbo habbo = this.client.getHabbo();
- Room room = habbo.getHabboInfo().getCurrentRoom();
-
- if (room == null)
- return;
-
- RoomTrade trade = room.getActiveTradeForHabbo(habbo);
-
- if (trade == null)
- return;
-
- trade.stopTrade(habbo);
- room.stopTrade(trade);
+ stopTrade(this.client.getHabbo());
}
+
+
}
diff --git a/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java
new file mode 100644
index 00000000..a2fb005a
--- /dev/null
+++ b/src/main/java/com/eu/habbo/messages/incoming/trading/TradingEvent.java
@@ -0,0 +1,23 @@
+package com.eu.habbo.messages.incoming.trading;
+
+import com.eu.habbo.habbohotel.rooms.Room;
+import com.eu.habbo.habbohotel.rooms.RoomTrade;
+import com.eu.habbo.habbohotel.users.Habbo;
+import com.eu.habbo.messages.incoming.MessageHandler;
+
+public abstract class TradingEvent extends MessageHandler {
+ protected void stopTrade(Habbo habbo) {
+ Room room = habbo.getHabboInfo().getCurrentRoom();
+
+ if (room == null)
+ return;
+
+ RoomTrade trade = room.getActiveTradeForHabbo(habbo);
+
+ if (trade == null)
+ return;
+
+ trade.stopTrade(habbo);
+ room.stopTrade(trade);
+ }
+}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotCommandConfigurationComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotCommandConfigurationComposer.java
index b64b1395..b8dc868c 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotCommandConfigurationComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/rooms/BotCommandConfigurationComposer.java
@@ -21,12 +21,9 @@ public class BotCommandConfigurationComposer extends MessageComposer {
this.response.appendInt(this.settingId);
switch (this.settingId) {
- case 1:
- this.response.appendString("");
- break;
- case 2:
+ case 1, 3, 4, 6 -> this.response.appendString("");
+ case 2 -> {
StringBuilder data = new StringBuilder();
-
if (this.bot.hasChat()) {
for (String s : this.bot.getChatLines()) {
data.append(s).append("\r");
@@ -34,28 +31,13 @@ public class BotCommandConfigurationComposer extends MessageComposer {
} else {
data.append(Bot.NO_CHAT_SET);
}
-
-
data.append(";#;").append(this.bot.isChatAuto() ? "true" : "false");
data.append(";#;").append(this.bot.getChatDelay());
data.append(";#;").append(this.bot.isChatRandom() ? "true" : "false");
this.response.appendString(data.toString());
- break;
- case 3:
- this.response.appendString("");
- break;
- case 4:
- this.response.appendString("");
- break;
- case 5:
- this.response.appendString(this.bot.getName());
- break;
- case 6:
- this.response.appendString("");
- break;
- case 9:
- this.response.appendString(this.bot.getMotto());
- break;
+ }
+ case 5 -> this.response.appendString(this.bot.getName());
+ case 9 -> this.response.appendString(this.bot.getMotto());
}
return this.response;
}
diff --git a/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java b/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java
index 367b5763..3e8cea75 100644
--- a/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java
+++ b/src/main/java/com/eu/habbo/messages/outgoing/users/FavouriteChangedComposer.java
@@ -5,7 +5,6 @@ import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.Outgoing;
-import gnu.trove.procedure.TIntProcedure;
import lombok.AllArgsConstructor;
@AllArgsConstructor
@@ -18,12 +17,9 @@ public class FavouriteChangedComposer extends MessageComposer {
this.response.init(Outgoing.favouritesComposer);
this.response.appendInt(Emulator.getConfig().getInt("hotel.rooms.max.favorite"));
this.response.appendInt(this.habbo.getHabboStats().getFavoriteRooms().size());
- this.habbo.getHabboStats().getFavoriteRooms().forEach(new TIntProcedure() {
- @Override
- public boolean execute(int value) {
- FavouriteChangedComposer.this.response.appendInt(value);
- return true;
- }
+ this.habbo.getHabboStats().getFavoriteRooms().forEach(value -> {
+ FavouriteChangedComposer.this.response.appendInt(value);
+ return true;
});
return this.response;
}
diff --git a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java
index 3a87ee19..11581a4f 100644
--- a/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java
+++ b/src/main/java/com/eu/habbo/plugin/events/inventory/InventoryItemEvent.java
@@ -2,9 +2,7 @@ package com.eu.habbo.plugin.events.inventory;
import com.eu.habbo.habbohotel.users.HabboInventory;
import com.eu.habbo.habbohotel.users.HabboItem;
-import lombok.AllArgsConstructor;
import lombok.Getter;
-import lombok.experimental.SuperBuilder;
@Getter
public class InventoryItemEvent extends InventoryEvent {