Events, Spawns, Source Servers, and many more!

User Tools

Site Tools


Sidebar

home

issues

downloads


bukkit plugins

windows 8 apps

windows phone apps


Maintaining these plugins takes a lot of work, so if your server is enriched by them please consider sending some love my way!

If you're penniless I'm also partial to TF2 items. Send any you don't want my way! STEAM id: coldandtired

If you don't know what TF2 is, then start playing! It's free and fun!

events:targeting

The actions page has this example

<mob-spawns>
    <if>
        <mob-type>pig</mob-type>
        <then>    
            <targeting>
                <target>coldandtired</target>
                <tell>Hey, a mob's spawning!</tell>
            </targeting>
        </then>
    </if>
</mob-spawns>

which briefly illustrates how to use the targeting container.

When the event happens, the plugin uses the event's data in conditions and actions. In the case of the mob-spawns event, this means the mob that is trying to spawn, and the location where it's trying to spawn. From these the plugin can work out the world, block, biome, weather, etc. that it needs for certain things.

Outside of the targeting container these values are always used, so when the plugin gets to the mob-type condition it will check the desired value (pig) against the type of mob spawning.

Inside the targeting container, however, things are a little different. Internally, the plugin creates a list of all the targets you specify, and then loops through this list passing each value to any conditions and actions

<mob-spawns>
    <if>
        <mob-type>pig</mob-type>
        <then>    
            <targeting>
                <target>coldandtired</target>
                <if>
                    <mob-type>pig</mob-type>
                    <then>
                        <tell>Hey, a mob's spawning!</tell>
                    </then>
                </if>
            </targeting>
        </then>
    </if>
</mob-spawns>

The second mob-type condition will fail as the relevant mob is now a player.

<mob-spawns>
    <if>
        <mob-type>pig</mob-type>
        <then>    
            <targeting>
                <target>coldandtired</target>
                <if>
                    <mob-type>pig</mob-type>
                    <then>
                        <tell>Hey, a mob's spawning!</tell>
                    </then>
                </if>
            </targeting>
            <if>
                <mob-type>pig</mob-type>
                <then>
                    <cancel-event/>
                </then>
            </if>
        </then>
    </if>
</mob-spawns>

The third mob-type condition will pass as we have returned from the targeting container and are back using the event's mob.


But the targeting container isn't limited to just one target

<mob-spawns>
    <targeting>
        <target>player</target>
        <tell>Hey, a mob's spawning!</tell>
    </targeting>
</mob-spawns>

This will tell all players there's a mob spawning.

<mob-spawns>
    <targeting>
        <target>player</target>
        <target>25:66:100</target>
        <tell>Hey, a mob's spawning!</tell>
        <spawn-exp>100</spawn-exp>
    </targeting>
</mob-spawns>

In this example every player will receive the message, and 100 exp will spawn at their feet, along with the block at 25:66:100. Note that while any actions with invalid targets (like tell above) will be silently ignored, any conditions with invalid targets will fail.

You can read about the possible target values here.

events/targeting.txt · Last modified: 2014/08/27 14:55 by sylian