WorldGuard Events 1.15.2

Easy way to get per-player region entry/departure events.

  1. Weby
    Native Minecraft Version:
    1.15
    Tested Minecraft Versions:
    • 1.15
    Source Code:
    https://github.com/Webbeh/WorldGuard-Events
    WorldGuard Events
    For server admins
    This plugin may be required by some other plugins. If so, simply drop the JAR in the plugins folder of your server, reload it, and you're set.

    It doesn't do anything on its own and is useless unless required by another plugin.

    For developers
    Events
    This plugin provides you with the following events :
    • RegionsChangedEvent
    • RegionsEnteredEvent
    • RegionsLeftEvent
    • RegionEnteredEvent
    • RegionLeftEvent
    All of those are fired upon each player movement into a new set of regions, in that order.

    They are all pretty self-explainatory. You can use any event interchangeably : the events returning a single ProtectedRegion are fired at the same time as the events returning a Set of ProtectedRegions (which is useful if you have multiple overlapping/neighbouring regions).

    Cancelling any of the events will prevent the movement from happening.

    API
    On top of events, and since version 1.15.2 of this plugin, we now provide you with a small API to get the most basic informations out of WorldGuard :
    • getRegions
    • getRegionNames
    • isPlayerInRegion
    • isPlayerInAnyRegion
    • isPlayerInAllRegions
    All of those use the UUID of the player to fetch information about him from WorldGuard.

    Be aware that those region names are case insensitive, just like WorldGuard, and that they are checked for the world the player is currently in.

    Usage example
    Code (Java):

    import net.raidstone.wgevents.WorldGuardEvents;
    import net.raidstone.wgevents.events.RegionEnteredEvent;
    import net.raidstone.wgevents.events.RegionsLeftEvent;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.Set;

    public class TestPLugin extends JavaPlugin implements Listener {
        @Override
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
         
            // On plugin activation, send a message to players that are located in a jail.
            for(Player p : Bukkit.getOnlinePlayers())
            {
                if(WorldGuardEvents.isPlayerInAnyRegion(p.getUniqueId(), "jail", "cell"))
                {
                    p.sendMessage("You are in jail ! Did you do something bad ?");
                }
            }
        }
     
       @EventHandler
       public void onRegionEntered(RegionEnteredEvent event)
       {
           Player player = Bukkit.getPlayer(event.getUUID());
           if (player == null) return;
         
           String regionName = event.getRegionName();
           if(regionName.equalsIgnoreCase("jail"))
           {
               player.sendMessage("You are now in jail !");
           }
       }

       @EventHandler
       public void onRegionsLeft(RegionsLeftEvent event)
       {
           Player player = Bukkit.getPlayer(event.getUUID());
           if(player == null) return;
         
           Set<String> regionsNames = event.getRegionsNames();
         
           if(regionsNames.contains("jail") || regionsNames.contains("cell"))
           {
               player.sendMessage("You are in jail, you can't escape !");
               event.setCancelled(true);
           }
       }
    }
     
    Maven dependency
    This plugin is located in the Maven Central repository, so you simply need to add it as dependency.
    Code (HTML5):
    <dependency>
       <groupId>net.raidstone</groupId>
       <artifactId>WorldGuardEvents</artifactId>
       <version>1.15.2</version>
       <scope>provided</scope>
    </dependency>
    If you like this plugin, don't forget to rate it, to help other people discover it !

    Also, please use the Github's page to report bugs and ask for features !
    VectOrz, JedM and TomCreeper like this.

Recent Reviews

  1. ethwal22
    ethwal22
    5/5,
    Version: 1.15.2
    Amazing API. Recommend for all plugin devs! Was struggling for so long with other APIs
  2. eliasboy0202
    eliasboy0202
    5/5,
    Version: 1.15.2
    Best api so far, talked to WorldGuard itself and aparently they don't want to add them.
    Amazing job !
  3. dinoboss2001
    dinoboss2001
    5/5,
    Version: 1.15.2
    podrias aƱadir schrmatics ?????????????????????????????????????????????? es para mi plugin de SuperTowersDefenser
    1. Weby
      Author's Response
      This is a simple WorldGuard helper, it has nothing to do with WorldEdit, or schematics.
  4. Zastrix
    Zastrix
    3/5,
    Version: 1.15.1
    I had not tested it yet but I can't really rate more than 3 stars because this is compiled on Java 10 while the standard is Java 8.
    1. Weby
      Author's Response
      So instead of asking for a Java 8 JAR, you rate 3 stars without even trying the plugin ?
      Not cool.
  5. Halflove
    Halflove
    5/5,
    Version: 1.13.2-R0.2
    Great up to date replacement for WGRegionEvents API for developers, thanks for putting this out there and making it easier to code for people like me ;)
    1. Weby
      Author's Response
      With pleasure !