Quantcast
Channel: Server Mods from Bukkit.org
Viewing all articles
Browse latest Browse all 2356

WorldGuard Region Events

$
0
0

Table of contents

  1. 1Description
  2. 2Example

Description

WorldGuard Region Events allows modders to trigger function if a player enters or leaves a region. It adds four events that you can use to trigger your functions: RegionEnterEvent, RegionEnteredEvent, RegionLeaveEvent and RegionLeftEvent. They can be used just as any other Bukkit event (for more information look here .)

The RegionEnteredEvent and RegionLeftEvent are triggered a short time after a player entered/left a region so you cannot cancel them, but use the to check the flags of the regions the player is in.

Example

If you don't want to create a plugin ignore this

To send a player a text whenever he enters a region:

importcom.mewin.WGRegionEvents.events.RegionEnterEvent;...@EventHandlerpublicvoidonRegionEnter(RegionEnterEvente){e.getPlayer().sendMessage("You just entered "+e.getRegion().getId());}

Or to quit players from escaping from jail:

importcom.mewin.WGRegionEvents.events.RegionLeaveEvent...@EventHandlerpublicvoidonRegionLeave(RegionLeaveEvente){if(e.getRegion().getId().equals("jail")&&e.isCancellable())// you cannot cancel the event if the player leaved the region because he died{e.setCancelled(true);e.getPlayer().sendMessage("You cannot leave the jail!");}}

Viewing all articles
Browse latest Browse all 2356

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>