fiveriverflow

TeleportCommands

Sep 28th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.65 KB | None | 0 0
  1. package server.model.players.content.command.impl;
  2.  
  3. import lombok.Getter;
  4. import server.Config;
  5. import server.model.Position;
  6. import server.model.minigames.weapongame.WeaponMinigame;
  7. import server.model.players.DonatorRights;
  8. import server.model.players.Player;
  9. import server.model.players.PlayerRights;
  10. import server.model.players.Requirements;
  11. import server.model.players.content.command.Command;
  12. import server.model.players.content.command.CommandContainer;
  13. import server.model.players.content.command.CommandEntry;
  14. import server.model.players.content.dialogue.SimpleDialogues;
  15. import server.model.players.content.quests.Quests;
  16. import server.model.players.content.quests.impl.TurtleDonationQuest;
  17. import server.model.players.content.quests.impl.zeus.ZeusInstance;
  18. import server.model.players.content.raid.two.RaidsTwoDifficulty;
  19. import server.model.players.content.world_boss.WorldBossHandler;
  20. import server.util.Misc;
  21.  
  22. import java.util.ArrayList;
  23. import java.util.Arrays;
  24. import java.util.List;
  25. import java.util.Optional;
  26.  
  27. public class TeleportCommandExecutor implements CommandContainer {
  28.  
  29.     enum Location {
  30.         RAIDS_ONE(new Position(2577, 2502, 0), "raids1", "raidsone", "raid1", "raidone"),
  31.         RAIDS_TWO(new Position(1563, 10017, 0), "raids2", "raidstwo", "raid2", "raidtwo"),
  32.         EVIL_WISE_OLD_MAN(new Position(3194, 3876, 0), "ewom", "evilman"),
  33.         ZEUS(new Position(2873, 3546, 0)),
  34.         PUMMELLER(new Position(2742, 5103, 4), "pummel"),
  35.         QUEEN_BLACK_DRAGON(new Position(1441, 6363, 1), "qbd", "queendragon", "qdragon"),
  36.         GAMBLING_NPC(new Position(2396, 3495, 16), "npcgamble"),
  37.         CERBERUS(new Position(3100, 3930, 4)),
  38.         CORPOREAL_BEAST(new Position(3304, 9375, 0), "corp", "corpbeast", "cbeast"),
  39.         MONEY_ZONE(new Position(2728, 9690, 0), "mzone"),
  40.         HOME(new Position(2751, 2745, 0)),
  41.         SHOPS(new Position(2751, 2784, 0), "shop", "shopping"),
  42.         AUCTIONEER(new Position(2772, 2772, 0), "auction"),
  43.         PRESTIGE_ZONE(new Position(3541, 9866, 0), "prestige"),
  44.         VORAGO_CAVE(new Position(2776, 2734, 0), "omen"),
  45.         LUCKY_KNIGHTS(new Position(3234, 9570, 0), "luckyknight", "lknight"),
  46.         KRIL_TSUTSAROTH(new Position(3284, 2818, 0), "kril"),
  47.         HANK_THE_TANK(new Position(2772, 9341, 0), "hank"),
  48.         DIABLO(new Position(2475, 5214, 0)),
  49.         TORMENTED_DEMON(new Position(2712, 9813, 0), "tds", "td"),
  50.         TZHAAR(new Position(2445, 5177, 0)),
  51.         TERROR_BIRD_BOSS(new Position(2762, 9312, 0), "terror", "tbb", "terrorbird"),
  52.         ALTAR(new Position(2727, 2774, 0)),
  53.         MARKET(new Position(2037, 4526, 0)),
  54.         GUARDIAN(new Position(2742, 2725, 0)),
  55.         SLAYER_MASTER(new Position(2766, 2725, 0), "slayer"),
  56.         SLAYER_TOWER(new Position(3428, 3538, 0)),
  57.         FROST_DRAGONS(new Position(3056, 9563, 0), "frosts"),
  58.         TRAINING_AREA(new Position(2716, 2750, 0), "train"),
  59.  
  60.         ;
  61.  
  62.         @Getter Position position;
  63.         @Getter String[] aliases;
  64.  
  65.         Location(Position position, String... aliases) {
  66.             this.position = position;
  67.             this.aliases = aliases;
  68.         }
  69.  
  70.     }
  71.  
  72.     @Override
  73.     public List<Command> execute() {
  74.         List<Command> commands = new ArrayList<>();
  75.  
  76.         for (Location location : Location.values()) {
  77.             commands.add(new Command(location.name().replaceAll("_", " ").toLowerCase(),
  78.                     Optional.of(String.format("Teleport to the %s location.", Misc.formatString(location.name())))) {
  79.                 @Override
  80.                 public void execute(Player player, CommandEntry command) {
  81.                     player.getPacketSender().spellTeleport(location.getPosition());
  82.                     player.sendMessage("Successfully teleported to the %s location.", Misc.formatString(location.name()));
  83.                 }
  84.  
  85.                 @Override
  86.                 public List<String> getAliases() {
  87.                     return Arrays.asList(location.getAliases());
  88.                 }
  89.             });
  90.         }
  91.  
  92.         commands.add(new Command("worldboss", Optional.of("Teleport you to the world boss if available.")) {
  93.             @Override
  94.             public void execute(Player player, CommandEntry command) {
  95.                 Position position = WorldBossHandler.get().getTeleportPosition();
  96.                 if (position == null) {
  97.                     player.sendMessage("The world boss is currently inactive for another " + WorldBossHandler.get().timeRemaining() + ".");
  98.                     return;
  99.                 }
  100.                 player.getPacketSender().spellTeleport(position.getX(), position.getY(), position.getZ());
  101.                 player.sendMessage("Successfully teleported to the World Boss.");
  102.             }
  103.         });
  104.  
  105.         commands.add(new Command("christmas",  Optional.of("Teleport to the Christmas location.")) {
  106.             @Override
  107.             public void execute(Player player, CommandEntry command) {
  108.                 if (Config.CHRISTMAS_ENABLED) {
  109.                     player.getPacketSender().spellTeleport(2397, 3488, 4);
  110.                     player.sendMessage("Successfully teleported to the Christmas event location.");
  111.                 } else {
  112.                     player.sendMessage("You may only do this when Christmas event is enabled.");
  113.                 }
  114.             }
  115.  
  116.             @Override
  117.             public boolean isHidden(Player player) {
  118.                 return !Config.CHRISTMAS_ENABLED;
  119.             }
  120.         });
  121.  
  122.         commands.add(new Command("skeletons", Optional.of("Teleport to the Halloween Skeleton location.")) {
  123.             @Override
  124.             public void execute(Player player, CommandEntry command) {
  125.                 if (Requirements.meetsRequirements(player, 0, "HALLOWEEN", false, PlayerRights.PLAYER)) {
  126.                     player.getPacketSender().spellTeleport(3561, 9784, 0);
  127.                     player.sendMessage("Successfully teleported to the Halloween Skeleton location.");
  128.                 }
  129.             }
  130.  
  131.             @Override
  132.             public boolean isHidden(Player player) {
  133.                 return Requirements.meetsRequirements(player, 0, "HALLOWEEN", false, PlayerRights.PLAYER, false);
  134.             }
  135.         });
  136.  
  137.         commands.add(new Command("halloween", Optional.of("Teleport to the Halloween location.")) {
  138.             @Override
  139.             public void execute(Player player, CommandEntry command) {
  140.                 if (Config.HALLOWEEN_EVENT_ENABLED) {
  141.                     player.getPacketSender().spellTeleport(1863, 5244, 0);
  142.                     player.sendMessage("Successfully teleported to the Halloween location.");
  143.                 }
  144.             }
  145.  
  146.             @Override
  147.             public boolean isHidden(Player player) {
  148.                 return !Config.HALLOWEEN_EVENT_ENABLED;
  149.             }
  150.         });
  151.  
  152.         commands.add(new Command("turtle", Optional.of("Teleport to the Diablo location.")) {
  153.             @Override
  154.             public void execute(Player player, CommandEntry command) {
  155.                 if (player.getQuestStage(Quests.TURTLE_DONATION) == 0) {
  156.                     new TurtleDonationQuest(player).incrementStage();
  157.                 }
  158.                 player.getPacketSender().spellTeleport(2762, 9312, 0);
  159.                 player.sendMessage("Successfully teleported to the Diablo location.");
  160.             }
  161.  
  162.             @Override
  163.             public List<String> getAliases() {
  164.                 return Arrays.asList("turtlezone", "turtles", "tzone");
  165.             }
  166.         });
  167.  
  168.         return commands;
  169.     }
  170.  
  171.     @Override
  172.     public PlayerRights getBasePlayerRights() {
  173.         return PlayerRights.PLAYER;
  174.     }
  175.  
  176.     @Override
  177.     public DonatorRights getBaseDonatorRights() {
  178.         return DonatorRights.NONE;
  179.     }
  180.  
  181. }
Advertisement
Add Comment
Please, Sign In to add comment