From 66bab74a10fd7886cc173f5d537705feafb5851d Mon Sep 17 00:00:00 2001 From: Alejandro <25-alejandro@users.noreply.git.krews.org> Date: Fri, 17 May 2019 21:22:27 +0300 Subject: [PATCH] Make discounts configurable from database --- sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql | 6 ++++++ src/main/java/com/eu/habbo/plugin/PluginManager.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql index c49c2386..35f7b2c6 100644 --- a/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql +++ b/sqlupdates/2_0_0-RC-2_TO_2_0_0-RC-3.sql @@ -21,4 +21,10 @@ INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('commands.error.cmd_mimic.f ALTER TABLE `permissions` ADD COLUMN `acc_mimic_unredeemed` enum('0','1') NOT NULL DEFAULT '0'; +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.max.allowed.items', '100'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.batch.size', '6'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.batch.free.items', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.bonus.min.discounts', '1'); +INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('discount.additional.thresholds', '40;99'); + #END DATABASE UPDATE: 2.0.0 RC-2 -> 2.0.0 RC-3 diff --git a/src/main/java/com/eu/habbo/plugin/PluginManager.java b/src/main/java/com/eu/habbo/plugin/PluginManager.java index 98fefed4..cdae96d8 100644 --- a/src/main/java/com/eu/habbo/plugin/PluginManager.java +++ b/src/main/java/com/eu/habbo/plugin/PluginManager.java @@ -24,6 +24,7 @@ import com.eu.habbo.habbohotel.wired.WiredHandler; import com.eu.habbo.messages.PacketManager; import com.eu.habbo.messages.incoming.floorplaneditor.FloorPlanEditorSaveEvent; import com.eu.habbo.messages.incoming.hotelview.HotelViewRequestLTDAvailabilityEvent; +import com.eu.habbo.messages.outgoing.catalog.DiscountComposer; import com.eu.habbo.plugin.events.emulator.EmulatorConfigUpdatedEvent; import com.eu.habbo.plugin.events.roomunit.RoomUnitLookAtPointEvent; import com.eu.habbo.plugin.events.users.*; @@ -42,6 +43,7 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Objects; @@ -332,6 +334,11 @@ public class PluginManager RoomTrade.TRADING_ENABLED = Emulator.getConfig().getBoolean("hotel.trading.enabled") && !ShutdownEmulator.instantiated; RoomTrade.TRADING_REQUIRES_PERK = Emulator.getConfig().getBoolean("hotel.trading.requires.perk"); WordFilter.ENABLED_FRIENDCHAT = Emulator.getConfig().getBoolean("hotel.wordfilter.messenger"); + DiscountComposer.MAXIMUM_ALLOWED_ITEMS = Emulator.getConfig().getInt("discount.max.allowed.items", 100); + DiscountComposer.DISCOUNT_BATCH_SIZE = Emulator.getConfig().getInt("discount.batch.size", 6); + DiscountComposer.DISCOUNT_AMOUNT_PER_BATCH = Emulator.getConfig().getInt("discount.batch.free.items", 1); + DiscountComposer.MINIMUM_DISCOUNTS_FOR_BONUS = Emulator.getConfig().getInt("discount.bonus.min.discounts", 1); + DiscountComposer.ADDITIONAL_DISCOUNT_THRESHOLDS = Arrays.stream(Emulator.getConfig().getValue("discount.additional.thresholds", "40;99").split(";")).mapToInt(Integer::parseInt).toArray(); BotManager.MINIMUM_CHAT_SPEED = Emulator.getConfig().getInt("hotel.bot.chat.minimum.interval"); BotManager.MAXIMUM_CHAT_LENGTH = Emulator.getConfig().getInt("hotel.bot.max.chatlength");