• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Mage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.elmakers.mine.bukkit.api.magic.Mage的典型用法代码示例。如果您正苦于以下问题:Java Mage类的具体用法?Java Mage怎么用?Java Mage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Mage类属于com.elmakers.mine.bukkit.api.magic包,在下文中一共展示了Mage类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: has

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public boolean has(Spell spell)
{
    if (!(spell instanceof MageSpell)) return false;
    Mage mage = ((MageSpell)spell).getMage();
    int amount = getAmount(spell);
    boolean hasItem = true;
    if (item != null && amount > 0 && !isConsumeFree(spell))
    {
        hasItem = mage.hasItem(item.getItemStack(amount), item.getData() == null);
    }
    boolean hasXp = xp <= 0 || mage.getExperience() >= getXP(spell);
    boolean hasMana = mana <= 0 || mage.getMana() >= getMana(spell);
    boolean hasCurrency = currency <= 0;
    if (!hasCurrency) {
        VaultController vault = VaultController.getInstance();
        hasCurrency = vault.has(mage.getPlayer(), getCurrency(spell));
    }

    return hasItem && hasXp && hasMana && hasCurrency;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:21,代码来源:CastingCost.java


示例2: use

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public void use(Spell spell)
{
    if (!(spell instanceof MageSpell)) return;
    Mage mage = ((MageSpell)spell).getMage();
    int amount = getAmount(spell);
    if (item != null && amount > 0 && !isConsumeFree(spell)) {
        ItemStack itemStack = getItemStack(spell);
        mage.removeItem(itemStack, item.getData() == null);
    }
    int xp = getXP(spell);
    if (xp > 0) {
        mage.removeExperience(xp);
    }
    float mana = getMana(spell);
    if (mana > 0) {
        mage.removeMana(mana);
    }
    double currency = getCurrency(spell);
    if (currency > 0) {
        VaultController vault = VaultController.getInstance();
        vault.withdrawPlayer(mage.getPlayer(), currency);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:24,代码来源:CastingCost.java


示例3: messageTargets

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
@Override
public void messageTargets(String messageKey)
{
    Mage mage = getMage();
    if (mage.isStealth()) return;
    Collection<Entity> targets = getTargetedEntities();
    if (targets == null || targets.isEmpty()) return;

    MageController controller = getController();
    LivingEntity sourceEntity = mage == null ? null : mage.getLivingEntity();
    String playerMessage = getMessage(messageKey);
    if (playerMessage.length() > 0)
    {
        for (Entity target : targets)
        {
            UUID targetUUID = target.getUniqueId();
            if (target instanceof Player && target != sourceEntity && !targetMessagesSent.contains(targetUUID))
            {
                targetMessagesSent.add(targetUUID);
                playerMessage = playerMessage.replace("$spell", spell.getName());
                Mage targetMage = controller.getMage(target);
                targetMage.sendMessage(playerMessage);
            }
        }
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:27,代码来源:CastContext.java


示例4: hasItemCosts

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
protected boolean hasItemCosts(CastContext context, ShopItem shopItem) {
    Mage mage = context.getMage();
    MageController controller = context.getController();
    double worth = shopItem.getWorth();
    boolean hasCosts = true;
    if (worth > 0) {
        if (isXP) {
            worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthXP());
            hasCosts = mage.getExperience() >= (int)(double)worth;
        } else if (isItems) {
            worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthItemAmount());
            int hasAmount = getItemAmount(controller, mage);
            hasCosts = hasAmount >= worth;
        } else if (isSkillPoints) {
            worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthSkillPoints());
            hasCosts = mage.getSkillPoints() >= Math.ceil(worth);
        } else {
            worth = Math.ceil(costScale * worth * controller.getWorthBase());
            hasCosts = VaultController.getInstance().has(mage.getPlayer(), worth);
        }
    }

    return hasCosts;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:25,代码来源:BaseShopAction.java


示例5: takeCosts

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
protected void takeCosts(CastContext context, ShopItem shopItem) {
    Mage mage = context.getMage();
    MageController controller = context.getController();
    double worth = shopItem.getWorth();

    if (isXP) {
        worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthXP());
        mage.removeExperience((int)(double)worth);
    }
    else if (isItems)
    {
        worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthItemAmount());
        removeItems(controller, mage, (int)Math.ceil(worth));
    }
    else if (isSkillPoints)
    {
        worth = Math.ceil(costScale * worth * controller.getWorthBase() / controller.getWorthSkillPoints());
        mage.addSkillPoints(-(int)Math.ceil(worth));
    }
    else
    {
        worth = Math.ceil(costScale * worth * controller.getWorthBase());
        VaultController.getInstance().withdrawPlayer(mage.getPlayer(), worth);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:26,代码来源:BaseShopAction.java


示例6: getBalanceDescription

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
protected String getBalanceDescription(CastContext context) {
    Mage mage = context.getMage();
    MageController controller = context.getController();
    Messages messages = controller.getMessages();
    String description = "";
    if (isXP) {
        String xpAmount = Integer.toString(mage.getExperience());
        description = messages.get("costs.xp_amount").replace("$amount", xpAmount);
    } else if (isItems) {
        int itemAmount = getItemAmount(controller, mage);
        description = formatItemAmount(controller, itemAmount);
    } else if (isSkillPoints) {
        String spAmount = Integer.toString(mage.getSkillPoints());
        description = messages.get("costs.sp_amount").replace("$amount", spAmount);
    } else {
        double balance = VaultController.getInstance().getBalance(mage.getPlayer());
        description = VaultController.getInstance().format(balance);
    }

    return description;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:22,代码来源:BaseShopAction.java


示例7: removeItems

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
protected void removeItems(MageController controller, Mage mage, ItemStack worthItem, int amount) {
    int remainingAmount = amount;
    Inventory inventory = mage.getInventory();
    ItemStack[] contents = inventory.getContents();
    for (int i = 0; i < contents.length; i++)
    {
        if (contents[i] != null && controller.itemsAreEqual(contents[i], worthItem))
        {
            if (contents[i].getAmount() <= remainingAmount) {
                remainingAmount -= contents[i].getAmount();
                contents[i] = null;
            } else {
                contents[i].setAmount(contents[i].getAmount() - remainingAmount);
                remainingAmount = 0;
            }
        }
        if (remainingAmount <= 0) {
            break;
        }
    }
    inventory.setContents(contents);
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:23,代码来源:BaseShopAction.java


示例8: finish

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public void finish() {
    if (endSpell != null && !endSpell.isEmpty()) {
        Mage arenaMage = arena.getMage();
        arenaMage.setLocation(arena.getCenter());
        Spell spell = arenaMage.getSpell(endSpell);
        if (spell != null) {
            spell.cast();
        }
    }

    Plugin plugin = arena.getController().getPlugin();
    for (Entity entity : spawned) {
        if (entity.isValid()) {
            entity.removeMetadata("arena", plugin);
            entity.remove();
        }
    }
    spawned.clear();
}
 
开发者ID:elBukkit,项目名称:MagicArenas,代码行数:20,代码来源:ArenaStage.java


示例9: Target

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public Target(Location sourceLocation, Mage mage, int minRange, int maxRange, double angle, boolean reverseDistance)
{
    this.maxDistanceSquared = maxRange * maxRange;
    this.minDistanceSquared = minRange * minRange;
    this.maxAngle = angle;
    this.reverseDistance = reverseDistance;
    this.source = sourceLocation;
    this.mage = mage;
    if (mage != null) {
        this._entity = new WeakReference<Entity>(mage.getLivingEntity());
    }
    if (mage != null) this.location = mage.getEyeLocation();
    calculateScore();
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:15,代码来源:Target.java


示例10: applyPotionEffects

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public void applyPotionEffects(Location location, int radius, Collection<PotionEffect> potionEffects) {
    if (potionEffects == null || radius <= 0 || potionEffects.size() == 0) return;

    int radiusSquared = radius * 2;
    List<Entity> entities = CompatibilityUtils.getNearbyEntities(location, radius, radius, radius);
    for (Entity entity : entities) {
        if (entity instanceof LivingEntity) {
            Mage targetMage = null;
            if (controller.isMage(entity)) {
                targetMage = controller.getMage(entity);
            }

            boolean isSourcePlayer = entity == mage.getEntity();
            if (isSourcePlayer && getTargetType() != TargetType.ANY && getTargetType() != TargetType.SELF) {
                continue;
            }

            // Check for protected players
            if (targetMage != null && isSuperProtected(targetMage) && !isSourcePlayer) {
                continue;
            }

            if (!canTarget(entity)) continue;

            if (entity.getLocation().distanceSquared(location) < radiusSquared) {
                registerPotionEffects(entity);
                CompatibilityUtils.applyPotionEffects((LivingEntity)entity, potionEffects);

                if (targetMage != null) {
                    String playerMessage = getMessage("cast_player_message");
                    if (playerMessage.length() > 0) {
                        playerMessage = playerMessage.replace("$spell", getName());
                        targetMage.sendMessage(playerMessage);
                    }
                }
            }
        }
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:40,代码来源:UndoableSpell.java


示例11: getFireworkEffect

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public static FireworkEffect getFireworkEffect(CastContext context, Color color1, Color color2, org.bukkit.FireworkEffect.Type fireworkType, Boolean flicker, Boolean trail) {
    Mage mage = context.getMage();
    Random random = context.getRandom();
    Color wandColor = mage == null ? null : mage.getEffectColor();
    if (wandColor != null) {
        color1 = wandColor;
        color2 = wandColor.mixColors(color1, Color.WHITE);
    } else {
        if (color1 == null) {
            color1 = Color.fromRGB(random.nextInt(255), random.nextInt(255), random.nextInt(255));
        }
        if (color2 == null) {
            color2 = Color.fromRGB(random.nextInt(255), random.nextInt(255), random.nextInt(255));
        }
    }
    if (fireworkType == null) {
        fireworkType = org.bukkit.FireworkEffect.Type.values()[random.nextInt(org.bukkit.FireworkEffect.Type.values().length)];
    }
    if (flicker == null) {
        flicker = random.nextBoolean();
    }
    if (trail == null) {
        trail = random.nextBoolean();
    }

    return FireworkEffect.builder().flicker(flicker).withColor(color1).withFade(color2).with(fireworkType).trail(trail).build();
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:28,代码来源:EffectUtils.java


示例12: UndoableBatch

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public UndoableBatch(Mage mage, UndoList undoList) {
    this.controller = mage.getController();
    this.mage = mage;
    this.undoList = undoList;
    undoList.setBatch(this);
    mage.prepareForUndo(this.undoList);
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:8,代码来源:UndoableBatch.java


示例13: UndoBatch

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public UndoBatch(UndoList blockList) {
    Mage mage = blockList.getOwner();
    controller = mage.getController();

    undoList = blockList;
    this.applyPhysics = blockList.getApplyPhysics();
    this.attachables = new HashSet<Material>();

    CastContext context = undoList.getContext();
    if (context != null) {
        context.playEffects("undo");
    }

    Set<Material> addToAttachables = controller.getMaterialSet("attachable");
    if (addToAttachables != null) {
        attachables.addAll(addToAttachables);
    }
    addToAttachables = controller.getMaterialSet("attachable_wall");
    if (addToAttachables != null) {
        attachables.addAll(addToAttachables);
    }
    addToAttachables = controller.getMaterialSet("attachable_double");
    if (addToAttachables != null) {
        attachables.addAll(addToAttachables);
    }
    addToAttachables = controller.getMaterialSet("delayed");
    if (addToAttachables != null) {
        attachables.addAll(addToAttachables);
    }

    // Sort so attachable items don't break
    undoList.sort(attachables);
    listSize = undoList.size();
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:35,代码来源:UndoBatch.java


示例14: load

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
@Override
public void load(Mage mage, ConfigurationSection data)
{
    for (ActionHandler handler : handlers.values())
    {
        handler.loadData(mage, data);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:9,代码来源:CompoundAction.java


示例15: save

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
@Override
public void save(Mage mage, ConfigurationSection data)
{
    for (ActionHandler handler : handlers.values())
    {
        handler.saveData(mage, data);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:9,代码来源:CompoundAction.java


示例16: loadData

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public void loadData(Mage mage, ConfigurationSection data)
{
    for (ActionContext action : actions)
    {
        action.getAction().load(mage, data);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:8,代码来源:ActionHandler.java


示例17: saveData

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
public void saveData(Mage mage, ConfigurationSection data)
{
    for (ActionContext action : actions)
    {
        action.getAction().save(mage, data);
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:8,代码来源:ActionHandler.java


示例18: showMessage

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
@Override
public void showMessage(String key, String def)
{
    Mage mage = getMage();
    if (mage != null)
    {
        mage.sendMessage(getMessage(key, def));
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:10,代码来源:CastContext.java


示例19: finish

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
@Override
public void finish() {
    if (finished) return;
    finished = true;
    Mage mage = getMage();

    if (finishedHandlers != null) {
        for (ActionHandlerContext context : finishedHandlers) {
            context.finish();
        }
        finishedHandlers = null;
    }
    if (undoSpell != null && undoSpell.isUndoable())
    {
        if (!undoList.isScheduled())
        {
            getController().update(undoList);
        }
        mage.registerForUndo(undoList);
    }
    result = result.max(initialResult);
    if (spell != null) {
        mage.sendDebugMessage(ChatColor.WHITE + "Finish " + ChatColor.GOLD + spell.getName() + ChatColor.WHITE  + ": " + ChatColor.AQUA + result.name().toLowerCase(), 2);
        spell.finish(this);
    }
    String resultName = result.name().toLowerCase();
    castMessageKey(resultName + "_finish");
    playEffects(resultName + "_finish");
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:30,代码来源:CastContext.java


示例20: getItemAmount

import com.elmakers.mine.bukkit.api.magic.Mage; //导入依赖的package包/类
protected int getItemAmount(MageController controller, ItemStack worthItem, Mage mage) {
    int itemAmount = 0;
    ItemStack[] contents = mage.getInventory().getContents();
    for (int i = 0; i < contents.length; i++) {
        if (contents[i] != null && controller.itemsAreEqual(contents[i], worthItem))
        {
            itemAmount += contents[i].getAmount();
        }
    }

    return itemAmount;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:13,代码来源:BaseShopAction.java



注:本文中的com.elmakers.mine.bukkit.api.magic.Mage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MipMapGenerator类代码示例发布时间:2022-05-16
下一篇:
Java MultiLineTooltipUI类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap