Release bytebuf to prevent leaks, use new logger.

This commit is contained in:
Mike 2020-05-10 18:54:55 +02:00
parent 2eb36ec13a
commit b6c58a0448
2 changed files with 74 additions and 60 deletions

View File

@ -10,6 +10,8 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufInputStream; import io.netty.buffer.ByteBufInputStream;
import javafx.scene.Camera; import javafx.scene.Camera;
import org.krews.apollyon.ftp.FTPUploadService; import org.krews.apollyon.ftp.FTPUploadService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -18,8 +20,9 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.IllegalArgumentException; import java.lang.IllegalArgumentException;
public class CameraRoomPictureEvent extends MessageHandler public class CameraRoomPictureEvent extends MessageHandler {
{ private static final Logger LOGGER = LoggerFactory.getLogger(CameraRoomPictureEvent.class);
@Override @Override
public void handle() { public void handle() {
if (!this.client.getHabbo().hasPermission("acc_camera")) { if (!this.client.getHabbo().hasPermission("acc_camera")) {
@ -38,6 +41,8 @@ public class CameraRoomPictureEvent extends MessageHandler
if (image == null) if (image == null)
return; return;
try {
this.packet.readString(); this.packet.readString();
this.packet.readString(); this.packet.readString();
this.packet.readInt(); this.packet.readInt();
@ -70,10 +75,13 @@ public class CameraRoomPictureEvent extends MessageHandler
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.println("[Apollyon] You are using a Habbo.swf that has not been patched to work with Apollyon. Please read the read me on a guide to patching your swf, or download a prepatched one on our git at:"); LOGGER.error("[Apollyon] You are using a Habbo.swf that has not been patched to work with Apollyon. Please read the read me on a guide to patching your swf, or download a prepatched one on our git at:");
System.out.println("[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 CameraURLComposer(URL));
} finally {
image.release();
}
} }
} }

View File

@ -8,6 +8,8 @@ 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 org.krews.apollyon.ftp.FTPUploadService; import org.krews.apollyon.ftp.FTPUploadService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
@ -15,8 +17,8 @@ import java.awt.image.DataBufferByte;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
public class CameraRoomThumbnailEvent extends MessageHandler public class CameraRoomThumbnailEvent extends MessageHandler {
{ private static final Logger LOGGER = LoggerFactory.getLogger(CameraRoomThumbnailEvent.class);
@Override @Override
public void handle() { public void handle() {
@ -43,6 +45,7 @@ public class CameraRoomThumbnailEvent extends MessageHandler
if(image == null) if(image == null)
return; return;
try {
this.packet.readString(); this.packet.readString();
this.packet.readString(); this.packet.readString();
this.packet.readInt(); this.packet.readInt();
@ -62,10 +65,13 @@ public class CameraRoomThumbnailEvent extends MessageHandler
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
System.out.println("[Apollyon] You are using a Habbo.swf that has not been patched to work with Apollyon. Please read the read me on a guide to patching your swf, or download a prepatched one on our git at:"); LOGGER.error("[Apollyon] You are using a Habbo.swf that has not been patched to work with Apollyon. Please read the read me on a guide to patching your swf, or download a prepatched one on our git at:");
System.out.println("[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 CameraRoomThumbnailSavedComposer());
} finally {
image.release();
}
} }
} }