From 32383e7cc447f763ab868794c449609f6be476db Mon Sep 17 00:00:00 2001 From: duckietm Date: Wed, 29 May 2024 11:38:23 +0200 Subject: [PATCH] :up: Gamecenter --- .../com/eu/habbo/habbohotel/bots/Bot.java | 3 +- .../eu/habbo/habbohotel/bots/BotManager.java | 22 ++++--- .../habbo/habbohotel/items/ItemManager.java | 14 ++++ .../com/eu/habbo/habbohotel/rooms/Room.java | 5 +- .../habbo/habbohotel/rooms/RoomManager.java | 1 + .../eu/habbo/habbohotel/rooms/RoomUnit.java | 33 ++++++++++ .../habbohotel/rooms/RoomUnitStatus.java | 6 ++ .../com/eu/habbo/habbohotel/users/Habbo.java | 1 + .../rooms/users/RoomUserLookAtPoint.java | 9 +++ .../rooms/users/RoomUserWalkEvent.java | 2 +- .../com/eu/habbo/plugin/PluginManager.java | 64 +++++++++++++++++++ .../runnables/RoomUnitWalkToLocation.java | 5 ++ 12 files changed, 151 insertions(+), 14 deletions(-) diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java index da1eb8d..aef23ad 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/Bot.java @@ -266,7 +266,8 @@ public class Bot implements Runnable { if(PLACEMENT_MESSAGES.length > 0) { String message = PLACEMENT_MESSAGES[Emulator.getRandom().nextInt(PLACEMENT_MESSAGES.length)]; if (!WiredHandler.handle(WiredTriggerType.SAY_SOMETHING, this.getRoomUnit(), room, new Object[]{message})) { - this.talk(message); + if(!habbo.roomBypass) this.talk(message); + else this.talk("Deliver the drink here, " + habbo.getHabboInfo().getUsername() + "!"); } } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java index 2eebcc6..ed189b2 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/bots/BotManager.java @@ -109,18 +109,20 @@ public class BotManager { return; if (room != null && bot != null && habbo != null) { - if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_PLACEFURNI)) { - if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS)) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); - return; - } + if (room.getOwnerId() == habbo.getHabboInfo().getId() || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || habbo.hasPermission(Permission.ACC_PLACEFURNI) || habbo.roomBypass) { + if(!habbo.roomBypass){ + if (room.getCurrentBots().size() >= Room.MAXIMUM_BOTS && !habbo.hasPermission(Permission.ACC_UNLIMITED_BOTS)) { + habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_MAX_BOTS)); + return; + } - if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY)) - return; + if (room.hasHabbosAt(location.x, location.y) || (!location.isWalkable() && location.state != RoomTileState.SIT && location.state != RoomTileState.LAY)) + return; - if (room.hasBotsAt(location.x, location.y)) { - habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); - return; + if (room.hasBotsAt(location.x, location.y)) { + habbo.getClient().sendResponse(new BotErrorComposer(BotErrorComposer.ROOM_ERROR_BOTS_SELECTED_TILE_NOT_FREE)); + return; + } } RoomUnit roomUnit = new RoomUnit(); diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java index ca0a93c..8fc8bbf 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/items/ItemManager.java @@ -518,6 +518,20 @@ public class ItemManager { } } + public HabboItem createItemNoSql(int habboId, Item item, int limitedStack, int limitedSells, String extraData) { + Class itemClass = item.getInteractionType().getType(); + int id = new Random().nextInt(10000000) + 1000000000; + if (itemClass != null) { + try { + return itemClass.getDeclaredConstructor(int.class, int.class, Item.class, String.class, int.class, int.class).newInstance(id, habboId, item, extraData, limitedStack, limitedSells); + } catch (Exception e) { + LOGGER.error("Caught exception", e); + return new InteractionDefault(id, habboId, item, extraData, limitedStack, limitedSells); + } + } + return null; + } + public void addNewUserGift(NewUserGift gift) { this.newuserGifts.put(gift.getId(), gift); } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java index 0ced0a6..9d1b335 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/Room.java @@ -1643,8 +1643,9 @@ public class Room implements Comparable, ISerialize, Runnable { return true; } } else { - if (unit.hasStatus(RoomUnitStatus.MOVE) && !unit.animateWalk) { + if ((unit.hasStatus(RoomUnitStatus.MOVE) || unit.hasStatus(RoomUnitStatus.SNOWWAR_RUN)) && !unit.animateWalk) { unit.removeStatus(RoomUnitStatus.MOVE); + unit.removeStatus(RoomUnitStatus.SNOWWAR_RUN); update = true; } @@ -1670,7 +1671,7 @@ public class Room implements Comparable, ISerialize, Runnable { } } - if (!unit.isWalking() && !unit.cmdLay) { + if (!unit.isWalking() && !unit.cmdLay && !unit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK)) { HabboItem topItem = this.getTopItemAt(unit.getX(), unit.getY()); if (topItem == null || !topItem.getBaseItem().allowLay()) { diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java index 3bf26bc..c869d23 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomManager.java @@ -531,6 +531,7 @@ public class RoomManager { } if (overrideChecks || + habbo.roomBypass || room.isOwner(habbo) || room.getState() == RoomState.OPEN || habbo.hasPermission(Permission.ACC_ANYROOMOWNER) || diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java index 8ad4d82..8d27ad5 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnit.java @@ -79,6 +79,7 @@ public class RoomUnit { private Room room; private RoomRightLevels rightsLevel = RoomRightLevels.NONE; private THashSet overridableTiles; + private boolean isGameSnow; public RoomUnit() { this.id = 0; @@ -95,6 +96,7 @@ public class RoomUnit { this.isKicked = false; this.overridableTiles = new THashSet<>(); this.timeInRoom = 0; + this.isGameSnow = false; } public void clearWalking() { @@ -155,8 +157,13 @@ public class RoomUnit { if (this.status.remove(RoomUnitStatus.SIT) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.MOVE) != null) this.statusUpdate = true; + if (this.status.remove(RoomUnitStatus.SNOWWAR_RUN) != null) this.statusUpdate = true; if (this.status.remove(RoomUnitStatus.LAY) != null) this.statusUpdate = true; + if (this.status.remove(RoomUnitStatus.SNOWWAR_PICK) != null) this.statusUpdate = true; + if (this.status.remove(RoomUnitStatus.SNOWWAR_DIE_BACK) != null) this.statusUpdate = true; + if (this.status.remove(RoomUnitStatus.SNOWWAR_DIE_FRONT) != null) this.statusUpdate = true; + for (Map.Entry set : this.status.entrySet()) { if (set.getKey().removeWhenWalking) { this.status.remove(set.getKey()); @@ -334,7 +341,18 @@ public class RoomUnit { this.setPreviousLocation(this.getCurrentLocation()); + if(this.getIsGameSnow()){ + this.setStatus(RoomUnitStatus.SNOWWAR_RUN, next.x + "," + next.y + "," + zHeight); + } + this.setStatus(RoomUnitStatus.MOVE, next.x + "," + next.y + "," + zHeight); + + if(this.getStatusMap().containsKey(RoomUnitStatus.SNOWWAR_RUN)){ + this.removeStatus(RoomUnitStatus.MOVE); + this.removeStatus(RoomUnitStatus.SNOWWAR_RUN); + this.setStatus(RoomUnitStatus.SNOWWAR_RUN, next.x + "," + next.y + "," + zHeight); + } + if (habbo != null) { if (habbo.getHabboInfo().getRiding() != null) { RoomUnit ridingUnit = habbo.getHabboInfo().getRiding().getRoomUnit(); @@ -694,6 +712,14 @@ public class RoomUnit { return; } + if (this.status.containsKey(RoomUnitStatus.SNOWWAR_DIE_BACK) || this.status.containsKey(RoomUnitStatus.SNOWWAR_DIE_FRONT)) { + return; + } + + if (this.status.containsKey(RoomUnitStatus.SNOWWAR_PICK)) { + return; + } + if (!this.status.containsKey(RoomUnitStatus.SIT)) { this.bodyRotation = (RoomUserRotation.values()[Rotation.Calculate(this.getX(), this.getY(), location.x, location.y)]); } @@ -820,4 +846,11 @@ public class RoomUnit { public void setMoveBlockingTask(ScheduledFuture moveBlockingTask) { this.moveBlockingTask = moveBlockingTask; } + + public boolean getIsGameSnow() { + return isGameSnow; + } + public void setGameSnow(boolean gameSnow) { + isGameSnow = gameSnow; + } } diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java index 7319176..851f336 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/rooms/RoomUnitStatus.java @@ -52,6 +52,12 @@ public enum RoomUnitStatus { GROW_6("grw6"), GROW_7("grw7"), + SNOWWAR_DIE_BACK("swdieback", true), + SNOWWAR_DIE_FRONT("swdiefront", true), + SNOWWAR_PICK("swpick", true), + SNOWWAR_RUN("swrun", true), + SNOWWAR_THROW("swthrow", true), + KICK("kck"), WAG_TAIL("wag"), DANCE("dan"), diff --git a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index ddccb55..8026aed 100644 --- a/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/Emulator/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -45,6 +45,7 @@ public class Habbo implements Runnable { private volatile boolean update; private volatile boolean disconnected = false; private volatile boolean disconnecting = false; + public boolean roomBypass = false; public Habbo(ResultSet set) { this.client = null; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java index f4f7c00..36d83c7 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserLookAtPoint.java @@ -32,12 +32,21 @@ public class RoomUserLookAtPoint extends MessageHandler { if (!roomUnit.canWalk()) return; + if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_RUN)) + return; + if (roomUnit.isWalking() || roomUnit.hasStatus(RoomUnitStatus.MOVE)) return; if (roomUnit.cmdLay || roomUnit.hasStatus(RoomUnitStatus.LAY)) return; + if (roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK) || roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_DIE_FRONT)) + return; + + if (roomUnit.hasStatus(RoomUnitStatus.SNOWWAR_PICK)) + return; + if (roomUnit.isIdle()) return; diff --git a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java index 859be04..beb385f 100644 --- a/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java +++ b/Emulator/src/main/java/com/eu/habbo/messages/incoming/rooms/users/RoomUserWalkEvent.java @@ -98,7 +98,7 @@ public class RoomUserWalkEvent extends MessageHandler { } // Don't care - if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY)) { + if (habbo.getRoomUnit().hasStatus(RoomUnitStatus.LAY) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_PICK) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_DIE_FRONT) || habbo.getRoomUnit().hasStatus(RoomUnitStatus.SNOWWAR_DIE_BACK)) { if (room.getLayout().getTilesInFront(habbo.getRoomUnit().getCurrentLocation(), habbo.getRoomUnit().getBodyRotation().getValue(), 2).contains(tile)) return; } diff --git a/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java b/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java index a7d6027..feea3c2 100644 --- a/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/Emulator/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -285,6 +285,70 @@ public class PluginManager { } } + public void updatePluginByName(String name) { + File loc = new File("plugins"); + HabboPlugin pluginReload = null; + + for(HabboPlugin p : this.plugins){ + if(p.configuration.name.equalsIgnoreCase(name)){ + pluginReload = p; + } + } + + if (!loc.exists()) { + if (loc.mkdirs()) { + LOGGER.info("Created plugins directory!"); + } + } + + for (File file : Objects.requireNonNull(loc.listFiles(file -> file.getPath().toLowerCase().endsWith(".jar")))) { + URLClassLoader urlClassLoader; + InputStream stream; + try { + urlClassLoader = URLClassLoader.newInstance(new URL[]{file.toURI().toURL()}); + stream = urlClassLoader.getResourceAsStream("plugin.json"); + + if (stream == null) { + throw new RuntimeException("Invalid Jar! Missing plugin.json in: " + file.getName()); + } + + byte[] content = new byte[stream.available()]; + + if (stream.read(content) > 0) { + String body = new String(content); + + Gson gson = new GsonBuilder().create(); + HabboPluginConfiguration pluginConfigurtion = gson.fromJson(body, HabboPluginConfiguration.class); + + try { + Class clazz = urlClassLoader.loadClass(pluginConfigurtion.main); + Class stackClazz = clazz.asSubclass(HabboPlugin.class); + Constructor constructor = stackClazz.getConstructor(); + HabboPlugin plugin = constructor.newInstance(); + plugin.configuration = pluginConfigurtion; + plugin.classLoader = urlClassLoader; + plugin.stream = stream; + + if(plugin.configuration.name.equalsIgnoreCase(name) && pluginReload != null){ + if(this.plugins.contains(pluginReload) && this.plugins.remove(pluginReload)){ + this.plugins.add(plugin); + plugin.onEnable(); + LOGGER.info("Plugin: " + plugin.configuration.name + " updated!"); + } + } + } catch (Exception e) { + LOGGER.error("Could not load plugin {}!", pluginConfigurtion.name); + LOGGER.error("Caught exception", e); + } + } + } catch (Exception e) { + LOGGER.error("Caught exception", e); + } + } + + + } + public void registerEvents(HabboPlugin plugin, EventListener listener) { synchronized (plugin.registeredEvents) { Method[] methods = listener.getClass().getMethods(); diff --git a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java index a2f65db..ef445b2 100644 --- a/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java +++ b/Emulator/src/main/java/com/eu/habbo/threading/runnables/RoomUnitWalkToLocation.java @@ -53,6 +53,11 @@ public class RoomUnitWalkToLocation implements Runnable { return; } + if (!this.walker.getGoal().equals(this.goalTile) || (this.walker.getPath().size() == 0 && (!this.walker.hasStatus(RoomUnitStatus.MOVE) || !this.walker.hasStatus(RoomUnitStatus.SNOWWAR_RUN)))) { + onFail(); + return; + } + Emulator.getThreading().run(this, 250); }