Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. package com.pudgecraft.StaffMail.commands;
  2.  
  3. import java.util.List;
  4.  
  5. import org.bukkit.command.Command;
  6. import org.bukkit.command.CommandExecutor;
  7. import org.bukkit.command.CommandSender;
  8. import org.bukkit.entity.Player;
  9.  
  10. import com.pudgecraft.StaffMail.StaffMail;
  11.  
  12. public class Commands implements CommandExecutor{
  13.  
  14. private StaffMail plugin;
  15.  
  16. public Commands(StaffMail plugin) {
  17. this.plugin = plugin;
  18.  
  19. plugin.getCommand("staffmail").setExecutor(this);
  20. }
  21.  
  22. @Override
  23. public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
  24. Player player = (Player) sender;
  25. if (player.hasPermission("staffmail.allow")) {
  26. if(label.equalsIgnoreCase("staffmail") || label.equalsIgnoreCase("sm")) {
  27. if(args.length==0) {
  28. plugin.HelpMessage(player);
  29. }
  30. else {
  31. if(args[0].equalsIgnoreCase("read")) {
  32. List<String> list = plugin.getConfig().getStringList("staffmail");
  33. for(String s : list){
  34. plugin.sendMessage(player, s + "");
  35. }
  36. }
  37. else if(args[0].equalsIgnoreCase("send")) {
  38. if(args.length == 1) {
  39. plugin.sendMessage(player, "&3Correct Usage: /staffmail send <message>.");
  40. }
  41. else {
  42. String word = "";
  43. for (int i = 1; i <= (args.length - 1); i++) {
  44. word = word + " " + args[i];
  45. }
  46. List<String> list = plugin.getConfig().getStringList("staffmail");
  47. list.add(word);
  48. plugin.getConfig().set("staffmail", list);
  49. plugin.saveConfig();
  50. plugin.sendMessage(player, "&3Mail sent.");
  51. }
  52. }
  53. else if(args[0].equalsIgnoreCase("clear")) {
  54. if(!(player.hasPermission("staffmail.admin"))) {
  55. plugin.sendMessage(player, "&4You have to be an Admin to use this.");
  56. }
  57. else {
  58. List<String> list = plugin.getConfig().getStringList("staffmail");
  59. list.clear();
  60. plugin.getConfig().set("staffmail", list);
  61. plugin.saveConfig();
  62. plugin.sendMessage(player, "&3You have successfully cleared staff mail.");
  63. }
  64. }
  65. else {
  66. plugin.HelpMessage(player);
  67. }
  68. }
  69. }
  70. return false;
  71. }
  72. plugin.sendMessage(player,"&4You don't have permission");
  73. return false;
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement