Examples/example07
Advanced use case showing off some integrations with MultiVerse and WorldGuard.
Many of the features in this example are not available until HSP 1.7
Part1: Multiverse integration
In this example, we want a Multiverse portal named "funbox" that when a player enters it, they are randomly spawned somewhere in world2. Further, we want HSP to keep track of their random spawn such that if they enter that portal again later, they end up at the same place. Last, if they leave "world2" via any means (portals, /home, /mvtp, whatever), we want them to return to the place they left (which will be portal "funbox", since that's where they teleported from). Here's the setup:
First, you need to setup your "funbox" portal in Multiverse to point to some location in world2. Doesn't matter where, but test that when you enter "funbox" you are in fact teleported to world2. With this in place, here is the HSP config to accomplish the above:
events: world: world2: # this event fires when they use Multiverse to TP into this # world (portal, command or otherwise) multiverseCrossWorldTeleport: # this mode requires they ported here using "funbox" portal, # no other strategies will run if this is not true until the next # mode reset (such as modeDefault below) - ModeMultiverseSourcePortal:funbox # if they have ported into this world before, this strategy will # send them to that location - SpawnLocalPlayerSpawn # turn on "remember" mode, so wherever we send them, HSP # will remember it (for future use by SpawnLocalPlayerSpawn) - ModeRememberLocation # setup modes that will affect the random spawn coming up, such # as limiting the Y bound to be no lower than 60, no higher than 85 - ModeYBounds:60;85 - ModeNoWater - ModeNoIce - ModeNoLilyPad - ModeNoLeaves # now spawn them in a random place on the local world. This # location will be remembered by HSP due to the # "ModeRememberLocation" above - SpawnWorldRandom # if we make it here, then they didn't use the funbox portal, so # do nothing - modeDefault - default
This shows off the power of HSP and the various strategies to be put together in some interesting ways. But wait, didn't we say if they left world2, they were supposed to go back to wherever they were on the previous world? Here's the strategy for that:
events: multiverseCrossWorldTeleport: # if the sourceworld is "world2", then we send them back to their # "last Location" on whatever world they are now on - modeSourceWorld:world2 - spawnLastLocation # do they same whether it's a Multiverse teleport (above) or something # else like a /home crossWorldTeleport: - modeSourceWorld:world2 - spawnLastLocation
HSP always remembers the location a player was at when they leave a given world. You can access that location to send them back there by using the "spawnLastLocation" strategy.
Part2: WorldGuard integration
modeInRegion, spawnWGregion and spawnRegionRandom
In this section, we are further modifying our config to do some special things with some worldGuard regions. The first and easiest is, we have a few regions setup where we've used the WG spawn flag to specify a spawn point within that region. If a player dies in one of those regions, we want them to go to the WorldGuard spawn point, but if they're not in a region, we want some other HSP strategies to apply (such as they go to their home or spawn).
Second, we have two special regions we want to do something a little different with. The first is region "colosseum". If a player dies within this region, we want to send them to a spawn location just outside the region (up in the stands or something). We'll accomplish this by setting a spawn point "/setspawn colosseumSpawn" and send them there. For the other region, called "arena", if a player dies in that region, we want them to spawn at a completely random point inside the region.
Here's the setup:
events: onDeath: # if they are in the colosseum region, send them to colosseumSpawn - modeInRegion:colosseum - spawnNamedSpawn:colosseumSpawn # if they are in the arena region, spawn them at a random point # inside that region - modeInRegion:arena - spawnRegionRandom:arena # reset mode, so strategies below can run - modeDefault # if they are in any other WG region that has the "spawn flag" set, # then send them there - spawnWGregion # otherwise just send them to their home or the local spawn - homeMultiWorld - spawnLocalWorld
onRegionExit and onRegionEnter
Additionally, HSP can monitor for WorldGuard region entrances and exits. Here is an example:
events: # as the player enters region "orange" on world, spawn them # randomly inside it onRegionEnter;orange,world: - spawnRegionRandom:orange # if the player leaves region "orange", spawn them at the spawn # named "orangeExit" onRegionExit;orange,world: - spawnNamedSpawn:orangeExit # not world-specific. If you have region "blue" defined on 3 # different worlds, this event will apply to all of them. onRegionExit;blue: - spawnLocalSpawn
Note that while the region,world syntax is provided so you can specify the world, it's safe to just use region unless you have the re-used the same region name on multiple different worlds and want different behavior on each. Also note that HSP will automatically infer the world context for a world-specific rule. So, assuming you have a region "red" on myworld and have not re-used that region name on any other world, the following statements are all equivalent:
events: onRegionEnter;red,myworld: - spawnRegionRandom:red onRegionEnter;red: - spawnRegionRandom:red world: myworld: onRegionEnter;red: - spawnRegionRandom:red
Comments