67 lines
3.6 KiB
Java
Raw Normal View History

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;
2019-05-26 21:14:53 +03:00
public class PointsCommand extends Command {
public PointsCommand() {
2018-07-06 13:30:00 +00:00
super("cmd_points", Emulator.getTexts().getValue("commands.keys.cmd_points").split(";"));
}
@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
Habbo habbo = Emulator.getGameServer().getGameClientManager().getHabbo(params[1]);
2019-05-26 21:14:53 +03:00
if (habbo != null) {
try {
2018-07-06 13:30:00 +00:00
int type = Emulator.getConfig().getInt("seasonal.primary.type");
2019-05-26 21:14:53 +03:00
if (params.length == 4) {
try {
2018-07-06 13:30:00 +00:00
type = Integer.valueOf(params[3]);
2019-05-26 21:14:53 +03:00
} catch (Exception e) {
2018-07-06 13:30:00 +00:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_type").replace("%types%", Emulator.getConfig().getValue("seasonal.types").replace(";", ", ")), RoomChatMessageBubbles.ALERT);
return true;
}
}
2019-03-18 01:22:00 +00:00
int amount;
2018-10-06 22:28:00 +00:00
2019-05-26 21:14:53 +03:00
try {
2018-10-06 22:28:00 +00:00
amount = Integer.valueOf(params[2]);
2019-05-26 21:14:53 +03:00
} catch (Exception e) {
2018-10-06 22:28:00 +00:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.error.cmd_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
return true;
}
2019-05-26 21:14:53 +03:00
if (amount != 0) {
2018-07-06 13:30:00 +00:00
habbo.givePoints(type, amount);
2019-05-26 21:14:53 +03:00
if (habbo.getHabboInfo().getCurrentRoom() != null)
2018-07-06 13:30:00 +00:00
habbo.whisper(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), RoomChatMessageBubbles.ALERT);
else
2019-03-18 01:22:00 +00:00
habbo.alert(Emulator.getTexts().getValue("commands.generic.cmd_points.received").replace("%amount%", amount + "").replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)));
2018-07-06 13:30:00 +00:00
2019-05-26 21:14:53 +03:00
// habbo.getClient().sendResponse(new UserPointsComposer(habbo.getHabboInfo().getCurrencyAmount(type), amount, type));
2018-07-06 13:30:00 +00:00
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.succes.cmd_points.send").replace("%amount%", amount + "").replace("%user%", params[1]).replace("%type%", Emulator.getTexts().getValue("seasonal.name." + type)), 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_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
}
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_points.invalid_amount"), 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_points.user_offline").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_points.invalid_amount"), RoomChatMessageBubbles.ALERT);
}
return true;
}
}