Ejemplo n.º 1
0
  public void attachRocketBoots(Player player, ItemStack boots) {

    if (gamemodeCheck.check(player, GameMode.CREATIVE, GameMode.SPECTATOR)) {
      commonString.messageSend(
          RocketInit.getPlugin(), player, true, RocketLanguage.RB_GAMEMODE_ERROR);
      disableRocketBoots(player, false, false, false, false, false);
      return;
    }

    UUID playerUUID = player.getUniqueId();

    ItemMeta rocketMeta = boots.getItemMeta();
    Block blockMiddle = player.getLocation().getBlock().getRelative(BlockFace.SELF);

    Boolean isWaterVariant = false;
    Boolean isRunnerVariant = false;

    String[] rocketMessage = new String[3];
    rocketMessage[0] = RocketLanguage.RB_ACTIVATE;

    switch (rocketMeta.getLore().size()) {
      case 1:
        rocketMessage[1] = RocketLanguage.RB_VARIANT + RocketLanguage.RB_NOT_FOUND;
        rocketMessage[2] = RocketLanguage.RB_ENHANCE + RocketLanguage.RB_NOT_FOUND;
        RocketInit.rocketVariant.put(playerUUID, Variant.ORIGINAL);
        RocketInit.rocketEnhancement.put(playerUUID, RocketEnhancement.Enhancement.NOTHING);
        break;

      case 2:
        String loreLine = ChatColor.stripColor(rocketMeta.getLore().get(1));

        if (Variant.isVariant(loreLine)) {
          Variant variantType = Variant.getEnum(loreLine);
          if (variantType != null) {
            rocketMessage[1] = RocketLanguage.RB_VARIANT + loreLine;
            rocketMessage[2] = RocketLanguage.RB_ENHANCE + RocketLanguage.RB_NOT_FOUND;

            RocketInit.rocketVariant.put(playerUUID, variantType);
            RocketInit.rocketEnhancement.put(playerUUID, RocketEnhancement.Enhancement.NOTHING);

            if (variantType.equals(Variant.WATER)) isWaterVariant = true;
            if (variantType.equals(Variant.RUNNER)) isRunnerVariant = true;
          }
        }

        if (RocketEnhancement.Enhancement.isEnhancement(loreLine)) {
          RocketEnhancement.Enhancement enhancementType =
              RocketEnhancement.Enhancement.getEnum(loreLine);
          if (enhancementType != null) {
            rocketMessage[1] = RocketLanguage.RB_VARIANT + RocketLanguage.RB_NOT_FOUND;
            rocketMessage[2] = RocketLanguage.RB_ENHANCE + loreLine;

            RocketInit.rocketVariant.put(playerUUID, Variant.ORIGINAL);
            RocketInit.rocketEnhancement.put(playerUUID, enhancementType);
          }
        }
        break;

      case 3:
        String variantLore = ChatColor.stripColor(rocketMeta.getLore().get(1));
        String enhancementLore = ChatColor.stripColor(rocketMeta.getLore().get(2));

        Variant variantType = Variant.getEnum(variantLore);
        RocketEnhancement.Enhancement enhancementType =
            RocketEnhancement.Enhancement.getEnum(enhancementLore);

        if (variantType != null && enhancementType != null) {
          rocketMessage[1] = RocketLanguage.RB_VARIANT + variantLore;
          RocketInit.rocketVariant.put(playerUUID, variantType);

          if (variantType.equals(Variant.WATER)) isWaterVariant = true;
          if (variantType.equals(Variant.RUNNER)) isRunnerVariant = true;

          rocketMessage[2] = RocketLanguage.RB_ENHANCE + enhancementLore;
          RocketInit.rocketEnhancement.put(playerUUID, enhancementType);
        }
        break;
    }

    if (!isWaterVariant && blockMiddle.isLiquid()) {
      RocketInit.rocketWater.add(playerUUID);
      commonString.messageSend(
          RocketInit.getPlugin(), player, true, RocketLanguage.RB_WATER_WARNING);
      return;
    }

    if (RocketInit.rocketVariant.get(playerUUID) == null
        || RocketInit.rocketEnhancement.get(playerUUID) == null) {
      commonString.messageSend(RocketInit.getPlugin(), player, true, RocketLanguage.RB_FAIL_ATTACH);
      disableRocketBoots(player, false, false, false, false, false);
      return;
    }

    if (RocketInit.rocketVariant.get(playerUUID) != Variant.ORIGINAL
        && player.getWorld().getName().equals("world_nether")) {
      commonString.messageSend(RocketInit.getPlugin(), player, true, RocketLanguage.RB_NETHER);
      disableRocketBoots(player, false, false, false, false, false);
      return;
    }

    if (player.getInventory().getBoots() == null)
      if (gamemodeCheck.check(player, GameMode.SURVIVAL, GameMode.ADVENTURE)) {

        commonString.messageSend(RocketInit.getPlugin(), player, true, rocketMessage);
        if (!isRunnerVariant) player.setAllowFlight(true);
        RocketInit.rocketPower.put(playerUUID, getBootPowerLevel(boots));
      }
  }
Ejemplo n.º 2
0
  public void disableRocketBoots(
      Player player,
      Boolean keepUsage,
      Boolean keepPower,
      Boolean keepFlight,
      Boolean keepVariant,
      Boolean keepEnhancement) {

    UUID playerUUID = player.getUniqueId();

    if (!keepUsage && RocketInit.rocketUsage.contains(playerUUID))
      RocketInit.rocketUsage.remove(playerUUID);

    if (RocketInit.rocketSprint.containsKey(playerUUID)) RocketInit.rocketSprint.remove(playerUUID);

    if (!keepPower && RocketInit.rocketPower.containsKey(playerUUID))
      RocketInit.rocketPower.remove(playerUUID);

    if (!RocketInit.rocketFire.isEmpty()) RocketInit.rocketFire.clear();

    if (RocketInit.rocketWater.contains(playerUUID)) RocketInit.rocketWater.remove(playerUUID);

    if (RocketInit.rocketRepair.containsKey(playerUUID)) RocketInit.rocketRepair.remove(playerUUID);

    if (!keepEnhancement && RocketInit.rocketEnhancement.containsKey(playerUUID))
      RocketInit.rocketEnhancement.remove(playerUUID);

    if (!keepVariant && RocketInit.rocketVariant.containsKey(playerUUID)) {

      switch (RocketInit.rocketVariant.get(playerUUID)) {
        case ENDER:
          player.removePotionEffect(PotionEffectType.NIGHT_VISION);
          player.removePotionEffect(PotionEffectType.HEALTH_BOOST);
          break;

        case ZERO:
          player.removePotionEffect(PotionEffectType.CONFUSION);
          player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
          player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
          break;

        case STEALTH:
          for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.showPlayer(player);
          break;

        case DRUNK:
          player.removePotionEffect(PotionEffectType.CONFUSION);
          player.removePotionEffect(PotionEffectType.FAST_DIGGING);
          break;

        case BOOST:
          player.removePotionEffect(PotionEffectType.HEAL);
          break;

        case RUNNER:
          player.removePotionEffect(PotionEffectType.SPEED);
          break;
      }

      RocketInit.rocketVariant.remove(playerUUID);
    }

    if (player.isOnline() && gamemodeCheck.check(player, GameMode.SURVIVAL, GameMode.ADVENTURE)) {

      for (Player onlinePlayer : Bukkit.getOnlinePlayers()) onlinePlayer.showPlayer(player);

      player.setFlySpeed(0.1f);
      player.setFlying(false);
      if (!keepFlight) player.setAllowFlight(false);

      player.setNoDamageTicks(100);
      player.setFallDistance(0);
    }
  }
Ejemplo n.º 3
0
  public void interactRocketBoots(InventoryClickEvent event, ItemStack boots) {

    Player player = (Player) event.getWhoClicked();
    ClickType click = event.getClick();
    Boolean hasRocketMeta = boots.hasItemMeta();

    if (gamemodeCheck.check(player, GameMode.CREATIVE, GameMode.SPECTATOR)) {
      event.setCancelled(true);
      player.closeInventory();
      disableRocketBoots(player, false, false, false, false, false);
      commonString.messageSend(
          RocketInit.getPlugin(), player, true, RocketLanguage.RB_GAMEMODE_ERROR);
      return;
    }

    if (hasRocketMeta) {

      ItemMeta rocketMeta = boots.getItemMeta();

      if (rocketMeta.hasDisplayName())
        if (rocketMeta.getDisplayName().matches(ChatColor.RED + "Rocket Boots"))
          if (rocketMeta.hasLore()) {

            String rocketLore = rocketMeta.getLore().get(0);
            String variantLore = null;

            if (rocketMeta.getLore().size() >= 2)
              variantLore = ChatColor.stripColor(rocketMeta.getLore().get(1));

            Set<String> specialVariants = new HashSet<>(Collections.singletonList("Robin Hood"));

            if (variantLore != null)
              if (specialVariants.contains(variantLore)) {

                Variant variantType = Variant.getEnum(variantLore);

                if (variantType != null)
                  if (variantType == Variant.MONEY)
                    if (RocketInit.getVaultEconomy() == null) {
                      commonString.messageSend(
                          RocketInit.getPlugin(), player, true, RocketLanguage.RB_EQUIP_ERROR);
                      return;
                    }
              }

            if (rocketLore.matches(ChatColor.YELLOW + "Rocket Level I{0,3}V?X?"))
              if (!RocketInit.rocketUsage.contains(player.getUniqueId()))
                if (click == ClickType.MIDDLE) event.setCancelled(true);
                else attachRocketBoots(player, boots);
          }

    } else if (RocketInit.rocketSprint.containsKey(player.getUniqueId())) {

      commonString.messageSend(
          RocketInit.getPlugin(),
          player,
          true,
          new String[] {RocketLanguage.RB_COOLDOWN_TOUCH, RocketLanguage.RB_COOLDOWN_LAND});

      event.setCancelled(true);
      player.closeInventory();

    } else if (RocketInit.rocketPower.containsKey(player.getUniqueId()))
      disableRocketBoots(player, false, false, false, false, false);
  }