예제 #1
0
  public void fuelRemove(Player player, Material block, Material single, int cost) {

    Inventory fuelInventory = getFuelInventory(player);

    for (ItemStack item : fuelInventory.getContents())
      if (item != null) if (item.getAmount() <= 0) item.setType(Material.AIR);

    if (!blockStacks.split(fuelInventory, block, single, cost, (9 - cost))) {
      commonString.messageSend(
          RocketInit.getPlugin(),
          player,
          true,
          RocketLanguage.FuelOutage(single.toString().toLowerCase()));
      disableRocketBoots(player, true, true, true, true, true);
    }

    try {

      Material jacketType = player.getInventory().getChestplate().getType();
      FileConfiguration fuelConfig = getFuelConfig(player);

      fuelConfig.set(getFuelJacketConfigString(jacketType), fuelInventory.getContents());
      fuelConfig.save(getFuelFile(player));

    } catch (IOException e) {
      commonString.messageSend(
          RocketInit.getPlugin(), player, true, RocketLanguage.RB_JACKET_SAVE_ERROR);
      e.printStackTrace();
    }
  }
예제 #2
0
  public boolean fuelCheck(Player player, Material single, Material block) {

    Inventory fuelInventory = getFuelInventory(player);
    ItemStack rocketBoots = player.getInventory().getBoots();

    int fuelCost = 0;

    switch (rocketBoots.getType()) {
      case LEATHER_BOOTS:
        fuelCost = 1 + getBootPowerLevel(rocketBoots);
        break;

      case IRON_BOOTS:
        fuelCost = 2 + getBootPowerLevel(rocketBoots);
        break;

      case GOLD_BOOTS:
        fuelCost = 3 + getBootPowerLevel(rocketBoots);
        break;

      case DIAMOND_BOOTS:
        fuelCost = 4 + getBootPowerLevel(rocketBoots);
        break;
    }

    if (fuelInventory.containsAtLeast(new ItemStack(block), fuelCost)) return true;
    if (fuelInventory.containsAtLeast(new ItemStack(single), fuelCost)) return true;

    commonString.messageSend(
        RocketInit.getPlugin(),
        player,
        true,
        RocketLanguage.FuelRequired(single.name().toLowerCase()));
    RocketInit.rocketTimeout.add(player.getUniqueId());

    new BukkitRunnable() {
      int c = 5;

      @Override
      public void run() {
        if (c <= 0) {
          RocketInit.rocketTimeout.remove(player.getUniqueId());
          this.cancel();
          return;
        }
        player.setFlying(false);
        c--;
      }
    }.runTaskTimer(RocketInit.getPlugin(), 0, 20);

    return false;
  }