Guest User

Untitled

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