コード例 #1
0
  @SuppressWarnings("deprecation")
  public static void setAvailableGuns(Player p) {
    if ((KitInventory.getKit(p).getItem(1) == null)
        || (KitInventory.getKit(p).getItem(3) == null)) {
      return;
    }

    none = new ItemStack(Material.EMERALD);

    ItemMeta noneMeta = none.getItemMeta();
    noneMeta.setDisplayName("§4None");
    none.setItemMeta(noneMeta);

    ArrayList<String> lore = new ArrayList<String>();

    final ItemStack Primary =
        new ItemStack(
            KitInventory.getKit(p).getItem(1).getType(),
            1,
            KitInventory.getKit(p).getItem(1).getData().getData());

    ItemMeta pMeta = Primary.getItemMeta();
    pMeta.setDisplayName(KitInventory.getKit(p).getItem(1).getItemMeta().getDisplayName());

    final ItemStack Secondary =
        new ItemStack(
            KitInventory.getKit(p).getItem(3).getType(),
            1,
            KitInventory.getKit(p).getItem(3).getData().getData());

    ItemMeta sMeta = Secondary.getItemMeta();
    sMeta.setDisplayName(KitInventory.getKit(p).getItem(3).getItemMeta().getDisplayName());

    String PrimaryName = pMeta.getDisplayName();
    String SecondaryName = sMeta.getDisplayName();

    ItemMeta PMeta = Primary.getItemMeta();
    PMeta.setDisplayName("§7Current Primary:§e " + PrimaryName);
    lore.add("§8Click this item to change");
    lore.add("§8your primary weapon");
    lore.add("");
    PMeta.setLore(lore);
    Primary.setItemMeta(PMeta);

    lore.clear();

    ItemMeta SMeta = Secondary.getItemMeta();
    SMeta.setDisplayName("§7Current Secondary:§e " + SecondaryName);
    lore.add("§8Click this item to change");
    lore.add("§8your secondary weapon");
    SMeta.setLore(lore);
    Secondary.setItemMeta(SMeta);

    PGun.put(p, Primary);
    SGun.put(p, Secondary);

    ClassSelection.get(p).setItem(27, Primary);
    ClassSelection.get(p).setItem(29, Secondary);
    ClassSelection.get(p).setItem(31, none);
    ClassSelection.get(p).setItem(33, none);

    Perk name = PerkAPI.getPerk(p);

    if (name == Perk.NO_PERK) {
      ItemsAndInventories.ClassSelection.get(p).setItem(35, none);
    } else if (name == Perk.SPEED) {
      ItemsAndInventories.ClassSelection.get(p)
          .setItem(
              35,
              Items.createItem(
                  PerkAPI.Speed.getType(),
                  1,
                  0,
                  "§a§lSpeed",
                  new ArrayList<String>(Arrays.asList("§2Click to change"))));
    } else if (name == Perk.MARATHON) {
      ItemsAndInventories.ClassSelection.get(p)
          .setItem(
              35,
              Items.createItem(
                  PerkAPI.Marathon.getType(),
                  1,
                  0,
                  "§a§lMarathon",
                  new ArrayList<String>(Arrays.asList("§2Click to change"))));
    } else if (name == Perk.SCAVENGER) {
      ItemsAndInventories.ClassSelection.get(p)
          .setItem(
              35,
              Items.createItem(
                  PerkAPI.Scavenger.getType(),
                  1,
                  0,
                  "§a§lScavenger",
                  new ArrayList<String>(Arrays.asList("§2Click to change"))));
    } else if (name == Perk.HARDLINE) {
      ItemsAndInventories.ClassSelection.get(p)
          .setItem(
              35,
              Items.createItem(
                  PerkAPI.Hardline.getType(),
                  1,
                  0,
                  "§a§lHardline",
                  new ArrayList<String>(Arrays.asList("§2Click to change"))));
    }
  }
コード例 #2
0
  public static void setPerkInv(Player p) {
    PerkAPI.loadOwnedPerks(p);
    PerkAPI.loadPerk(p);

    perks.put(p, Bukkit.getServer().createInventory(null, 45, "Perks"));
    Inventory inv = perks.get(p);

    inv.setItem(22, PerkAPI.noPerk);

    if (PerkAPI.ownsPerk(p, Perk.SPEED)) {
      inv.setItem(18, PerkAPI.ownsSpeed);
    } else {
      inv.setItem(18, PerkAPI.Speed);
    }

    if (PerkAPI.ownsPerk(p, Perk.MARATHON)) {
      inv.setItem(20, PerkAPI.ownsMarathon);
    } else {
      inv.setItem(20, PerkAPI.Marathon);
    }

    if (PerkAPI.ownsPerk(p, Perk.SCAVENGER)) {
      inv.setItem(24, PerkAPI.ownsScavenger);
    } else {
      inv.setItem(24, PerkAPI.Scavenger);
    }

    if (PerkAPI.ownsPerk(p, Perk.HARDLINE)) {
      inv.setItem(26, PerkAPI.ownsHardline);
    } else {
      inv.setItem(26, PerkAPI.Hardline);
    }

    if (PerkAPI.isUsingPerk(p)) {
      if (PerkAPI.getPerk(p) == Perk.SPEED) inv.setItem(9, PerkAPI.downArrow);
      if (PerkAPI.getPerk(p) == Perk.MARATHON) inv.setItem(11, PerkAPI.downArrow);
      if (PerkAPI.getPerk(p) == Perk.SCAVENGER) inv.setItem(15, PerkAPI.downArrow);
      if (PerkAPI.getPerk(p) == Perk.HARDLINE) inv.setItem(17, PerkAPI.downArrow);
    } else {
      inv.setItem(13, PerkAPI.downArrow);
    }

    inv.setItem(40, backAG);

    perks.put(p, inv);
  }