Teleporting to Spawn when leaving allowed region

Discussion in 'Plugin Development' started by Booshayy, Dec 12, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Booshayy

    Hi.
    So, I was wondering how you would make a player teleport the the world spawn when the leave the allowed region, set with WorldGuard. I already imported the WE and WG API's.

    Thank you for any help.
     
  2. Offline

    Jake6177

    Haven't used the API(s) yet, but after a quick look at the page, do something like this:

    First: Make sure they're loaded:
    Code:java
    1. // WorldGuard may not be loaded
    2. if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
    3. return null; // Maybe you want throw an exception instead
    4. }


    Second: Get an ApplicableRegionSet from the player's location:
    Code:java
    1. ApplicableRegionSet set = WGBukkit.getRegionManager(world).getApplicableRegions(location);


    Third: Enhanced For-Loop through it:
    Code:java
    1. for (Region? r : set) {
    2. //do something
    3. }


    the "Region?" part is me not knowing what the class is.

    Next, I guess, you would see if the player is still present in it? If not, teleport.

    Sorry, I can't be much help. As stated before, haven't used them.
     
  3. Offline

    Booshayy

    Thanks for the assistance, I'll be trying it momentarily Jake6177
     
Thread Status:
Not open for further replies.

Share This Page