Fix more issues.

This commit is contained in:
Mike 2020-05-10 00:02:46 +02:00
parent 4c140d9402
commit 463fb82654
5 changed files with 62 additions and 35 deletions

View File

@ -35,12 +35,18 @@ public class EventCommand extends Command {
ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose(); ServerMessage msg = new BubbleAlertComposer("hotel.event", codes).compose();
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { msg.retain();
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(msg); try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(msg);
}
} finally {
msg.release();
} }
return true; return true;

View File

@ -32,21 +32,25 @@ public class MassBadgeCommand extends Command {
keys.put("image", "${image.library.url}album1584/" + badge + ".gif"); keys.put("image", "${image.library.url}album1584/" + badge + ".gif");
keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received")); keys.put("message", Emulator.getTexts().getValue("commands.generic.cmd_badge.received"));
ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); ServerMessage message = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
message.retain();
try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { if (habbo.isOnline()) {
Habbo habbo = set.getValue(); if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) {
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
if (habbo.isOnline()) { if (b != null) {
if (habbo.getInventory() != null && habbo.getInventory().getBadgesComponent() != null && !habbo.getInventory().getBadgesComponent().hasBadge(badge)) { habbo.getClient().sendResponse(new AddUserBadgeComposer(b));
HabboBadge b = BadgesComponent.createBadge(badge, habbo);
if (b != null) { habbo.getClient().sendResponse(message);
habbo.getClient().sendResponse(new AddUserBadgeComposer(b)); }
habbo.getClient().sendResponse(message);
} }
} }
} }
} finally {
message.release();
} }
} }
return true; return true;

View File

@ -60,20 +60,26 @@ public class MassGiftCommand extends Command {
ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose(); ServerMessage giftNotificiationMessage = new BubbleAlertComposer(BubbleAlertKeys.RECEIVED_BADGE.key, keys).compose();
Emulator.getThreading().run(() -> { Emulator.getThreading().run(() -> {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { giftNotificiationMessage.retain();
Habbo habbo = set.getValue();
HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, ""); try {
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
Habbo habbo = set.getValue();
Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]); HabboItem item = Emulator.getGameEnvironment().getItemManager().createItem(0, baseItem, 0, 0, "");
String extraData = "1\t" + item.getId(); Item giftItem = Emulator.getGameEnvironment().getItemManager().getItem((Integer) Emulator.getGameEnvironment().getCatalogManager().giftFurnis.values().toArray()[Emulator.getRandom().nextInt(Emulator.getGameEnvironment().getCatalogManager().giftFurnis.size())]);
extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0); String extraData = "1\t" + item.getId();
extraData += "\t0\t0\t0\t" + finalMessage + "\t0\t0";
habbo.getClient().sendResponse(new InventoryRefreshComposer()); Emulator.getGameEnvironment().getItemManager().createGift(habbo.getHabboInfo().getUsername(), giftItem, extraData, 0, 0);
habbo.getClient().sendResponse(giftNotificiationMessage);
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(giftNotificiationMessage);
}
} finally {
giftNotificiationMessage.release();
} }
}); });

View File

@ -43,12 +43,17 @@ public class ImageHotelAlert extends RCONMessage<ImageHotelAlert.JSON> {
} }
ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose(); ServerMessage message = new BubbleAlertComposer(json.bubble_key, keys).compose();
for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) { message.retain();
Habbo habbo = set.getValue(); try {
if (habbo.getHabboStats().blockStaffAlerts) for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
continue; Habbo habbo = set.getValue();
if (habbo.getHabboStats().blockStaffAlerts)
continue;
habbo.getClient().sendResponse(message); habbo.getClient().sendResponse(message);
}
} finally {
message.release();
} }
} }

View File

@ -33,18 +33,24 @@ public class CannonKickAction implements Runnable {
dater.put("title", "${notification.room.kick.cannonball.title}"); dater.put("title", "${notification.room.kick.cannonball.title}");
dater.put("message", "${notification.room.kick.cannonball.message}"); dater.put("message", "${notification.room.kick.cannonball.message}");
ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
int rotation = this.cannon.getRotation(); int rotation = this.cannon.getRotation();
List<RoomTile> tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3); List<RoomTile> tiles = this.room.getLayout().getTilesInFront(this.room.getLayout().getTile(this.cannon.getX(), this.cannon.getY()), rotation + 6, 3);
for (RoomTile t : tiles) { ServerMessage message = new BubbleAlertComposer("cannon.png", dater).compose();
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) { message.retain();
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
habbo.getClient().sendResponse(message); //kicked composer try {
for (RoomTile t : tiles) {
for (Habbo habbo : this.room.getHabbosAt(t.x, t.y)) {
if (!habbo.hasPermission(Permission.ACC_UNKICKABLE) && !this.room.isOwner(habbo)) {
Emulator.getGameEnvironment().getRoomManager().leaveRoom(habbo, this.room);
habbo.getClient().sendResponse(message); //kicked composer
}
} }
} }
} finally {
message.release();
} }
} }
} }