Guest User

Untitled

a guest
Dec 24th, 2017
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.AceLV.RandomTeleport;
  2.  
  3.  
  4. import java.io.File;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class Main extends JavaPlugin {
  14. @Override
  15. public void onEnable() {
  16.  
  17. if(!new File(this.getDataFolder(), "config.yml").exists()) {
  18. this.saveDefaultConfig();
  19. }
  20. if(this.getConfig().getBoolean("onCommand"));
  21. }
  22. @Override
  23. public void onDisable() {
  24. }
  25.  
  26. public boolean onCommand(CommandSender thesender, Command cmd, String commandLabel, String[] args)
  27. {
  28. if(commandLabel.equalsIgnoreCase("rt"))
  29. {
  30. Player player = (Player) thesender;
  31. int randomX = (int) (Math.random() * 1000);
  32. int randomZ = (int) (Math.random() * 1000);
  33. int randomY = player.getWorld().getHighestBlockYAt(randomX, randomZ);
  34.  
  35.  
  36. Location randomLocation = new Location(player.getWorld(), randomX, randomY, randomZ);
  37. if(player.hasPermission("RandomTeleport.tp"))
  38. player.teleport(randomLocation);
  39. else player.sendMessage(ChatColor.RED + "You dont have permissions, to do that!");
  40. if(player.hasPermission("RandomTeleport.tp"))
  41. player.sendMessage(getConfig().getString("teleport-message"));
  42. return true;
  43. }
  44. //This will make the player variable
  45. Player player = (Player) thesender;
  46.  
  47. //This will get the string from the config
  48. String Config = this.getConfig().getString("teleport-message");
  49.  
  50. //This will replace the {Player} With the name
  51. String Replaced = Config.replace("{Player}", player.getName());
  52.  
  53. //This will translate the color codes!
  54. player.sendMessage(ChatColor.translateAlternateColorCodes('&', Replaced));
  55. return true;
  56.  
  57. }
  58. }
RAW Paste Data