Merge branch 'dev' into 'wired-to-json'

# Conflicts:
#   sqlupdates/2_4_0 to 3_0_BETA_1.sql
This commit is contained in:
Harmonic 2021-01-10 18:06:29 -05:00
commit 934741ea16
6 changed files with 185 additions and 28 deletions

View File

@ -101,6 +101,8 @@ INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('commands.error.cmd_subscr
INSERT INTO `emulator_texts` (`key`, `value`) VALUES ('subscriptions.hc.payday.message', 'Woohoo HC Payday has arrived! You have received %amount% credits to your purse. Enjoy!');
INSERT INTO `emulator_settings` (`key`, `value`) VALUES ('hotel.roomuser.idle.not_dancing.ignore.wired_idle', '0');
-- OPTIONAL HC MIGRATION
-- INSERT INTO users_subscriptions SELECT NULL, user_id, 'HABBO_CLUB' as `subscription_type`, UNIX_TIMESTAMP() AS `timestamp_start`, (club_expire_timestamp - UNIX_TIMESTAMP()) AS `duration`, 1 AS `active` FROM users_settings WHERE club_expire_timestamp > UNIX_TIMESTAMP();

View File

@ -217,6 +217,7 @@ public class CommandHandler {
addCommand(new LayCommand());
addCommand(new MachineBanCommand());
addCommand(new MassBadgeCommand());
addCommand(new RoomBadgeCommand());
addCommand(new MassCreditsCommand());
addCommand(new MassGiftCommand());
addCommand(new MassPixelsCommand());

View File

@ -0,0 +1,54 @@
package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboBadge;
import com.eu.habbo.habbohotel.users.inventory.BadgesComponent;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertKeys;
import com.eu.habbo.messages.outgoing.users.AddUserBadgeComposer;
import gnu.trove.map.hash.THashMap;
public class RoomBadgeCommand extends Command {
public RoomBadgeCommand() {
super("cmd_roombadge", Emulator.getTexts().getValue("commands.keys.cmd_roombadge").split(";"));
}
@Override
public boolean handle(GameClient gameClient, String[] params) throws Exception {
if (gameClient == null)
return true;
if (params.length == 2) {
String badge;
badge = params[1];
if (!badge.isEmpty()) {
THashMap<String, String> keys = new THashMap<>();
keys.put("display", "BUBBLE");
keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
for (Habbo habbo : gameClient.getHabbo().getRoomUnit().getRoom().getHabbos()) {
if (habbo.isOnline()) {
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
habbo.getClient().sendResponse(message);
}
}
}
}
return true;
}
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_roombadge.no_badge"), RoomChatMessageBubbles.ALERT);
return true;
}
}

View File

@ -1,5 +1,6 @@
package com.eu.habbo.habbohotel.items.interactions;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.bots.Bot;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
@ -7,6 +8,8 @@ import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.rooms.RoomUnitType;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboGender;
import com.eu.habbo.habbohotel.wired.WiredHandler;
import com.eu.habbo.habbohotel.wired.WiredTriggerType;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -32,7 +35,11 @@ public class InteractionEffectTile extends InteractionPressurePlate {
@Override
public void onWalkOff(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
super.onWalkOff(roomUnit, room, objects);
Emulator.getThreading().run(() -> updateState(room), 100);
if(objects != null && objects.length > 0) {
WiredHandler.handle(WiredTriggerType.WALKS_OFF_FURNI, roomUnit, room, new Object[]{this});
}
}
@Override

View File

@ -5,14 +5,28 @@ import com.eu.habbo.habbohotel.achievements.AchievementManager;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.Item;
import com.eu.habbo.habbohotel.rooms.Room;
import com.eu.habbo.habbohotel.rooms.RoomLayout;
import com.eu.habbo.habbohotel.rooms.RoomTile;
import com.eu.habbo.habbohotel.rooms.RoomUnit;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.ServerMessage;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.wired.WiredEffectType;
import com.eu.habbo.threading.runnables.RoomUnitWalkToLocation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
public class InteractionFireworks extends InteractionDefault {
private static final Logger LOGGER = LoggerFactory.getLogger(InteractionFireworks.class);
private static final String STATE_EMPTY = "0"; // Not used since the removal of pixels
private static final String STATE_CHARGED = "1";
private static final String STATE_EXPLOSION = "2";
public class InteractionFireworks extends HabboItem {
public InteractionFireworks(ResultSet set, Item baseItem) throws SQLException {
super(set, baseItem);
}
@ -26,35 +40,103 @@ public class InteractionFireworks extends HabboItem {
return false;
}
@Override
public boolean isWalkable() {
return this.getBaseItem().allowWalk();
}
@Override
public void onWalk(RoomUnit roomUnit, Room room, Object[] objects) throws Exception {
}
@Override
public void serializeExtradata(ServerMessage serverMessage) {
serverMessage.appendInt((this.isLimited() ? 256 : 0));
serverMessage.appendString(this.getExtradata());
super.serializeExtradata(serverMessage); //Design flaw ;(
}
/**
* Checked in Habbo on 2021-01-03
* - Fireworks should be charged to be able to detonate them
* - Habbos with Rights can detonate fireworks from anywhere in a room
* - Habbos without rights have to walk to an adjecent tile to be able to detonate (see Interaction Switch)
* - Wired can always detonate fireworks
*/
@Override
public void onClick(GameClient client, Room room, Object[] objects) throws Exception {
super.onClick(client, room, objects);
if (room == null)
return;
if (client != null && this.getExtradata().equalsIgnoreCase("2")) //2 explodes I think (0 = empty, 1 = charged, 2 = effect)
{
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
// Wireds can always detonate fireworks if charged
if (objects.length >= 2 && objects[1] instanceof WiredEffectType && objects[1] == WiredEffectType.TOGGLE_STATE) {
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
super.onClick(client, room, objects);
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION)) {
this.reCharge(room);
}
}
return;
}
if (client == null)
return;
// Habbos without rights have to walk to an adjecent tile to be able to detonate the fireworks
if (!this.canToggle(client.getHabbo(), room)) {
RoomTile closestTile = null;
for (RoomTile tile : room.getLayout().getTilesAround(room.getLayout().getTile(this.getX(), this.getY()))) {
if (tile.isWalkable() && (closestTile == null || closestTile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()) > tile.distance(client.getHabbo().getRoomUnit().getCurrentLocation()))) {
closestTile = tile;
}
}
if (closestTile != null && !closestTile.equals(client.getHabbo().getRoomUnit().getCurrentLocation())) {
List<Runnable> onSuccess = new ArrayList<>();
onSuccess.add(() -> {
try {
this.onClick(client, room, objects);
} catch (Exception e) {
e.printStackTrace();
}
});
client.getHabbo().getRoomUnit().setGoalLocation(closestTile);
Emulator.getThreading().run(new RoomUnitWalkToLocation(client.getHabbo().getRoomUnit(), closestTile, room, onSuccess, new ArrayList<>()));
}
}
if (this.getExtradata().equalsIgnoreCase(STATE_CHARGED)) {
super.onClick(client, room, objects);
if (this.getExtradata().equalsIgnoreCase(STATE_EXPLOSION))
{
this.reCharge(room);
AchievementManager.progressAchievement(client.getHabbo(), Emulator.getGameEnvironment().getAchievementManager().getAchievement("FireworksCharger"));
}
}
}
@Override
public boolean allowWiredResetState() {
return true;
return false;
}
@Override
public void onPlace(Room room) {
super.onPlace(room);
this.setExtradata(STATE_CHARGED);
}
@Override
public boolean canToggle(Habbo habbo, Room room) {
return room.hasRights(habbo) || RoomLayout.tilesAdjecent(
room.getLayout().getTile(this.getX(), this.getY()),
habbo.getRoomUnit().getCurrentLocation()
);
}
private void reCharge(Room room) {
// Default = 5000, Nuclear Firework should have 10000 in its custom params according to Habbo
int explodeDuration = 5000;
if (!this.getBaseItem().getCustomParams().isEmpty()) {
try {
explodeDuration = Integer.parseInt(this.getBaseItem().getCustomParams());
} catch (NumberFormatException e) {
LOGGER.error("Incorrect customparams (" + this.getBaseItem().getCustomParams() + ") for base item ID (" + this.getBaseItem().getId() + ") of type (" + this.getBaseItem().getName() + ")");
}
}
Emulator.getThreading().run(() -> {
this.setExtradata(STATE_CHARGED);
this.needsUpdate(true);
room.updateItemState(this);
}, explodeDuration);
}
}

View File

@ -383,6 +383,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.updateItem(item);
}
}
for (HabboItem item : this.roomSpecialTypes.getItemsOfType(InteractionFireworks.class)) {
item.setExtradata("1");
this.updateItem(item);
}
}
Emulator.getPluginManager().fireEvent(new RoomLoadedEvent(this));
@ -1205,8 +1210,11 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
habbo.getRoomUnit().increaseIdleTimer();
if (habbo.getRoomUnit().isIdle()) {
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
boolean danceIsNone = (habbo.getRoomUnit().getDanceType() == DanceType.NONE);
if (danceIsNone)
this.sendComposer(new RoomUnitIdleComposer(habbo.getRoomUnit()).compose());
if (danceIsNone && !Emulator.getConfig().getBoolean("hotel.roomuser.idle.not_dancing.ignore.wired_idle"))
WiredHandler.handle(WiredTriggerType.IDLES, habbo.getRoomUnit(), this, new Object[]{habbo});
}
} else {
habbo.getRoomUnit().increaseIdleTimer();
@ -2419,7 +2427,10 @@ public class Room implements Comparable<Room>, ISerialize, Runnable {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionSnowboardSlope) {
this.roomSpecialTypes.addUndefined(item);
} else if (item instanceof InteractionFireworks) {
this.roomSpecialTypes.addUndefined(item);
}
}
}