示例#1
0
 @Override
 public void addPlayer(Player p) {
   ItemStack helmet = new ItemStack(Material.LEATHER_HELMET);
   ItemMeta helmetMeta = setArmourColor(helmet.getItemMeta(), Color.BLUE);
   helmetMeta.addEnchant(Enchantment.OXYGEN, 3, true);
   helmet.setItemMeta(helmetMeta);
   setHelmet(helmet, p);
   setChestplate(new ItemStack(Material.CHAINMAIL_CHESTPLATE), p);
   setLeggings(new ItemStack(Material.CHAINMAIL_LEGGINGS), p);
   ItemStack boots = new ItemStack(Material.LEATHER_BOOTS);
   ItemMeta bootsMeta = setArmourColor(boots.getItemMeta(), Color.BLUE);
   // bootsMeta.addEnchant(Enchantment.DEPTH_STRIDER, 3, true);
   // can't add depth strider because No cheat plus blocks it atm.
   bootsMeta.addEnchant(Enchantment.PROTECTION_FALL, 3, true);
   boots.setItemMeta(bootsMeta);
   setBoots(boots, p);
   ItemStack sword = new ItemStack(Material.GOLD_SWORD);
   ItemMeta swordMeta = sword.getItemMeta();
   swordMeta.setDisplayName(ChatColor.BLUE + "Trident");
   swordMeta.setLore(Arrays.asList("Crouch in water to activate!"));
   swordMeta.addEnchant(Enchantment.DAMAGE_ALL, 1, true);
   swordMeta.addEnchant(Enchantment.DURABILITY, 5, true);
   sword.setItemMeta(swordMeta);
   setWeapon(sword, p);
   p.setLevel(1);
   fillSoup(p);
 }
  /*
   * @Return: True if they have an ability matching the held item. False if
   * they do not have any abilities matching held item
   */
  public boolean useAbility(Player sender, Player target) {
    // check if they're holding anything
    if (sender.getItemInHand() == null) {
      return false;
    }

    ItemStack i = sender.getItemInHand();

    // sees if they are fightclassed
    FightClass f = FightClass.get(sender);
    // goes through each ability, seeeing if any of the MID's match the
    // lore of the item
    for (Ability a : f.getAbilities()) {
      if (i.getItemMeta().hasLore()
          && i.getItemMeta().getLore().get(0).equalsIgnoreCase(a.getMID())) {
        // check if cost is able to be paid, and pay it
        if (a.useCost(sender)) {
          if (!sender.equals(target)) {
            a.effect(sender, target);
          }
        } else {
          // nothing
        }
        return true;
      }
    }
    return false;
  }
  public void loadLobbyInventory(Game game) {
    ItemMeta im = null;

    // choose team only when autobalance is disabled
    if (!game.isAutobalanceEnabled()) {
      // Choose team (Wool)
      ItemStack teamSelection = new ItemStack(Material.BED, 1);
      im = teamSelection.getItemMeta();
      im.setDisplayName(Main._l("lobby.chooseteam"));
      teamSelection.setItemMeta(im);
      this.player.getInventory().addItem(teamSelection);
    }

    // Leave Game (Slimeball)
    ItemStack leaveGame = new ItemStack(Material.SLIME_BALL, 1);
    im = leaveGame.getItemMeta();
    im.setDisplayName(Main._l("lobby.leavegame"));
    leaveGame.setItemMeta(im);
    this.player.getInventory().setItem(8, leaveGame);

    if (this.player.hasPermission("bw.setup")
        || this.player.isOp()
        || this.player.hasPermission("bw.vip.forcestart")) {
      // Force start game (Diamond)
      ItemStack startGame = new ItemStack(Material.DIAMOND, 1);
      im = startGame.getItemMeta();
      im.setDisplayName(Main._l("lobby.startgame"));
      startGame.setItemMeta(im);
      this.player.getInventory().addItem(startGame);
    }

    this.player.updateInventory();
  }
示例#4
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onPlayerJoin(PlayerJoinEvent event) {
    if (this.getConfig().getBoolean("clearInventoryOnJoin")) {
      Player p = event.getPlayer();
      p.getInventory().clear();

      if (this.getConfig().getBoolean("backToHubItem")) {
        ItemStack bth = new ItemStack(Material.NETHER_STAR, 1);
        ItemMeta bthMeta = bth.getItemMeta();
        bthMeta.setDisplayName(
            ChatColor.LIGHT_PURPLE + "Back " + ChatColor.GREEN + "To " + ChatColor.BLUE + "Hub");
        bth.setItemMeta(bthMeta);

        p.getInventory().setItem(8, bth);
      }
      if (this.getConfig().getBoolean("quickWarpItem")) {
        ItemStack qw = new ItemStack(Material.COMPASS, 1);
        ItemMeta qwMeta = qw.getItemMeta();
        qwMeta.setDisplayName(ChatColor.LIGHT_PURPLE + "Quick Warp");
        qw.setItemMeta(qwMeta);

        p.getInventory().setItem(7, qw);
      }
      p.updateInventory();
    }
  }
  public static void openGomibako(CommandSender sender) {
    if (!(sender instanceof Player)) {
      Msg.warning(sender, "ゴミ箱コマンドはゲーム内からのみ実行できます");
    }

    Player player = (Player) sender;

    if (!(player.hasPermission(Permissions.getGomibakoPermisson()))) {
      Msg.noPermissionMessage(sender, Permissions.getGomibakoPermisson());
      return;
    }

    ItemStack item0 = new ItemStack(Material.BOOK);
    ItemMeta itemmeta0 = item0.getItemMeta();
    itemmeta0.setDisplayName(ChatColor.GOLD + "ゴミ箱の使い方");
    itemmeta0.setLore(
        Arrays.asList(ChatColor.WHITE + "ゴミ箱に不要なアイテムを収納し、", ChatColor.WHITE + "画面を閉じると処分が完了します。"));
    item0.setItemMeta(itemmeta0);

    ItemStack item1 = new ItemStack(Material.BED);
    ItemMeta itemmeta1 = item1.getItemMeta();
    itemmeta1.setDisplayName(ChatColor.GOLD + "画面を閉じる");
    itemmeta1.setLore(Arrays.asList(ChatColor.GRAY + "定食サーバオリジナルプラグイン!"));
    item1.setItemMeta(itemmeta1);

    Inventory inv = Bukkit.createInventory(player, 36, " ゴミ箱 ");
    inv.setItem(0, item0);
    inv.setItem(1, item1);
    player.openInventory(inv);
  }
  public int getBootRepairRate(ItemStack boots) {

    boolean fastRepair = false;

    if (isValidRocketBoots(boots))
      if (boots.getItemMeta().getLore().size() == 3) {
        String enhancementLore = boots.getItemMeta().getLore().get(2);
        RocketEnhancement.Enhancement enhancement =
            RocketEnhancement.Enhancement.getEnum(enhancementLore);
        if (enhancement != null)
          if (enhancement.equals(RocketEnhancement.Enhancement.FASTREP)) fastRepair = true;
      }

    switch (getBootPowerLevel(boots)) {
      case 1:
        return fastRepair ? 20 : 5;

      case 2:
        return fastRepair ? 17 : 4;

      case 3:
        return fastRepair ? 15 : 3;

      case 4:
        return fastRepair ? 13 : 2;

      case 5:
        return fastRepair ? 10 : 1;
    }

    return 0;
  }
 public boolean upgradePearl(Inventory inv, PrisonPearl pp) {
   final String prisoner = pp.getImprisonedName();
   ItemStack is = new ItemStack(Material.ENDER_PEARL, 1, pp.getID());
   int pearlslot = inv.first(is);
   if (pearlslot < 0) {
     // If the pearl has been converted, first won't return it here
     // as the metadata doesn't match.
     return false;
   }
   ItemStack existing_is = inv.getItem(pearlslot);
   if (existing_is != null) {
     ItemMeta existing_meta = existing_is.getItemMeta();
     if (existing_meta != null) {
       String existing_name = existing_meta.getDisplayName();
       if (existing_name != null && existing_name.compareTo(prisoner) == 0) {
         return true;
       }
     }
   }
   ItemMeta im = is.getItemMeta();
   // Rename pearl to that of imprisoned player
   im.setDisplayName(prisoner);
   List<String> lore = new ArrayList<String>();
   lore.add(prisoner + " is held within this pearl");
   // Given enchantment effect
   // Durability used because it doesn't affect pearl behaviour
   im.addEnchant(Enchantment.DURABILITY, 1, true);
   im.setLore(lore);
   is.setItemMeta(im);
   is.removeEnchantment(Enchantment.DURABILITY);
   inv.clear(pearlslot);
   inv.setItem(pearlslot, is);
   return true;
 }
示例#8
0
 public void jobOrientation(Player p) {
   p.setGameMode(GameMode.SURVIVAL);
   if (this.equals(TimeProfession.OFFICER)) {
     PlayerInventory pi = p.getInventory();
     ItemStack inv_item = pi.getItem(0);
     String display_name = "";
     if (inv_item != null) {
       display_name = inv_item.getItemMeta().getDisplayName();
       if (display_name == null) display_name = "";
     }
     if (inv_item == null
         || !inv_item.getType().equals(Material.STICK)
         || !display_name.equals("Baton")) {
       ItemStack is = new ItemStack(Material.STICK, 1);
       ItemStack is_backup = null;
       if (inv_item != null) is_backup = inv_item.clone();
       ItemMeta im = is.getItemMeta();
       im.setDisplayName("Baton");
       ArrayList<String> lore = new ArrayList();
       lore.add("Arrests bountied players");
       im.setLore(lore);
       is.setItemMeta(im);
       pi.setItem(0, is);
       if (inv_item != null) pi.addItem(is_backup);
       p.updateInventory();
     }
   }
 }
示例#9
0
  static {
    diamondSplegg = new ItemStack(Material.DIAMOND_SPADE);
    ItemMeta diamondSpleggMeta = diamondSplegg.getItemMeta();
    ArrayList<String> lore = new ArrayList<>();

    diamondSpleggMeta.setDisplayName(ChatColor.DARK_AQUA + "Diamond Splegg");
    lore.add(ChatColor.DARK_PURPLE + "Costs 100 coins!");
    lore.add(ChatColor.AQUA + "Shoots three snowballs!");

    diamondSpleggMeta.setLore(lore);
    diamondSplegg.setItemMeta(diamondSpleggMeta);

    goldSplegg = new ItemStack(Material.GOLD_SPADE);
    ItemMeta goldSpleggMeta = goldSplegg.getItemMeta();
    lore.clear();

    goldSpleggMeta.setDisplayName(ChatColor.GOLD + "Gold Splegg");
    lore.add(ChatColor.DARK_PURPLE + "Costs 75 coins!");
    lore.add(ChatColor.AQUA + "Shoots two snowballs!");

    goldSpleggMeta.setLore(lore);
    goldSplegg.setItemMeta(goldSpleggMeta);

    stoneSplegg = new ItemStack(Material.STONE_SPADE);
    ItemMeta stoneSpleggMeta = stoneSplegg.getItemMeta();
    lore.clear();

    stoneSpleggMeta.setDisplayName(ChatColor.GRAY + "Stone Splegg");
    lore.add(ChatColor.DARK_PURPLE + "Costs 50 coins!");
    lore.add(ChatColor.AQUA + "Shoots one snowball!");

    stoneSpleggMeta.setLore(lore);
    stoneSplegg.setItemMeta(stoneSpleggMeta);
  }
  public static void updateShop(Player p) {
    ItemStack alert = new ItemStack(Material.REDSTONE);

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

    if (!isEmpty(ShopInventoryPrimary.getPrimaryShop(p))) {
      ItemMeta PAlert = alert.getItemMeta();
      PAlert.setDisplayName("§6§lGuns Available");
      lore.add("§7You can buy a new");
      lore.add("§7primary gun");
      PAlert.setLore(lore);
      alert.setItemMeta(PAlert);

      ShopMainMenu.get(p).setItem(28, alert);
    } else {
      ShopMainMenu.get(p).setItem(28, null);
    }

    lore.clear();

    if (!isEmpty(ShopInventorySecondary.getSecondaryShop(p))) {
      ItemMeta SAlert = alert.getItemMeta();
      SAlert.setDisplayName("§6§lGuns Available");
      lore.add("§7You can buy a new");
      lore.add("§7secondary gun");
      SAlert.setLore(lore);
      alert.setItemMeta(SAlert);

      ShopMainMenu.get(p).setItem(34, alert);
    } else {
      ShopMainMenu.get(p).setItem(34, null);
    }
  }
 public void addItem(ItemStack i, int loc, BSShop shop, BasicConnector c) {
   to_ping.add(c);
   if (!i.hasItemMeta()) {
     c.setOldData(null, null, i, shop, loc);
     return;
   }
   c.setOldData(i.getItemMeta().getLore(), i.getItemMeta().getDisplayName(), i, shop, loc);
 }
示例#12
0
 @Override
 protected boolean isSpecialItem(ItemStack stack) {
   if (stack != null && stack.hasItemMeta() && stack.getItemMeta().hasDisplayName()) {
     String name = stack.getItemMeta().getDisplayName();
     if (name.contains(getSpecialItemName()) && KitUtils.isSoulbound(stack)) return true;
   }
   return false;
 }
 public PrisonPearl getPearlbyItemStack(ItemStack stack) {
   if (!stack.hasItemMeta() || stack.getType() != Material.ENDER_PEARL) return null;
   if (!stack.getItemMeta().hasLore()) return null;
   List<String> lore = stack.getItemMeta().getLore();
   if (lore.size() != 3) return null;
   UUID uuid = UUID.fromString(lore.get(1).split(" ")[1]);
   return pearls_byimprisoned.get(uuid);
 }
示例#14
0
 public String itemToString(ItemStack item) {
   String str = "";
   String n =
       item.getItemMeta().hasDisplayName()
           ? ChatColor.stripColor(item.getItemMeta().getDisplayName())
           : item.getType().name();
   String a = item.getAmount() > 1 ? "*" + item.getAmount() : "";
   str = n + a;
   return str;
 }
示例#15
0
  /**
   * Returns true is the item stack is not null, if the item is a full sized stack, with size more
   * than one (to prevent simply adding lore to single items), that the item does NOT have lore, and
   * that the item has simple metadata (not a book, fireworks, banners, beacons, other "special"
   * items that generate a host of edge cases like duplication and cheap dye and other problems.)
   *
   * @param is the ItemStack to check validity of compaction
   * @return true if can be compacted, false otherwise
   */
  private boolean canCompact(ItemStack is) {
    return is != null
        && is.getAmount() == is.getMaxStackSize()
        && is.getAmount() > 1
        && !is.getItemMeta().hasLore()
        && is.getItemMeta().getClass().getSuperclass().equals(java.lang.Object.class);

    /* bit of a hack at the end, but effectively only items with "simple" meta, where the implementation
     * is strictly a subclass of Object, and not a subclass of bukkit's CraftMetaItem. */
  }
示例#16
0
 @Override
 public void setColor(ItemStack itemStack, Color color) {
   ItemMeta meta = itemStack.getItemMeta();
   if (meta != null && itemStack.getItemMeta() instanceof LeatherArmorMeta) {
     org.bukkit.Color bukkitColor = getBukkitColor(color);
     LeatherArmorMeta lam = (LeatherArmorMeta) itemStack.getItemMeta();
     lam.setColor(bukkitColor);
     itemStack.setItemMeta(lam);
   }
 }
示例#17
0
 @Override
 public Color getColor(ItemStack itemStack) {
   ItemMeta meta = itemStack.getItemMeta();
   if (meta != null && itemStack.getItemMeta() instanceof LeatherArmorMeta) {
     LeatherArmorMeta lam = (LeatherArmorMeta) itemStack.getItemMeta();
     return new Color(
         lam.getColor().getRed(), lam.getColor().getGreen(), lam.getColor().getBlue());
   }
   return null;
 }
示例#18
0
 public static String getItemName(ItemStack stack) {
   if (stack != null) {
     if (stack.getItemMeta() != null && stack.getItemMeta().getDisplayName() != null) {
       return stack.getItemMeta().getDisplayName();
     }
     ItemInfo itemInfo = Items.itemByStack(stack);
     return itemInfo != null ? itemInfo.getName() : "" + stack.getType();
   }
   return null;
 }
示例#19
0
 @EventHandler(ignoreCancelled = true)
 public void onPrefsMenuClick(InventoryClickEvent event) {
   Inventory inv = event.getInventory();
   String name = inv.getTitle();
   if (name.equals("§4TARDIS Key Prefs Menu")) {
     Player p = (Player) event.getWhoClicked();
     int slot = event.getRawSlot();
     if (slot >= 0 && slot < 27) {
       switch (slot) {
         case 0:
         case 1:
         case 2:
         case 3:
         case 4:
         case 5:
         case 6:
         case 7:
         case 8:
         case 10:
         case 12:
         case 14:
         case 16:
           event.setCancelled(true);
           // set display name of key in slot 18
           ItemStack key = inv.getItem(18);
           if (key == null || !key.getType().equals(Material.GOLD_NUGGET) || !key.hasItemMeta()) {
             return;
           }
           // get Display name of selected key
           ItemStack choice = inv.getItem(slot);
           ItemMeta choice_im = choice.getItemMeta();
           String choice_name = choice_im.getDisplayName();
           ItemMeta sonic_im = key.getItemMeta();
           sonic_im.setDisplayName(choice_name);
           key.setItemMeta(sonic_im);
           break;
         case 18:
           break;
         case 26:
           // close
           event.setCancelled(true);
           close(p);
           break;
         default:
           event.setCancelled(true);
           break;
       }
     } else {
       ClickType click = event.getClick();
       if (click.equals(ClickType.SHIFT_RIGHT) || click.equals(ClickType.SHIFT_LEFT)) {
         event.setCancelled(true);
       }
     }
   }
 }
示例#20
0
 public static ItemStack addLore(ItemStack item, String i) {
   ArrayList<String> lore = new ArrayList<String>();
   ItemMeta m = item.getItemMeta();
   if (item.getItemMeta().hasLore()) {
     lore.addAll(item.getItemMeta().getLore());
   }
   lore.add(i);
   m.setLore(lore);
   item.setItemMeta(m);
   return item;
 }
示例#21
0
 public static boolean isFireBlade(ItemStack is) {
   if (is == null) {
     return false;
   }
   if ((is.getItemMeta() != null)
       && (is.getItemMeta().getLore() != null)
       && is.getItemMeta().getLore().contains(LORE_NAME)) {
     return true;
   }
   return false;
 }
示例#22
0
 @EventHandler
 protected static void onPlayerInteract(PlayerInteractEvent event) {
   Action action = event.getAction();
   ItemStack item = event.getItem();
   if (action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) {
     if (item != null
         && item.getType() == ITEM.getType()
         && item.getItemMeta().getLore() == ITEM.getItemMeta().getLore()) {
       openGUI(event.getPlayer());
     }
   }
 }
示例#23
0
 public String disName(ItemStack i) {
   if (i == null) {
     return null;
   }
   if (!i.hasItemMeta()) {
     return null;
   }
   if (!i.getItemMeta().hasDisplayName()) {
     return null;
   }
   return i.getItemMeta().getDisplayName();
 }
示例#24
0
 public boolean isAncientSword(final ItemStack item) {
   final ArrayList<String> lore = new ArrayList<String>();
   lore.add("AncientSword");
   lore.add("Very old and mysterious sword.");
   lore.add("This will protect you aganist Herobrine.");
   if ((item != null) && (item.getItemMeta() != null) && (item.getItemMeta().getLore() != null)) {
     final ArrayList<String> ilore = (ArrayList<String>) item.getItemMeta().getLore();
     if (ilore.containsAll(lore)) {
       return true;
     }
   }
   return false;
 }
  /**
   * Creates a new ItemDisplay inventory that will allow the user to cycle through the "/bi items"
   * command
   *
   * @param player the player that this inventory will display for
   * @param showStats if the items should have their attributes shown as lore
   * @param page the page number for the inventory (almost always 0)
   */
  public ItemDisplay(Player player, boolean showStats, int page) {
    this.player = player;
    this.showStats = showStats;
    this.page = page;
    ItemMeta meta1 = PREV_BUTTON.getItemMeta();
    meta1.setDisplayName(ChatColor.RED + "Prev");
    PREV_BUTTON.setItemMeta(meta1);

    ItemMeta meta2 = NEXT_BUTTON.getItemMeta();
    meta2.setDisplayName(ChatColor.GREEN + "Next");
    NEXT_BUTTON.setItemMeta(meta2);
    createInventory();
  }
示例#26
0
 @Override
 public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
   if (sender instanceof Player) {
     Player p = (Player) sender;
     if ((p.hasPermission("advancedrename.relore")) || (p.hasPermission("advancedrename.*"))) {
       if (args.length >= 1) {
         if ((p.getItemInHand() != null) && (p.getItemInHand().getType() != Material.AIR)) {
           String name = args[0];
           for (int i = 0; i < args.length; i++) {
             name = name + " " + args[i];
           }
           name = ChatColor.translateAlternateColorCodes('&', name);
           if ((name.contains(";"))) {
             ItemStack i = p.getItemInHand();
             ItemMeta im = i.getItemMeta();
             String[] lore = name.split(";");
             List<String> il = new ArrayList<String>();
             for (int l = 1; l < lore.length; l++) {
               il.add(lore[l]);
             }
             im.setLore(il);
             i.setItemMeta(im);
             p.updateInventory();
             p.sendMessage(Main.pr + "�uccessfully lore set for the item.");
             return true;
           } else {
             ItemStack i = p.getItemInHand();
             ItemMeta im = i.getItemMeta();
             List<String> il = new ArrayList<String>();
             il.add(name);
             im.setLore(il);
             i.setItemMeta(im);
             p.updateInventory();
             p.sendMessage(Main.pr + "�uccessfully lore set for the item.");
             return true;
           }
         } else {
           p.sendMessage(Main.pr + "Please hold a Item in your hand.");
           return true;
         }
       }
     } else {
       p.sendMessage(Main.pr + "You dont have permission to use this command!");
       return true;
     }
   } else {
     sender.sendMessage("[AdvancedRename] You must be a player to relore a item.");
     return true;
   }
   return false;
 }
 public boolean upgradePearl(Inventory inv, PrisonPearl pp) {
   final UUID prisonerId = pp.getImprisonedId();
   final String prisoner;
   if (plugin.isNameLayerLoaded()) prisoner = NameAPI.getCurrentName(pp.getImprisonedId());
   else prisoner = Bukkit.getOfflinePlayer(prisonerId).getName();
   ItemStack is = new ItemStack(Material.ENDER_PEARL, 1);
   for (ItemStack existing_is : inv.getContents()) {
     if (existing_is == null || existing_is.getType() != Material.ENDER_PEARL) continue;
     int pearlslot = inv.first(existing_is);
     if (existing_is != null) {
       existing_is.setDurability((short) 0);
       ItemMeta existing_meta = existing_is.getItemMeta();
       if (existing_meta != null) {
         String existing_name = existing_meta.getDisplayName();
         List<String> lore = existing_meta.getLore();
         if (existing_name != null
             && prisoner != null
             && existing_name.compareTo(prisoner) == 0
             && lore != null
             && lore.size() == 3) {
           // This check says all existing stuff is there so return true.
           return true;
         } else if (existing_name != null
             && prisoner != null
             && existing_name.compareTo(prisoner) != 0)
           // If we don't have the right pearl keep looking.
           continue;
         else if (existing_name == null)
           // This pearl can't even be right so just return.
           return true;
       }
     }
     ItemMeta im = is.getItemMeta();
     // Rename pearl to that of imprisoned player
     im.setDisplayName(prisoner);
     List<String> lore = new ArrayList<String>();
     lore.add(prisoner + " is held within this pearl");
     lore.add("UUID: " + pp.getImprisonedId().toString());
     lore.add("Unique: " + pp.getUniqueIdentifier());
     // Given enchantment effect
     // Durability used because it doesn't affect pearl behaviour
     im.addEnchant(Enchantment.DURABILITY, 1, true);
     im.setLore(lore);
     is.setItemMeta(im);
     inv.clear(pearlslot);
     inv.setItem(pearlslot, is);
     return true;
   }
   return false;
 }
示例#28
0
 @Override
 public boolean apply(ItemStack stack) {
   if (stack.hasItemMeta()) {
     ItemMeta meta = stack.getItemMeta();
     if (meta.hasLore()) {
       String lore = Joiner.on('\n').join(stack.getItemMeta().getLore());
       if (ignoreColors) {
         lore = ChatColor.stripColor(lore);
       }
       return pattern.matcher(lore).find();
     }
   }
   return false;
 }
示例#29
0
 /**
  * @param player Set the player
  * @param itemstack The bank note itemstack
  * @param newvalue Set the new value of the Banknote
  */
 @SuppressWarnings("deprecation")
 public void changeBanknoteAmount(Player player, ItemStack itemstack, int newvalue) {
   ArrayList<String> lore = new ArrayList<String>();
   String one = itemstack.getItemMeta().getLore().get(0);
   String[] split = one.split(" ");
   String s1 = split[0];
   String s2 = split[1];
   String part1 = s1.replaceAll("[\\d]+", String.valueOf(newvalue));
   lore.add(part1 + " " + s2);
   lore.add(itemstack.getItemMeta().getLore().get(1));
   setItemText(itemstack, itemstack.getItemMeta().getDisplayName(), lore);
   player.playSound(player.getLocation(), Sound.ENDERDRAGON_WINGS, (float) 0.3, 1);
   player.updateInventory();
 }
示例#30
0
  @SuppressWarnings("deprecation")
  public static void onPlayerKillPlayer(Player killer) {
    if (getPerk(killer) == Perk.SCAVENGER) {
      if (Main.PlayingPlayers.contains(killer)) {
        if (killer.getInventory().getItem(19) != null) {
          ItemStack ammoPrimary = killer.getInventory().getItem(19);
          int Primary25 = ammoPrimary.getAmount() / 4;
          if (Primary25 <= 0) return;
          killer
              .getInventory()
              .addItem(
                  Items.createItem(
                      ammoPrimary.getType(),
                      Primary25,
                      ammoPrimary.getData().getData(),
                      ammoPrimary.getItemMeta().getDisplayName()));
        }

        if (killer.getInventory().getItem(25) != null) {
          ItemStack ammoSecondary = killer.getInventory().getItem(25);
          int Secondary25 = ammoSecondary.getAmount() / 4;
          if (Secondary25 <= 0) return;
          killer
              .getInventory()
              .addItem(
                  Items.createItem(
                      ammoSecondary.getType(),
                      Secondary25,
                      ammoSecondary.getData().getData(),
                      ammoSecondary.getItemMeta().getDisplayName()));
        }

        if (killer.getInventory().getItem(8) != null) {
          ItemStack ammoFFA = killer.getInventory().getItem(8);
          int FFA25 = ammoFFA.getAmount() / 4;
          if (FFA25 <= 0) return;
          killer
              .getInventory()
              .addItem(
                  Items.createItem(
                      ammoFFA.getType(),
                      FFA25,
                      ammoFFA.getData().getData(),
                      ammoFFA.getItemMeta().getDisplayName()));
        }
      }
    }
  }