Plot World Generation

Discussion in 'Spigot Plugin Development' started by Kompye, Nov 8, 2019.

  1. Using Location?
    Using Location and CommandExecutor

    Not to be rude, but, do you really think someone is going to write the whole 'logic' for you?
     
  2. Leave it, I can't do it. There is no source of information on how to do it. Thanks for your help everyone!
     
  3. Hold on my friend, to claim plots you can use WorldGuard, it will be for you really simple, just create region at that location, give owner and flags, if you want to see how to do that i can give you too example of a code.
     
    • Friendly Friendly x 1
  4. If you wouldn’t mind...
     
  5. Code (Java):
    public class RegionCreator {
        public static ProtectedRegion regionCreate(Location opt, int radius, String regionName) {


            Location firstCorner = new Location(opt.getWorld(), opt.getX(), opt.getY() - 6, opt.getZ());
            radius--;
            Location secondCorner = new Location(firstCorner.getWorld(), firstCorner.getX() - (radius), firstCorner.getY() + 256, firstCorner.getZ() + radius);

            BlockVector min = new BlockVector(firstCorner.getX(), firstCorner.getY(), firstCorner.getZ());
            BlockVector max = new BlockVector(secondCorner.getX(), secondCorner.getY(), secondCorner.getZ());
            ProtectedRegion region = new ProtectedCuboidRegion("H" + regionName, min, max);
            RegionManager regions = DevHousing.getWorldGuardApi().getRegionManager(Bukkit.getWorld(File.getHouses().getString("worldName")));
            assert regions != null;
            if(regions.hasRegion(region.getId())){
                regions.removeRegion(region.getId());
                try{
                    regions.save();
                } catch(StorageException e){
                    e.printStackTrace();
                }
            }
            Objects.requireNonNull(regions).addRegion(region);
            try{
                regions.save();
            } catch(StorageException e1){
                e1.printStackTrace();
            }

            region.setFlag(DefaultFlag.INTERACT, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.BLOCK_BREAK, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.CHEST_ACCESS, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.USE, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.BLOCK_PLACE, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.LAVA_FIRE, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.LAVA_FLOW, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.WATER_FLOW, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.LIGHTNING, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.LIGHTER, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.PISTONS, StateFlag.State.ALLOW);
            region.setFlag(DefaultFlag.LAVA_FIRE, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.OTHER_EXPLOSION, StateFlag.State.DENY);
            region.setFlag(DefaultFlag.INVINCIBILITY, StateFlag.State.ALLOW);

            return region;
        }
    }

    unfortunately i have no time to describe that code to you at that moment, i will be right back in 2 days, but i think that you will understand, the one you have to do is too set owner, then you have to use method from that topic https://bukkit.org/threads/solved-w...ing-owner-disappears-on-server-restart.62451/
     
    • Like Like x 1
  6. How did you learn World Generation? There’s barely any resource of information out there
     
  7. Hes not using world generation, hes just using worldedit's api.
     
    • Like Like x 1
  8. Oh, and do plugins like plotsquared also use that?
     
  9. It's API of WE or WG ?
     
  10. I mean are they also using worldedit api to make the plots?
     
  11. Currently both, we to make plots and wg for regions
     
  12. You can, Just pregenerate it with we