本文整理汇总了Java中com.elmakers.mine.bukkit.api.wand.WandUpgradePath类的典型用法代码示例。如果您正苦于以下问题:Java WandUpgradePath类的具体用法?Java WandUpgradePath怎么用?Java WandUpgradePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WandUpgradePath类属于com.elmakers.mine.bukkit.api.wand包,在下文中一共展示了WandUpgradePath类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInventoryTitle
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
protected String getInventoryTitle(CastContext context)
{
Wand wand = context.getWand();
WandUpgradePath path = (wand == null ? null : wand.getPath());
String pathName = (path == null ? null : path.getName());
if (pathName == null) {
pathName = "";
}
String title = context.getMessage("title", "Shop ($balance)");
title = title.replace("$path", pathName);
return title;
}
示例2: finish
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
@Override
public void finish(com.elmakers.mine.bukkit.api.action.CastContext context) {
SpellResult result = context.getResult();
// Notify other plugins of this spell cast
CastEvent castEvent = new CastEvent(mage, this, result);
Bukkit.getPluginManager().callEvent(castEvent);
// Message targets
if (result.isSuccess() && !mage.isQuiet()) {
messageTargets("cast_player_message");
}
// Track cast counts
if (result.isSuccess() && trackCasts) {
castCount++;
if (template != null) {
template.castCount++;
}
// Reward SP
Wand wand = context.getWand();
WandUpgradePath path = wand == null ? null : wand.getPath();
if (earns > 0 && wand != null && path != null && path.earnsSP() && controller.isSPEnabled() && !mage.isAtMaxSkillPoints()) {
long now = System.currentTimeMillis();
int scaledEarn = earns;
if (lastEarn > 0 && earnCooldown > 0 && now < lastEarn + earnCooldown) {
scaledEarn = (int)Math.floor((double)earns * (now - lastEarn) / earnCooldown);
if (scaledEarn > 0) {
context.playEffects("earn_scaled_sp");
}
} else {
context.playEffects("earn_sp");
}
if (scaledEarn > 0) {
mage.addSkillPoints(scaledEarn);
lastEarn = now;
}
}
// Check for level up
// This currently only works on wands.
if (wand != null && !wand.isLocked() && controller.isSpellUpgradingEnabled() && wand.getSpellLevel(spellKey.getKey()) == spellKey.getLevel())
{
SpellTemplate upgrade = getUpgrade();
long requiredCasts = getRequiredUpgradeCasts();
if (upgrade != null && requiredCasts > 0 && getCastCount() >= requiredCasts)
{
String upgradePath = getRequiredUpgradePath();
WandUpgradePath currentPath = wand.getPath();
if (upgradePath == null || upgradePath.isEmpty() || (currentPath != null && currentPath.hasPath(upgradePath)))
{
Spell newSpell = mage.getSpell(upgrade.getKey());
if (isActive()) {
deactivate(true, true);
if (newSpell != null && newSpell instanceof MageSpell) {
((MageSpell)newSpell).activate();
}
}
wand.addSpell(upgrade.getKey());
Messages messages = controller.getMessages();
String levelDescription = upgrade.getLevelDescription();
if (levelDescription == null || levelDescription.isEmpty()) {
levelDescription = upgrade.getName();
}
playEffects("upgrade");
mage.sendMessage(messages.get("wand.spell_upgraded").replace("$name", upgrade.getName()).replace("$wand", getName()).replace("$level", levelDescription));
mage.sendMessage(upgrade.getUpgradeDescription().replace("$name", upgrade.getName()));
SpellUpgradeEvent upgradeEvent = new SpellUpgradeEvent(mage, wand, this, newSpell);
Bukkit.getPluginManager().callEvent(upgradeEvent);
}
}
}
}
}
示例3: showItems
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public SpellResult showItems(CastContext context, List<ShopItem> items) {
Mage mage = context.getMage();
this.context = context;
Player player = mage.getPlayer();
if (player == null) {
return SpellResult.PLAYER_REQUIRED;
}
this.showingItems = new HashMap<Integer, ShopItem>();
// Load items
itemStacks = new ArrayList<ItemStack>();
String costString = context.getMessage("cost_lore", "Costs: $cost");
for (ShopItem shopItem : items) {
int currentSlot = itemStacks.size();
if (shopItem == null) {
this.showingItems.put(currentSlot, null);
itemStacks.add(new ItemStack(Material.AIR));
continue;
}
ItemStack item = InventoryUtils.getCopy(shopItem.getItem());
if (item == null) continue;
ItemMeta meta = item.getItemMeta();
if (meta == null) {
itemStacks.add(item);
continue;
}
List<String> lore = meta.getLore();
if (lore == null) {
lore = new ArrayList<String>();
}
String costs = costString.replace("$cost", getItemCost(context, shopItem));
lore.add(ChatColor.GOLD + costs);
meta.setLore(lore);
item.setItemMeta(meta);
item = InventoryUtils.makeReal(item);
InventoryUtils.setMeta(item, "shop", Integer.toString(currentSlot));
if (showConfirmation) {
InventoryUtils.setMeta(item, "confirm", "true");
}
this.showingItems.put(currentSlot, shopItem);
itemStacks.add(item);
}
if (itemStacks.size() == 0) {
Wand wand = mage.getActiveWand();
if (wand != null && autoUpgrade) {
com.elmakers.mine.bukkit.api.wand.WandUpgradePath path = wand.getPath();
WandUpgradePath nextPath = path != null ? path.getUpgrade(): null;
if (nextPath != null && path.checkUpgradeRequirements(wand, null) && !path.canEnchant(wand)) {
path.upgrade(wand, mage);
return SpellResult.CAST;
}
}
context.showMessage("no_items", "There is nothing for you to buy here");
return SpellResult.FAIL;
}
Inventory displayInventory = getInventory(context);
mage.activateGUI(this, displayInventory);
return SpellResult.CAST;
}
示例4: WandUpgradeEvent
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public WandUpgradeEvent(Mage mage, Wand wand, WandUpgradePath oldPath, WandUpgradePath newPath) {
this.mage = mage;
this.wand = wand;
this.oldPath = oldPath;
this.newPath = newPath;
}
示例5: getOldPath
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public WandUpgradePath getOldPath() {
return oldPath;
}
示例6: getNewPath
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public WandUpgradePath getNewPath() {
return newPath;
}
示例7: getBoundWandPath
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public WandUpgradePath getBoundWandPath(String templateKey);
示例8: getPath
import com.elmakers.mine.bukkit.api.wand.WandUpgradePath; //导入依赖的package包/类
public WandUpgradePath getPath(String key);