Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. package hu.bendi.rndtp;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.bukkit.Location;
  6. import org.bukkit.Material;
  7. import org.bukkit.command.Command;
  8. import org.bukkit.command.CommandSender;
  9. import org.bukkit.entity.Player;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11.  
  12. public class Main extends JavaPlugin {
  13.  
  14. @Override
  15. public void onEnable() {
  16. getLogger().info("[RandomTP] Sikeresen elindult a plugin!");
  17. }
  18.  
  19. @Override
  20. public void onDisable() {
  21. getLogger().info("[RandomTP] Sikeresen leált a plugin!");
  22. }
  23.  
  24. @Override
  25. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  26. Player p = (Player)sender;
  27. System.out.println(command.getName()+ " " + command.getLabel() + " " + label);
  28. if (command.getName().equalsIgnoreCase("rndtp") && args.length > 0) {
  29. System.out.println("adsaf");
  30. switch (args[0]) {
  31. case "help":
  32. p.sendMessage("RandomTP Plugin By Bendi.");
  33. return true;
  34. case "tp":
  35. if (args.length > 1) {
  36. Location loc = getRandomLoc();
  37. getServer().getPlayer(args[1]).getLocation().setX(loc.getX());
  38. getServer().getPlayer(args[1]).getLocation().setY(loc.getY());
  39. getServer().getPlayer(args[1]).getLocation().setZ(loc.getZ());
  40. }else {
  41. Location loc = getRandomLoc();
  42. p.getLocation().setX(loc.getX());
  43. p.getLocation().setY(loc.getY());
  44. p.getLocation().setZ(loc.getZ());
  45. }
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51.  
  52. public Location getRandomLoc() {
  53. Random rnd = new Random();
  54. int x = rnd.nextInt() / 100;
  55. int z = rnd.nextInt() / 100;
  56. boolean plx = rnd.nextBoolean();
  57. boolean plz = rnd.nextBoolean();
  58. if (plx) {
  59. while (x < 2047) {
  60. x = rnd.nextInt()/ 100;
  61. System.out.println(x);
  62. }
  63. }else {
  64. while (x > -1536) {
  65. x = rnd.nextInt()/100;
  66. System.out.println(x);
  67. }
  68. }
  69. if (plz) {
  70. while (z < 2943) {
  71. z = rnd.nextInt()/100;
  72. System.out.println(z);
  73. }
  74. }else {
  75. while (z > -1536) {
  76. z = rnd.nextInt()/100;
  77. System.out.println(z);
  78. }
  79. }
  80. for (int i =255;i>0;i--) {
  81. Location lc = new Location(getServer().getWorld("world"), x, i, z);
  82. if (lc.getBlock().getType() != Material.AIR || lc.getBlock().getType() != Material.WATER) {
  83. return lc;
  84. }
  85.  
  86. }
  87. return new Location(getServer().getWorld("world"), 0, 100, 0);
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement