purepk95

Untitled

Apr 11th, 2011
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. // The Package
  2. package norway.purepk95.HelpMe;
  3.  
  4. // All the imports
  5. import org.bukkit.ChatColor;
  6. import org.bukkit.command.Command;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.plugin.PluginDescriptionFile;
  10. import org.bukkit.plugin.java.JavaPlugin;
  11. import org.bukkit.plugin.Plugin;
  12.  
  13. import com.nijiko.permissions.PermissionHandler;
  14. import com.nijikokun.bukkit.Permissions.Permissions;
  15.  
  16. /**
  17. * HelpMe for Bukkit
  18. *
  19. * @author purepk95
  20. */
  21.  
  22. //Starts the class
  23. public class HelpMe extends JavaPlugin{
  24. public static PermissionHandler Permissions;
  25.  
  26. // onDisable
  27. public void onDisable() {
  28. PluginDescriptionFile pdfFile = this.getDescription();
  29. System.out.println( pdfFile.getName() + " is disabled!" );
  30. }
  31. // onEnable
  32. public void onEnable() {
  33. setupPermissions();
  34. PluginDescriptionFile pdfFile = this.getDescription();
  35. System.out.println( pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" ); }
  36.  
  37.  
  38. // Permission setup
  39. private void setupPermissions() {
  40. Plugin test = this.getServer().getPluginManager().getPlugin("Permissions");
  41. if (HelpMe.Permissions == null) {
  42. if (test != null) {
  43. HelpMe.Permissions = ((Permissions)test).getHandler();
  44. } else {
  45. System.out.println("Permission system not detected, defaulting to OP");
  46. }
  47. }
  48. }
  49.  
  50. // Command system
  51. public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
  52. if (sender instanceof Player) {
  53. Player player = (Player) sender;
  54. if(Permissions.has(player, "HelpMe.use") && command.getName().equalsIgnoreCase("helpme")) {
  55. player.sendMessage(ChatColor.DARK_GREEN + "A mod or a admin will come and help you soon as possible.");
  56. player.sendMessage(ChatColor.DARK_GREEN + "If no one come and helps you within 20 minutes, perform the command again.");
  57. getServer().broadcastMessage(ChatColor.DARK_RED + player.getDisplayName() + ChatColor.DARK_GREEN + " need some help!");
  58. }
  59. }
  60. return true;
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment