Пример #1
0
  public void OmplirCofre(Block blk) {
    Chest chest = (Chest) blk.getState();
    Inventory inv = chest.getInventory();
    inv.clear();
    // inv.clear();
    int maxN = Utils.NombreEntre(4, 9);
    int n = 0;

    while (n < maxN) {
      if (Utils.Possibilitat(4)) {
        inv.addItem(new ItemStack(Material.DIAMOND, 1));
      }
      if (Utils.Possibilitat(8)) {
        inv.addItem(new ItemStack(Material.GOLDEN_APPLE, 1));
      }
      if (Utils.Possibilitat(2)) {
        inv.addItem(new ItemStack(Material.GOLDEN_APPLE, 1, (short) 1));
      }
      if (Utils.Possibilitat(12)) {
        inv.addItem(new ItemStack(Material.IRON_INGOT, 1));
      }
      if (Utils.Possibilitat(5)) {
        inv.addItem(new ItemStack(Material.GOLD_INGOT, 1));
      }
      if (Utils.Possibilitat(3)) {
        inv.addItem(new ItemStack(Material.ENDER_PEARL, 1));
      }
      if (Utils.Possibilitat(4)) {
        Material hoe = Material.WOOD_HOE;
        if (Utils.Possibilitat(35)) {
          hoe = Material.GOLD_HOE;
        }
        if (Utils.Possibilitat(15)) {
          hoe = Material.STONE_HOE;
        }
        if (Utils.Possibilitat(10)) {
          hoe = Material.IRON_HOE;
        }
        if (Utils.Possibilitat(8)) {
          hoe = Material.DIAMOND_HOE;
        }

        inv.addItem(
            Utils.setItemNameAndLore(
                new ItemStack(hoe, 1),
                getBridgeToolName(),
                "Col·loca automàticament els blocs formant un passadís"));
      }
      //			if(Utils.Possibilitat(2)){
      //				inv.addItem(new ItemStack(Material.TNT, 1));
      //			}
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_LEGGINGS, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_CHESTPLATE, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        item.addUnsafeEnchantment(Enchantment.THORNS, Utils.NombreEntre(1, 3));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.GOLD_BOOTS, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 5));
        item.addUnsafeEnchantment(Enchantment.PROTECTION_FALL, Utils.NombreEntre(1, 8));
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.IRON_HELMET, 1);
        item.addUnsafeEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, Utils.NombreEntre(1, 7));
        inv.addItem(item);
      }
      // Pocions
      if (Utils.Possibilitat(5)) {
        ItemStack item = new ItemStack(Material.POTION, Utils.NombreEntre(1, 4));
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.INSTANT_HEAL);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(4)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.POISON);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.INSTANT_DAMAGE);
        pot.setLevel(2);
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      if (Utils.Possibilitat(3)) {
        ItemStack item = new ItemStack(Material.POTION, 1);
        Potion pot =
            new Potion(
                1); // The constructor calls for an (int name), but I'm not sure what that is... I
                    // tried 1 and it works fine.
        pot.setType(PotionType.STRENGTH);
        pot.setLevel(Utils.NombreEntre(1, 2));
        pot.setSplash(true);
        pot.apply(item);
        inv.addItem(item);
      }
      n = 0;
      for (ItemStack i : inv.getContents()) {
        if (i != null) {
          n++;
        }
      }
    }
  }
Пример #2
0
  @EventHandler
  public void invclick(InventoryClickEvent e) {
    final Player p = (Player) e.getWhoClicked();
    if (e.getInventory().getName().equalsIgnoreCase(ChatColor.BLUE + "Kits")) {
      Long time = System.currentTimeMillis();
      e.setCancelled(true);
      if (e.getCurrentItem().getType() == Material.WOOD) {

        if (Inventoryy.start.containsKey(p.getName())) {
          Long lu = Inventoryy.start.get(p.getName());
          if (lu + 1800000 > time) {
            p.sendMessage(prefix + ChatColor.GREEN + "Du musst noch warten!");
            return;
          }
        }
        p.sendMessage(prefix + ChatColor.GREEN + "Du hast das Starterkit erhalten!");
        p.getInventory().addItem(new ItemStack(Material.CHAINMAIL_BOOTS));
        p.getInventory().addItem(new ItemStack(Material.CHAINMAIL_CHESTPLATE));
        p.getInventory().addItem(new ItemStack(Material.CHAINMAIL_LEGGINGS));
        p.getInventory().addItem(new ItemStack(Material.CHAINMAIL_HELMET));
        p.getInventory().addItem(new ItemStack(Material.STONE_SWORD));
        p.getInventory().addItem(new ItemStack(Material.STONE_AXE));
        p.getInventory().addItem(new ItemStack(Material.STONE_PICKAXE));
        p.getInventory().addItem(new ItemStack(Material.STONE_HOE));
        p.getInventory().addItem(new ItemStack(Material.APPLE, 32));
        Inventoryy.start.put(p.getName(), time);
      } else if (e.getCurrentItem().getType() == Material.IRON_SWORD) {
        if (Inventoryy.fight.containsKey(p.getName())) {
          Long lu = Inventoryy.fight.get(p.getName());
          if (lu + 1800000 > time) {
            p.sendMessage(prefix + ChatColor.GREEN + "Du musst noch warten!");
            return;
          }
        }
        p.sendMessage(prefix + ChatColor.GREEN + "Du hast das Fight Kit erhalten!");
        p.sendMessage(
            prefix + ChatColor.GREEN + "Warte 30 Minuten, um dieses Kit wieder zu holen!");

        ItemStack schwert = new ItemStack(Material.IRON_SWORD);
        ItemMeta metaschwert = schwert.getItemMeta();
        metaschwert.addEnchant(Enchantment.DAMAGE_ALL, 2, true);
        metaschwert.setDisplayName(ChatColor.GREEN + "Fight Schwert");
        schwert.setItemMeta(metaschwert);
        p.getInventory().addItem(schwert);

        ItemStack helm = new ItemStack(Material.IRON_HELMET);
        ItemMeta metahelm = helm.getItemMeta();
        metahelm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 2, true);
        metahelm.setDisplayName(ChatColor.GREEN + "Fight Helm");
        helm.setItemMeta(metahelm);
        p.getInventory().addItem(helm);

        ItemStack brustplatte = new ItemStack(Material.IRON_CHESTPLATE);
        ItemMeta metabrustplatte = brustplatte.getItemMeta();
        metabrustplatte.addEnchant(Enchantment.PROTECTION_PROJECTILE, 3, true);
        metabrustplatte.setDisplayName(ChatColor.GREEN + "Fight Brustplatte");
        brustplatte.setItemMeta(metabrustplatte);
        p.getInventory().addItem(brustplatte);

        ItemStack hose = new ItemStack(Material.IRON_LEGGINGS);
        ItemMeta metahose = hose.getItemMeta();
        metahose.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 2, true);
        metahose.setDisplayName(ChatColor.GREEN + "Fight Hose");
        hose.setItemMeta(metahose);
        p.getInventory().addItem(hose);

        ItemStack schuhe = new ItemStack(Material.IRON_BOOTS);
        ItemMeta metaschuhe = schuhe.getItemMeta();
        metaschuhe.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 3, true);
        metaschuhe.setDisplayName(ChatColor.GREEN + "Fight Schuhe");
        schuhe.setItemMeta(metaschuhe);
        p.getInventory().addItem(schuhe);

        ItemStack heal = new ItemStack(Material.POTION, 5);
        Potion healpot = new Potion(PotionType.INSTANT_HEAL, 2, true);
        healpot.apply(heal);
        p.getInventory().addItem(heal);

        ItemStack starke = new ItemStack(Material.POTION, 3);
        Potion starkepot = new Potion(PotionType.STRENGTH, 1, true);
        starkepot.apply(starke);
        p.getInventory().addItem(starke);

        ItemStack feuer = new ItemStack(Material.POTION, 1);
        Potion feuerpot = new Potion(PotionType.FIRE_RESISTANCE, 1, true);
        feuerpot.apply(feuer);
        p.getInventory().addItem(feuer);

        Inventoryy.fight.put(p.getName(), time);

      } else if (e.getCurrentItem().getType() == Material.IRON_PICKAXE) {
        if (Inventoryy.bau.containsKey(p.getName())) {
          Long lu = Inventoryy.bau.get(p.getName());
          if (lu + 1800000 > time) {
            p.sendMessage(prefix + ChatColor.GREEN + "Du musst noch warten!");
            return;
          }
        }
        ItemStack schaufel = new ItemStack(Material.IRON_SPADE);
        ItemMeta metaschaufel = schaufel.getItemMeta();
        metaschaufel.addEnchant(Enchantment.DIG_SPEED, 2, true);
        metaschaufel.setDisplayName(ChatColor.GREEN + "Bau Schaufel");
        schaufel.setItemMeta(metaschaufel);
        p.getInventory().addItem(schaufel);

        ItemStack hacke = new ItemStack(Material.IRON_PICKAXE);
        ItemMeta metahacke = hacke.getItemMeta();
        metahacke.addEnchant(Enchantment.DIG_SPEED, 2, true);
        metaschaufel.setDisplayName(ChatColor.GREEN + "Bau Spitzhacke");
        hacke.setItemMeta(metahacke);
        p.getInventory().addItem(hacke);

        ItemStack axt = new ItemStack(Material.IRON_AXE);
        ItemMeta metaaxt = axt.getItemMeta();
        metaaxt.addEnchant(Enchantment.DIG_SPEED, 2, true);
        metaschaufel.setDisplayName(ChatColor.GREEN + "Bau Axt");
        axt.setItemMeta(metaaxt);
        p.getInventory().addItem(axt);

        p.sendMessage(prefix + ChatColor.GREEN + "Du hast das Bau Kit erhalten!");
        p.sendMessage(
            prefix + ChatColor.GREEN + "Warte 30 Minuten, um dieses Kit wieder zu holen!");

      } else if (e.getCurrentItem().getType() == Material.EXP_BOTTLE) {
        if (p.hasPermission("karotte.premium")) {
          if (Inventoryy.xp.containsKey(p.getName())) {
            Long lu = Inventoryy.xp.get(p.getName());
            if (lu + 43200000 > time) {
              p.sendMessage(prefix + ChatColor.GREEN + "Du musst noch warten!");
              return;
            }
          }
          int i = 0;
          while (i != 5) {
            ItemStack xp = new ItemStack(Material.EXP_BOTTLE, 64);
            ItemMeta metaxp = xp.getItemMeta();
            metaxp.setDisplayName(ChatColor.GREEN + "XP-Fl�schchen");
            xp.setItemMeta(metaxp);
            p.getInventory().addItem(xp);

            i++;
          }
          Inventoryy.xp.put(p.getName(), time);

        } else {
          p.sendMessage(
              prefix
                  + ChatColor.DARK_RED
                  + "Kaufe dir den Premium Rang, um dieses Feature freizuschalten.");
        }
      } else if (e.getCurrentItem().getType() == Material.OBSIDIAN) {
        if (p.hasPermission("karotte.titan")) {
          if (Inventoryy.titan.containsKey(p.getName())) {
            Long lu = Inventoryy.titan.get(p.getName());
            if (lu + 43200000 > time) {
              p.sendMessage(prefix + ChatColor.GREEN + "Du musst noch warten!");
              return;
            }
          }
          p.sendMessage(prefix + ChatColor.GREEN + "Du hast das Titan Kit erhalten!");
          p.sendMessage(
              prefix + ChatColor.GREEN + "Warte 12 Stunden, um dieses Kit wieder zu holen!");
          p.getInventory().addItem(new ItemStack(Material.DIAMOND_BOOTS));
          p.getInventory().addItem(new ItemStack(Material.DIAMOND_CHESTPLATE));
          p.getInventory().addItem(new ItemStack(Material.DIAMOND_LEGGINGS));
          p.getInventory().addItem(new ItemStack(Material.DIAMOND_HELMET));

          ItemStack titan = new ItemStack(Material.DIAMOND_SWORD);
          ItemMeta metatitan = titan.getItemMeta();
          metatitan.addEnchant(Enchantment.FIRE_ASPECT, 1, true);
          metatitan.setDisplayName(ChatColor.AQUA + "Titan Schwert");
          titan.setItemMeta(metatitan);
          p.getInventory().addItem(titan);
          Inventoryy.titan.put(p.getName(), time);
        } else {
          p.sendMessage(
              prefix
                  + ChatColor.DARK_RED
                  + "Kaufe dir den Titan Rang, um dieses Feature freizuschalten.");
        }
      } else if (e.getCurrentItem().getType() == Material.IRON_DOOR) {
        p.closeInventory();
      }
    } else if (e.getInventory().getName().equalsIgnoreCase(ChatColor.RED + "Spiele")
        || e.getInventory()
            .getName()
            .equalsIgnoreCase(
                ChatColor.DARK_GRAY
                    + "Stein "
                    + ChatColor.DARK_PURPLE
                    + "Schere "
                    + ChatColor.WHITE
                    + "Papier")
        || e.getInventory().getName().equalsIgnoreCase(ChatColor.AQUA + "Spieler gefunden! =D")
        || e.getInventory().getName().equalsIgnoreCase(ChatColor.DARK_GREEN + "InGame")
        || e.getInventory().getName().equalsIgnoreCase(ChatColor.GOLD + "Smartphone OS 1.0")) {

      e.setCancelled(true);

      if (e.getCurrentItem().getType() == Material.SHEARS
          && e.getCurrentItem()
              .getItemMeta()
              .getDisplayName()
              .equalsIgnoreCase(
                  ChatColor.DARK_GRAY
                      + "Stein "
                      + ChatColor.DARK_PURPLE
                      + "Schere "
                      + ChatColor.WHITE
                      + "Papier")) {

        wartessp.add(p);
        Games.wartemenu(p);

        p.closeInventory();
      } else if (e.getCurrentItem().getType() == Material.IRON_DOOR) {
        p.closeInventory();
        if (wartessp.contains(p)) {
          wartessp.remove(p);
        }
      } else if (e.getCurrentItem().getType() == Material.NETHER_STAR) {

      }
    }
  }