Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. Main class:
  2.  
  3.  
  4. package com.xpietqr_.pack;
  5.  
  6. import java.util.logging.Logger;
  7.  
  8. import org.bukkit.plugin.PluginDescriptionFile;
  9. import org.bukkit.plugin.java.JavaPlugin;
  10.  
  11. import com.xpietqr_.pack.commands.Goodbye;
  12. import com.xpietqr_.pack.commands.Hello;
  13.  
  14. public class PlayerMessagePlugin extends JavaPlugin {
  15.  
  16. public void onEnalble() {
  17.  
  18. PluginDescriptionFile pdffile = getDescription();
  19. Logger logger = getLogger();
  20.  
  21. getCommand("hello").setExecutor(new Hello());
  22. getCommand("goodbye").setExecutor(new Goodbye());
  23.  
  24. logger.info(pdffile.getName() + " Has been Enabled! (V." + pdffile.getVersion() + ")");
  25. }
  26.  
  27. public void onDisable() {
  28.  
  29. PluginDescriptionFile pdffile = getDescription();
  30. Logger logger = getLogger();
  31.  
  32. logger.info(pdffile.getName() + " Has been disabled! (V." + pdffile.getVersion() + ")");
  33. }
  34.  
  35. }
  36.  
  37. goodbye class:
  38.  
  39.  
  40.  
  41. package com.xpietqr_.pack.commands;
  42.  
  43. import org.bukkit.ChatColor;
  44. import org.bukkit.Location;
  45. import org.bukkit.command.Command;
  46. import org.bukkit.command.CommandExecutor;
  47. import org.bukkit.command.CommandSender;
  48. import org.bukkit.entity.Player;
  49.  
  50. public class Goodbye implements CommandExecutor {
  51.  
  52. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
  53. String[] args) {
  54.  
  55. if (!(sender instanceof Player)) {
  56. sender.sendMessage("You MUST be a player to use this command!");
  57. return false;
  58. }
  59. Player player = (Player) sender;
  60.  
  61. Location l = new Location(player.getWorld(), 0, 64, 0);
  62. player.sendMessage(ChatColor.RED + "Goodbye");
  63. player.teleport(l);
  64. return true;
  65. }
  66.  
  67. }
  68.  
  69.  
  70.  
  71.  
  72. Hello class
  73.  
  74.  
  75. package com.xpietqr_.pack.commands;
  76.  
  77. import org.bukkit.ChatColor;
  78. import org.bukkit.command.Command;
  79. import org.bukkit.command.CommandExecutor;
  80. import org.bukkit.command.CommandSender;
  81. import org.bukkit.entity.Player;
  82.  
  83.  
  84. public class Hello implements CommandExecutor {
  85.  
  86. public boolean onCommand(CommandSender sender, Command command,
  87. String label, String[] args) {
  88. if (!(sender instanceof Player)) {
  89. sender.sendMessage("You MUST be a player to use this command!");
  90. return false;
  91. }
  92. Player player = (Player) sender;
  93.  
  94. player.sendMessage(ChatColor.RED + "Hello " + player.getName());
  95.  
  96. return true;
  97. }
  98.  
  99. }
  100.  
  101.  
  102.  
  103. plugin.yml
  104.  
  105.  
  106. main: com.xpietqr_.pack.PlayerMessagePlugin
  107. version: 1.0
  108. name: PlayerMessagePlugin
  109.  
  110. commands:
  111. hello:
  112. description: Sends a player a message! :)
  113. goodbye:
  114. description: Teleports the player to the goodbye!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement