🆙 Added the latest Compiled version and cleanup

This commit is contained in:
duckietm
2026-03-23 16:25:22 +01:00
parent 6350106b23
commit f6588c378a
83 changed files with 1 additions and 2446 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -8,5 +8,5 @@
</list> </list>
</option> </option>
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="graalvm-jdk-21" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_23" default="true" project-jdk-name="openjdk-23" project-jdk-type="JavaSDK" />
</project> </project>
Binary file not shown.
-2
View File
@@ -1,2 +0,0 @@
# Auto detect text files and perform LF normalization
* text=auto
-19
View File
@@ -1,19 +0,0 @@
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# https://github.com/takari/maven-wrapper#usage-without-binary-jar
.mvn/wrapper/maven-wrapper.jar
# Eclipse m2e generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath
.idea
Binary file not shown.
Binary file not shown.
Binary file not shown.
-21
View File
@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2023 ThisAccountHasBeenSuspended, EntenKoeniq, habbo.sx
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-56
View File
@@ -1,56 +0,0 @@
# 📷 Camera
**New features compared to Apollyon**
- [x] Small and more efficient than Apollyon.
- [x] `*_small.png` are really small (original / 2) and not just copied.
- [x] Creates a folder structure if it doesn't exist.
- [x] Report failures to Habbo.
- [x] Added a cooldown time for taking photos to prevent your hard drive from filling up.
- [x] Prevent exploits on thumbnails, not just photos.
- [x] No more FTP (no one used that).
[Download the latest compiled version here!](https://github.com/duckietm/Arcturus-Morningstar-Extended/blob/main/Plugins/Camera/Compiled/Camera-1.6.jar)
## Informations
All missing settings in the database will be created with this plugin after the first launch of your emulator.
### emulator_settings
- `camera.url`
- - The URL from which you can access the image (default: http://localhost/camera/)
- `imager.location.output.camera`
- - The location where to save the photo (default: C:/inetpub/wwwroot/public/camera/)
- `imager.location.output.thumbnail`
- - The location to save the thumbnail (default: C:/inetpub/wwwroot/public/camera/thumbnails/)
- `camera.price.points.publish`
- - The price of points for publishing this photo (default: 1)
- `camera.price.points.publish.type`
- - The type of points to publish (default: 5 = diamonds)
- `camera.publish.delay`
- - The time, in seconds, how long the user should wait to post a new photo (default: 180)
- `camera.price.credits`
- - The credits required to purchase this photo (default: 2)
- `camera.price.points`
- - The price of points to purchase this photo (default: 0 = no points required)
- `camera.price.points.type`
- - The type of points to buy this photo (default: 5 = diamonds)
- `camera.render.delay`
- - The time, in seconds, how long the user should wait to take a new photo (default: 5)
### emulator_texts
- `camera.permission`
- - default: "You don't have permission to use the camera!"
- `camera.wait`
- - default: "Please wait %seconds% seconds before making another picture."
- `camera.error.creation`
- - default: "Failed to create your picture. \*sadpanda\*"
Since this plugin doesn't use FTP like “Apollyon”, you can delete these values in your database under `emulator_settings` if necessary.
## Comparison
Apollyon doesn't show you any errors like you don't have enough currency.
# Credits
- EntenKoeniq for releaseing the fixes and rewritten the plugin. (This camera plugin was written for https://habbo.sx/ and is now available to the community for free.)
- John
- Beny (Packet Hijacking)
- Ovflowd (Original Implimentation)
- Alejandro (Error Handling Help)
-37
View File
@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.eu.camera</groupId>
<artifactId>Camera</artifactId>
<version>1.6</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId>
<version>3.5.2</version>
</dependency>
</dependencies>
</project>
@@ -1,101 +0,0 @@
package com.eu.camera;
import com.eu.camera.handlers.PublishPhotoEvent;
import com.eu.camera.handlers.PurchasePhotoEvent;
import com.eu.camera.handlers.RenderRoomEvent;
import com.eu.camera.handlers.RenderRoomThumbnailEvent;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.PacketManager;
import com.eu.habbo.messages.incoming.Incoming;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.EventListener;
import com.eu.habbo.plugin.HabboPlugin;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
import gnu.trove.map.hash.THashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.lang.reflect.Field;
public class Main extends HabboPlugin implements EventListener {
private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
@Override
public void onEnable() throws Exception {
Emulator.getPluginManager().registerEvents(this, this);
if (Emulator.isReady && !Emulator.isShuttingDown) {
this.onEmulatorLoadedEvent(null);
}
}
@Override
public void onDisable() throws Exception {
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
Field incomingField = PacketManager.class.getDeclaredField("incoming");
incomingField.setAccessible(true);
@SuppressWarnings("unchecked")
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>)incomingField.get(packetManager);
// Removes the custom handlers for these packets.
incoming.remove(Incoming.CameraPublishToWebEvent, PublishPhotoEvent.class);
incoming.remove(Incoming.CameraPurchaseEvent, PurchasePhotoEvent.class);
incoming.remove(Incoming.CameraRoomPictureEvent, RenderRoomEvent.class);
incoming.remove(Incoming.CameraRoomThumbnailEvent, RenderRoomThumbnailEvent.class);
}
@Override
public boolean hasPermission(Habbo habbo, String string) {
return false;
}
@EventHandler
public void onEmulatorLoadedEvent(EmulatorLoadedEvent event) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, Exception {
// Adds missing SQLs if they are not found.
Emulator.getConfig().register("camera.url", "http://localhost/camera/");
Emulator.getConfig().register("imager.location.output.camera", "C:/inetpub/wwwroot/public/camera/");
Emulator.getConfig().register("imager.location.output.thumbnail", "C:/inetpub/wwwroot/camera/thumbnails/");
Emulator.getConfig().register("camera.price.points.publish", "1");
Emulator.getConfig().register("camera.price.points.publish.type", "5");
Emulator.getConfig().register("camera.publish.delay", "180");
Emulator.getConfig().register("camera.price.credits", "2");
Emulator.getConfig().register("camera.price.points", "0");
Emulator.getConfig().register("camera.price.points.type", "5");
Emulator.getConfig().register("camera.render.delay", "5");
Emulator.getTexts().register("camera.permission", "You don't have permission to use the camera!");
Emulator.getTexts().register("camera.wait", "Please wait %seconds% seconds before making another picture.");
Emulator.getTexts().register("camera.error.creation", "Failed to create your picture. *sadpanda*");
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
Field incomingField = PacketManager.class.getDeclaredField("incoming");
incomingField.setAccessible(true);
@SuppressWarnings("unchecked")
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>)incomingField.get(packetManager);
// Removes the current handlers for these packets.
incoming.remove(Incoming.CameraPublishToWebEvent);
incoming.remove(Incoming.CameraPurchaseEvent);
incoming.remove(Incoming.CameraRoomPictureEvent);
incoming.remove(Incoming.CameraRoomThumbnailEvent);
// Adds the new handlers for these packets.
packetManager.registerHandler(Incoming.CameraPublishToWebEvent, PublishPhotoEvent.class);
packetManager.registerHandler(Incoming.CameraPurchaseEvent, PurchasePhotoEvent.class);
packetManager.registerHandler(Incoming.CameraRoomPictureEvent, RenderRoomEvent.class);
packetManager.registerHandler(Incoming.CameraRoomThumbnailEvent, RenderRoomThumbnailEvent.class);
// Create the output directories if they don't exist.
File outputDir = new File(Emulator.getConfig().getValue("imager.location.output.thumbnail"));
if (!outputDir.exists()) {
outputDir.mkdirs();
}
LOGGER.info("[Camera] Plugin has loaded!");
}
}
@@ -1,71 +0,0 @@
package com.eu.camera.handlers;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.camera.CameraPublishWaitMessageComposer;
import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class PublishPhotoEvent extends MessageHandler {
public static final int CAMERA_PUBLISH_POINTS = Emulator.getConfig().getInt("camera.price.points.publish", 1);
public static final int CAMERA_PUBLISH_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.publish.type", 5);
public static final int CAMERA_PUBLISH_DELAY = Emulator.getConfig().getInt("camera.publish.delay", 180);
@Override
public void handle() {
Habbo habbo = this.client.getHabbo();
HabboInfo habboInfo = habbo.getHabboInfo();
int points = habboInfo.getCurrencyAmount(CAMERA_PUBLISH_POINTS_TYPE);
if (points < CAMERA_PUBLISH_POINTS) {
String currencyName = Emulator.getTexts().getValue("seasonal.name." + Integer.toString(CAMERA_PUBLISH_POINTS_TYPE), "currency");
String alertMessage = "You don't have enough " + currencyName + "!";
habbo.alert(alertMessage);
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CAMERA_PUBLISH_POINTS_TYPE));
return;
}
int photoTimestamp = habboInfo.getPhotoTimestamp();
String photoJSON = habboInfo.getPhotoJSON();
if (photoTimestamp == 0 || photoJSON.isEmpty() || !photoJSON.contains(Integer.toString(photoTimestamp))) {
return;
}
int currentTimestamp = Emulator.getIntUnixTimestamp();
int timeSinceLastPublish = currentTimestamp - habboInfo.getWebPublishTimestamp();
if (timeSinceLastPublish < CAMERA_PUBLISH_DELAY) {
int wait = CAMERA_PUBLISH_DELAY - timeSinceLastPublish;
this.client.sendResponse(new CameraPublishWaitMessageComposer(false, wait, habboInfo.getPhotoURL()));
} else {
UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(habbo, habboInfo.getPhotoURL(), currentTimestamp, habboInfo.getPhotoRoomId());
if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) {
try (Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("INSERT INTO camera_web (user_id, room_id, timestamp, url) VALUES (?, ?, ?, ?)")) {
statement.setInt(1, habboInfo.getId());
statement.setInt(2, publishPictureEvent.roomId);
statement.setInt(3, publishPictureEvent.timestamp);
statement.setString(4, publishPictureEvent.URL);
statement.execute();
habboInfo.setWebPublishTimestamp(currentTimestamp);
habbo.givePoints(CAMERA_PUBLISH_POINTS_TYPE, -CAMERA_PUBLISH_POINTS);
} catch (SQLException throwable) {
throwable.printStackTrace();
}
}
this.client.sendResponse(new CameraPublishWaitMessageComposer(true, 0, ""));
}
}
}
@@ -1,87 +0,0 @@
package com.eu.camera.handlers;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.messages.outgoing.camera.CameraPurchaseSuccesfullComposer;
import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
public class PurchasePhotoEvent extends MessageHandler {
public static final int CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits", 2);
public static final int CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 0);
public static final int CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 5);
public static final int CAMERA_ITEM_ID = Emulator.getConfig().getInt("camera.item_id");
public static final String EXTERNAL_IMAGE_INTERACTION = "external_image";
@Override
public void handle() {
Habbo habbo = this.client.getHabbo();
HabboInfo habboInfo = habbo.getHabboInfo();
if (habboInfo.getCredits() < CAMERA_PURCHASE_CREDITS) {
handleInsufficientCredits(habbo);
return;
}
if (habboInfo.getCurrencyAmount(CAMERA_PURCHASE_POINTS_TYPE) < CAMERA_PURCHASE_POINTS) {
handleInsufficientPoints(habbo);
return;
}
if (!isValidPhoto(habboInfo)) {
return;
}
if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(habbo, habboInfo.getPhotoURL(), habboInfo.getCurrentRoom().getId(), habboInfo.getPhotoTimestamp())).isCancelled()) {
return;
}
Item item = Emulator.getGameEnvironment().getItemManager().getItem(CAMERA_ITEM_ID);
if (item == null || !item.getInteractionType().getName().equals(EXTERNAL_IMAGE_INTERACTION)) {
return;
}
handlePurchasedPhoto(habbo, habboInfo, item);
}
private void handleInsufficientCredits(Habbo habbo) {
habbo.alert("You don't have enough credits!");
this.client.sendResponse(new NotEnoughPointsTypeComposer(true, false, 0));
}
private void handleInsufficientPoints(Habbo habbo) {
String alertMessage = "You don't have enough " + Emulator.getTexts().getValue("seasonal.name." + Integer.toString(CAMERA_PURCHASE_POINTS_TYPE), "currency") + "!";
habbo.alert(alertMessage);
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CAMERA_PURCHASE_POINTS_TYPE));
}
private boolean isValidPhoto(HabboInfo habboInfo) {
return habboInfo.getPhotoTimestamp() != 0 && !habboInfo.getPhotoJSON().isEmpty() && habboInfo.getPhotoJSON().contains(Integer.toString(habboInfo.getPhotoTimestamp()));
}
private void handlePurchasedPhoto(Habbo habbo, HabboInfo habboInfo, Item item) {
HabboItem photoItem = Emulator.getGameEnvironment().getItemManager().createItem(habboInfo.getId(), item, 0, 0, habboInfo.getPhotoJSON());
if (photoItem != null) {
photoItem.setExtradata(photoItem.getExtradata().replace("%id%", Integer.toString(photoItem.getId())));
photoItem.needsUpdate(true);
habbo.getInventory().getItemsComponent().addItem(photoItem);
this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
this.client.sendResponse(new AddHabboItemComposer(photoItem));
this.client.sendResponse(new InventoryRefreshComposer());
habbo.giveCredits(-CAMERA_PURCHASE_CREDITS);
habbo.givePoints(CAMERA_PURCHASE_POINTS_TYPE, -CAMERA_PURCHASE_POINTS);
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"));
}
}
}
@@ -1,136 +0,0 @@
package com.eu.camera.handlers;
import com.eu.habbo.Emulator;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboStats;
import com.eu.habbo.messages.outgoing.camera.CameraURLComposer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufUtil;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class RenderRoomEvent extends MessageHandler {
public static final int CAMERA_RENDER_DELAY = Emulator.getConfig().getInt("camera.render.delay", 5);
private ByteBuf image = null;
@Override
public void handle() {
try {
make();
} finally {
if (this.image != null) {
this.image.release();
}
}
}
private void make() {
Habbo habbo = this.client.getHabbo();
if (!habbo.hasPermission("acc_camera")) {
habbo.alert(Emulator.getTexts().getValue("camera.permission"));
return;
}
HabboInfo habboInfo = habbo.getHabboInfo();
HabboStats habboStats = habbo.getHabboStats();
int timestamp = Emulator.getIntUnixTimestamp();
if (habboStats.cache.containsKey("camera_render_cooldown")) {
int cameraTimestamp = (int) habboStats.cache.get("camera_render_cooldown");
if (timestamp - cameraTimestamp < CAMERA_RENDER_DELAY) {
String alertMessage = Emulator.getTexts().getValue("camera.wait")
.replace("%seconds%", Integer.toString(timestamp - cameraTimestamp));
habbo.alert(alertMessage);
// Show the correct last photo.
String[] splittedPhotoURL = habboInfo.getPhotoURL().split("/");
if (splittedPhotoURL.length > 0) {
this.client.sendResponse(new CameraURLComposer(splittedPhotoURL[splittedPhotoURL.length - 1]));
}
return;
}
}
habboStats.cache.put("camera_render_cooldown", (Object) timestamp);
Room room = habboInfo.getCurrentRoom();
if (room == null) {
return;
}
final int count = this.packet.readInt();
this.image = this.packet.getBuffer().readBytes(count);
if (this.image == null) {
return;
}
// Prevent possible exploits.
byte[] imageBytes = ByteBufUtil.getBytes(this.image, 0, 4, true);
if (imageBytes == null || imageBytes.length < 4 || !isPNG(imageBytes)) {
return;
}
BufferedImage theImage;
try (ByteBufInputStream in = new ByteBufInputStream(this.image)) {
theImage = ImageIO.read(in);
} catch (IOException e) {
handleImageProcessingError(habbo);
return;
}
String fileName = habboInfo.getId() + "_" + timestamp;
String URL = fileName + ".png";
String URLsmall = fileName + "_small.png";
String base = Emulator.getConfig().getValue("camera.url");
String json = Emulator.getConfig().getValue("camera.extradata")
.replace("%timestamp%", Integer.toString(timestamp))
.replace("%room_id%", Integer.toString(room.getId()))
.replace("%url%", base + URL);
habboInfo.setPhotoURL(base + URL);
habboInfo.setPhotoTimestamp(timestamp);
habboInfo.setPhotoRoomId(room.getId());
habboInfo.setPhotoJSON(json);
File imageFile = new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL);
File smallImageFile = new File(Emulator.getConfig().getValue("imager.location.output.camera") + URLsmall);
try {
ImageIO.write(theImage, "png", imageFile);
Image smallImage = theImage.getScaledInstance(theImage.getWidth(null) / 2, theImage.getHeight(null) / 2, Image.SCALE_SMOOTH);
BufferedImage bi = new BufferedImage(smallImage.getWidth(null), smallImage.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics2D = bi.createGraphics();
graphics2D.drawImage(smallImage, 0, 0, null);
graphics2D.dispose();
ImageIO.write(bi, "png", smallImageFile);
} catch (IOException e) {
handleImageProcessingError(habbo);
return;
}
this.client.sendResponse(new CameraURLComposer(URL));
}
private boolean isPNG(byte[] bytes) {
return bytes[0] == -119 && bytes[1] == 80 && bytes[2] == 78 && bytes[3] == 71;
}
private void handleImageProcessingError(Habbo habbo) {
habbo.alert(Emulator.getTexts().getValue("camera.error.creation"));
}
}
@@ -1,96 +0,0 @@
package com.eu.camera.handlers;
import com.eu.habbo.Emulator;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboInfo;
import com.eu.habbo.habbohotel.users.HabboStats;
import com.eu.habbo.messages.outgoing.camera.CameraRoomThumbnailSavedComposer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufUtil;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
public class RenderRoomThumbnailEvent extends MessageHandler {
public static final int CAMERA_RENDER_DELAY = Emulator.getConfig().getInt("camera.render.delay", 5);
private ByteBuf image = null;
@Override
public void handle() {
try {
make();
} finally {
if (this.image != null) {
this.image.release();
}
}
}
private void make() {
Habbo habbo = this.client.getHabbo();
if (!habbo.hasPermission("acc_camera")) {
habbo.alert(Emulator.getTexts().getValue("camera.permission"));
return;
}
HabboStats habboStats = habbo.getHabboStats();
int timestamp = Emulator.getIntUnixTimestamp();
if (habboStats.cache.containsKey("camera_render_cooldown")) {
int cameraTimestamp = (int) habboStats.cache.get("camera_render_cooldown");
if (timestamp - cameraTimestamp < CAMERA_RENDER_DELAY) {
String alertMessage = Emulator.getTexts().getValue("camera.wait")
.replace("%seconds%", Integer.toString(timestamp - cameraTimestamp));
habbo.alert(alertMessage);
return;
}
}
habboStats.cache.put("camera_render_cooldown", (Object) timestamp);
HabboInfo habboInfo = habbo.getHabboInfo();
Room room = habboInfo.getCurrentRoom();
if (room == null || !room.isOwner(habbo)) {
return;
}
final int count = this.packet.readInt();
this.image = this.packet.getBuffer().readBytes(count);
if (this.image == null || !isValidImage(this.image)) {
return;
}
BufferedImage theImage = null;
try (ByteBufInputStream in = new ByteBufInputStream(this.image)) {
theImage = ImageIO.read(in);
} catch (IOException e) {
e.printStackTrace();
habbo.alert(Emulator.getTexts().getValue("camera.error.creation"));
return;
}
File imageFile = new File(Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png");
try {
ImageIO.write(theImage, "png", imageFile);
} catch (IOException e) {
e.printStackTrace();
habbo.alert(Emulator.getTexts().getValue("camera.error.creation"));
return;
}
this.client.sendResponse(new CameraRoomThumbnailSavedComposer());
}
private boolean isValidImage(ByteBuf imageBuffer) {
byte[] imageBytes = ByteBufUtil.getBytes(imageBuffer, 0, 4, true);
return (imageBytes != null && imageBytes.length >= 4 &&
imageBytes[0] == -119 && imageBytes[1] == 80 && imageBytes[2] == 78 && imageBytes[3] == 71);
}
}
@@ -1,6 +0,0 @@
{
"main" : "com.eu.camera.Main",
"name" : "Camera",
"author" : "EntenKoeniq and habbo.sx"
}
-13
View File
@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Javascript-Plugin" />
</profile>
</annotationProcessing>
</component>
</project>
-20
View File
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
-12
View File
@@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="19" project-jdk-type="JavaSDK" />
</project>
-46
View File
@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="70aa710c-e4e9-422f-b975-f5a0269f3cd4" name="Changes" comment="" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="useMavenConfig" value="true" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectId" id="2eo2cBWnOhrkOAmNE8p379Uvtpa" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"last_opened_file_path": "C:/Camwijs/Source/Javascript-Plugin"
}
}]]></component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="70aa710c-e4e9-422f-b975-f5a0269f3cd4" name="Changes" comment="" />
<created>1712556687432</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1712556687432</updated>
</task>
<servers />
</component>
</project>
-24
View File
@@ -1,24 +0,0 @@
# javascript-plugin
Allows 2-way communication between some javascript running in your client and your emulator using the FlashExternalInterface
## How do I use it?
You can use the following Vue application which will work out of the box with this plugin: https://github.com/dank074/youtube-overlay
Just include the scripts and add a div with id=app, and you are set to go
## I don't wanna use that Vue trash, how do I use it with my own javascript?
Receiving a message:
```js
FlashExternalInterface.openHabblet = function(a,b){console.log("recieved " + a)}
```
Sending a message:
```js
document.querySelector('object, embed').openroom(JSON.stringify({"header": "test", "data": {"name": "Efrain"}}))
```
## Built in features
- [x] Arrowkey walking
- [x] Youtube jukebox (use interaction `yt_jukebox` on any furniture)
- [x] Slots Machine (use interaction `slots_machine` on any furniture)
- [x] :youtube command ```ALTER TABLE permissions
ADD COLUMN cmd_youtube enum('0','1') DEFAULT '1';```
-39
View File
@@ -1,39 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.skeletor</groupId>
<artifactId>Javascript-Plugin</artifactId>
<version>1.1-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.eu.habbo</groupId>
<artifactId>Habbo</artifactId>
<version>3.5.1</version>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<version>20240325.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
@@ -1,36 +0,0 @@
package com.skeletor.plugin.javascript.audio;
import java.util.concurrent.ConcurrentHashMap;
public class RoomAudioManager {
private static RoomAudioManager _instance;
private ConcurrentHashMap<Integer, RoomPlaylist> roomAudio = new ConcurrentHashMap<>();
public RoomPlaylist getPlaylistForRoom(int roomId) {
if (this.roomAudio.containsKey(Integer.valueOf(roomId)))
return this.roomAudio.get(Integer.valueOf(roomId));
RoomPlaylist newPlaylist = new RoomPlaylist();
this.roomAudio.put(Integer.valueOf(roomId), newPlaylist);
return newPlaylist;
}
public void dispose(int roomId) {
this.roomAudio.remove(Integer.valueOf(roomId));
}
public static void Init() {
_instance = new RoomAudioManager();
}
public void Dispose() {
this.roomAudio.clear();
_instance = null;
}
public static RoomAudioManager getInstance() {
if (_instance == null)
_instance = new RoomAudioManager();
return _instance;
}
}
@@ -1,93 +0,0 @@
package com.skeletor.plugin.javascript.audio;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import gnu.trove.map.hash.THashMap;
import java.util.ArrayList;
import static com.skeletor.plugin.javascript.utils.RegexUtility.sanitize;
public class RoomPlaylist {
private ArrayList<YoutubeVideo> playlist = new ArrayList<>();
private int current = 0;
private boolean playing = false;
public YoutubeVideo nextSong() {
if (this.current < this.playlist.size() - 1) {
this.current++;
} else {
this.current = 0;
}
return this.playlist.get(this.current);
}
public YoutubeVideo prevSong() {
if (this.current > 0)
this.current--;
return this.playlist.get(this.current);
}
public boolean isPlaying() {
return this.playing;
}
public void setPlaying(boolean playing) {
this.playing = playing;
}
public void addSong(YoutubeVideo song) {
this.playlist.add(song);
}
public YoutubeVideo removeSong(int index) {
YoutubeVideo res = null;
if(playlist.size() - 1 >= index)
res = this.playlist.remove(index);
if(playlist.isEmpty()) this.setPlaying(false);
if(index == this.getCurrentIndex()) {
if(index > this.playlist.size() - 1 && !this.playlist.isEmpty()) {
this.current = this.playlist.size() - 1;
}
}
else if(index < this.getCurrentIndex() && this.getCurrentIndex() > 0) {
this.current--;
}
return res;
}
public YoutubeVideo getCurrentSong() {
return this.playlist.get(this.current);
}
public int getCurrentIndex() {
return this.current;
}
public ArrayList<YoutubeVideo> getPlaylist() {
return this.playlist;
}
public static class YoutubeVideo {
public String name;
public String videoId;
public String channel;
public YoutubeVideo(String name, String videoId, String channel) {
this.name = name;
this.videoId = videoId;
this.channel = channel;
}
}
public MessageComposer getNowPlayingBubbleAlert() {
final THashMap<String, String> keys = new THashMap<>();
keys.put("display", "BUBBLE");
keys.put("image", ("${image.library.url}notifications/music.png"));
keys.put("message", "Now playing " + sanitize(this.getCurrentSong().name));
return new BubbleAlertComposer("", keys);
}
}
@@ -1,37 +0,0 @@
package com.skeletor.plugin.javascript.categories;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class Category {
private int id;
private String name;
private List<String> permissions;
public Category(ResultSet set) throws SQLException {
this.id = set.getInt("id");
this.name = set.getString("name");
this.permissions = new ArrayList<>();
}
public void addPermission(String permission) {
if (!this.permissions.contains(permission))
this.permissions.add(permission);
}
public int getId() {
return this.id;
}
public String getName() {
return this.name;
}
public List<String> getPermissions() {
return this.permissions;
}
}
@@ -1,72 +0,0 @@
package com.skeletor.plugin.javascript.categories;
import com.eu.habbo.Emulator;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CommandManager {
private static final Logger LOGGER = LoggerFactory.getLogger(CommandManager.class);
private final List<Category> commandCategories;
public CommandManager() {
this.commandCategories = new ArrayList<>();
reload();
}
public void reload() {
dispose();
try(Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT * FROM `command_categories` ORDER BY `order`");
ResultSet set = statement.executeQuery()) {
while (set.next()) {
Category category = new Category(set);
this.commandCategories.add(category);
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
try(Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("SELECT * FROM `command_category_permissions` ORDER BY `order`");
ResultSet set = statement.executeQuery()) {
while (set.next()) {
if (hasCommandCategory(Integer.valueOf(set.getInt("category_id")))) {
Category category = getCommandCategory(Integer.valueOf(set.getInt("category_id")));
((Category)this.commandCategories.get(this.commandCategories.indexOf(category))).addPermission(set.getString("permission"));
}
}
} catch (SQLException e) {
LOGGER.error("Caught SQL exception", e);
}
}
public void dispose() {
this.commandCategories.clear();
}
public boolean hasCommandCategory(Integer id) {
return
(((List)this.commandCategories.stream().filter(p -> (p.getId() == id.intValue())).collect(Collectors.toList())).size() > 0);
}
public Category getCommandCategory(Integer id) {
if (hasCommandCategory(id))
return ((List<Category>)this.commandCategories
.stream()
.filter(p -> (p.getId() == id.intValue()))
.collect(Collectors.toList())).get(0);
return null;
}
public List<Category> getCommandCategories() {
return this.commandCategories;
}
}
@@ -1,23 +0,0 @@
package com.skeletor.plugin.javascript.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.CommandsComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import java.util.List;
public class CmdCommand extends Command {
public CmdCommand() {
super("cmd_commands", Emulator.getTexts().getValue("jscommands.keys.cmd_commands").split(";"));
}
public boolean handle(GameClient gameClient, String[] strings) throws Exception {
List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(gameClient.getHabbo().getHabboInfo().getRank().getId());
CommandsComposer commandsComposer = new CommandsComposer(commands);
gameClient.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)commandsComposer));
return true;
}
}
@@ -1,33 +0,0 @@
package com.skeletor.plugin.javascript.commands;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.TwitchVideoComposer;
import com.skeletor.plugin.javascript.main;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class TwitchCommand extends Command {
public TwitchCommand() {
super("cmd_twitch", new String[] { "twitch" });
}
public boolean handle(GameClient gameClient, String[] strings) throws Exception {
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
if ((room.hasRights(gameClient.getHabbo()) || gameClient.getHabbo().getHabboInfo().getRank().getName().equals("VIP")) &&
strings.length > 1) {
String videoId = strings[1];
if (videoId.isEmpty()) {
gameClient.getHabbo().whisper("You must supply the twitch channel/video");
return true;
}
main.addTwitchRoom(room.getId(), videoId);
TwitchVideoComposer twitchVideoComposer = new TwitchVideoComposer(videoId);
room.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)twitchVideoComposer)).compose());
return true;
}
gameClient.getHabbo().whisper("You do not have permission to use this command in this room");
return true;
}
}
@@ -1,19 +0,0 @@
package com.skeletor.plugin.javascript.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.plugin.EventListener;
import com.skeletor.plugin.javascript.main;
public class UpdateCategoriesCommand extends Command implements EventListener {
public UpdateCategoriesCommand(String permission, String[] keys) {
super(permission, keys);
}
public boolean handle(GameClient gameClient, String[] strings) throws Exception {
main.getCommandManager().reload();
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("categories.cmd_update_categories.success"));
return true;
}
}
@@ -1,45 +0,0 @@
package com.skeletor.plugin.javascript.commands;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.YoutubeTVComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import com.skeletor.plugin.javascript.utils.RegexUtility;
public class YoutubeCommand extends Command {
public YoutubeCommand() {
super("cmd_youtube", new String[] { "youtube" });
}
public boolean handle(GameClient gameClient, String[] strings) throws Exception {
Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
if (strings.length > 1) {
String videoId = RegexUtility.getYouTubeId(strings[1]);
int time = 0;
if (videoId.isEmpty()) {
gameClient.getHabbo().whisper("Invalid youtube url", RoomChatMessageBubbles.ALERT);
return true;
}
if (strings[1].contains("t="))
try {
String[] realParams = strings[1].split("\\?");
if (realParams.length > 1) {
String[] params = realParams[1].split("&");
for (String param : params) {
String[] split = param.split("=");
if (split.length > 1 &&
split[0].equals("t"))
time = Integer.parseInt(split[1].replace("s", ""));
}
}
} catch (Exception exception) {}
YoutubeTVComposer youtubeTVComposer = new YoutubeTVComposer(videoId, Integer.valueOf(time));
room.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)youtubeTVComposer)).compose());
return true;
}
return true;
}
}
@@ -1,85 +0,0 @@
package com.skeletor.plugin.javascript.communication;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.incoming.audio.AddSongEvent;
import com.skeletor.plugin.javascript.communication.incoming.audio.NextSongEvent;
import com.skeletor.plugin.javascript.communication.incoming.audio.PlayStopEvent;
import com.skeletor.plugin.javascript.communication.incoming.audio.PreviousSongEvent;
import com.skeletor.plugin.javascript.communication.incoming.audio.RemoveSongEvent;
import com.skeletor.plugin.javascript.communication.incoming.audio.SongEndedEvent;
import com.skeletor.plugin.javascript.communication.incoming.common.MoveAvatarEvent;
import com.skeletor.plugin.javascript.communication.incoming.common.RequestCommandsEvent;
import com.skeletor.plugin.javascript.communication.incoming.common.RequestCreditsEvent;
import com.skeletor.plugin.javascript.communication.incoming.common.RequestSpinSlotMachineEvent;
import com.skeletor.plugin.javascript.communication.incoming.loaded.LoadedEvent;
import com.skeletor.plugin.javascript.utils.JsonFactory;
import gnu.trove.map.hash.THashMap;
public class CommunicationManager {
private static CommunicationManager instance;
private final THashMap<String, Class<? extends IncomingWebMessage>> _incomingMessages;
static {
try {
instance = new CommunicationManager();
} catch (Exception e) {
e.printStackTrace();
}
}
public CommunicationManager() {
this._incomingMessages = new THashMap();
initializeMessages();
}
public void initializeMessages() {
registerMessage("move_avatar", (Class)MoveAvatarEvent.class);
registerMessage("request_credits", (Class)RequestCreditsEvent.class);
registerMessage("spin_slot_machine", (Class)RequestSpinSlotMachineEvent.class);
registerMessage("add_song", (Class)AddSongEvent.class);
registerMessage("next_song", (Class)NextSongEvent.class);
registerMessage("prev_song", (Class)PreviousSongEvent.class);
registerMessage("play_stop", (Class)PlayStopEvent.class);
registerMessage("remove_song", (Class)RemoveSongEvent.class);
registerMessage("song_ended", (Class)SongEndedEvent.class);
registerMessage("request_commands", (Class)RequestCommandsEvent.class);
registerMessage("js_loaded", (Class)LoadedEvent.class);
}
public void registerMessage(String key, Class<? extends IncomingWebMessage> message) {
this._incomingMessages.put(key, message);
}
public THashMap<String, Class<? extends IncomingWebMessage>> getIncomingMessages() {
return this._incomingMessages;
}
public static CommunicationManager getInstance() {
if (instance == null)
try {
instance = new CommunicationManager();
} catch (Exception e) {
Emulator.getLogging().logErrorLine(e.getMessage());
}
return instance;
}
public void OnMessage(String jsonPayload, GameClient sender) {
try {
IncomingWebMessage.JSONIncomingEvent heading = (IncomingWebMessage.JSONIncomingEvent)JsonFactory.getInstance().fromJson(jsonPayload, IncomingWebMessage.JSONIncomingEvent.class);
Class<? extends IncomingWebMessage> message = (Class<? extends IncomingWebMessage>)getInstance().getIncomingMessages().get(heading.header);
IncomingWebMessage webEvent = message.getDeclaredConstructor(new Class[0]).newInstance(new Object[0]);
webEvent.handle(sender, JsonFactory.getInstance().fromJson(heading.data.toString(), webEvent.type));
} catch (Exception e) {
Emulator.getLogging().logUndefinedPacketLine("unknown message: " + jsonPayload);
}
}
public void Dispose() {
this._incomingMessages.clear();
instance = null;
}
}
@@ -1,20 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.google.gson.JsonObject;
public abstract class IncomingWebMessage<T> {
public final Class<T> type;
public IncomingWebMessage(Class<T> type) {
this.type = type;
}
public abstract void handle(GameClient paramGameClient, T paramT);
public static class JSONIncomingEvent {
public String header;
public JsonObject data;
}
}
@@ -1,37 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.AddSongComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class AddSongEvent extends IncomingWebMessage<AddSongEvent.JSONAddSong> {
public AddSongEvent() {
super(JSONAddSong.class);
}
public void handle(GameClient client, JSONAddSong message) {
Room currentRoom = client.getHabbo().getHabboInfo().getCurrentRoom();
if (currentRoom == null)
return;
if (currentRoom.hasRights(client.getHabbo())) {
RoomPlaylist playlist = RoomAudioManager.getInstance().getPlaylistForRoom(currentRoom.getId());
RoomPlaylist.YoutubeVideo song = new RoomPlaylist.YoutubeVideo(message.name, message.videoId, message.channel);
playlist.addSong(song);
AddSongComposer addSongComposer = new AddSongComposer(song);
currentRoom.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)addSongComposer)).compose());
}
}
public static class JSONAddSong {
public String name;
public String videoId;
public String channel;
}
}
@@ -1,34 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlaySongComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class NextSongEvent extends IncomingWebMessage<NextSongEvent.JSONNextSongEvent> {
public NextSongEvent() {
super(JSONNextSongEvent.class);
}
public void handle(GameClient client, JSONNextSongEvent message) {
Room currentRoom = client.getHabbo().getHabboInfo().getCurrentRoom();
if (currentRoom == null)
return;
if (currentRoom.hasRights(client.getHabbo())) {
RoomPlaylist playlist = RoomAudioManager.getInstance().getPlaylistForRoom(currentRoom.getId());
playlist.nextSong();
playlist.setPlaying(true);
PlaySongComposer playSongComposer = new PlaySongComposer(playlist.getCurrentIndex());
currentRoom.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)playSongComposer)).compose());
currentRoom.sendComposer(playlist.getNowPlayingBubbleAlert().compose());
}
}
public static class JSONNextSongEvent {
public int currentIndex;
}
}
@@ -1,33 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlayStopComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class PlayStopEvent extends IncomingWebMessage<PlayStopEvent.JSONPlayStopEvent> {
public PlayStopEvent() {
super(JSONPlayStopEvent.class);
}
public void handle(GameClient client, JSONPlayStopEvent message) {
Room room = client.getHabbo().getHabboInfo().getCurrentRoom();
if (room == null)
return;
if (room.hasRights(client.getHabbo())) {
RoomPlaylist roomPlaylist = RoomAudioManager.getInstance().getPlaylistForRoom(room.getId());
roomPlaylist.setPlaying(message.play);
room.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)new PlayStopComposer(message.play))).compose());
if (message.play)
room.sendComposer(roomPlaylist.getNowPlayingBubbleAlert().compose());
}
}
public static class JSONPlayStopEvent {
public boolean play;
}
}
@@ -1,34 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlaySongComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class PreviousSongEvent extends IncomingWebMessage<PreviousSongEvent.JSONPreviousSongEvent> {
public PreviousSongEvent() {
super(JSONPreviousSongEvent.class);
}
public void handle(GameClient client, JSONPreviousSongEvent message) {
Room currentRoom = client.getHabbo().getHabboInfo().getCurrentRoom();
if (currentRoom == null)
return;
if (currentRoom.hasRights(client.getHabbo())) {
RoomPlaylist playlist = RoomAudioManager.getInstance().getPlaylistForRoom(currentRoom.getId());
playlist.prevSong();
playlist.setPlaying(true);
PlaySongComposer playSongComposer = new PlaySongComposer(playlist.getCurrentIndex());
currentRoom.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)playSongComposer)).compose());
currentRoom.sendComposer(playlist.getNowPlayingBubbleAlert().compose());
}
}
public static class JSONPreviousSongEvent {
public int currentIndex;
}
}
@@ -1,31 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.RemoveSongComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class RemoveSongEvent extends IncomingWebMessage<RemoveSongEvent.JSONRemoveSongEvent> {
public RemoveSongEvent() {
super(JSONRemoveSongEvent.class);
}
public void handle(GameClient client, JSONRemoveSongEvent message) {
Room room = client.getHabbo().getHabboInfo().getCurrentRoom();
if (room == null)
return;
if (room.hasRights(client.getHabbo())) {
RoomPlaylist roomPlaylist = RoomAudioManager.getInstance().getPlaylistForRoom(room.getId());
roomPlaylist.removeSong(message.index);
room.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)new RemoveSongComposer(message.index))).compose());
}
}
public static class JSONRemoveSongEvent {
public int index;
}
}
@@ -1,36 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.audio;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlaySongComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class SongEndedEvent extends IncomingWebMessage<SongEndedEvent.JSONSongEndedEvent> {
public SongEndedEvent() {
super(JSONSongEndedEvent.class);
}
public void handle(GameClient client, JSONSongEndedEvent message) {
Room room = client.getHabbo().getHabboInfo().getCurrentRoom();
if (room == null)
return;
if (room.hasRights(client.getHabbo())) {
RoomPlaylist playlist = RoomAudioManager.getInstance().getPlaylistForRoom(room.getId());
if (playlist.getCurrentIndex() == message.currentIndex) {
playlist.nextSong();
playlist.setPlaying(true);
PlaySongComposer playSongComposer = new PlaySongComposer(playlist.getCurrentIndex());
room.sendComposer((new JavascriptCallbackComposer((OutgoingWebMessage)playSongComposer)).compose());
room.sendComposer(playlist.getNowPlayingBubbleAlert().compose());
}
}
}
class JSONSongEndedEvent {
public int currentIndex;
}
}
@@ -1,54 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.common;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
public class MoveAvatarEvent extends IncomingWebMessage<MoveAvatarEvent.JSONMoveAvatarEvent> {
private static final short DEFAULT_WALK_AMOUNT = 1;
public MoveAvatarEvent() {
super(JSONMoveAvatarEvent.class);
}
public void handle(GameClient client, JSONMoveAvatarEvent message) {
Room room = client.getHabbo().getRoomUnit().getRoom();
if (room == null)
return;
short x = (client.getHabbo().getRoomUnit().getGoal()).x;
short y = (client.getHabbo().getRoomUnit().getGoal()).y;
switch (message.direction) {
case "stop":
return;
case "left":
y = (short)(y + 1);
break;
case "right":
y = (short)(y - 1);
break;
case "up":
x = (short)(x - 1);
break;
case "down":
x = (short)(x + 1);
break;
default:
return;
}
try {
RoomTile goal = room.getLayout().getTile(x, y);
if (goal == null)
return;
if (goal.isWalkable() || client.getHabbo().getHabboInfo().getCurrentRoom().canSitOrLayAt(goal.x, goal.y)) {
if (client.getHabbo().getRoomUnit().getMoveBlockingTask() != null)
client.getHabbo().getRoomUnit().getMoveBlockingTask().get();
client.getHabbo().getRoomUnit().setGoalLocation(goal);
}
} catch (Exception exception) {}
}
static class JSONMoveAvatarEvent {
String direction;
}
}
@@ -1,27 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.common;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.CommandsComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import java.util.List;
public class RequestCommandsEvent extends IncomingWebMessage<RequestCommandsEvent.JSONRequestCommandsEvent> {
public RequestCommandsEvent() {
super(JSONRequestCommandsEvent.class);
}
public void handle(GameClient client, JSONRequestCommandsEvent message) {
List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(client.getHabbo().getHabboInfo().getRank().getId());
CommandsComposer commandsComposer = new CommandsComposer(commands);
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)commandsComposer));
}
static class JSONRequestCommandsEvent {
boolean idk;
}
}
@@ -1,25 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.common;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.UpdateCreditsComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class RequestCreditsEvent extends IncomingWebMessage<RequestCreditsEvent.JSONRequestCreditsEvent> {
public RequestCreditsEvent() {
super(JSONRequestCreditsEvent.class);
}
public void handle(GameClient client, JSONRequestCreditsEvent message) {
client.sendResponse((MessageComposer)new UserCreditsComposer(client.getHabbo()));
UpdateCreditsComposer creditsComposer = new UpdateCreditsComposer(client.getHabbo().getHabboInfo().getCredits());
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)creditsComposer));
}
static class JSONRequestCreditsEvent {
boolean idk;
}
}
@@ -1,91 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.common;
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.HabboItem;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.messages.outgoing.users.UserCreditsComposer;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.UpdateCreditsComposer;
import com.skeletor.plugin.javascript.communication.outgoing.slotmachine.SpinResultComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class RequestSpinSlotMachineEvent extends IncomingWebMessage<RequestSpinSlotMachineEvent.JSONRequestSpinSlotMachineEvent> {
private static final int maxNumber = 5;
private static final int LEMON = 0;
private static final int MELON = 1;
private static final int GRAPES = 2;
private static final int CHERRY = 3;
private static final int BAR = 4;
public RequestSpinSlotMachineEvent() {
super(JSONRequestSpinSlotMachineEvent.class);
}
public void handle(GameClient client, JSONRequestSpinSlotMachineEvent message) {
HabboItem item = client.getHabbo().getRoomUnit().getRoom().getHabboItem(message.itemId);
if (item == null)
return;
if (message.bet <= 0 || message.bet > client.getHabbo().getHabboInfo().getCredits())
return;
client.getHabbo().getHabboInfo().addCredits(-message.bet);
client.sendResponse((MessageComposer)new UserCreditsComposer(client.getHabbo()));
client.getHabbo().talk(Emulator.getTexts().getValue("slot.machines.spin", "* Bets %amount% on Slots Machine *").replace("%amount%", message.bet + ""), RoomChatMessageBubbles.ALERT);
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new UpdateCreditsComposer(client.getHabbo().getHabboInfo().getCredits())));
int result1 = Emulator.getRandom().nextInt(5);
int result2 = Emulator.getRandom().nextInt(5);
int result3 = Emulator.getRandom().nextInt(5);
int amountWon = 0;
boolean won = false;
if (result1 == result2 && result2 == result3) {
won = true;
switch (result1) {
case 0:
amountWon = 5 * message.bet;
break;
case 1:
amountWon = 6 * message.bet;
break;
case 2:
amountWon = 10 * message.bet;
break;
case 3:
amountWon = 15 * message.bet;
break;
case 4:
amountWon = 20 * message.bet;
break;
}
client.getHabbo().getHabboInfo().addCredits(amountWon);
} else if (result1 == 4 && result2 == 4) {
won = true;
amountWon = 4 * message.bet;
client.getHabbo().getHabboInfo().addCredits(amountWon);
} else if (result1 == 3 && result2 == 3) {
won = true;
amountWon = 3 * message.bet;
client.getHabbo().getHabboInfo().addCredits(amountWon);
} else if (result1 == 3) {
won = true;
amountWon = 2 * message.bet;
client.getHabbo().getHabboInfo().addCredits(amountWon);
}
SpinResultComposer resultComposer = new SpinResultComposer(result1, result2, result3, won, amountWon);
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)resultComposer));
int finalAmount = amountWon;
Emulator.getThreading().run(() -> client.getHabbo().talk(Emulator.getTexts().getValue("slot.machines.won", "* Won %amount% in Slots Machine *").replace("%amount%", finalAmount + ""), RoomChatMessageBubbles.ALERT), 5000L);
}
static class JSONRequestSpinSlotMachineEvent {
int itemId;
int bet;
}
}
@@ -1,33 +0,0 @@
package com.skeletor.plugin.javascript.communication.incoming.loaded;
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.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.incoming.IncomingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.commands.CommandsPopUpComposer;
import com.skeletor.plugin.javascript.main;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import java.util.List;
public class LoadedEvent extends IncomingWebMessage<LoadedEvent.JSONLoadedEvent> {
public LoadedEvent() {
super(JSONLoadedEvent.class);
}
public void handle(GameClient client, JSONLoadedEvent message) {
Habbo habbo = client.getHabbo();
if (habbo == null)
return;
(habbo.getHabboStats()).cache.put(main.USER_LOADED_EVENT, Boolean.valueOf(true));
List<Command> commands = Emulator.getGameEnvironment().getCommandHandler().getCommandsForRank(client.getHabbo().getHabboInfo().getRank().getId());
CommandsPopUpComposer commandsPopUpComposer = new CommandsPopUpComposer(commands, (habbo.getHabboInfo().getRank().getLevel() >= 5));
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)commandsPopUpComposer));
}
static class JSONLoadedEvent {
boolean idk;
}
}
@@ -1,14 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing;
import com.google.gson.JsonObject;
public abstract class OutgoingWebMessage {
public String header;
public JsonObject data;
public OutgoingWebMessage(String name) {
this.header = name;
this.data = new JsonObject();
}
}
@@ -1,18 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class AddSongComposer extends OutgoingWebMessage {
public AddSongComposer(RoomPlaylist.YoutubeVideo video) {
super("add_song");
JsonObject song = new JsonObject();
song.add("name", (JsonElement)new JsonPrimitive(video.name));
song.add("videoId", (JsonElement)new JsonPrimitive(video.videoId));
song.add("channel", (JsonElement)new JsonPrimitive(video.channel));
this.data.add("song", (JsonElement)song);
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class ChangeVolumeComposer extends OutgoingWebMessage {
public ChangeVolumeComposer(int volume) {
super("change_volume");
this.data.add("volume", (JsonElement)new JsonPrimitive(Integer.valueOf(volume)));
}
}
@@ -1,9 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class DisposePlaylistComposer extends OutgoingWebMessage {
public DisposePlaylistComposer() {
super("dispose_playlist");
}
}
@@ -1,23 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class JukeboxComposer extends OutgoingWebMessage {
public JukeboxComposer(RoomPlaylist playlist) {
super("jukebox_player");
JsonArray playlistJson = new JsonArray();
for (RoomPlaylist.YoutubeVideo video : playlist.getPlaylist()) {
JsonObject song = new JsonObject();
song.add("name", (JsonElement)new JsonPrimitive(video.name));
song.add("videoId", (JsonElement)new JsonPrimitive(video.videoId));
song.add("channel", (JsonElement)new JsonPrimitive(video.channel));
playlistJson.add((JsonElement)song);
}
this.data.add("playlist", (JsonElement)playlistJson);
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class PlaySongComposer extends OutgoingWebMessage {
public PlaySongComposer(int index) {
super("play_song");
this.data.add("index", (JsonElement)new JsonPrimitive(Integer.valueOf(index)));
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class PlayStopComposer extends OutgoingWebMessage {
public PlayStopComposer(boolean isPlaying) {
super("play_stop");
this.data.add("playing", (JsonElement)new JsonPrimitive(Boolean.valueOf(isPlaying)));
}
}
@@ -1,23 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class PlaylistComposer extends OutgoingWebMessage {
public PlaylistComposer(RoomPlaylist playlist) {
super("playlist");
JsonArray playlistJson = new JsonArray();
for (RoomPlaylist.YoutubeVideo video : playlist.getPlaylist()) {
JsonObject song = new JsonObject();
song.add("name", (JsonElement)new JsonPrimitive(video.name));
song.add("videoId", (JsonElement)new JsonPrimitive(video.videoId));
song.add("channel", (JsonElement)new JsonPrimitive(video.channel));
playlistJson.add((JsonElement)song);
}
this.data.add("playlist", (JsonElement)playlistJson);
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.audio;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class RemoveSongComposer extends OutgoingWebMessage {
public RemoveSongComposer(int index) {
super("remove_song");
this.data.add("index", (JsonElement)new JsonPrimitive(Integer.valueOf(index)));
}
}
@@ -1,27 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class CommandsPopUpComposer extends OutgoingWebMessage {
public CommandsPopUpComposer(List<Command> commands, boolean mod) {
super("commands_pop_up");
JsonArray json_cmd = new JsonArray();
Collections.sort(commands, new Comparator<Command>() {
public int compare(Command command2, Command command1) {
return Emulator.getTexts().getValue("commands.description." + command2.permission, "commands.description." + command2.permission).compareTo(Emulator.getTexts().getValue("commands.description." + command1.permission, "commands.description." + command1.permission));
}
});
for (Command c : commands)
json_cmd.add(Emulator.getTexts().getValue("commands.description." + c.permission, "commands.description." + c.permission));
this.data.add("commands", (JsonElement)json_cmd);
this.data.add("mod", (JsonElement)new JsonPrimitive(Boolean.valueOf(mod)));
}
}
@@ -1,77 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.skeletor.plugin.javascript.categories.Category;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.main;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class CommandsComposer extends OutgoingWebMessage {
public CommandsComposer(List<Command> commands) {
super("commands");
JsonArray json_cmd = new JsonArray();
Collections.sort(commands, new Comparator<Command>() {
public int compare(Command command2, Command command1) {
return Emulator.getTexts().getValue("commands.description." + command2.permission, "commands.description." + command2.permission).compareTo(Emulator.getTexts().getValue("commands.description." + command1.permission, "commands.description." + command1.permission));
}
});
List<Command> duplicateCommands = new ArrayList<>(commands);
List<String> tempList = new ArrayList<>();
boolean hasPermission = false;
for (Category category : main.getCommandManager().getCommandCategories()) {
tempList = new ArrayList<>();
hasPermission = false;
if (category.getPermissions().size() > 0) {
for (String permission : category.getPermissions()) {
for (Command command : commands) {
if (command.permission.equals(permission)) {
duplicateCommands.remove(command);
String keys = "";
if (Emulator.getConfig().getBoolean("categories.cmd_commandsc.show_keys")) {
for (String key : command.keys) {
if (keys.equals("")) {
keys = "(" + key;
} else {
keys = keys + " " + key;
}
}
keys = keys + ")";
}
tempList.add(Emulator.getTexts().getValue("commands.description." + command.permission, "commands.description." + command.permission + " " + keys));
hasPermission = true;
}
}
}
if (hasPermission) {
json_cmd.add(category.getName());
for (String temp : tempList)
json_cmd.add(temp);
}
}
}
if (duplicateCommands.size() > 0 && Emulator.getConfig().getBoolean("categories.cmd_commandsc.show_others")) {
json_cmd.add(Emulator.getTexts().getValue("commands.generic.cmd_commandsc.others"));
for (Command command : duplicateCommands) {
String keys = "";
if (Emulator.getConfig().getBoolean("categories.cmd_commandsc.show_keys")) {
for (String key : command.keys) {
if (keys.equals("")) {
keys = "(" + key;
} else {
keys = keys + " " + key;
}
}
keys = keys + ")";
}
json_cmd.add(Emulator.getTexts().getValue("commands.description." + command.permission, "commands.description." + command.permission) + " " + keys);
}
}
this.data.add("commands", (JsonElement)json_cmd);
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class OnlineCountComposer extends OutgoingWebMessage {
public OnlineCountComposer(int count) {
super("online_count");
this.data.add("count", (JsonElement)new JsonPrimitive(Integer.valueOf(count)));
}
}
@@ -1,15 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class SessionDataComposer extends OutgoingWebMessage {
public SessionDataComposer(int id, String username, String look, int credits) {
super("session_data");
this.data.add("id", (JsonElement)new JsonPrimitive(Integer.valueOf(id)));
this.data.add("username", (JsonElement)new JsonPrimitive(username));
this.data.add("look", (JsonElement)new JsonPrimitive(look));
this.data.add("credits", (JsonElement)new JsonPrimitive(Integer.valueOf(credits)));
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class TwitchVideoComposer extends OutgoingWebMessage {
public TwitchVideoComposer(String videoId) {
super("twitch");
this.data.add("videoId", (JsonElement)new JsonPrimitive(videoId));
}
}
@@ -1,12 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class UpdateCreditsComposer extends OutgoingWebMessage {
public UpdateCreditsComposer(int credits) {
super("update_credits");
this.data.add("credits", (JsonElement)new JsonPrimitive(Integer.valueOf(credits)));
}
}
@@ -1,14 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.common;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class YoutubeTVComposer extends OutgoingWebMessage {
public YoutubeTVComposer(String videoId, Integer time) {
super("youtube_tv");
this.data.add("videoId", (JsonElement)new JsonPrimitive(videoId));
this.data.add("time", (JsonElement)new JsonPrimitive(time));
this.data.add("itemId", (JsonElement)new JsonPrimitive(Integer.valueOf(0)));
}
}
@@ -1,13 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.slotmachine;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class SlotMachineComposer extends OutgoingWebMessage {
public SlotMachineComposer(int itemId, int credits) {
super("slot_machine");
this.data.add("itemId", (JsonElement)new JsonPrimitive(Integer.valueOf(itemId)));
this.data.add("credits", (JsonElement)new JsonPrimitive(Integer.valueOf(credits)));
}
}
@@ -1,16 +0,0 @@
package com.skeletor.plugin.javascript.communication.outgoing.slotmachine;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
public class SpinResultComposer extends OutgoingWebMessage {
public SpinResultComposer(int result1, int result2, int result3, boolean won, int payout) {
super("slot_result");
this.data.add("result1", (JsonElement)new JsonPrimitive(Integer.valueOf(result1)));
this.data.add("result2", (JsonElement)new JsonPrimitive(Integer.valueOf(result2)));
this.data.add("result3", (JsonElement)new JsonPrimitive(Integer.valueOf(result3)));
this.data.add("won", (JsonElement)new JsonPrimitive(Boolean.valueOf(won)));
this.data.add("payout", (JsonElement)new JsonPrimitive(Integer.valueOf(payout)));
}
}
@@ -1,39 +0,0 @@
package com.skeletor.plugin.javascript.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.slotmachine.SlotMachineComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionSlotMachine extends InteractionDefault {
public InteractionSlotMachine(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
public InteractionSlotMachine(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
public boolean isWalkable() {
return false;
}
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {}
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
SlotMachineComposer webComposer = new SlotMachineComposer(getId(), client.getHabbo().getHabboInfo().getCredits());
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)webComposer));
}
}
@@ -1,44 +0,0 @@
package com.skeletor.plugin.javascript.interactions;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.items.interactions.InteractionDefault;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.JukeboxComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import java.sql.ResultSet;
import java.sql.SQLException;
public class InteractionYoutubeJukebox extends InteractionDefault {
public InteractionYoutubeJukebox(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
public InteractionYoutubeJukebox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
super(id, userId, item, extradata, limitedStack, limitedSells);
}
public boolean canWalkOn(RoomUnit roomUnit, Room room, Object[] objects) {
return false;
}
public boolean isWalkable() {
return false;
}
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {}
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
if (room.hasRights(client.getHabbo())) {
RoomPlaylist roomPlaylist = RoomAudioManager.getInstance().getPlaylistForRoom(room.getId());
JukeboxComposer webComposer = new JukeboxComposer(roomPlaylist);
client.sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)webComposer));
}
}
}
@@ -1,197 +0,0 @@
package com.skeletor.plugin.javascript;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.commands.Command;
import com.eu.habbo.habbohotel.commands.CommandHandler;
import com.eu.habbo.habbohotel.items.ItemInteraction;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.eu.habbo.plugin.EventHandler;
import com.eu.habbo.plugin.EventListener;
import com.eu.habbo.plugin.HabboPlugin;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadItemsManagerEvent;
import com.eu.habbo.plugin.events.emulator.EmulatorLoadedEvent;
import com.eu.habbo.plugin.events.rooms.RoomUncachedEvent;
import com.eu.habbo.plugin.events.users.UserCreditsEvent;
import com.eu.habbo.plugin.events.users.UserEnterRoomEvent;
import com.eu.habbo.plugin.events.users.UserExitRoomEvent;
import com.eu.habbo.plugin.events.users.UserLoginEvent;
import com.eu.habbo.plugin.events.users.UserSavedSettingsEvent;
import com.skeletor.plugin.javascript.audio.RoomAudioManager;
import com.skeletor.plugin.javascript.audio.RoomPlaylist;
import com.skeletor.plugin.javascript.categories.CommandManager;
import com.skeletor.plugin.javascript.commands.CmdCommand;
import com.skeletor.plugin.javascript.commands.TwitchCommand;
import com.skeletor.plugin.javascript.commands.UpdateCategoriesCommand;
import com.skeletor.plugin.javascript.commands.YoutubeCommand;
import com.skeletor.plugin.javascript.communication.CommunicationManager;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.audio.ChangeVolumeComposer;
import com.skeletor.plugin.javascript.communication.outgoing.audio.DisposePlaylistComposer;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlaySongComposer;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlayStopComposer;
import com.skeletor.plugin.javascript.communication.outgoing.audio.PlaylistComposer;
import com.skeletor.plugin.javascript.communication.outgoing.common.OnlineCountComposer;
import com.skeletor.plugin.javascript.communication.outgoing.common.SessionDataComposer;
import com.skeletor.plugin.javascript.communication.outgoing.common.TwitchVideoComposer;
import com.skeletor.plugin.javascript.communication.outgoing.common.UpdateCreditsComposer;
import com.skeletor.plugin.javascript.interactions.InteractionSlotMachine;
import com.skeletor.plugin.javascript.interactions.InteractionYoutubeJukebox;
import com.skeletor.plugin.javascript.override_packets.incoming.JavascriptCallbackEvent;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import com.skeletor.plugin.javascript.runnables.OnlineCountRunnable;
import com.skeletor.plugin.javascript.scheduler.CheckLoadedScheduler;
import gnu.trove.map.hash.THashMap;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class main extends HabboPlugin implements EventListener {
public static final int JSCALLBACKEVENTHEADER = 314;
private static CommandManager commandManager;
private static THashMap<Integer, String> twitchRooms;
public static String USER_LOADED_EVENT = "user.loaded.event.key";
public static String STARTED_LOADING_EVENT = "user.loading.event.key";
public void onEnable() throws Exception {
Emulator.getPluginManager().registerEvents(this, this);
if (Emulator.isReady && !Emulator.isShuttingDown)
onEmulatorLoadedEvent(null);
}
@EventHandler
public void onEmulatorLoadedEvent(EmulatorLoadedEvent e) throws Exception {
Emulator.getGameServer().getPacketManager().registerHandler(Integer.valueOf(314), JavascriptCallbackEvent.class);
Emulator.getTexts().register("jscommands.keys.cmd_commands", "commands");
Emulator.getTexts().register("commands.description.cmd_commandsc", ":commandsc");
Emulator.getTexts().register("categories.cmd_commandsc.keys", "commandsc");
Emulator.getTexts().register("commands.generic.cmd_commandsc.text", "Your Commands");
Emulator.getTexts().register("commands.generic.cmd_commandsc.others", "Others");
Emulator.getTexts().register("commands.description.cmd_update_categories", ":update_categories");
Emulator.getTexts().register("categories.cmd_update_categories.keys", "update_categories");
Emulator.getTexts().register("categories.cmd_update_categories.success", "Successfully updated command categories");
Emulator.getConfig().register("categories.cmd_commandsc.show_keys", "1");
Emulator.getConfig().register("categories.cmd_commandsc.show_others", "1");
boolean reloadPermissions = false;
reloadPermissions = registerPermission("cmd_commandsc", "'0', '1'", "1", reloadPermissions);
reloadPermissions = registerPermission("cmd_update_categories", "'0', '1'", "0", reloadPermissions);
if (reloadPermissions)
Emulator.getGameEnvironment().getPermissionsManager().reload();
CommandHandler.addCommand((Command)new YoutubeCommand());
CommandHandler.addCommand((Command)new CmdCommand());
CommandHandler.addCommand((Command)new TwitchCommand());
CommandHandler.addCommand((Command)new UpdateCategoriesCommand("cmd_update_categories", Emulator.getTexts().getValue("categories.cmd_update_categories.keys").split(";")));
RoomAudioManager.Init();
OnlineCountRunnable.getInstance().start();
commandManager = new CommandManager();
twitchRooms = new THashMap();
new CheckLoadedScheduler();
}
private boolean registerPermission(String name, String options, String defaultValue, boolean defaultReturn) {
try(Connection connection = Emulator.getDatabase().getDataSource().getConnection();
PreparedStatement statement = connection.prepareStatement("ALTER TABLE `permissions` ADD `" + name + "` ENUM( " + options + " ) NOT NULL DEFAULT '" + defaultValue + "'")) {
statement.execute();
return true;
} catch (SQLException sQLException) {
return defaultReturn;
}
}
@EventHandler
public void onLoadItemsManager(EmulatorLoadItemsManagerEvent e) {
Emulator.getGameEnvironment().getItemManager().addItemInteraction(new ItemInteraction("slots_machine", InteractionSlotMachine.class));
Emulator.getGameEnvironment().getItemManager().addItemInteraction(new ItemInteraction("yt_jukebox", InteractionYoutubeJukebox.class));
}
@EventHandler
public void onUserEnterRoomEvent(UserEnterRoomEvent e) {
RoomPlaylist playlist = RoomAudioManager.getInstance().getPlaylistForRoom(e.room.getId());
if (playlist.getPlaylist().size() > 0) {
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new PlaylistComposer(playlist)));
if (playlist.isPlaying()) {
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new PlaySongComposer(playlist.getCurrentIndex())));
e.habbo.getClient().sendResponse(playlist.getNowPlayingBubbleAlert());
}
}
if (e.room.getHabbos() == null || e.room.getHabbos().size() == 0)
twitchRooms.remove(Integer.valueOf(e.room.getId()));
if (twitchRooms.containsKey(Integer.valueOf(e.room.getId()))) {
TwitchVideoComposer twitchVideoComposer = new TwitchVideoComposer((String)twitchRooms.get(Integer.valueOf(e.room.getId())));
e.habbo.getClient().sendResponse((new JavascriptCallbackComposer((OutgoingWebMessage)twitchVideoComposer)).compose());
}
}
@EventHandler
public void onUserExitRoomEvent(UserExitRoomEvent e) {
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new PlayStopComposer(false)));
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new DisposePlaylistComposer()));
}
@EventHandler
public void onRoomUncachedEvent(RoomUncachedEvent e) {
RoomAudioManager.getInstance().dispose(e.room.getId());
}
@EventHandler
public void onUserLoginEvent(UserLoginEvent e) {
if (e.habbo == null || e.habbo.getClient() == null)
return;
Habbo habbo = e.habbo;
(e.habbo.getHabboStats()).cache.put(USER_LOADED_EVENT, Boolean.valueOf(false));
(e.habbo.getHabboStats()).cache.put(STARTED_LOADING_EVENT, Integer.valueOf(Emulator.getIntUnixTimestamp()));
SessionDataComposer sessionDataComposer = new SessionDataComposer(e.habbo.getHabboInfo().getId(), e.habbo.getHabboInfo().getUsername(), e.habbo.getHabboInfo().getLook(), e.habbo.getHabboInfo().getCredits());
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)sessionDataComposer));
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new ChangeVolumeComposer((e.habbo.getHabboStats()).volumeTrax)));
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new OnlineCountComposer(Emulator.getGameEnvironment().getHabboManager().getOnlineCount())));
Emulator.getThreading().run(() -> userCheckLoaded(habbo), 500L);
}
public void userCheckLoaded(Habbo habbo) {
if (habbo == null || habbo.getClient() == null || !habbo.isOnline())
return;
if (((Boolean)(habbo.getHabboStats()).cache.get(USER_LOADED_EVENT)).booleanValue())
return;
if (Emulator.getIntUnixTimestamp() - ((Integer)(habbo.getHabboStats()).cache.get(STARTED_LOADING_EVENT)).intValue() > 15)
return;
SessionDataComposer sessionDataComposer = new SessionDataComposer(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getCredits());
habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)sessionDataComposer));
habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new ChangeVolumeComposer((habbo.getHabboStats()).volumeTrax)));
habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new OnlineCountComposer(Emulator.getGameEnvironment().getHabboManager().getOnlineCount())));
Emulator.getThreading().run(() -> userCheckLoaded(habbo), 500L);
}
@EventHandler
public void onUserCreditsEvent(UserCreditsEvent e) {
UpdateCreditsComposer creditsComposer = new UpdateCreditsComposer(e.habbo.getHabboInfo().getCredits());
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)creditsComposer));
}
@EventHandler
public void onUserSavedSettingsEvent(UserSavedSettingsEvent e) {
e.habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new ChangeVolumeComposer((e.habbo.getHabboStats()).volumeTrax)));
}
public void onDisable() throws Exception {
CommunicationManager.getInstance().Dispose();
RoomAudioManager.getInstance().Dispose();
OnlineCountRunnable.getInstance().stop();
}
public static CommandManager getCommandManager() {
return commandManager;
}
public static void addTwitchRoom(int roomId, String twitch) {
twitchRooms.put(Integer.valueOf(roomId), twitch);
}
public boolean hasPermission(Habbo habbo, String s) {
return false;
}
}
@@ -1,11 +0,0 @@
package com.skeletor.plugin.javascript.override_packets.incoming;
import com.eu.habbo.messages.incoming.MessageHandler;
import com.skeletor.plugin.javascript.communication.CommunicationManager;
public class JavascriptCallbackEvent extends MessageHandler {
public void handle() {
String payload = this.packet.readString();
CommunicationManager.getInstance().OnMessage(payload, this.client);
}
}
@@ -1,21 +0,0 @@
package com.skeletor.plugin.javascript.override_packets.outgoing;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.utils.JsonFactory;
public class JavascriptCallbackComposer extends MessageComposer {
private OutgoingWebMessage webMessage;
public JavascriptCallbackComposer(OutgoingWebMessage message) {
this.webMessage = message;
}
public ServerMessage composeInternal() {
this.response.init(2023);
String jsonMessage = JsonFactory.getInstance().toJson(this.webMessage).replace("/", "&#47;");
this.response.appendString("habblet/open/" + jsonMessage);
return this.response;
}
}
@@ -1,36 +0,0 @@
package com.skeletor.plugin.javascript.runnables;
import com.eu.habbo.Emulator;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.OnlineCountComposer;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
public class OnlineCountRunnable implements Runnable {
private static final OnlineCountRunnable instance = new OnlineCountRunnable();
private volatile boolean running = false;
public void run() {
if (this.running) {
int count = Emulator.getGameEnvironment().getHabboManager().getOnlineCount();
Emulator.getGameServer().getGameClientManager().sendBroadcastResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)new OnlineCountComposer(count)));
Emulator.getThreading().run(this, 30000L);
}
}
public static OnlineCountRunnable getInstance() {
return instance;
}
public void start() {
if (!this.running) {
this.running = true;
Emulator.getThreading().run(this);
}
}
public void stop() {
this.running = false;
}
}
@@ -1,34 +0,0 @@
package com.skeletor.plugin.javascript.scheduler;
import com.eu.habbo.Emulator;
import com.eu.habbo.core.Scheduler;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.MessageComposer;
import com.skeletor.plugin.javascript.communication.outgoing.OutgoingWebMessage;
import com.skeletor.plugin.javascript.communication.outgoing.common.SessionDataComposer;
import com.skeletor.plugin.javascript.main;
import com.skeletor.plugin.javascript.override_packets.outgoing.JavascriptCallbackComposer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class CheckLoadedScheduler extends Scheduler {
private static final Logger LOGGER = LoggerFactory.getLogger(CheckLoadedScheduler.class);
public CheckLoadedScheduler() {
super(60);
run();
}
public void run() {
super.run();
if (Emulator.getConfig().getBoolean("pop.up.enabled", true))
for (Habbo habbo : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().values()) {
if (!(habbo.getHabboStats()).cache.containsKey(main.USER_LOADED_EVENT))
continue;
if (((Boolean)(habbo.getHabboStats()).cache.get(main.USER_LOADED_EVENT)).booleanValue())
continue;
SessionDataComposer sessionDataComposer = new SessionDataComposer(habbo.getHabboInfo().getId(), habbo.getHabboInfo().getUsername(), habbo.getHabboInfo().getLook(), habbo.getHabboInfo().getCredits());
habbo.getClient().sendResponse((MessageComposer)new JavascriptCallbackComposer((OutgoingWebMessage)sessionDataComposer));
}
}
}
@@ -1,11 +0,0 @@
package com.skeletor.plugin.javascript.utils;
import com.google.gson.Gson;
public class JsonFactory {
private static final Gson gson = new Gson();
public static Gson getInstance() {
return gson;
}
}
@@ -1,30 +0,0 @@
package com.skeletor.plugin.javascript.utils;
import org.owasp.html.HtmlPolicyBuilder;
import org.owasp.html.PolicyFactory;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class RegexUtility {
public static String getYouTubeId (String youTubeUrl) {
String pattern = "(?<=youtu.be/|watch\\?v=|/videos/|embed\\/)[^#\\&\\?]*";
Pattern compiledPattern = Pattern.compile(pattern);
Matcher matcher = compiledPattern.matcher(youTubeUrl);
if(matcher.find()){
return matcher.group();
} else {
return "";
}
}
/**
* Sanitizes a string by removing any potentially harmful HTML elements.
*
* @param str The string to be sanitized.
* @return The sanitized string.
*/
public static String sanitize(String str) {
PolicyFactory policy = new HtmlPolicyBuilder().toFactory();
return policy.sanitize(str);
}
}
@@ -1,5 +0,0 @@
{
"main" : "com.skeletor.plugin.javascript.main",
"name" : "Javascript Plugin",
"author" : "skeletor"
}