Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. package de.lurch.functions;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Location;
  7. import org.bukkit.Material;
  8.  
  9. import de.lurch.ffa.FFA;
  10.  
  11. public class LoadMaps {
  12.    
  13.     FFA plugin;
  14.    
  15.     public LoadMaps(FFA ffa) {
  16.         this.plugin = ffa;
  17.    
  18.     }
  19.  
  20.     public void setRandomSpawn(final FFA plugin) {
  21.         this.plugin = plugin;
  22.        
  23.         final Random rand = new Random();
  24.        
  25.         rand.nextInt(100);
  26.        
  27.         Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
  28.            
  29.            
  30.             @Override
  31.             public void run() {
  32.  
  33.                 plugin.rdmloc = new Location(Bukkit.getWorld(plugin.currentworld), rand.nextInt(100) -100, 1, rand.nextInt(100) -100, 0, 0);
  34.                
  35.                 while (!Bukkit.getWorld(plugin.currentworld).getBlockAt(plugin.rdmloc).getType().equals(Material.AIR)) {
  36.                        
  37.                         plugin.rdmloc.setY(plugin.rdmloc.getY() + 1);
  38.                         if (Bukkit.getWorld(plugin.currentworld).getBlockAt(plugin.rdmloc).getType().equals(Material.AIR) &&
  39.                                 Bukkit.getWorld(plugin.currentworld).getBlockAt((int) plugin.rdmloc.getX(), (int) plugin.rdmloc.getY() + 1, (int) plugin.rdmloc.getZ()).getType().equals(Material.AIR)) {
  40.                                 plugin.spawnable = true;
  41.                         } else {
  42.                             plugin.spawnable = false;
  43.                         }
  44.                 }
  45.             }
  46.            
  47.         }, 0, 1);
  48.        
  49.        
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement