feat: update to ms4
This commit is contained in:
parent
1a685d3dba
commit
10aeca2880
@ -1,5 +1,9 @@
|
|||||||
# Apollyon #
|
# Apollyon #
|
||||||
|
|
||||||
|
## Changes ##
|
||||||
|
Because Arcturus Morningstar 3 is deprecated, Apollyon must be changed. Overall FTP support was removed, because the protocol shouldn't be used in 2023 in my opinion and if so at least SFTP should be used.
|
||||||
|
Also the dependency changed to the current Morningstar ms4 Version. `onEnable()` can't throw any Exception and updated Incoming packet ids.
|
||||||
|
|
||||||
## What is Apollyon? ##
|
## What is Apollyon? ##
|
||||||
Apollyon is a Camera Plugin for Arcturus Morningstar
|
Apollyon is a Camera Plugin for Arcturus Morningstar
|
||||||
|
|
||||||
|
11
pom.xml
11
pom.xml
@ -6,15 +6,16 @@
|
|||||||
|
|
||||||
<groupId>com.eu.habbo</groupId>
|
<groupId>com.eu.habbo</groupId>
|
||||||
<artifactId>Apollyon</artifactId>
|
<artifactId>Apollyon</artifactId>
|
||||||
<version>1</version>
|
<version>2.0.0</version>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>8</source>
|
<source>19</source>
|
||||||
<target>8</target>
|
<target>19</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
@ -23,8 +24,8 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.eu.habbo</groupId>
|
<groupId>com.eu.habbo</groupId>
|
||||||
<artifactId>Habbo</artifactId>
|
<artifactId>Morningstar</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>4.0-DEVPREVIEW</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
package org.krews.apollyon;
|
package org.krews.apollyon;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.messages.PacketManager;
|
import com.eu.habbo.messages.PacketManager;
|
||||||
@ -22,16 +23,18 @@ import java.lang.reflect.Field;
|
|||||||
/**
|
/**
|
||||||
* Apollyon
|
* Apollyon
|
||||||
* The Official Camera Plugin for Morningstar. Credits to John, Beny, Ovflowd, and Alejandro
|
* The Official Camera Plugin for Morningstar. Credits to John, Beny, Ovflowd, and Alejandro
|
||||||
|
*
|
||||||
* @author Krews.org
|
* @author Krews.org
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Main extends HabboPlugin implements EventListener {
|
public class Main extends HabboPlugin implements EventListener {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Emulator.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() throws Exception {
|
public void onEnable() {
|
||||||
Emulator.getPluginManager().registerEvents(this, this);
|
Emulator.getPluginManager().registerEvents(this, this);
|
||||||
|
|
||||||
if(Emulator.isReady && !Emulator.isShuttingDown) {
|
if (Emulator.isReady && !Emulator.isShuttingDown) {
|
||||||
this.onEmulatorLoadedEvent(null);
|
this.onEmulatorLoadedEvent(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -42,28 +45,27 @@ public class Main extends HabboPlugin implements EventListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() throws Exception {
|
public void onDisable() {
|
||||||
|
try {
|
||||||
// put the original packets back
|
// put the original packets back
|
||||||
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
|
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
|
||||||
Field f = PacketManager.class.getDeclaredField("incoming");
|
Field f = PacketManager.class.getDeclaredField("incoming");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>)f.get(packetManager);
|
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>) f.get(packetManager);
|
||||||
incoming.remove(Incoming.CameraRoomPictureEvent, CameraRoomPictureEvent.class);
|
incoming.remove(Incoming.renderRoomEvent, CameraRoomPictureEvent.class);
|
||||||
incoming.remove(Incoming.CameraPublishToWebEvent, CameraPublishToWebEvent.class);
|
incoming.remove(Incoming.publishPhotoEvent, CameraPublishToWebEvent.class);
|
||||||
incoming.remove(Incoming.CameraPurchaseEvent, CameraPurchaseEvent.class);
|
incoming.remove(Incoming.purchasePhotoEvent, CameraPurchaseEvent.class);
|
||||||
incoming.remove(Incoming.CameraRoomThumbnailEvent, CameraRoomThumbnailEvent.class);
|
incoming.remove(Incoming.renderRoomThumbnailEvent, CameraRoomThumbnailEvent.class);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Apollyon failed to disable!");
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEmulatorLoadedEvent(EmulatorLoadedEvent e) throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException, Exception {
|
public void onEmulatorLoadedEvent(EmulatorLoadedEvent e) {
|
||||||
|
try {
|
||||||
// Adds missing sqls if they are not found.
|
// Adds missing sqls if they are not found.
|
||||||
Emulator.getConfig().register("apollyon.cooldown.amount", "250");
|
|
||||||
Emulator.getConfig().register("ftp.enabled", "0");
|
|
||||||
Emulator.getConfig().register("ftp.user", "root");
|
|
||||||
Emulator.getConfig().register("ftp.password", "password123");
|
|
||||||
Emulator.getConfig().register("ftp.host", "example.com");
|
|
||||||
Emulator.getConfig().register("camera.url", "http://yourdomain.com/swfdirectory/camera/");
|
Emulator.getConfig().register("camera.url", "http://yourdomain.com/swfdirectory/camera/");
|
||||||
Emulator.getConfig().register("imager.location.output.camera", "C:\\yourdirectory\\swfdirectory\\camera\\");
|
Emulator.getConfig().register("imager.location.output.camera", "C:\\yourdirectory\\swfdirectory\\camera\\");
|
||||||
Emulator.getConfig().register("imager.location.output.thumbnail", "C:\\yourdirectory\\swfdirectory\\camera\\thumbnails\\thumbnail_");
|
Emulator.getConfig().register("imager.location.output.thumbnail", "C:\\yourdirectory\\swfdirectory\\camera\\thumbnails\\thumbnail_");
|
||||||
@ -71,22 +73,26 @@ public class Main extends HabboPlugin implements EventListener {
|
|||||||
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
|
PacketManager packetManager = Emulator.getGameServer().getPacketManager();
|
||||||
Field f = PacketManager.class.getDeclaredField("incoming");
|
Field f = PacketManager.class.getDeclaredField("incoming");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>)f.get(packetManager);
|
THashMap<Integer, Class<? extends MessageHandler>> incoming = (THashMap<Integer, Class<? extends MessageHandler>>) f.get(packetManager);
|
||||||
|
|
||||||
// Removes the current arcturus handlers for these packets
|
// Removes the current arcturus handlers for these packets
|
||||||
incoming.remove(Incoming.CameraRoomPictureEvent);
|
incoming.remove(Incoming.renderRoomEvent);
|
||||||
incoming.remove(Incoming.CameraPublishToWebEvent);
|
incoming.remove(Incoming.publishPhotoEvent);
|
||||||
incoming.remove(Incoming.CameraPurchaseEvent);
|
incoming.remove(Incoming.purchasePhotoEvent);
|
||||||
incoming.remove(Incoming.CameraRoomThumbnailEvent);
|
incoming.remove(Incoming.renderRoomThumbnailEvent);
|
||||||
|
|
||||||
// Adds the PNGCamera Packet Handlers
|
// Adds the PNGCamera Packet Handlers
|
||||||
packetManager.registerHandler(Incoming.CameraRoomPictureEvent, CameraRoomPictureEvent.class);
|
packetManager.registerHandler(Incoming.renderRoomEvent, CameraRoomPictureEvent.class);
|
||||||
packetManager.registerHandler(Incoming.CameraPublishToWebEvent, CameraPublishToWebEvent.class);
|
packetManager.registerHandler(Incoming.publishPhotoEvent, CameraPublishToWebEvent.class);
|
||||||
packetManager.registerHandler(Incoming.CameraPurchaseEvent, CameraPurchaseEvent.class);
|
packetManager.registerHandler(Incoming.purchasePhotoEvent, CameraPurchaseEvent.class);
|
||||||
packetManager.registerHandler(Incoming.CameraRoomThumbnailEvent, CameraRoomThumbnailEvent.class);
|
packetManager.registerHandler(Incoming.renderRoomThumbnailEvent, CameraRoomThumbnailEvent.class);
|
||||||
|
|
||||||
// Send the message to the Emulator that PNGCamera has started.
|
// Send the message to the Emulator that PNGCamera has started.
|
||||||
LOGGER.info("Official Plugin - Apollyon 1.0 has loaded!");
|
LOGGER.info("OFFICIAL PLUGIN - Apollyon has been loaded!");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
LOGGER.error("Apollyon failed to load!");
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
package org.krews.apollyon.ftp;
|
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
|
||||||
import org.krews.apollyon.utils.PngSignatureChecker;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.net.URLEncoder;
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class FTPUploadService {
|
|
||||||
private static final String ftpUrl = "ftp://%s:%s@%s/%s;type=i";
|
|
||||||
|
|
||||||
public static void uploadImage(byte[] image, String uploadPath) throws IOException {
|
|
||||||
if (PngSignatureChecker.isPngFile(image)) {
|
|
||||||
String host = Emulator.getConfig().getValue("ftp.host");
|
|
||||||
String user = Emulator.getConfig().getValue("ftp.user");
|
|
||||||
String pass = Emulator.getConfig().getValue("ftp.password");
|
|
||||||
|
|
||||||
String uploadURL = String.format(ftpUrl, URLEncoder.encode(user, "UTF-8"), URLEncoder.encode(pass, "UTF-8"), host, uploadPath);
|
|
||||||
|
|
||||||
URL url = new URL(uploadURL);
|
|
||||||
URLConnection conn = url.openConnection();
|
|
||||||
OutputStream outputStream = conn.getOutputStream();
|
|
||||||
outputStream.write(image, 0, image.length);
|
|
||||||
outputStream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,22 +2,23 @@ package org.krews.apollyon.incoming;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.camera.CameraPublishWaitMessageComposer;
|
import com.eu.habbo.messages.outgoing.camera.CameraPublishStatusMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
|
import com.eu.habbo.messages.outgoing.catalog.NotEnoughBalanceMessageComposer;
|
||||||
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
|
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class CameraPublishToWebEvent extends MessageHandler
|
public class CameraPublishToWebEvent extends MessageHandler {
|
||||||
{
|
private static final Logger LOGGER = LoggerFactory.getLogger(CameraPublishToWebEvent.class);
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points.publish")) {
|
if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points.publish")) {
|
||||||
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, 0));
|
this.client.sendResponse(new NotEnoughBalanceMessageComposer(false, true, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
|
if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
|
||||||
@ -30,15 +31,14 @@ public class CameraPublishToWebEvent extends MessageHandler
|
|||||||
int wait = 0;
|
int wait = 0;
|
||||||
if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) {
|
if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) {
|
||||||
wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay");
|
wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId());
|
UserPublishPictureEvent publishPictureEvent = new UserPublishPictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), timestamp, this.client.getHabbo().getHabboInfo().getPhotoRoomId());
|
||||||
if (!Emulator.getPluginManager().fireEvent(publishPictureEvent).isCancelled()) {
|
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 (?, ?, ?, ?)")) {
|
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, this.client.getHabbo().getHabboInfo().getId());
|
statement.setInt(1, this.client.getHabbo().getHabboInfo().getId());
|
||||||
statement.setInt(2, publishPictureEvent.roomId);
|
statement.setInt(2, publishPictureEvent.getRoomId());
|
||||||
statement.setInt(3, publishPictureEvent.timestamp);
|
statement.setInt(3, publishPictureEvent.getTimestamp());
|
||||||
statement.setString(4, publishPictureEvent.URL);
|
statement.setString(4, publishPictureEvent.getURL());
|
||||||
statement.execute();
|
statement.execute();
|
||||||
this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
|
this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
|
||||||
this.client.getHabbo().givePixels(-Emulator.getConfig().getInt("camera.price.points.publish"));
|
this.client.getHabbo().givePixels(-Emulator.getConfig().getInt("camera.price.points.publish"));
|
||||||
@ -47,13 +47,12 @@ public class CameraPublishToWebEvent extends MessageHandler
|
|||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new CameraPublishWaitMessageComposer(published, wait, published ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
|
this.client.sendResponse(new CameraPublishStatusMessageComposer(published, wait, published ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,10 @@ import com.eu.habbo.habbohotel.items.Item;
|
|||||||
import com.eu.habbo.habbohotel.users.Habbo;
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.camera.CameraPurchaseSuccesfullComposer;
|
import com.eu.habbo.messages.outgoing.camera.CameraPurchaseOKMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
|
import com.eu.habbo.messages.outgoing.catalog.NotEnoughBalanceMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.AddHabboItemComposer;
|
import com.eu.habbo.messages.outgoing.inventory.FurniListInvalidateComposer;
|
||||||
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
import com.eu.habbo.messages.outgoing.inventory.UnseenItemsComposer;
|
||||||
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
|
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
|
||||||
import gnu.trove.map.hash.THashMap;
|
import gnu.trove.map.hash.THashMap;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -20,21 +20,17 @@ public class CameraPurchaseEvent extends MessageHandler {
|
|||||||
public static int CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits");
|
public static int CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits");
|
||||||
public static int CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points");
|
public static int CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points");
|
||||||
public static int CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type");
|
public static int CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type");
|
||||||
public THashMap<Habbo, Integer> lastRanTimestamps = new THashMap<Habbo, Integer>();
|
public THashMap<Habbo, Integer> lastRanTimestamps = new THashMap<>();
|
||||||
public int getRatelimit() {
|
|
||||||
return Emulator.getConfig().getInt("apollyon.cooldown.amount");
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
|
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCredits() < CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS) {
|
if (this.client.getHabbo().getHabboInfo().getCredits() < CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS) {
|
||||||
this.client.sendResponse(new NotEnoughPointsTypeComposer(true, false, 0));
|
this.client.sendResponse(new NotEnoughBalanceMessageComposer(true, false, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE) < CameraPurchaseEvent.CAMERA_PURCHASE_POINTS) {
|
if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE) < CameraPurchaseEvent.CAMERA_PURCHASE_POINTS) {
|
||||||
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE));
|
this.client.sendResponse(new NotEnoughBalanceMessageComposer(false, true, CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,9 +67,9 @@ public class CameraPurchaseEvent extends MessageHandler {
|
|||||||
|
|
||||||
this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
|
this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
|
||||||
|
|
||||||
this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
|
this.client.sendResponse(new CameraPurchaseOKMessageComposer());
|
||||||
this.client.sendResponse(new AddHabboItemComposer(photoItem));
|
this.client.sendResponse(new UnseenItemsComposer(photoItem));
|
||||||
this.client.sendResponse(new InventoryRefreshComposer());
|
this.client.sendResponse(new FurniListInvalidateComposer());
|
||||||
this.client.getHabbo().giveCredits(-CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS);
|
this.client.getHabbo().giveCredits(-CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS);
|
||||||
this.client.getHabbo().givePoints(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE, -CameraPurchaseEvent.CAMERA_PURCHASE_POINTS);
|
this.client.getHabbo().givePoints(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE, -CameraPurchaseEvent.CAMERA_PURCHASE_POINTS);
|
||||||
|
|
||||||
|
@ -3,12 +3,10 @@ package org.krews.apollyon.incoming;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.camera.CameraURLComposer;
|
import com.eu.habbo.messages.outgoing.camera.CameraStorageUrlMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufInputStream;
|
import io.netty.buffer.ByteBufInputStream;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
import io.netty.util.ReferenceCountUtil;
|
||||||
import org.krews.apollyon.ftp.FTPUploadService;
|
|
||||||
import org.krews.apollyon.utils.PngSignatureChecker;
|
import org.krews.apollyon.utils.PngSignatureChecker;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -17,7 +15,6 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.IllegalArgumentException;
|
|
||||||
|
|
||||||
public class CameraRoomPictureEvent extends MessageHandler {
|
public class CameraRoomPictureEvent extends MessageHandler {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(CameraRoomPictureEvent.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(CameraRoomPictureEvent.class);
|
||||||
@ -25,7 +22,7 @@ public class CameraRoomPictureEvent extends MessageHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
if (!this.client.getHabbo().hasPermission("acc_camera")) {
|
if (!this.client.getHabbo().hasPermission("acc_camera")) {
|
||||||
this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("camera.permission")));
|
this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,11 +34,12 @@ public class CameraRoomPictureEvent extends MessageHandler {
|
|||||||
final int count = this.packet.readInt();
|
final int count = this.packet.readInt();
|
||||||
|
|
||||||
ByteBuf image = this.packet.getBuffer().readBytes(count);
|
ByteBuf image = this.packet.getBuffer().readBytes(count);
|
||||||
ByteBuf imageCopy = image.copy();
|
|
||||||
|
|
||||||
if (image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ByteBuf imageCopy = image.copy();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
byte[] imageBytes = new byte[image.readableBytes()];
|
byte[] imageBytes = new byte[image.readableBytes()];
|
||||||
image.readBytes(imageBytes);
|
image.readBytes(imageBytes);
|
||||||
@ -67,14 +65,9 @@ public class CameraRoomPictureEvent extends MessageHandler {
|
|||||||
lol.lastRanTimestamps.put(this.client.getHabbo(), Emulator.getIntUnixTimestamp());
|
lol.lastRanTimestamps.put(this.client.getHabbo(), Emulator.getIntUnixTimestamp());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Emulator.getConfig().getInt("ftp.enabled") == 1) {
|
|
||||||
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL);
|
|
||||||
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.camera") + URL_small);
|
|
||||||
} else {
|
|
||||||
BufferedImage theImage = ImageIO.read(new ByteBufInputStream(imageCopy));
|
BufferedImage theImage = ImageIO.read(new ByteBufInputStream(imageCopy));
|
||||||
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL));
|
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL));
|
||||||
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL_small));
|
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.camera") + URL_small));
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -82,7 +75,7 @@ public class CameraRoomPictureEvent extends MessageHandler {
|
|||||||
LOGGER.error("[Apollyon] https://git.krews.org/morningstar/apollyon");
|
LOGGER.error("[Apollyon] https://git.krews.org/morningstar/apollyon");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new CameraURLComposer(URL));
|
this.client.sendResponse(new CameraStorageUrlMessageComposer(URL));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
ReferenceCountUtil.release(image);
|
ReferenceCountUtil.release(image);
|
||||||
|
@ -3,18 +3,15 @@ package org.krews.apollyon.incoming;
|
|||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.rooms.Room;
|
import com.eu.habbo.habbohotel.rooms.Room;
|
||||||
import com.eu.habbo.messages.incoming.MessageHandler;
|
import com.eu.habbo.messages.incoming.MessageHandler;
|
||||||
import com.eu.habbo.messages.outgoing.camera.CameraRoomThumbnailSavedComposer;
|
import com.eu.habbo.messages.outgoing.camera.ThumbnailStatusMessageComposer;
|
||||||
import com.eu.habbo.messages.outgoing.generic.alerts.GenericAlertComposer;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufInputStream;
|
import io.netty.buffer.ByteBufInputStream;
|
||||||
import io.netty.util.ReferenceCountUtil;
|
import io.netty.util.ReferenceCountUtil;
|
||||||
import org.krews.apollyon.ftp.FTPUploadService;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.awt.image.DataBufferByte;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -23,8 +20,8 @@ public class CameraRoomThumbnailEvent extends MessageHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() {
|
public void handle() {
|
||||||
if (! this.client.getHabbo().hasPermission("acc_camera")) {
|
if (!this.client.getHabbo().hasPermission("acc_camera")) {
|
||||||
this.client.sendResponse(new GenericAlertComposer(Emulator.getTexts().getValue("camera.permission")));
|
this.client.getHabbo().alert(Emulator.getTexts().getValue("camera.permission"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +40,7 @@ public class CameraRoomThumbnailEvent extends MessageHandler {
|
|||||||
|
|
||||||
ByteBuf image = this.packet.getBuffer().readBytes(count);
|
ByteBuf image = this.packet.getBuffer().readBytes(count);
|
||||||
|
|
||||||
if(image == null)
|
if (image == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -53,16 +50,9 @@ public class CameraRoomThumbnailEvent extends MessageHandler {
|
|||||||
this.packet.readInt();
|
this.packet.readInt();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(Emulator.getConfig().getInt("ftp.enabled") == 1) {
|
|
||||||
byte[] imageBytes = new byte[image.readableBytes()];
|
|
||||||
image.readBytes(imageBytes);
|
|
||||||
FTPUploadService.uploadImage(imageBytes, Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
BufferedImage theImage = null;
|
BufferedImage theImage = null;
|
||||||
theImage = ImageIO.read(new ByteBufInputStream(image));
|
theImage = ImageIO.read(new ByteBufInputStream(image));
|
||||||
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png"));
|
ImageIO.write(theImage, "png", new File(Emulator.getConfig().getValue("imager.location.output.thumbnail") + room.getId() + ".png"));
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -70,7 +60,7 @@ public class CameraRoomThumbnailEvent extends MessageHandler {
|
|||||||
LOGGER.error("[Apollyon] https://git.krews.org/morningstar/apollyon");
|
LOGGER.error("[Apollyon] https://git.krews.org/morningstar/apollyon");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new CameraRoomThumbnailSavedComposer());
|
this.client.sendResponse(new ThumbnailStatusMessageComposer());
|
||||||
} finally {
|
} finally {
|
||||||
ReferenceCountUtil.release(image);
|
ReferenceCountUtil.release(image);
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user