Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void onEnable() {
- BukkitScheduler scheduler = getServer().getScheduler();
- scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
- @Override
- public void run() {
- if (executer != null) {
- World world = executer.getWorld();
- //some arbitrary conditions to get to this point
- if(world.getChunkAt(executer.getLocation()) != null && world.getBlockAt(executer.getLocation()) != null) {
- Chunk myChunk = world.getChunkAt(executer.getLocation());//this checked if it is loaded
- if(myChunk.isLoaded()) {
- if (countW == width) {
- countW = 0;
- if (countL == length) {
- countL = 0;
- executer.sendMessage(ChatColor.GREEN + "The chunk loading process is complete.");
- executer = null;
- length = 0;
- width = 0;
- } else {
- countL+= 1;
- executer.teleport(new Location(executer.getLocation().getWorld(), executer.getLocation().getX()-(16*width), executer.getLocation().getY(), executer.getLocation().getZ()+16));
- }
- }
- countW+= 1;
- executer.teleport(new Location(executer.getLocation().getWorld(), executer.getLocation().getX()+16, executer.getLocation().getY(), executer.getLocation().getZ()));
- }
- }
- }
- }
- }, 0L, 1L);
- }
- public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
- if (sender instanceof Player) {
- Player p = (Player) sender;
- if (cmdLabel.equalsIgnoreCase("loadchunks") && p.isOp()) {
- if (args.length==2) {
- if (executer == null) {
- if (Integer.parseInt(args[0]) > 0 && Integer.parseInt(args[1]) > 0) {
- Integer a = Integer.parseInt(args[0]);
- Integer b = Integer.parseInt(args[1]);
- Integer c = (int) Math.floor(a/2);
- Integer d = (int) Math.floor(b/2);
- p.sendMessage(ChatColor.GREEN + "The chunk loading process has begun. Please do not move at any time during this process or else you may ruin the results.");
- p.setGameMode(GameMode.CREATIVE);
- p.teleport(new Location(p.getWorld(), p.getLocation().getX()-c, p.getLocation().getY(), p.getLocation().getY()-d));
- length = a;
- width = b;
- executer = p;
- }
- }
- }
- }
- if (cmdLabel.equalsIgnoreCase("regenchunk") && p.isOp()) {
- if (args.length==2) {
- if (executer == null) {
- if (Integer.parseInt(args[0]) > 0 && Integer.parseInt(args[1]) > 0) {
- p.getWorld().regenerateChunk(Integer.parseInt(p.getLocation().getX() + ""), Integer.parseInt(p.getLocation().getZ() + ""));
- }
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement