Advertisement
Guest User

Untitled

a guest
Nov 15th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. public class Changelog implements CommandExecutor {
  2.  
  3. private Main plugin = Main.getPlugin(Main.class);
  4.  
  5. @Override
  6. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  7. if(cmd.getName().equalsIgnoreCase("changelog")) {
  8. if(!(sender instanceof Player)) {
  9. sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&l[!] &cOnly players are allowed to execute this command!"));
  10. } else {
  11. Player p = (Player) sender;
  12. Location loc = p.getLocation();
  13. if(args.length == 0) {
  14. Inventory inv = Bukkit.createInventory(null, 9, "Server Updates");
  15.  
  16. ItemStack changelog = new ItemStack(Material.BOOK);
  17. ItemMeta changelogmeta = changelog.getItemMeta();
  18. String name = ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("Item-Name"));
  19. changelogmeta.setDisplayName(name);
  20.  
  21.  
  22. // Lore
  23. List<String> getLore = this.plugin.getConfig().getStringList("Item-Lore");
  24. List<String> lore = new ArrayList<String>();
  25. for (String l : getLore) {
  26. lore.add(ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', l));
  27. changelogmeta.setLore(lore);
  28. // Item Meta set stuff
  29. changelog.setItemMeta(changelogmeta);
  30. inv.setItem(4, changelog);
  31. for (int i = 0; i < inv.getSize(); i++) {
  32. ItemStack empty = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)15);
  33. ItemMeta emptymeta = empty.getItemMeta();
  34. emptymeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&f"));
  35. empty.setItemMeta(emptymeta);
  36. if ((inv.getItem(i) == null) || (inv.getItem(i).getType() == Material.AIR)) {
  37. inv.setItem(i, empty);
  38.  
  39.  
  40.  
  41. // Open inventory
  42. p.openInventory(inv);
  43.  
  44. // Sound
  45. try {
  46. p.getWorld().playSound(loc, Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
  47. } catch(Exception e) {
  48. p.getWorld().playSound(loc, Sound.valueOf("LEVEL_UP"), 1, 0);
  49.  
  50. }
  51. }
  52. }
  53. }
  54.  
  55. } else {
  56. if ((args.length == 1) &&
  57. (args[0].equalsIgnoreCase("Reload"))) {
  58. if(p.hasPermission("changelog.reload")) {
  59. this.plugin.reloadConfig();
  60. ChatCenter.sendCenteredMessage(p, "");
  61. ChatCenter.sendCenteredMessage(p, "&a&l*&f&l*&a&l* &a&lCONFIGURATION RELOADED &a&l*&f&l*&a&l*");
  62. ChatCenter.sendCenteredMessage(p, "");
  63. try {
  64. p.getWorld().playSound(loc, Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
  65. } catch(Exception e) {
  66. p.getWorld().playSound(loc, Sound.valueOf("LEVEL_UP"), 1, 0);
  67.  
  68. }
  69. } else {
  70. ChatCenter.sendCenteredMessage(p, "");
  71. ChatCenter.sendCenteredMessage(p, "&c&l*&f&l*&c&l* &c&lPERMISSION ERROR &c&l*&f&l*&c&l*");
  72. ChatCenter.sendCenteredMessage(p, "");
  73. try {
  74. p.getWorld().playSound(loc, Sound.valueOf("BLOCK_ANVIL_BREAK"), 1, 0);
  75. } catch(Exception e) {
  76. p.getWorld().playSound(loc, Sound.valueOf("ANVIL_BREAK"), 1, 0);
  77. return true;
  78.  
  79. }
  80. }
  81.  
  82. }
  83. }
  84. return true;
  85. }
  86. return true;
  87. }
  88. return true;
  89.  
  90.  
  91.  
  92. }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement