2018-07-06 13:30:00 +00:00
|
|
|
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.HabboInfo;
|
|
|
|
import com.eu.habbo.habbohotel.users.HabboManager;
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
public class CreditsCommand extends Command {
|
|
|
|
public CreditsCommand() {
|
2018-07-06 13:30:00 +00:00
|
|
|
super("cmd_credits", Emulator.getTexts().getValue("commands.keys.cmd_credits").split(";"));
|
|
|
|
}
|
2019-05-26 21:14:53 +03:00
|
|
|
|
2018-07-06 13:30:00 +00:00
|
|
|
@Override
|
2019-05-26 21:14:53 +03:00
|
|
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
|
|
|
if (params.length == 3) {
|
2018-07-06 13:30:00 +00:00
|
|
|
HabboInfo info = HabboManager.getOfflineHabboInfo(params[1]);
|
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
if (info != null) {
|
2018-07-06 13:30:00 +00:00
|
|
|
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
|
|
|
|
|
2019-03-18 01:22:00 +00:00
|
|
|
int credits;
|
2019-05-26 21:14:53 +03:00
|
|
|
try {
|
2018-07-06 13:30:00 +00:00
|
|
|
credits = Integer.parseInt(params[2]);
|
2019-05-26 21:14:53 +03:00
|
|
|
} catch (NumberFormatException e) {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT);
|
|
|
|
return true;
|
|
|
|
}
|
2019-05-26 21:14:53 +03:00
|
|
|
if (habbo != null) {
|
|
|
|
if (credits != 0) {
|
|
|
|
habbo.giveCredits(credits);
|
|
|
|
if (habbo.getHabboInfo().getCurrentRoom() != null)
|
|
|
|
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""), RoomChatMessageBubbles.ALERT);
|
|
|
|
else
|
|
|
|
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_credits.received").replace("%amount%", Integer.parseInt(params[2]) + ""));
|
2018-07-06 13:30:00 +00:00
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
2018-07-06 13:30:00 +00:00
|
|
|
|
2019-05-26 21:14:53 +03:00
|
|
|
} else {
|
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT);
|
|
|
|
}
|
|
|
|
} else {
|
2018-07-06 13:30:00 +00:00
|
|
|
Emulator.getGameEnvironment().getHabboManager().giveCredits(info.getId(), credits);
|
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_credits.send").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
|
|
|
|
}
|
2019-05-26 21:14:53 +03:00
|
|
|
} else {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.user_not_found").replace("%amount%", Integer.parseInt(params[2]) + "").replace("%user%", params[1]), RoomChatMessageBubbles.ALERT);
|
|
|
|
}
|
2019-05-26 21:14:53 +03:00
|
|
|
} else {
|
2018-07-06 13:30:00 +00:00
|
|
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_credits.invalid_amount"), RoomChatMessageBubbles.ALERT);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|