当前位置: 首页>>代码示例>>Java>>正文


Java SpellResult类代码示例

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


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

示例1: start

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
public SpellResult start(CastContext context, ConfigurationSection parameters)
{
    prepare(context, parameters);
    reset(context);
    SpellResult handlerResult = perform(context);
    if (handlerResult == SpellResult.PENDING)
    {
        ActionBatch batch = new ActionBatch(context, this);
        if (!context.getMage().addBatch(batch)) {
            handlerResult = SpellResult.FAIL;

            finish(context);
            context.finish();
        }
    }
    else
    {
        finish(context);
        context.finish();
    }
    return handlerResult;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:23,代码来源:ActionHandler.java

示例2: step

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
   public SpellResult step(CastContext context)
{
       while (currentEntity < entities.size())
       {
           Entity entity = entities.get(currentEntity).get();
           if (entity == null)
           {
               currentEntity++;
               skippedActions(context);
               continue;
           }
           actionContext.setTargetEntity(entity);
           if (entity instanceof LivingEntity) {
               actionContext.setTargetLocation(((LivingEntity)entity).getEyeLocation());
           } else {
               actionContext.setTargetLocation(entity.getLocation());
           }
           return startActions();
       }

       return SpellResult.NO_ACTION;
   }
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:24,代码来源:CompoundEntityAction.java

示例3: onCast

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
public SpellResult onCast(ConfigurationSection parameters) {
	Target target = getTarget();
	if (!target.hasEntity()) {
		return SpellResult.NO_TARGET;
	}
	Entity targetEntity = target.getEntity();

	if (targetEntity instanceof Player) {
		Player targetPlayer = (Player)targetEntity;
		targetPlayer.kickPlayer(getMessage("cast_player_message"));
	} else {
		Collection<? extends Entity> entities = targetEntity.getWorld().getEntitiesByClass(targetEntity.getClass());
		for (Entity entity : entities) {
               if (controller.isNPC(entity)) continue;
			registerForUndo(entity);
			entity.remove();
		}
	}
	registerForUndo();
	return SpellResult.CAST;
}
 
开发者ID:elBukkit,项目名称:MagicWorlds,代码行数:23,代码来源:PurgeSpell.java

示例4: processResult

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
protected void processResult(SpellResult result, ConfigurationSection castParameters) {
    if (!result.isSuccess())
    {
        ActionHandler handler = actions.get(result.name().toLowerCase());
        if (handler != null)
        {
            handler.start(currentCast, castParameters);
        }
    }
    super.processResult(result, castParameters);
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:13,代码来源:ActionSpell.java

示例5: sendCastMessage

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
protected void sendCastMessage(SpellResult result, String message)
{
    Location source = getEyeLocation();
    if (mage == null || source == null) return;

    mage.sendDebugMessage(ChatColor.WHITE + "Cast " + ChatColor.GOLD + getName() + ChatColor.WHITE + " from " +
            ChatColor.GRAY + source.getBlockX() +
            ChatColor.DARK_GRAY + ","  + ChatColor.GRAY + source.getBlockY() +
            ChatColor.DARK_GRAY + "," + ChatColor.GRAY + source.getBlockZ() +
            ChatColor.WHITE  + ": " + ChatColor.AQUA + result.name().toLowerCase() +
            ChatColor.DARK_AQUA + message);
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:13,代码来源:BaseSpell.java

示例6: startActions

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
protected SpellResult startActions(String handlerKey) {
    currentHandler = handlerKey;
    ActionHandler handler = handlers.get(currentHandler);
    if (handler != null) {
        handler.reset(actionContext);
    } else {
        currentHandler = null;
    }

    return SpellResult.NO_ACTION;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:12,代码来源:CompoundAction.java

示例7: perform

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
public SpellResult perform(CastContext context) {
    SpellResult result = SpellResult.NO_ACTION;
    while (!result.isStop()) {
        if (state == State.NOT_STARTED) {
            result = result.min(start(context));

            // Don't continue if the action failed to start
            if (result.isStop() || result.isFailure()) break;
            state = State.STARTED;
        }

        if (state == State.STARTED) {
            result = result.min(step(context));
            if (result.isStop()) break;
            state = State.STEPPING;
        }

        ActionHandler handler = currentHandler == null ? null : handlers.get(currentHandler);
        if (handler != null) {
            result = result.min(handler.perform(actionContext));
            if (result.isStop()) break;
            if (stopOnSuccess && result.isSuccess()) {
                result = SpellResult.STOP;
                break;
            }
        }

        if (!next(context)) {
            if (handler != null) {
                handler.finish(actionContext);
            }
            break;
        }

        result = result.min(step(context));
    }
    return result;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:40,代码来源:CompoundAction.java

示例8: checkTracking

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
protected SpellResult checkTracking(CastContext context) {
    if (tracking == null) {
        return SpellResult.FAIL;
    }
    if (!track && !hasActions()) {
        // Don't bother tracking if we're not doing anything on hit
        if (!context.hasEffects("hit")) {
            tracking = null;
        }
        return SpellResult.CAST;
    }

    return SpellResult.NO_TARGET;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:15,代码来源:BaseProjectileAction.java

示例9: CastContext

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
public CastContext() {
    this.location = null;
    this.entity = null;
    this.base = this;
    this.result = SpellResult.NO_ACTION;
    targetMessagesSent = new HashSet<UUID>();
    currentEffects = new ArrayList<EffectPlay>();
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:9,代码来源:CastContext.java

示例10: processHandlers

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
public SpellResult processHandlers() {
    SpellResult result = SpellResult.NO_ACTION;
    if (handlers == null) return result;

    if (finishedHandlers == null) {
        finishedHandlers = new ArrayList<ActionHandlerContext>();
    }
    int startingWork = getWorkAllowed();
    int splitWork = Math.max(1, startingWork / handlers.size());
    for (Iterator<ActionHandlerContext> iterator = handlers.iterator(); iterator.hasNext();) {
        ActionHandlerContext handler = iterator.next();
        handler.setWorkAllowed(splitWork);
        SpellResult actionResult = handler.perform();
        if (actionResult != SpellResult.PENDING) {
            result = result.min(actionResult);
            finishedHandlers.add(handler);
            iterator.remove();
        }
    }
    
    if (handlers.isEmpty()) {
        handlers = null;
        return result;
    }

    return SpellResult.PENDING;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:29,代码来源:CastContext.java

示例11: perform

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
public SpellResult perform(CastContext context)
{
    boolean hasTarget = context.getTargetLocation() != null;
    boolean hasEntityTarget = context.getTargetEntity() != null;
    if (action.requiresTarget() && !hasTarget) return SpellResult.NO_TARGET;
    if (action.requiresTargetEntity() && !hasEntityTarget) return SpellResult.NO_TARGET;

    SpellResult result = action.perform(context);
    return action.ignoreResult() && !result.isStop() ? SpellResult.NO_ACTION : result;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:11,代码来源:ActionContext.java

示例12: onCast

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
public SpellResult onCast(ConfigurationSection parameters)
{
    currentCast.setWorkAllowed(workThreshold);
    SpellResult result = SpellResult.CAST;
    currentHandler = actions.get("cast");
    ActionHandler downHandler = actions.get("alternate_down");
    ActionHandler upHandler = actions.get("alternate_up");
    ActionHandler sneakHandler = actions.get("alternate_sneak");
    workThreshold = parameters.getInt("work_threshold", 500);
    if (downHandler != null && isLookingDown())
    {
        result = SpellResult.ALTERNATE_DOWN;
        currentHandler = downHandler;
    }
    else if (upHandler != null && isLookingUp())
    {
        result = SpellResult.ALTERNATE_UP;
        currentHandler = upHandler;
    }
    else if (sneakHandler != null && mage.isSneaking())
    {
        result = SpellResult.ALTERNATE_SNEAK;
        currentHandler = sneakHandler;
    }

    if (isUndoable())
    {
        getMage().prepareForUndo(getUndoList());
    }

    target();
    if (currentHandler != null)
    {
        currentHandler = (ActionHandler)currentHandler.clone();
        try {
            result = result.max(currentHandler.start(currentCast, parameters));
            currentCast.setInitialResult(result);
        } catch (Exception ex) {
            controller.getLogger().log(Level.WARNING, "Spell cast failed for " + getKey(), ex);
            result = SpellResult.FAIL;
            try {
                currentHandler.finish(currentCast);
            } catch (Exception finishException) {
                controller.getLogger().log(Level.WARNING, "Failed to clean up failed spell " + getKey(), finishException);
            }
        }
    }
    return result;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:51,代码来源:ActionSpell.java

示例13: finalizeCast

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
protected boolean finalizeCast(ConfigurationSection parameters) {
    SpellResult result = null;

    // Global parameters
    controller.disablePhysics(parameters.getInt("disable_physics", 0));

    if (!mage.isSuperPowered()) {
        if (backfireChance > 0 && random.nextDouble() < backfireChance) {
            backfire();
        } else if (fizzleChance > 0 && random.nextDouble() < fizzleChance) {
            result = SpellResult.FIZZLE;
        }
    }

    if (result == null) {
        result = onCast(parameters);
    }
    if (backfired) {
        result = SpellResult.BACKFIRE;
    }
    if (result == SpellResult.CAST) {
        LivingEntity sourceEntity = mage.getLivingEntity();
        Entity targetEntity = getTargetEntity();
        if (sourceEntity == targetEntity) {
            result = SpellResult.CAST_SELF;
        }
    }
    processResult(result, parameters);

    boolean success = result.isSuccess();
    boolean requiresCost = success || (castOnNoTarget && (result == SpellResult.NO_TARGET || result == SpellResult.NO_ACTION));
    boolean free = !requiresCost && result.isFree();
    if (!free) {
        if (costs != null && !mage.isCostFree()) {
            for (CastingCost cost : costs)
            {
                if (cost.isItem() && currentCast != null) {
                    currentCast.getUndoList().setConsumed(true);
                }
                cost.use(this);
            }
        }
        updateCooldown();
    }

    sendCastMessage(result, " (" + success + ")");
    return success;
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:49,代码来源:BaseSpell.java

示例14: getEffects

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的package包/类
@Override
public Collection<com.elmakers.mine.bukkit.api.effect.EffectPlayer> getEffects(SpellResult result) {
    return getEffects(result.name().toLowerCase());
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:5,代码来源:BaseSpell.java

示例15: finish

import com.elmakers.mine.bukkit.api.spell.SpellResult; //导入依赖的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);
                }
            }
        }
    }
}
 
开发者ID:elBukkit,项目名称:MagicLib,代码行数:77,代码来源:BaseSpell.java


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