Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.nextgenhabbo.plugin.commands;
- import com.eu.habbo.Emulator;
- import com.eu.habbo.habbohotel.rooms.Room;
- import com.eu.habbo.habbohotel.commands.Command;
- import com.eu.habbo.habbohotel.gameclients.GameClient;
- import com.eu.habbo.habbohotel.users.Habbo;
- import com.eu.habbo.messages.ServerMessage;
- import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
- import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer;
- import gnu.trove.map.hash.THashMap;
- import java.util.Map;
- public class ImHostingCommand extends Command {
- public ImHostingCommand(String permission, String[] keys) {
- super(permission, keys);
- }
- private THashMap<Habbo, Integer> lastRanTimestamps = new THashMap<Habbo, Integer>();
- @Override
- public boolean handle(GameClient gameClient, String[] strings) throws Exception {
- if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
- int type;
- System.out.println(Emulator.getConfig().getValue("seasonal.currency.diamond"));
- type = Emulator.getConfig().getInt("seasonal.currency.diamond");
- int amount = Emulator.getConfig().getInt("overhaul.imhosting.cost");
- if (strings.length == 1) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.howtouse").replace("%price%", Emulator.getConfig().getValue("overhaul.imhosting.cost")));
- return true;
- } else if (strings.length == 2 && strings[1].equalsIgnoreCase(Emulator.getTexts().getValue("overhaul.imhosting.confirmkey"))) {
- if (gameClient.getHabbo().getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.currency.diamond")) < Emulator.getConfig().getInt("overhaul.imhosting.cost")) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.notenough").replace("%username%", gameClient.getHabbo().getHabboInfo().getUsername()).replace("%price%", Emulator.getConfig().getValue("overhaul.imhosting.cost")));
- return true;
- } else {
- Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
- if (!room.hasRights(gameClient.getHabbo()) && room.guildRightLevel(gameClient.getHabbo()) < 2 && !gameClient.getHabbo().hasPermission("acc_moverotate")) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.norights"));
- return true;
- }
- if (this.lastRanTimestamps.containsKey(gameClient.getHabbo())) {
- int lastRanTimestamp = this.lastRanTimestamps.get(gameClient.getHabbo());
- if (Emulator.getIntUnixTimestamp() - lastRanTimestamp <= Emulator.getConfig().getInt("overhaul.imhosting.cooldownseconds")) {
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.toofast"));
- return true;
- }
- }
- // Do not update the timestamp when the cooldown check fails!
- this.lastRanTimestamps.put(gameClient.getHabbo(), Emulator.getIntUnixTimestamp());
- gameClient.getHabbo().givePoints(type, -amount);
- gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.success").replace("%username%", gameClient.getHabbo().getHabboInfo().getUsername()));
- THashMap<String, String> notify_hosting_keys = new THashMap<String, String>();
- notify_hosting_keys.put("display", "BUBBLE");
- notify_hosting_keys.put("image", "${image.library.url}notifications/event.png");
- notify_hosting_keys.put("linkUrl", "event:navigator/goto/" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId() + "");
- notify_hosting_keys.put("message", Emulator.getTexts().getValue("overhaul.imhosting.message").replace("%habbo%", gameClient.getHabbo().getHabboInfo().getUsername()));
- ServerMessage bubblemessage = new BubbleAlertComposer("mentioned", notify_hosting_keys).compose();
- for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
- Habbo habbo = set.getValue();
- if (habbo.getHabboStats().blockStaffAlerts)
- continue;
- habbo.getClient().sendResponse(bubblemessage);
- }
- return true;
- }
- }
- return false;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement