當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。