Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Changelog implements CommandExecutor {
- private Main plugin = Main.getPlugin(Main.class);
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if(cmd.getName().equalsIgnoreCase("changelog")) {
- if(!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&l[!] &cOnly players are allowed to execute this command!"));
- } else {
- Player p = (Player) sender;
- Location loc = p.getLocation();
- if(args.length == 0) {
- Inventory inv = Bukkit.createInventory(null, 9, "Server Updates");
- ItemStack changelog = new ItemStack(Material.BOOK);
- ItemMeta changelogmeta = changelog.getItemMeta();
- String name = ChatColor.translateAlternateColorCodes('&', this.plugin.getConfig().getString("Item-Name"));
- changelogmeta.setDisplayName(name);
- // Lore
- List<String> getLore = this.plugin.getConfig().getStringList("Item-Lore");
- List<String> lore = new ArrayList<String>();
- for (String l : getLore) {
- lore.add(ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', l));
- changelogmeta.setLore(lore);
- // Item Meta set stuff
- changelog.setItemMeta(changelogmeta);
- inv.setItem(4, changelog);
- for (int i = 0; i < inv.getSize(); i++) {
- ItemStack empty = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short)15);
- ItemMeta emptymeta = empty.getItemMeta();
- emptymeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&f"));
- empty.setItemMeta(emptymeta);
- if ((inv.getItem(i) == null) || (inv.getItem(i).getType() == Material.AIR)) {
- inv.setItem(i, empty);
- // Open inventory
- p.openInventory(inv);
- // Sound
- try {
- p.getWorld().playSound(loc, Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
- } catch(Exception e) {
- p.getWorld().playSound(loc, Sound.valueOf("LEVEL_UP"), 1, 0);
- }
- }
- }
- }
- } else {
- if ((args.length == 1) &&
- (args[0].equalsIgnoreCase("Reload"))) {
- if(p.hasPermission("changelog.reload")) {
- this.plugin.reloadConfig();
- ChatCenter.sendCenteredMessage(p, "");
- ChatCenter.sendCenteredMessage(p, "&a&l*&f&l*&a&l* &a&lCONFIGURATION RELOADED &a&l*&f&l*&a&l*");
- ChatCenter.sendCenteredMessage(p, "");
- try {
- p.getWorld().playSound(loc, Sound.valueOf("ENTITY_PLAYER_LEVELUP"), 1, 0);
- } catch(Exception e) {
- p.getWorld().playSound(loc, Sound.valueOf("LEVEL_UP"), 1, 0);
- }
- } else {
- ChatCenter.sendCenteredMessage(p, "");
- ChatCenter.sendCenteredMessage(p, "&c&l*&f&l*&c&l* &c&lPERMISSION ERROR &c&l*&f&l*&c&l*");
- ChatCenter.sendCenteredMessage(p, "");
- try {
- p.getWorld().playSound(loc, Sound.valueOf("BLOCK_ANVIL_BREAK"), 1, 0);
- } catch(Exception e) {
- p.getWorld().playSound(loc, Sound.valueOf("ANVIL_BREAK"), 1, 0);
- return true;
- }
- }
- }
- }
- return true;
- }
- return true;
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement