本文整理汇总了Java中org.bukkit.inventory.meta.Repairable.getRepairCost方法的典型用法代码示例。如果您正苦于以下问题:Java Repairable.getRepairCost方法的具体用法?Java Repairable.getRepairCost怎么用?Java Repairable.getRepairCost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.Repairable
的用法示例。
在下文中一共展示了Repairable.getRepairCost方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: increaseReapirCount
import org.bukkit.inventory.meta.Repairable; //导入方法依赖的package包/类
private void increaseReapirCount(ItemStack item, int x) {
if (x == 0) return;
ItemMeta meta = item.getItemMeta();
if (meta instanceof Repairable) {
Repairable r = (Repairable) meta;
int count = r.getRepairCost() + x;
if (count < 0) count = 0;
r.setRepairCost(count);
item.setItemMeta(meta);
}
}
示例2: RepairInstance
import org.bukkit.inventory.meta.Repairable; //导入方法依赖的package包/类
public RepairInstance(ItemStack item, RepairConfig config, NyaaUtils plugin) {
if (item == null || item.getType() == Material.AIR) return;
RepairConfig.RepairConfigItem cfg = config.getRepairConfig(item.getType());
if (cfg == null) return;
if (!(item.getItemMeta() instanceof Repairable)) return;
if (item.hasItemMeta() && item.getItemMeta().hasLore()) {
if (!plugin.cfg.globalLoreBlacklist.canRepair(item.getItemMeta().getLore())) {
stat = RepairStat.UNREPAIRABLE;
return;
}
}
stat = RepairStat.REPAIRABLE;
if (item.getItemMeta().isUnbreakable()) {
stat = RepairStat.UNREPAIRABLE_UNBREAKABLE;
}
Repairable repairableMeta = (Repairable) item.getItemMeta();
repairLimit = cfg.repairLimit;
if (repairLimit > 0 && repairableMeta.getRepairCost() >= repairLimit) {
stat = RepairStat.UNREPAIRABLE_RLE;
}
Material toolMaterial = item.getType();
repairMaterial = cfg.material;
int currentDurability = item.getDurability();
if (currentDurability <= 0) {
stat = RepairStat.UNREPAIRABLE_REPAIRED;
}
int enchLevel = 0;
for (Integer i : item.getEnchantments().values()) enchLevel += i;
int fullDurability = toolMaterial.getMaxDurability();
durRecovered = (int) Math.floor((double) fullDurability / ((double) cfg.fullRepairCost + (double) enchLevel * cfg.enchantCostPerLv));
expConsumption = (int) Math.floor(cfg.expCost + cfg.enchantCostPerLv * enchLevel);
if (durRecovered <= 0) {
stat = RepairStat.UNREPAIRABLE_LOWRECOVER;
}
}
示例3: onInventoryClick
import org.bukkit.inventory.meta.Repairable; //导入方法依赖的package包/类
@EventHandler
public static void onInventoryClick(InventoryClickEvent e){
if(e.isCancelled()) return;
HumanEntity ent = e.getWhoClicked();
if(!(ent instanceof Player)) return;
Player player = (Player)ent;
Inventory inv = e.getInventory();
if(!(inv instanceof AnvilInventory)) return;
EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.REPAIR_ITEM);
for(EpicQuestTask task : taskList){
AnvilInventory anvil = (AnvilInventory)inv;
InventoryView view = e.getView();
int rawSlot = e.getRawSlot();
if(rawSlot == view.convertSlot(rawSlot)){
// 2 = result slot
if(rawSlot != 2) return;
ItemStack[] items = anvil.getContents();
ItemStack item1 = items[0];
ItemStack item3 = e.getCurrentItem();
//if(item1 == null || item2 == null || item3 == null) return;
Material id1 = item1.getType();
Material id3 = item3.getType();
if(id1 != id3) return;
//See if correct item is repaired
if(id3 == Material.matchMaterial(task.getTaskID())){
ItemMeta meta = item3.getItemMeta();
if(meta == null) return;
if(meta instanceof Repairable){
Repairable repairable = (Repairable)meta;
int repairCost = repairable.getRepairCost();
if(player.getLevel() >= repairCost){
task.ProgressTask(1, epicPlayer, true);
}
}
}
}
}
}