mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-30 01:50:50 +01:00
Merge branch 'subscription-boxes' into 'dev'
Add subscription boxes See merge request morningstar/Arcturus-Community!32
This commit is contained in:
commit
a87ad2acb1
@ -8,6 +8,10 @@ ADD COLUMN `build_hash` varchar(64) NOT NULL AFTER `version`;
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('scripter.modtool.tickets', '1');
|
||||
|
||||
ALTER TABLE `items_crackable`
|
||||
ADD COLUMN `subscription_duration` int(3) NULL AFTER `required_effect`,
|
||||
ADD COLUMN `subscription_type` varchar(255) NULL COMMENT 'hc for Habbo Club, bc for Builders Club' AFTER `subscription_duration`;
|
||||
|
||||
INSERT INTO `emulator_settings`(`key`, `value`) VALUES ('invisible.prevent.chat', '0');
|
||||
INSERT INTO `emulator_texts`(`key`, `value`) VALUES ('invisible.prevent.chat.error', 'While being invisible you cannot talk.');
|
||||
|
||||
|
@ -17,6 +17,8 @@ public class CrackableReward
|
||||
public final String achievementTick;
|
||||
public final String achievementCracked;
|
||||
public final int requiredEffect;
|
||||
public final int subscriptionDuration;
|
||||
public final RedeemableSubscriptionType subscriptionType;
|
||||
|
||||
public CrackableReward(ResultSet set) throws SQLException
|
||||
{
|
||||
@ -25,10 +27,15 @@ public class CrackableReward
|
||||
this.achievementTick = set.getString("achievement_tick");
|
||||
this.achievementCracked = set.getString("achievement_cracked");
|
||||
this.requiredEffect = set.getInt("required_effect");
|
||||
this.subscriptionDuration = set.getInt("subscription_duration");
|
||||
this.subscriptionType = RedeemableSubscriptionType.fromString(set.getString("subscription_type"));
|
||||
|
||||
|
||||
String[] prizes = set.getString("prizes").split(";");
|
||||
this.prizes = new HashMap<>();
|
||||
|
||||
if (set.getString("prizes").isEmpty()) return;
|
||||
|
||||
this.totalChance = 0;
|
||||
for (String prize : prizes)
|
||||
{
|
||||
@ -59,6 +66,8 @@ public class CrackableReward
|
||||
|
||||
public int getRandomReward()
|
||||
{
|
||||
if (this.prizes.size() == 0) return 0;
|
||||
|
||||
int random = Emulator.getRandom().nextInt(this.totalChance);
|
||||
|
||||
int notFound = 0;
|
||||
|
@ -175,6 +175,7 @@ public class ItemManager
|
||||
this.interactionsList.add(new ItemInteraction("timer", InteractionGameTimer.class));
|
||||
this.interactionsList.add(new ItemInteraction("pressureplate_group", InteractionGroupPressurePlate.class));
|
||||
this.interactionsList.add(new ItemInteraction("effect_tile_group", InteractionEffectTile.class));
|
||||
this.interactionsList.add(new ItemInteraction("crackable_subscription_box", InteractionRedeemableSubscriptionBox.class));
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.eu.habbo.habbohotel.items;
|
||||
|
||||
public enum RedeemableSubscriptionType {
|
||||
HABBO_CLUB("hc"),
|
||||
BUILDERS_CLUB("bc");
|
||||
|
||||
public final String subscriptionType;
|
||||
|
||||
RedeemableSubscriptionType(String subscriptionType)
|
||||
{
|
||||
this.subscriptionType = subscriptionType;
|
||||
}
|
||||
|
||||
public static RedeemableSubscriptionType fromString(String subscriptionType) {
|
||||
switch (subscriptionType) {
|
||||
case "hc":
|
||||
return HABBO_CLUB;
|
||||
case "bc":
|
||||
return BUILDERS_CLUB;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -11,6 +11,8 @@ import com.eu.habbo.habbohotel.users.Habbo;
|
||||
import com.eu.habbo.habbohotel.users.HabboGender;
|
||||
import com.eu.habbo.habbohotel.users.HabboItem;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.users.UserClubComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer;
|
||||
import com.eu.habbo.threading.runnables.CrackableExplode;
|
||||
import com.eu.habbo.util.pathfinding.Rotation;
|
||||
|
||||
@ -77,7 +79,7 @@ public class InteractionCrackable extends HabboItem
|
||||
if (this.cracked)
|
||||
return;
|
||||
|
||||
if (client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5)
|
||||
if (this.userRequiredToBeAdjacent() && client.getHabbo().getRoomUnit().getCurrentLocation().distance(room.getLayout().getTile(this.getX(), this.getY())) > 1.5)
|
||||
{
|
||||
client.getHabbo().getRoomUnit().setGoalLocation(room.getLayout().getTileInFront(room.getLayout().getTile(this.getX(), this.getY()), Rotation.Calculate(client.getHabbo().getRoomUnit().getX(), client.getHabbo().getRoomUnit().getY(), this.getX(), this.getY())));
|
||||
return;
|
||||
@ -129,6 +131,24 @@ public class InteractionCrackable extends HabboItem
|
||||
{
|
||||
AchievementManager.progressAchievement(habbo, Emulator.getGameEnvironment().getAchievementManager().getAchievement(rewardData.achievementCracked));
|
||||
}
|
||||
|
||||
if (rewardData.subscriptionType != null && rewardData.subscriptionDuration > 0) {
|
||||
// subscriptions are given immediately upon cracking
|
||||
switch (rewardData.subscriptionType) {
|
||||
case HABBO_CLUB:
|
||||
if (habbo.getHabboStats().getClubExpireTimestamp() <= Emulator.getIntUnixTimestamp())
|
||||
habbo.getHabboStats().setClubExpireTimestamp(Emulator.getIntUnixTimestamp());
|
||||
|
||||
habbo.getHabboStats().setClubExpireTimestamp(habbo.getHabboStats().getClubExpireTimestamp() + (rewardData.subscriptionDuration * 86400));
|
||||
habbo.getClient().sendResponse(new UserPermissionsComposer(habbo));
|
||||
habbo.getClient().sendResponse(new UserClubComposer(habbo));
|
||||
habbo.getHabboStats().run();
|
||||
break;
|
||||
case BUILDERS_CLUB:
|
||||
habbo.alert("Builders club has not been implemented yet. Sorry!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -167,6 +187,10 @@ public class InteractionCrackable extends HabboItem
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean userRequiredToBeAdjacent() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void reset(Room room)
|
||||
{
|
||||
this.cracked = false;
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.eu.habbo.habbohotel.items.interactions;
|
||||
|
||||
import com.eu.habbo.Emulator;
|
||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||
import com.eu.habbo.habbohotel.items.Item;
|
||||
import com.eu.habbo.habbohotel.items.RedeemableSubscriptionType;
|
||||
import com.eu.habbo.habbohotel.rooms.Room;
|
||||
import com.eu.habbo.messages.ServerMessage;
|
||||
import com.eu.habbo.messages.outgoing.users.UserClubComposer;
|
||||
import com.eu.habbo.messages.outgoing.users.UserPermissionsComposer;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
public class InteractionRedeemableSubscriptionBox extends InteractionCrackable {
|
||||
public InteractionRedeemableSubscriptionBox(ResultSet set, Item baseItem) throws SQLException {
|
||||
super(set, baseItem);
|
||||
}
|
||||
|
||||
public InteractionRedeemableSubscriptionBox(int id, int userId, Item item, String extradata, int limitedStack, int limitedSells) {
|
||||
super(id, userId, item, extradata, limitedStack, limitedSells);
|
||||
}
|
||||
|
||||
public boolean userRequiredToBeAdjacent() {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -42,7 +42,7 @@ public class CrackableExplode implements Runnable
|
||||
if (!this.habboItem.resetable())
|
||||
{
|
||||
this.room.removeHabboItem(this.habboItem);
|
||||
this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem).compose());
|
||||
this.room.sendComposer(new RemoveFloorItemComposer(this.habboItem, true).compose());
|
||||
this.habboItem.setRoomId(0);
|
||||
Emulator.getGameEnvironment().getItemManager().deleteItem(this.habboItem);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user