Ejemplo n.º 1
0
  public final ResearchMap getParentMap() {
    if (Skills.mapExists(mapName)) {
      return Skills.getResearchMap(mapName);
    }

    return null;
  }
Ejemplo n.º 2
0
  public String getSkillsListTextually() {
    String ret = "";

    if (skills != null) {
      for (Skills skills1 : skills) {
        ret += (skills1.toString() + "," + '\'');
      }
    }

    return ret;
  }
Ejemplo n.º 3
0
 public boolean onBegin() {
   threadId = 412;
   UberPaint p =
       new UberPaint("ArteFalconry", threadId, getClass().getAnnotation(Manifest.class).version());
   p.skills.add(new Skill(Skills.HUNTER));
   p.skills.add(new Skill(Skills.PRAYER));
   strategies.add(new ReGetFalcon());
   strategies.add(new DropJunk());
   strategies.add(new CatchKebbit());
   strategies.add(new TakeFalcon());
   Options.add("spotted", Skills.getRealLevel(Skills.HUNTER) <= 69);
   Options.add("dark", Skills.getRealLevel(Skills.HUNTER) >= 57);
   Options.add("dashing", Skills.getRealLevel(Skills.HUNTER) >= 69);
   p.infoColumnValues = new String[] {"Status:", "Kebbits caught:", "Run time:"};
   p.addFrame("options");
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 356, "Hunt spotted: ", Options.getBoolean("spotted"), 65) {
             public void onPress() {
               if (Options.getBoolean("dashing") || Options.getBoolean("dark")) {
                 Options.flip("spotted");
                 setKebbits();
               }
             }
           });
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 371, "Hunt dark: ", Options.getBoolean("dark"), 74) {
             public void onPress() {
               if (Options.getBoolean("spotted") || Options.getBoolean("dashing")) {
                 Options.flip("dark");
                 setKebbits();
               }
             }
           });
   p.getFrame("options")
       .addComponent(
           new PCheckBox(8, 387, "Hunt dashing: ", Options.getBoolean("dashing"), 18) {
             public void onPress() {
               if (Options.getBoolean("spotted") || Options.getBoolean("dark")) {
                 Options.flip("dashing");
                 setKebbits();
               }
             }
           });
   setKebbits();
   ReGetFalcon.oldSetting = Settings.get(334);
   paintType = p;
   return true;
 }
Ejemplo n.º 4
0
  public static void treeFellerCheck(Player player, Block block, Plugin pluginx) {
    PlayerProfile PP = Users.getProfile(player);
    if (m.isAxes(player.getItemInHand())) {
      if (block != null) {
        if (!m.abilityBlockCheck(block)) return;
      }
      /*
       * CHECK FOR AXE PREP MODE
       */
      if (PP.getAxePreparationMode()) {
        PP.setAxePreparationMode(false);
      }
      int ticks = 2;
      int x = PP.getSkill("woodcutting");
      while (x >= 50) {
        x -= 50;
        ticks++;
      }

      if (!PP.getTreeFellerMode()
          && Skills.cooldownOver(
              player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)) {
        player.sendMessage(Messages.getString("Skills.TreeFellerOn"));
        for (Player y : pluginx.getServer().getOnlinePlayers()) {
          if (y != null && y != player && m.getDistance(player.getLocation(), y.getLocation()) < 10)
            y.sendMessage(
                Messages.getString("Skills.TreeFellerPlayer", new Object[] {player.getName()}));
        }
        PP.setTreeFellerActivatedTimeStamp(System.currentTimeMillis());
        PP.setTreeFellerDeactivatedTimeStamp(System.currentTimeMillis() + (ticks * 1000));
        PP.setTreeFellerMode(true);
      }
      if (!PP.getTreeFellerMode()
          && !Skills.cooldownOver(
              player, PP.getTreeFellerDeactivatedTimeStamp(), LoadProperties.treeFellerCooldown)) {
        player.sendMessage(
            ChatColor.RED
                + "You are too tired to use that ability again."
                + ChatColor.YELLOW
                + " ("
                + Skills.calculateTimeLeft(
                    player,
                    PP.getTreeFellerDeactivatedTimeStamp(),
                    LoadProperties.treeFellerCooldown)
                + "s)");
      }
    }
  }
Ejemplo n.º 5
0
  static void registerDeserializer(String id, Function<NBTTagCompound, ResearchNode> des) {
    Skills.log().info("Registering deserializer function with ID " + id);

    if (deserializers.containsKey(id)) {
      throw new IllegalArgumentException("Node deserializer " + id + " already exists");
    }

    deserializers.put(id, des);
  }
Ejemplo n.º 6
0
  /**
   * Get item results from Fishing.
   *
   * @param player The player that was fishing
   * @param event The event to modify
   */
  private static void getFishingResults(Player player, PlayerFishEvent event) {
    PlayerProfile PP = Users.getProfile(player);
    List<FishingTreasure> rewards = new ArrayList<FishingTreasure>();
    Item theCatch = (Item) event.getCaught();

    switch (getFishingLootTier(PP)) {
      case 1:
        rewards = LoadTreasures.fishingRewardsTier1;
        break;

      case 2:
        rewards = LoadTreasures.fishingRewardsTier2;
        break;

      case 3:
        rewards = LoadTreasures.fishingRewardsTier3;
        break;

      case 4:
        rewards = LoadTreasures.fishingRewardsTier4;
        break;

      case 5:
        rewards = LoadTreasures.fishingRewardsTier5;
        break;

      default:
        break;
    }

    if (LoadProperties.fishingDrops) {
      FishingTreasure treasure = rewards.get(random.nextInt(rewards.size()));

      if (random.nextDouble() * 100 <= treasure.getDropChance()) {
        Users.getProfile(player).addXP(SkillType.FISHING, treasure.getXp());
        theCatch.setItemStack(treasure.getDrop());
      }
    } else {
      theCatch.setItemStack(new ItemStack(Material.RAW_FISH));
    }

    short maxDurability = theCatch.getItemStack().getType().getMaxDurability();

    if (maxDurability > 0) {
      theCatch
          .getItemStack()
          .setDurability(
              (short) (random.nextInt(maxDurability))); // Change durability to random value
    }

    m.mcDropItem(player.getLocation(), new ItemStack(Material.RAW_FISH)); // Always drop a fish
    PP.addXP(SkillType.FISHING, LoadProperties.mfishing);
    Skills.XpCheckSkill(SkillType.FISHING, player);
  }
Ejemplo n.º 7
0
  /**
   * Handle the Super Breaker ability.
   *
   * @param player The player using the ability
   * @param block The block being affected
   */
  public static void SuperBreakerBlockCheck(Player player, Block block) {
    Material type = block.getType();
    int tier = m.getTier(player.getItemInHand());
    int durabilityLoss = LoadProperties.abilityDurabilityLoss;
    PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);

    switch (type) {
      case OBSIDIAN:
        if (tier < 4) {
          return;
        }
        durabilityLoss = durabilityLoss * 5; // Obsidian needs to do more damage than normal
        /* FALL THROUGH */

      case DIAMOND_ORE:
      case GLOWING_REDSTONE_ORE:
      case GOLD_ORE:
      case LAPIS_ORE:
      case REDSTONE_ORE:
        if (tier < 3) {
          return;
        }
        /* FALL THROUGH */

      case IRON_ORE:
        if (tier < 2) {
          return;
        }
        /* FALL THROUGH */

      case COAL_ORE:
      case ENDER_STONE:
      case GLOWSTONE:
      case MOSSY_COBBLESTONE:
      case NETHERRACK:
      case SANDSTONE:
      case STONE:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          return;
        }

        Bukkit.getPluginManager().callEvent(armswing);
        Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);

        miningBlockCheck(player, block);
        miningBlockCheck(player, block);

        if (LoadProperties.spoutEnabled) {
          SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
        }
    }
  }
Ejemplo n.º 8
0
  /**
   * Detonate TNT for Blast Mining
   *
   * @param event The PlayerInteractEvent
   * @param player Player detonating the TNT
   * @param plugin mcMMO plugin instance
   */
  public static void detonate(PlayerInteractEvent event, Player player, mcMMO plugin) {
    PlayerProfile PP = Users.getProfile(player);

    if (PP.getSkillLevel(SkillType.MINING) < 125) return;

    Block block = event.getClickedBlock();

    if (block == null || block.getType() != Material.TNT) {
      final byte SNOW = 78;
      final byte AIR = 0;
      final int BLOCKS_AWAY = 100;

      HashSet<Byte> transparent = new HashSet<Byte>();

      transparent.add(SNOW);
      transparent.add(AIR);

      block = player.getTargetBlock(transparent, BLOCKS_AWAY);

      if (block.getType() != Material.TNT) {
        return;
      }
    } else if (block.getType() == Material.TNT) {
      event.setCancelled(
          true); // This is the only way I know to avoid the original TNT to be triggered (in case
      // the player is close to it)
    }

    if (!Misc.blockBreakSimulate(block, player, true)) {
      return;
    }

    final double MAX_DISTANCE_AWAY = 10.0;
    final int TIME_CONVERSION_FACTOR = 1000;

    AbilityType ability = AbilityType.BLAST_MINING;

    /* Check Cooldown */
    if (!Skills.cooldownOver(
        PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
      player.sendMessage(
          LocaleLoader.getString("Skills.TooTired")
              + ChatColor.YELLOW
              + " ("
              + Skills.calculateTimeLeft(
                  PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())
              + "s)");

      return;
    }

    /* Send message to nearby players */
    for (Player y : player.getWorld().getPlayers()) {
      if (y != player && Misc.isNear(player.getLocation(), y.getLocation(), MAX_DISTANCE_AWAY)) {
        y.sendMessage(ability.getAbilityPlayer(player));
      }
    }

    player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));

    /* Create the TNT entity */
    TNTPrimed tnt = player.getWorld().spawn(block.getLocation(), TNTPrimed.class);
    plugin.tntTracker.put(tnt.getEntityId(), player);
    tnt.setFuseTicks(0);

    /* Disable the original one */
    block.setType(Material.AIR);

    PP.setSkillDATS(ability, System.currentTimeMillis()); // Save DATS for Blast Mining
    PP.setAbilityInformed(ability, false);
  }
Ejemplo n.º 9
0
  /**
   * Check for extra Herbalism drops.
   *
   * @param block The block to check for extra drops
   * @param player The player getting extra drops
   * @param event The event to use for Green Thumb
   * @param plugin mcMMO plugin instance
   */
  public static void herbalismProcCheck(
      final Block block, Player player, BlockBreakEvent event, mcMMO plugin) {
    final PlayerProfile PP = Users.getProfile(player);
    final int MAX_BONUS_LEVEL = 1000;

    int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
    int id = block.getTypeId();
    Material type = block.getType();

    Byte data = block.getData();
    Location loc = block.getLocation();
    Material mat = null;
    int xp = 0;
    int catciDrops = 0;
    int caneDrops = 0;

    switch (type) {
      case BROWN_MUSHROOM:
      case RED_MUSHROOM:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = Material.getMaterial(id);
          xp = LoadProperties.mmushroom;
        }
        break;

      case CACTUS:
        for (int y = 0; y <= 2; y++) {
          Block b = block.getRelative(0, y, 0);
          if (b.getType().equals(Material.CACTUS)) {
            mat = Material.CACTUS;
            if (!b.hasMetadata("mcmmoPlacedBlock")) {
              if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
                catciDrops++;
              }
              xp += LoadProperties.mcactus;
            }
          }
        }
        break;

      case CROPS:
        if (data == CropState.RIPE.getData()) {
          mat = Material.WHEAT;
          xp = LoadProperties.mwheat;

          if (LoadProperties.wheatRegrowth && mcPermissions.getInstance().greenThumbWheat(player)) {
            greenThumbWheat(block, player, event, plugin);
          }
        }
        break;

      case MELON_BLOCK:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = Material.MELON;
          xp = LoadProperties.mmelon;
        }
        break;

      case NETHER_WARTS:
        if (data == (byte) 0x3) {
          mat = Material.NETHER_STALK;
          xp = LoadProperties.mnetherwart;
        }
        break;

      case PUMPKIN:
      case JACK_O_LANTERN:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = Material.getMaterial(id);
          xp = LoadProperties.mpumpkin;
        }
        break;

      case RED_ROSE:
      case YELLOW_FLOWER:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = Material.getMaterial(id);
          xp = LoadProperties.mflower;
        }
        break;

      case SUGAR_CANE_BLOCK:
        for (int y = 0; y <= 2; y++) {
          Block b = block.getRelative(0, y, 0);
          if (b.getType().equals(Material.SUGAR_CANE_BLOCK)) {
            mat = Material.SUGAR_CANE;
            if (!b.hasMetadata("mcmmoPlacedBlock")) {
              if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
                caneDrops++;
              }
              xp += LoadProperties.msugar;
            }
          }
        }
        break;

      case VINE:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = type;
          xp = LoadProperties.mvines;
        }
        break;

      case WATER_LILY:
        if (!block.hasMetadata("mcmmoPlacedBlock")) {
          mat = type;
          xp = LoadProperties.mlilypad;
        }
        break;

      default:
        break;
    }

    if (mat == null) {
      return;
    } else {
      ItemStack is = new ItemStack(mat);

      if (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= herbLevel) {
        if (type.equals(Material.CACTUS)) {
          m.mcDropItems(loc, is, catciDrops);
        } else if (type.equals(Material.MELON_BLOCK)) {
          m.mcDropItems(loc, is, 3);
          m.mcRandomDropItems(loc, is, 50, 4);
        } else if (type.equals(Material.NETHER_WARTS)) {
          m.mcDropItems(loc, is, 2);
          m.mcRandomDropItems(loc, is, 50, 3);
        } else if (type.equals(Material.SUGAR_CANE_BLOCK)) {
          m.mcDropItems(loc, is, caneDrops);
        } else {
          m.mcDropItem(loc, is);
        }
      }

      PP.addXP(SkillType.HERBALISM, xp);
      Skills.XpCheckSkill(SkillType.HERBALISM, player);
    }
  }
Ejemplo n.º 10
0
  /**
   * Award XP for Mining blocks.
   *
   * @param player The player to award XP to
   * @param block The block to award XP for
   */
  public static void miningXP(Player player, Block block) {
    PlayerProfile PP = Users.getProfile(player);
    Material type = block.getType();
    int xp = 0;

    switch (type) {
      case COAL_ORE:
        xp += LoadProperties.mcoal;
        break;

      case DIAMOND_ORE:
        xp += LoadProperties.mdiamond;
        break;

      case ENDER_STONE:
        xp += LoadProperties.mendstone;
        break;

      case GLOWING_REDSTONE_ORE:
      case REDSTONE_ORE:
        xp += LoadProperties.mredstone;
        break;

      case GLOWSTONE:
        xp += LoadProperties.mglowstone;
        break;

      case GOLD_ORE:
        xp += LoadProperties.mgold;
        break;

      case IRON_ORE:
        xp += LoadProperties.miron;
        break;

      case LAPIS_ORE:
        xp += LoadProperties.mlapis;
        break;

      case MOSSY_COBBLESTONE:
        xp += LoadProperties.mmossstone;
        break;

      case NETHERRACK:
        xp += LoadProperties.mnetherrack;
        break;

      case OBSIDIAN:
        xp += LoadProperties.mobsidian;
        break;

      case SANDSTONE:
        xp += LoadProperties.msandstone;
        break;

      case STONE:
        xp += LoadProperties.mstone;
        break;

      default:
        break;
    }

    PP.addXP(SkillType.MINING, xp, player);
    Skills.XpCheckSkill(SkillType.MINING, player);
  }