Advertisement
agentsix1

stuff

Jul 31st, 2018
38,995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.66 KB | None | 0 0
  1. public void onEnable() {
  2.         BukkitScheduler scheduler = getServer().getScheduler();
  3.         scheduler.scheduleSyncRepeatingTask(this, new Runnable() {
  4.             @Override
  5.             public void run() {
  6.                 if (executer != null) {
  7.                     World world = executer.getWorld();
  8.                     //some arbitrary conditions to get to this point
  9.                     if(world.getChunkAt(executer.getLocation()) != null && world.getBlockAt(executer.getLocation()) != null) {
  10.                       Chunk myChunk = world.getChunkAt(executer.getLocation());//this checked if it is loaded
  11.                       if(myChunk.isLoaded()) {
  12.                           if (countW == width) {
  13.                               countW = 0;
  14.                               if (countL == length) {
  15.                                   countL = 0;
  16.                                   executer.sendMessage(ChatColor.GREEN + "The chunk loading process is complete.");
  17.                                   executer = null;
  18.                                   length = 0;
  19.                                   width = 0;
  20.                               } else {
  21.                                   countL+= 1;
  22.                                   executer.teleport(new Location(executer.getLocation().getWorld(), executer.getLocation().getX()-(16*width), executer.getLocation().getY(), executer.getLocation().getZ()+16));
  23.                               }
  24.                           }
  25.                           countW+= 1;
  26.                           executer.teleport(new Location(executer.getLocation().getWorld(), executer.getLocation().getX()+16, executer.getLocation().getY(), executer.getLocation().getZ()));
  27.                          
  28.                       }
  29.                     }
  30.                 }
  31.                
  32.                
  33.                
  34.             }
  35.         }, 0L, 1L);
  36.     }
  37.  
  38.    
  39.     public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
  40.         if (sender instanceof Player) {
  41.             Player p = (Player) sender;
  42.             if (cmdLabel.equalsIgnoreCase("loadchunks") && p.isOp()) {
  43.                 if (args.length==2) {
  44.                     if (executer == null) {
  45.                         if (Integer.parseInt(args[0]) > 0 && Integer.parseInt(args[1]) > 0) {
  46.                             Integer a = Integer.parseInt(args[0]);
  47.                             Integer b = Integer.parseInt(args[1]);
  48.                             Integer c = (int) Math.floor(a/2);
  49.                             Integer d = (int) Math.floor(b/2);
  50.                             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.");
  51.                             p.setGameMode(GameMode.CREATIVE);
  52.                             p.teleport(new Location(p.getWorld(), p.getLocation().getX()-c, p.getLocation().getY(), p.getLocation().getY()-d));
  53.                             length = a;
  54.                             width = b;
  55.                             executer = p;
  56.                         }
  57.                     }
  58.                 }
  59.             }
  60.            
  61.             if (cmdLabel.equalsIgnoreCase("regenchunk") && p.isOp()) {
  62.                 if (args.length==2) {
  63.                     if (executer == null) {
  64.                         if (Integer.parseInt(args[0]) > 0 && Integer.parseInt(args[1]) > 0) {
  65.                             p.getWorld().regenerateChunk(Integer.parseInt(p.getLocation().getX() + ""), Integer.parseInt(p.getLocation().getZ() + ""));
  66.                         }
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.         return false;
  72.        
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement