Advertisement
Guest User

Untitled

a guest
Jan 30th, 2020
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.77 KB | None | 0 0
  1. package com.nextgenhabbo.plugin.commands;
  2.  
  3. import com.eu.habbo.Emulator;
  4. import com.eu.habbo.habbohotel.rooms.Room;
  5. import com.eu.habbo.habbohotel.commands.Command;
  6. import com.eu.habbo.habbohotel.gameclients.GameClient;
  7. import com.eu.habbo.habbohotel.users.Habbo;
  8. import com.eu.habbo.messages.ServerMessage;
  9. import com.eu.habbo.messages.outgoing.generic.alerts.BubbleAlertComposer;
  10. import com.eu.habbo.messages.outgoing.rooms.promotions.RoomPromotionMessageComposer;
  11. import gnu.trove.map.hash.THashMap;
  12.  
  13. import java.util.Map;
  14.  
  15. public class ImHostingCommand extends Command {
  16. public ImHostingCommand(String permission, String[] keys) {
  17. super(permission, keys);
  18. }
  19.  
  20. private THashMap<Habbo, Integer> lastRanTimestamps = new THashMap<Habbo, Integer>();
  21.  
  22. @Override
  23. public boolean handle(GameClient gameClient, String[] strings) throws Exception {
  24. if (gameClient.getHabbo().getHabboInfo().getCurrentRoom() != null) {
  25. int type;
  26. System.out.println(Emulator.getConfig().getValue("seasonal.currency.diamond"));
  27. type = Emulator.getConfig().getInt("seasonal.currency.diamond");
  28. int amount = Emulator.getConfig().getInt("overhaul.imhosting.cost");
  29.  
  30. if (strings.length == 1) {
  31. gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.howtouse").replace("%price%", Emulator.getConfig().getValue("overhaul.imhosting.cost")));
  32.  
  33. return true;
  34. } else if (strings.length == 2 && strings[1].equalsIgnoreCase(Emulator.getTexts().getValue("overhaul.imhosting.confirmkey"))) {
  35.  
  36. if (gameClient.getHabbo().getHabboInfo().getCurrencyAmount(Emulator.getConfig().getInt("seasonal.currency.diamond")) < Emulator.getConfig().getInt("overhaul.imhosting.cost")) {
  37. gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.notenough").replace("%username%", gameClient.getHabbo().getHabboInfo().getUsername()).replace("%price%", Emulator.getConfig().getValue("overhaul.imhosting.cost")));
  38.  
  39. return true;
  40. } else {
  41. Room room = gameClient.getHabbo().getHabboInfo().getCurrentRoom();
  42. if (!room.hasRights(gameClient.getHabbo()) && room.guildRightLevel(gameClient.getHabbo()) < 2 && !gameClient.getHabbo().hasPermission("acc_moverotate")) {
  43. gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.norights"));
  44. return true;
  45. }
  46.  
  47. if (this.lastRanTimestamps.containsKey(gameClient.getHabbo())) {
  48. int lastRanTimestamp = this.lastRanTimestamps.get(gameClient.getHabbo());
  49.  
  50. if (Emulator.getIntUnixTimestamp() - lastRanTimestamp <= Emulator.getConfig().getInt("overhaul.imhosting.cooldownseconds")) {
  51. gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.toofast"));
  52. return true;
  53. }
  54. }
  55.  
  56. // Do not update the timestamp when the cooldown check fails!
  57. this.lastRanTimestamps.put(gameClient.getHabbo(), Emulator.getIntUnixTimestamp());
  58.  
  59. gameClient.getHabbo().givePoints(type, -amount);
  60. gameClient.getHabbo().whisper(Emulator.getTexts().getValue("overhaul.imhosting.success").replace("%username%", gameClient.getHabbo().getHabboInfo().getUsername()));
  61. THashMap<String, String> notify_hosting_keys = new THashMap<String, String>();
  62. notify_hosting_keys.put("display", "BUBBLE");
  63. notify_hosting_keys.put("image", "${image.library.url}notifications/event.png");
  64. notify_hosting_keys.put("linkUrl", "event:navigator/goto/" + gameClient.getHabbo().getHabboInfo().getCurrentRoom().getId() + "");
  65. notify_hosting_keys.put("message", Emulator.getTexts().getValue("overhaul.imhosting.message").replace("%habbo%", gameClient.getHabbo().getHabboInfo().getUsername()));
  66. ServerMessage bubblemessage = new BubbleAlertComposer("mentioned", notify_hosting_keys).compose();
  67.  
  68. for (Map.Entry<Integer, Habbo> set : Emulator.getGameEnvironment().getHabboManager().getOnlineHabbos().entrySet()) {
  69. Habbo habbo = set.getValue();
  70. if (habbo.getHabboStats().blockStaffAlerts)
  71. continue;
  72.  
  73. habbo.getClient().sendResponse(bubblemessage);
  74. }
  75.  
  76. return true;
  77.  
  78. }
  79. }
  80. return false;
  81. }
  82.  
  83. return true;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement