Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. package me.anton.FirstPlugin;
  2.  
  3. import java.util.Random;
  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 Turtle extends JavaPlugin
  15. {
  16. Logger myPluginLogger = Bukkit.getLogger();
  17.  
  18. @Override
  19. public void onEnable()
  20. {
  21. myPluginLogger.info("[FirstPlugin] Plugin is starting up");
  22. }
  23.  
  24. @Override
  25. public void onDisable()
  26. {
  27. myPluginLogger.info("[FirstPlugin] Plugin shutting down");
  28.  
  29. }
  30.  
  31. // This is basic command operation returning a message to the player
  32.  
  33. public boolean onCommand(CommandSender theSender, Command cmd, String commandLabel, String[] args)
  34. {
  35. if(commandLabel.equalsIgnoreCase("flameon"))
  36. {
  37. Player thePlayer = (Player) theSender;
  38.  
  39. if(args.length == 1)
  40. {
  41. if (args[0].equalsIgnoreCase("Hello"))
  42. {
  43.  
  44. thePlayer.sendMessage(ChatColor.AQUA + "Hi");
  45. }
  46. }
  47. else thePlayer.sendMessage(ChatColor.DARK_AQUA + "FlameON :D");
  48. }
  49.  
  50. return true;
  51. }
  52.  
  53. // Teleportation and Locations
  54.  
  55. public boolean onCommand1(CommandSender Sender, Command cmd, String command, String[] args)
  56. {
  57. if(cmd.getName().equalsIgnoreCase("teleportme") && Sender instanceof Player)
  58. {
  59. Player player = (Player) Sender;
  60.  
  61. Location originalLocation = player.getLocation();
  62.  
  63. Random random = new Random();
  64.  
  65. int x = random.nextInt(1000) + 1;
  66. int y = 150;
  67. int z = random.nextInt(1000) + 1;
  68.  
  69. Location teleportLocation = new Location(player.getWorld(), x, y, z);
  70.  
  71. player.teleport(teleportLocation);
  72.  
  73. player.sendMessage(ChatColor.GREEN + "You have been teleported" + (int) teleportLocation.distance(originalLocation) + "blocks away");
  74.  
  75. return true;
  76.  
  77. }
  78.  
  79.  
  80.  
  81.  
  82.  
  83. return true;
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement