Hey. I'm getting this error: http://pastebin.com/PfQYGthX My Main class is this: Code (Text): package me.DecisionsYT; import org.bukkit.Bukkit; import org.bukkit.event.Listener; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import Broadcasting.Broadcast; import ChatChannels.DonorChat; import ChatChannels.StaffChat; import ChatFilter.AntiAdvertise; import ChatFilter.AntiSpam; import ChatFilter.AntiSwear; import ChatFilter.CmdSpy; import ChatFormat.ChatFormat; import ClearChat.ClearChat; import Events.Join; import Events.Quit; import Events.UnknownCommand; import GUI.GUI; import HelpCommand.Help; import Punishments.Kick; import ReloadConfig.Reload; import TabList.Tab; public class Main extends JavaPlugin implements Listener { public void onEnable() { saveDefaultConfig(); //Events PluginManager pm = Bukkit.getServer().getPluginManager(); CmdSpy cmdSpy = new CmdSpy(this); pm.registerEvents(this, this); pm.registerEvents(new AntiSwear(this), this); pm.registerEvents(cmdSpy, this); pm.registerEvents(new Tab(this), this); pm.registerEvents(new GUI(this), this); pm.registerEvents(new Join(this), this); pm.registerEvents(new Quit(this), this); pm.registerEvents(new AntiSpam(this), this); pm.registerEvents(new ChatFormat(this), this); pm.registerEvents(new AntiAdvertise(this), this); pm.registerEvents(new UnknownCommand(this), this); //StaffChat getCommand("SC").setExecutor(new StaffChat(this)); getCommand("StaffChat").setExecutor(new StaffChat(this)); //DonorChat getCommand("DC").setExecutor(new DonorChat(this)); getCommand("DonorChat").setExecutor(new DonorChat(this)); //ClearChat getCommand("ClearChat").setExecutor(new ClearChat(this)); getCommand("CC").setExecutor(new ClearChat(this)); //Help getCommand("ChatX").setExecutor(new Help(this)); //CmdSpy getCommand("CmdSpy").setExecutor(cmdSpy); //Broadcast getCommand("Broadcast").setExecutor(new Broadcast(this)); getCommand("BC").setExecutor(new Broadcast(this)); //Reload Config getCommand("ChatXReload").setExecutor(new Reload(this)); //Kick getCommand("Kick").setExecutor(new Kick(this)); //GUI getCommand("ChatXFeatures").setExecutor(new GUI(this)); Bukkit.getServer().getConsoleSender().sendMessage("§b§lChatX has been enabled!"); } public void onDisable() { Bukkit.getServer().getConsoleSender().sendMessage("§b§lChatX has been disabled!"); } } My GUI class is this: Code (Text): package GUI; import java.util.Arrays; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import me.DecisionsYT.Main; public class GUI implements CommandExecutor, Listener { Main plugin; public GUI(Main passedPlugin) { this.plugin = passedPlugin; } ItemStack tab = new ItemStack(Material.EMERALD_BLOCK);{ ItemMeta tabmeta = tab.getItemMeta(); tabmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled"))); tabmeta.setLore(Arrays.asList(new String[] { ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled-Lore")) })); tab.setItemMeta(tabmeta); } @EventHandler public void onInvClick(InventoryClickEvent e) { Player player = (Player) e.getWhoClicked(); if (e.getCurrentItem().isSimilar(tab)) { if (plugin.getConfig().getBoolean("Tab-Enabled")) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Tab-Disabled-GUI"))); plugin.getConfig().set("Tab-Enabled", false); if (!plugin.getConfig().getBoolean("Tab-Enabled")) { player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Tab-Enabled-GUI"))); plugin.getConfig().set("Tab-Enabled", true); } } } } @Override public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) { Inventory inv = Bukkit.getServer().createInventory(null, 9, plugin.getConfig().getString("GUI-Name")); Player player = (Player) sender; if (player.hasPermission("ChatX.GUI")) { player.openInventory(inv); inv.setItem(1, tab); } return true; } } GUI line 31 is: Code (Text): tabmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled"))); MAIN line 42 is: Code (Text): pm.registerEvents(new GUI(this), this); Spoiler: CONFIG # ChatX made by DecisionsYT # Version 1.1 # Sounds list: http://pastebin.com/VLRR7fYz Tab-Enabled: true ChatFormat-Enabled: true Join-Event-Enabled: true Quit-Event-Enabled: true Chat-Format: '&b{player}&3: {message}' StaffChat-Format: '&7[&b&lSTAFFCHAT&7] &3{player}: &b{message}' StaffChat-Sound: 'NOTE_PLING' StaffChat-Usage: '&7[&b&lUSAGE&7] &b/StaffChat (message)' DonorChat-Format: '&7[&b&lDONORCHAT&7] &3{player}: &b{message}' DonorChat-Sound: 'NOTE_PLING' DonorChat-Usage: '&7[&b&lUSAGE&7] &b/DonorChat (message)' ClearChat-Own: '&7[&b&lCLEARCHAT&7] &bYou have cleared your own chat.' ClearChat-All: '&7[&b&lCLEARCHAT&7] &bThe chat has been cleared by &3{player}.' ClearChat-Usage: '&7[&b&lUSAGE&7] &b/ClearChat (Own, All)' Advertising-Message: '&7[&b&lADVERTISING&7] &bPlease do not advertise.' Advertising-Notify: '&7[&b&lNOFIFY&7] &3{player} &bmight be advertising, &3{message}' # Time in ticks 1 second = 20 ticks AntiSpam-Cooldown: 60 AntiSpam-Message: '&7[&b&lSPAM&7] &bPlease wait until you can send another message.' # Interval in seconds Broadcast-Usage: '&7[&b&lBROADCAST&7] &b/Broadcast (message)' Broadcast-Format: '&7[&b&lBROADCAST&7] &b{message}' CmdSpy-Usage: '&7[&b&lCMDSPY&7] &b/CmdSpy (On, Off)' CmdSpy-Format: '&7[&b&lCMDSPY&7] &3{player}&b: &3{command}' CmdSpy-Enabled: '&7[&b&lCMDSPY&7] &bCmdSpy enabled.' CmdSpy-Disabled: '&7[&b&lCMDSPY&7] &bCmdSpy disabled.' Kick-Usage: '&7[&b&lUSAGE&7] &b/Kick (Player) (Reason)' Kicked-Player: '&7[&b&lKICK&7] &bYou have kicked &3{target}&b.' Kick-Default-Reason: '&7[&b&lKICK&7] &bYou have been kicked from the server.' Kick-Notify: '&7[&b&lNOTIFY&7] &3{player} &bhas kicked &3{target}&b.' Join-Title: '&7[&b&lJOIN&7]' Join-Subtitle: '&bWelcome back &3{player}&b.' First-Join-Title: '&7[&b&lJOIN&7]' First-Join-Subtitle: '&bWelcome to SERVERNAME &3{player}&b.' Join-Message: '&7[&b&lJOIN&7] &bWelcome back &3{player}&b.' Join-Broadcast: '&7[&b&lJOIN&7] &3{player} &bhas joined the server.' First-Join-Message: '&7[&b&lJOIN&7] &bWelcome to SERVERNAME &3{player}&b.' First-Join-Broadcast: '&7[&b&lJOIN&7] &3{player} &bhas joined for the first time.' Quit-Broadcast: '&7[&b&lQUIT&7] &3{player} &bhas left the server.' Tab-Header: '&7[&b&lSERVER NAME&7]' Tab-Footer: '&bHello {player}' No-Perm-Message: '&7[&b&lERROR&7] &bSorry, you do not have permission to do that.' Feature-Disabled: '&7[&b&lERROR&7] &bSorry, that feature is disabled.' Invalid-Player: '&7[&b&lERROR&7] &bSorry, that player is not online.' Non-Player: '&7[&b&lERROR&7] &bSorry, you must be a player to do that.' Unknown-Command-Message: '&7[&b&lERROR&7] &bThe command &3{command} &bis unknown. Do &3/help&b.' Config-Reloaded: '&7[&b&lCONFIG&7] &bSuccessfully reloaded the config file.' GUI-Name: '&7[&b&lOPTIONS&7]' GUI-Tab-Enabled: '&bThe feature &3TAB &bis currently &3enabled&b.' GUI-Tab-Enabled-Lore: '&bClick to &3disable&b.' Tab-Disabled-GUI: '&bTab disabled' Tab-Enabled-GUI: '&bTab enabled' Blocked-Word-Message: '&7[&b&lANTI-SWEAR&7] &bSorry, you are not allowed to say that.' Blocked-Words: - 'blocked' - 'words' - 'here'
How about checking if parts of line 31 are null? Like for example: Code (Text): System.out.println(plugin.getConfig().getString("GUI-Tab-Enabled")); System.out.println(ChatColor.translateAlternateColorCodes('&', "&bThe feature &3TAB &bis currently &3enabled&b.")); Edit: Wait what are you doing here? Code (Text): ItemStack tab = new ItemStack(Material.EMERALD_BLOCK);{ ItemMeta tabmeta = tab.getItemMeta(); tabmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled"))); tabmeta.setLore(Arrays.asList(new String[] { ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled-Lore")) })); tab.setItemMeta(tabmeta); }
When doing Code (Text): System.out.println(getConfig().getString("GUI-Tab-Enabled")); It works. It found what it's meant to be finding.
But the code isn't inside a method. I guess it gets called when a new object of this class gets created. Maybe it gets called before your constructor is executed so plugin is null. When do you want to create the emerald item actually?
When a player does /ChatXFeatures But I need to keep it a global variable so that the EventHandler can see it.
I told you this before: remove the useless braces. The error is occuring because the ItemStack is being created before the constructor is called. Basic Java.
So if the tab variable never changes then this is a cleaner approach: Code (Text): Main plugin; ItemStack tab public GUI(Main passedPlugin) { this.plugin = passedPlugin; tab = new ItemStack(Material.EMERALD_BLOCK); ItemMeta tabmeta = tab.getItemMeta(); tabmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled"))); tabmeta.setLore(Arrays.asList(new String[] { ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI-Tab-Enabled-Lore")) })); tab.setItemMeta(tabmeta); }
Next time initialize your variables inside a constructor. That is what they are made for And please mark this as solved.
Okay. Also, just checked this. When doing /ChatXFeatures, the inventory (GUI) is not coming up. I highly doubt it, but I've never worked with inventories in separate classes, you don't need to register them or something?? If you know, please let me know. Thanks!
No that shouldn't change anything, your code seems to be fine. Are there errors in the console? Is your command executed? Maybe add a Code (Text): player.sendMessage("The command works"); to the command executor.
Okay so. I added the player.sendMessage("The command works") and it DOESN'T come up. Any suggestions now?