コード例 #1
0
 @Override
 public ItemStack[] generate() {
   ItemStack[] itemStacks = new ItemStack[getInventory().getSize()];
   int i = 0;
   for (RewardItem item : itemList) {
     ItemStackBuilder builder = new ItemStackBuilder();
     if (item.hasPermission(player)) {
       if (item.canUseReward(player)) {
         builder.withType(Material.EMERALD);
         builder.withName(ChatColor.GREEN + "Click to redeem");
       } else {
         builder.withType(Material.WATCH);
         builder.withName(
             ChatColor.RED + "Wait " + player.getWaitTime(item.getBlankname(), item.getTime()));
       }
     } else {
       builder.withType(Material.BARRIER);
       builder.withName(ChatColor.DARK_RED + item.getDenymsg());
     }
     builder.withLore("", ChatColor.AQUA + item.getName(), "");
     for (String s : item.getDescription()) {
       builder.withLore(ChatColor.GRAY + s);
     }
     itemStacks[i] = builder.build();
     i++;
   }
   return itemStacks;
 }
コード例 #2
0
 @Override
 public void click(Player player, ClickType clickType, int i, ItemStack itemStack) {
   if (i < itemList.size()) {
     RewardItem item = itemList.get(i);
     if (item.hasPermission(this.player)) {
       if (item.canUseReward(this.player)) {
         player.playSound(player.getLocation(), Sound.LEVEL_UP, 1f, 1f);
         item.use(this.player);
         item.giveReward(this.player, player);
         update();
       } else {
         player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1f, 1f);
         player.sendMessage(
             ChatColor.BLUE
                 + "You need to wait "
                 + ChatColor.AQUA
                 + this.player.getWaitTime(item.getBlankname(), item.getTime())
                 + ChatColor.BLUE
                 + " till you can use this");
       }
     } else {
       player.playSound(player.getLocation(), Sound.BLAZE_DEATH, 1f, 1f);
       player.sendMessage(ChatColor.RED + item.getDenymsg());
     }
   }
 }