Advertisement
Guest User

Untitled

a guest
May 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.90 KB | None | 0 0
  1. package me.wildtp.commands;
  2.  
  3. import java.util.concurrent.ThreadLocalRandom;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.Chunk;
  7. import org.bukkit.Location;
  8. import org.bukkit.Material;
  9. import org.bukkit.World;
  10. import org.bukkit.block.Block;
  11. import org.bukkit.command.Command;
  12. import org.bukkit.command.CommandExecutor;
  13. import org.bukkit.command.CommandSender;
  14. import org.bukkit.entity.Player;
  15.  
  16. import me.wildtp.Main;
  17. import net.md_5.bungee.api.ChatColor;
  18.  
  19. public class Wild implements CommandExecutor{
  20.    
  21. private Main mainInstance;
  22.    
  23.     public Wild(Main main) {
  24.         this.mainInstance = main;
  25.     }
  26.     public String cmd1 = "Wild";
  27.     public String perm;
  28.     int x;
  29.     int y;
  30.     int z;
  31.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  32.             if(cmd.getName().equalsIgnoreCase(cmd1)) {
  33.                 Player p = ((Player) sender);
  34.                 if(this.mainInstance.getConfig().getString("Perm") == "") {
  35.                     perm = "WildTP.wild";
  36.                     if(p.hasPermission(perm)) {
  37.                         World w = Bukkit.getServer().getWorld(this.mainInstance.getConfig().getString("tpWorld"));
  38.                         locationpicker(p,w);
  39.                         return false;
  40.                        
  41.                        
  42.                        
  43.                        
  44.                        
  45.                        
  46.                        
  47.                        
  48.                        
  49.                        
  50.                        
  51.                        
  52.                        
  53.                        
  54.                     }else {
  55.                         //String noPerm = this.mainInstance.getConfig().getString("noPerms");
  56.                         String noPMessage = this.mainInstance.getConfig().getString("noPerms");
  57.                         p.sendMessage(ChatColor.translateAlternateColorCodes('&', noPMessage));
  58.                         return false;
  59.                     }
  60.                 }
  61.                 if(p.hasPermission(this.mainInstance.getConfig().getString("Perm"))) {
  62.                     World w = Bukkit.getServer().getWorld(this.mainInstance.getConfig().getString("tpWorld"));
  63.                     locationpicker(p,w);
  64.                     return false;
  65.                 }else {
  66.                     String noPMessage = this.mainInstance.getConfig().getString("noPerms");
  67.                     p.sendMessage(ChatColor.translateAlternateColorCodes('&', noPMessage));
  68.                     return false;
  69.                 }
  70.             }
  71.             return false;
  72.     }
  73.    
  74.    
  75.    
  76.     public void locationpicker(Player p, World w) {
  77.         System.out.println("Location Picker Started");
  78.         pickcoords(p,w);
  79.         Location location = new Location(w,x,y,z);
  80.         Location location2 = new Location(w,x,y+1,z);
  81.         Location location3 = new Location(w,x,y-1,z);
  82.         Location location4 = new Location(w,x,y-4,z);
  83.         Block b = p.getWorld().getBlockAt(location);
  84.         Block b2 = p.getWorld().getBlockAt(location2);
  85.         Block b3 = p.getWorld().getBlockAt(location3);
  86.         Block b4 = p.getWorld().getBlockAt(location4);
  87.         while(b.getType() != Material.AIR || b2.getType() != Material.AIR || b3.getType() == Material.AIR) {
  88.             pickcoords(p,w);
  89.         }
  90. //      if(b.getType() != Material.AIR) {
  91. //          System.out.println("Bottom Not Air");
  92. //          locationpicker(p,w);
  93. //      }if (b2.getType() != Material.AIR) {
  94. //          System.out.println("Top Not Air");
  95. //          locationpicker(p,w);
  96. //      }if (b3.getType() == Material.AIR || b4.getType() == Material.AIR) {
  97. //          System.out.println("Floor Is Air");
  98. //          locationpicker(p,w);
  99. //      }
  100.         System.out.println("Chosen");
  101.         System.out.println("b="+b.getType());
  102.         System.out.println("b2="+b2.getType());
  103.         System.out.println("b3="+b3.getType());
  104.         System.out.println("b4="+b4.getType());
  105.        
  106.        
  107.        
  108.         Chunk chunk = p.getWorld().getChunkAt(location);
  109.         chunk.load();
  110.         Bukkit.getServer().getScheduler().runTaskLater(mainInstance, () -> {
  111.             p.teleport(location);
  112.         }, 100);
  113.     }
  114.    
  115.    
  116.     public void pickcoords(Player p, World w) {
  117.         System.out.println("Picking CoOrds");
  118.         int minX = this.mainInstance.getConfig().getInt("minX");
  119.         int minZ = this.mainInstance.getConfig().getInt("minZ");
  120.         int maxX = this.mainInstance.getConfig().getInt("maxX");
  121.         int maxZ = this.mainInstance.getConfig().getInt("maxZ");
  122.         x = ThreadLocalRandom.current().nextInt(minX, maxX + 1);
  123.         y = ThreadLocalRandom.current().nextInt(50, 255 + 1);
  124.         z = ThreadLocalRandom.current().nextInt(minZ, maxZ + 1);
  125. //      x=9826;
  126. //      y=76;
  127. //      z=9012;
  128.         return;
  129.     }
  130.    
  131.    
  132.    
  133.    
  134.  
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement