No Flow World Guard

Discussion in 'Archived: Plugin Requests' started by 15987632, Sep 27, 2014.

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

    15987632

    Plugin category: Mechanics

    Suggested name: WGNoFlow

    What I want: I know world guard has a no flow flag but thats not what i want. I want a plugin that stops lava or water from flowing into a world guard region. I want water and lava to be able to flow inside a region but not be able to flow into a region

    Ideas for commands: No commands needed for this plugin.

    Ideas for permissions: no perms are needed

    When I'd like it by: ASAP but take your time
     
  2. Offline

    au2001

    15987632 Custom WG flags are hard to make (in fact, I don't even know how to make one :O)
    So why don't you use the no flow flag? Would be easier for everybody ;)
     
  3. Online

    timtower Administrator Administrator Moderator

    au2001 He is not asking for a flag though, just always active.
     
  4. Offline

    au2001

    timtower
    "I want a plugin that stops lava or water from flowing into a world guard region." isn't that called a flag? :p
    And it must be compatible with worldguard regions so yeah, still the same problem ;)
     
  5. Offline

    15987632

    au2001 because its a skygrid server and then players could put safety waterfalls in their claims and could make cobble generators pretty necessary stuff :p
     
  6. Offline

    au2001

  7. Offline

    JordyPwner

    worldguard already got this
     
  8. Online

    timtower Administrator Administrator Moderator

    JordyPwner That will stop flowing entirely. Not just when it flows into a region.
     
    15987632 likes this.
  9. Offline

    JordyPwner

    just create a region. use the no water flow flag. when you try to let water get in that region it stops flowing.
     
  10. Online

    timtower Administrator Administrator Moderator

    But that will also stop water flowing when the source block is in the region, not something what the OP wants
     
    15987632 likes this.
  11. Offline

    JordyPwner

    sorry read wrong :p
     
  12. Offline

    15987632

  13. Offline

    15987632

  14. Offline

    15987632

  15. Offline

    15987632

    au2001 timtower JordyPwner if anyone is interested i did this myself. It was a lot easier than i thought it would be

    Code:
    package me.trevor.bukkit;
     
    import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
    import com.sk89q.worldguard.protection.managers.RegionManager;
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockFromToEvent;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin implements Listener{
     
        @Override
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
        }
     
     
        private WorldGuardPlugin getWorldGuard() {
            Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
     
            // WorldGuard may not be loaded
            if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
                return null; // Maybe you want throw an exception instead
            }
     
            return (WorldGuardPlugin) plugin;
        }
     
     
        @EventHandler
        public void onLiquidFlow(BlockFromToEvent e){
            Location to = e.getToBlock().getLocation();
            Location from = e.getBlock().getLocation();
     
     
            WorldGuardPlugin worldGuard = getWorldGuard();
            RegionManager regionManager = worldGuard.getRegionManager(e.getBlock().getWorld());
           
            if (regionManager.getApplicableRegions(to).size() >= 1 && regionManager.getApplicableRegions(from).size() == 0){
                e.setCancelled(true);
               
            }
     
        }
    }
    
     
    au2001 likes this.
  16. Good approach - i was going to point out that there is a plugin doing cross-region abuse prevention already, while allowing stuff across your own regions:
    http://dev.bukkit.org/bukkit-plugins/safewgtool-swgt/

    This includes pistons, flow, growing structures, which can't be assigned to players actions directly. The concept is to allow cross-region stuff, if regions have the same set of (combined) owners+members. If you don't have neighboring regions with hostile region owners, then your approach will deal with fluids most efficiently.
     
  17. Offline

    15987632

    asofold nice :D ill look into yours which looks a lot better than my little thing
     
  18. It's also slightly heavier, so it might really depend on what you want to protect from and if you need some cross region stuff to work (e.g. with extension regions of the same owner). The coding is also pretty "old", but it might provide some useful hints.
     
Thread Status:
Not open for further replies.

Share This Page