mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-10-24 19:53:04 +02:00
59 lines
2.1 KiB
Java
59 lines
2.1 KiB
Java
|
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.outgoing.inventory.InventoryBadgesComposer;
|
||
|
|
||
|
public class TakeBadgeCommand extends Command
|
||
|
{
|
||
|
public TakeBadgeCommand()
|
||
|
{
|
||
|
super("cmd_take_badge", Emulator.getTexts().getValue("commands.keys.cmd_take_badge").split(";"));
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean handle(GameClient gameClient, String[] params) throws Exception
|
||
|
{
|
||
|
if (params.length == 2)
|
||
|
{
|
||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.forgot_badge"), RoomChatMessageBubbles.ALERT);
|
||
|
return true;
|
||
|
}
|
||
|
else if ( params.length == 1)
|
||
|
{
|
||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.forgot_username"), RoomChatMessageBubbles.ALERT);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if (params.length == 3)
|
||
|
{
|
||
|
String username = params[1];
|
||
|
String badge = params[2];
|
||
|
|
||
|
Habbo habbo = Emulator.getGameEnvironment().getHabboManager().getHabbo(username);
|
||
|
|
||
|
if (habbo != null)
|
||
|
{
|
||
|
HabboBadge b = habbo.getInventory().getBadgesComponent().removeBadge(badge);
|
||
|
|
||
|
if (b == null)
|
||
|
{
|
||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_take_badge.no_badge").replace("%username%", username).replace("%badge%", badge), RoomChatMessageBubbles.ALERT);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
habbo.getClient().sendResponse(new InventoryBadgesComposer(habbo));
|
||
|
}
|
||
|
|
||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_take_badge"), RoomChatMessageBubbles.ALERT);
|
||
|
|
||
|
BadgesComponent.deleteBadge(username, badge);
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
}
|