mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 09:50:51 +01:00
Make publishing pictures deduct duckets and make publish & purchase point type configurable
This commit is contained in:
parent
52209e52bd
commit
593bb74532
3
sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
Normal file
3
sqlupdates/2_3_0-RC-1_TO_2_3_0-RC-2.sql
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish', '5');
|
||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.publish.type', '0');
|
||||||
|
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('camera.price.points.type', '0');
|
@ -1,8 +1,10 @@
|
|||||||
package com.eu.habbo.messages.incoming.camera;
|
package com.eu.habbo.messages.incoming.camera;
|
||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
|
import com.eu.habbo.habbohotel.users.Habbo;
|
||||||
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.CameraPublishWaitMessageComposer;
|
||||||
|
import com.eu.habbo.messages.outgoing.catalog.NotEnoughPointsTypeComposer;
|
||||||
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
|
import com.eu.habbo.plugin.events.users.UserPublishPictureEvent;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@ -10,20 +12,31 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class CameraPublishToWebEvent extends MessageHandler {
|
public class CameraPublishToWebEvent extends MessageHandler {
|
||||||
|
public static int CAMERA_PUBLISH_POINTS = 5;
|
||||||
|
public static int CAMERA_PUBLISH_POINTS_TYPE = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
|
Habbo habbo = this.client.getHabbo();
|
||||||
if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) {
|
|
||||||
if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) {
|
if (habbo == null) return;
|
||||||
|
if (habbo.getHabboInfo().getPhotoTimestamp() == 0) return;
|
||||||
|
if (habbo.getHabboInfo().getPhotoJSON().isEmpty()) return;
|
||||||
|
if (!habbo.getHabboInfo().getPhotoJSON().contains(habbo.getHabboInfo().getPhotoTimestamp() + "")) return;
|
||||||
|
|
||||||
|
if (habbo.getHabboInfo().getCurrencyAmount(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE) < CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS) {
|
||||||
|
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int timestamp = Emulator.getIntUnixTimestamp();
|
int timestamp = Emulator.getIntUnixTimestamp();
|
||||||
|
|
||||||
boolean published = false;
|
boolean isOk = false;
|
||||||
int timeDiff = timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp();
|
int cooldownLeft = Math.max(0, Emulator.getConfig().getInt("camera.publish.delay") - (timestamp - this.client.getHabbo().getHabboInfo().getWebPublishTimestamp()));
|
||||||
int wait = 0;
|
|
||||||
if (timeDiff < Emulator.getConfig().getInt("camera.publish.delay")) {
|
if (cooldownLeft == 0) {
|
||||||
wait = timeDiff - Emulator.getConfig().getInt("camera.publish.delay");
|
|
||||||
} 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());
|
||||||
@ -31,19 +44,17 @@ public class CameraPublishToWebEvent extends MessageHandler {
|
|||||||
statement.setInt(3, publishPictureEvent.timestamp);
|
statement.setInt(3, publishPictureEvent.timestamp);
|
||||||
statement.setString(4, publishPictureEvent.URL);
|
statement.setString(4, publishPictureEvent.URL);
|
||||||
statement.execute();
|
statement.execute();
|
||||||
|
|
||||||
this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
|
this.client.getHabbo().getHabboInfo().setWebPublishTimestamp(timestamp);
|
||||||
published = true;
|
this.client.getHabbo().givePoints(CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE, -CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS);
|
||||||
|
|
||||||
|
isOk = true;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Emulator.getLogging().logSQLException(e);
|
Emulator.getLogging().logSQLException(e);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.client.sendResponse(new CameraPublishWaitMessageComposer(published, wait, published ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
|
this.client.sendResponse(new CameraPublishWaitMessageComposer(isOk, cooldownLeft, isOk ? this.client.getHabbo().getHabboInfo().getPhotoURL() : ""));
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,15 +11,27 @@ import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
|
|||||||
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
|
import com.eu.habbo.plugin.events.users.UserPurchasePictureEvent;
|
||||||
|
|
||||||
public class CameraPurchaseEvent extends MessageHandler {
|
public class CameraPurchaseEvent extends MessageHandler {
|
||||||
|
public static int CAMERA_PURCHASE_CREDITS = 5;
|
||||||
|
public static int CAMERA_PURCHASE_POINTS = 5;
|
||||||
|
public static int CAMERA_PURCHASE_POINTS_TYPE = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handle() throws Exception {
|
public void handle() throws Exception {
|
||||||
if (this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits") || this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points")) {
|
if (this.client.getHabbo().getHabboInfo().getCredits() < CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS) {
|
||||||
this.client.sendResponse(new NotEnoughPointsTypeComposer(this.client.getHabbo().getHabboInfo().getCredits() < Emulator.getConfig().getInt("camera.price.credits"), this.client.getHabbo().getHabboInfo().getCurrencyAmount(0) < Emulator.getConfig().getInt("camera.price.points"), 0));
|
this.client.sendResponse(new NotEnoughPointsTypeComposer(true, false, 0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() != 0) {
|
|
||||||
if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) {
|
if (this.client.getHabbo().getHabboInfo().getCurrencyAmount(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE) < CameraPurchaseEvent.CAMERA_PURCHASE_POINTS) {
|
||||||
if (this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + "")) {
|
this.client.sendResponse(new NotEnoughPointsTypeComposer(false, true, CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.client.getHabbo().getHabboInfo().getPhotoTimestamp() == 0) return;
|
||||||
|
if (this.client.getHabbo().getHabboInfo().getPhotoJSON().isEmpty()) return;
|
||||||
|
if (!this.client.getHabbo().getHabboInfo().getPhotoJSON().contains(this.client.getHabbo().getHabboInfo().getPhotoTimestamp() + ""))
|
||||||
|
return;
|
||||||
|
|
||||||
if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) {
|
if (Emulator.getPluginManager().fireEvent(new UserPurchasePictureEvent(this.client.getHabbo(), this.client.getHabbo().getHabboInfo().getPhotoURL(), this.client.getHabbo().getHabboInfo().getCurrentRoom().getId(), this.client.getHabbo().getHabboInfo().getPhotoTimestamp())).isCancelled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -29,16 +41,17 @@ public class CameraPurchaseEvent extends MessageHandler {
|
|||||||
if (photoItem != null) {
|
if (photoItem != null) {
|
||||||
photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + ""));
|
photoItem.setExtradata(photoItem.getExtradata().replace("%id%", photoItem.getId() + ""));
|
||||||
photoItem.needsUpdate(true);
|
photoItem.needsUpdate(true);
|
||||||
|
|
||||||
this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
|
this.client.getHabbo().getInventory().getItemsComponent().addItem(photoItem);
|
||||||
|
|
||||||
this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
|
this.client.sendResponse(new CameraPurchaseSuccesfullComposer());
|
||||||
this.client.sendResponse(new AddHabboItemComposer(photoItem));
|
this.client.sendResponse(new AddHabboItemComposer(photoItem));
|
||||||
this.client.sendResponse(new InventoryRefreshComposer());
|
this.client.sendResponse(new InventoryRefreshComposer());
|
||||||
this.client.getHabbo().giveCredits(-Emulator.getConfig().getInt("camera.price.credits"));
|
|
||||||
this.client.getHabbo().givePixels(-Emulator.getConfig().getInt("camera.price.points"));
|
this.client.getHabbo().giveCredits(-CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS);
|
||||||
|
this.client.getHabbo().givePoints(CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE, -CameraPurchaseEvent.CAMERA_PURCHASE_POINTS);
|
||||||
|
|
||||||
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"));
|
AchievementManager.progressAchievement(this.client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("CameraPhotoCount"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,25 +5,27 @@ import com.eu.habbo.messages.outgoing.MessageComposer;
|
|||||||
import com.eu.habbo.messages.outgoing.Outgoing;
|
import com.eu.habbo.messages.outgoing.Outgoing;
|
||||||
|
|
||||||
public class CameraPublishWaitMessageComposer extends MessageComposer {
|
public class CameraPublishWaitMessageComposer extends MessageComposer {
|
||||||
public final boolean published;
|
public final boolean isOk;
|
||||||
public final int seconds;
|
public final int cooldownSeconds;
|
||||||
public final String unknownString;
|
public final String extraDataId;
|
||||||
|
|
||||||
public CameraPublishWaitMessageComposer(boolean published, int seconds, String unknownString) {
|
public CameraPublishWaitMessageComposer(boolean isOk, int cooldownSeconds, String extraDataId) {
|
||||||
this.published = published;
|
this.isOk = isOk;
|
||||||
this.seconds = seconds;
|
this.cooldownSeconds = cooldownSeconds;
|
||||||
this.unknownString = unknownString;
|
this.extraDataId = extraDataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServerMessage compose() {
|
public ServerMessage compose() {
|
||||||
this.response.init(Outgoing.CameraPublishWaitMessageComposer);
|
this.response.init(Outgoing.CameraPublishWaitMessageComposer);
|
||||||
this.response.appendBoolean(this.published);
|
|
||||||
this.response.appendInt(this.seconds);
|
|
||||||
|
|
||||||
if (this.published) {
|
this.response.appendBoolean(this.isOk);
|
||||||
this.response.appendString(this.unknownString);
|
this.response.appendInt(this.cooldownSeconds);
|
||||||
|
|
||||||
|
if (!this.extraDataId.isEmpty()) {
|
||||||
|
this.response.appendString(this.extraDataId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.response;
|
return this.response;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,8 @@ import com.eu.habbo.habbohotel.users.HabboManager;
|
|||||||
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
import com.eu.habbo.habbohotel.wired.WiredHandler;
|
||||||
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
|
import com.eu.habbo.habbohotel.wired.highscores.WiredHighscoreManager;
|
||||||
import com.eu.habbo.messages.PacketManager;
|
import com.eu.habbo.messages.PacketManager;
|
||||||
|
import com.eu.habbo.messages.incoming.camera.CameraPublishToWebEvent;
|
||||||
|
import com.eu.habbo.messages.incoming.camera.CameraPurchaseEvent;
|
||||||
import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent;
|
import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent;
|
||||||
import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent;
|
import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent;
|
||||||
import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent;
|
import com.eu.habbo.messages.incoming.users.ChangeNameCheckUsernameEvent;
|
||||||
@ -124,6 +126,11 @@ public class PluginManager {
|
|||||||
RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics");
|
RoomManager.SHOW_PUBLIC_IN_POPULAR_TAB = Emulator.getConfig().getBoolean("hotel.navigator.populartab.publics");
|
||||||
|
|
||||||
ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.username.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,.");
|
ChangeNameCheckUsernameEvent.VALID_CHARACTERS = Emulator.getConfig().getValue("allowed.username.characters", "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-=!?@:,.");
|
||||||
|
CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS = Emulator.getConfig().getInt("camera.price.points.publish", 5);
|
||||||
|
CameraPublishToWebEvent.CAMERA_PUBLISH_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.publish.type", 0);
|
||||||
|
CameraPurchaseEvent.CAMERA_PURCHASE_CREDITS = Emulator.getConfig().getInt("camera.price.credits", 5);
|
||||||
|
CameraPurchaseEvent.CAMERA_PURCHASE_POINTS = Emulator.getConfig().getInt("camera.price.points", 5);
|
||||||
|
CameraPurchaseEvent.CAMERA_PURCHASE_POINTS_TYPE = Emulator.getConfig().getInt("camera.price.points.type", 0);
|
||||||
|
|
||||||
if (Emulator.isReady) {
|
if (Emulator.isReady) {
|
||||||
Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig();
|
Emulator.getGameEnvironment().getCreditsScheduler().reloadConfig();
|
||||||
|
Loading…
Reference in New Issue
Block a user