Merge branch 'empty-fixes' into 'dev'

Fixed Empty Commands, Added %username% to Succes** Message.

See merge request morningstar/Arcturus-Community!262
This commit is contained in:
Harmonic 2020-07-28 12:46:14 -04:00
commit 84689f8786
3 changed files with 27 additions and 37 deletions

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.inventory.InventoryBotsComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
@ -30,26 +31,24 @@ public class EmptyBotsInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
Habbo habbo = gameClient.getHabbo();
if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
}
Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap<Bot> bots = new TIntObjectHashMap<>();
bots.putAll(habbo.getInventory().getBotsComponent().getBots());
habbo.getInventory().getBotsComponent().getBots().clear();
bots.forEachValue(new TObjectProcedure<Bot>() {
@Override
public boolean execute(Bot object) {
bots.forEachValue(object -> {
Emulator.getGameEnvironment().getBotManager().deleteBot(object);
return true;
}
});
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(new InventoryBotsComposer(habbo));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.cleared"), RoomChatMessageBubbles.ALERT);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_bots.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty_bots"), RoomChatMessageBubbles.ALERT);
}
}

View File

@ -2,10 +2,8 @@ package com.eu.habbo.habbohotel.commands;
import com.eu.habbo.Emulator;
import com.eu.habbo.habbohotel.gameclients.GameClient;
import com.eu.habbo.habbohotel.items.interactions.InteractionJukeBox;
import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.rooms.TraxManager;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.habbohotel.users.HabboItem;
import com.eu.habbo.messages.outgoing.inventory.InventoryItemsComposer;
@ -34,28 +32,21 @@ public class EmptyInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
Habbo habbo = gameClient.getHabbo();
if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
}
Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectMap<HabboItem> items = new TIntObjectHashMap<>();
items.putAll(habbo.getInventory().getItemsComponent().getItems());
habbo.getInventory().getItemsComponent().getItems().clear();
for (HabboItem item : items.valueCollection()) {
if(item instanceof InteractionJukeBox)
TraxManager.removeAllSongs((InteractionJukeBox) item);
}
Emulator.getThreading().run(new QueryDeleteHabboItems(items));
habbo.getClient().sendResponse(new InventoryRefreshComposer());
habbo.getClient().sendResponse(new InventoryItemsComposer(0, 1, gameClient.getHabbo().getInventory().getItemsComponent().getItems()));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared"), RoomChatMessageBubbles.ALERT);
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty"), RoomChatMessageBubbles.ALERT);
}
}

View File

@ -6,6 +6,7 @@ import com.eu.habbo.habbohotel.permissions.Permission;
import com.eu.habbo.habbohotel.pets.Pet;
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
import com.eu.habbo.habbohotel.users.Habbo;
import com.eu.habbo.messages.outgoing.inventory.InventoryPetsComposer;
import com.eu.habbo.messages.outgoing.inventory.InventoryRefreshComposer;
import gnu.trove.map.hash.TIntObjectHashMap;
import gnu.trove.procedure.TObjectProcedure;
@ -30,25 +31,24 @@ public class EmptyPetsInventoryCommand extends Command {
}
if (params.length >= 2 && params[1].equalsIgnoreCase(Emulator.getTexts().getValue("generic.yes"))) {
Habbo habbo = gameClient.getHabbo();
if (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) {
habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]);
}
Habbo habbo = (params.length == 3 && gameClient.getHabbo().hasPermission(Permission.ACC_EMPTY_OTHERS)) ? Emulator.getGameEnvironment().getHabboManager().getHabbo(params[2]) : gameClient.getHabbo();
if (habbo != null) {
TIntObjectHashMap<Pet> pets = new TIntObjectHashMap<>();
pets.putAll(habbo.getInventory().getPetsComponent().getPets());
habbo.getInventory().getPetsComponent().getPets().clear();
pets.forEachValue(new TObjectProcedure<Pet>() {
@Override
public boolean execute(Pet object) {
pets.forEachValue(object -> {
Emulator.getGameEnvironment().getPetManager().deletePet(object);
return true;
}
});
habbo.getClient().sendResponse(new InventoryRefreshComposer());
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.cleared"), RoomChatMessageBubbles.ALERT);
habbo.getClient().sendResponse(new InventoryPetsComposer(habbo));
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_empty_pets.cleared").replace("%username%", habbo.getHabboInfo().getUsername()), RoomChatMessageBubbles.ALERT);
} else {
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_empty_pets"), RoomChatMessageBubbles.ALERT);
}
}