Hi, I'm creating a Wand Plugin and in my main class I get this error: Spoiler: Full code package me.kingdom.wand; import java.util.ArrayList; import java.util.List; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener{ public Main plugin; public List<String> spells = new ArrayList<String>(); public getTargets getTargets = new getTargets(); @Override public void onEnable() { plugin = this; } @Override public boolean onCommand (CommandSender sender, Command command, String label, String[] args) { if(label.equalsIgnoreCase("wand")) if((sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "Je moet een in-game speler zijn om dat te doen!"); } else { if(sender.hasPermission("wand.wand")) { Player p = (Player)sender; ItemStack stack = new ItemStack(Material.BLAZE_ROD); ItemMeta stackMeta = stack.getItemMeta(); stackMeta.setDisplayName(ChatColor.BLACK + "Tandi" + ChatColor.DARK_BLUE + "cium " + ChatColor.BLACK + "Wand"); stack.setItemMeta(stackMeta); ChatUtitlities.sendMessage(p, "Je hebt nu de Tandicium Wand ontvangen!"); p.getInventory().addItem(stack); }else{ sender.sendMessage(ChatColor.RED + "Je hebt geen permissie om dit te doen!"); } } return false; } } Spoiler: Error @Override public boolean onCommand (CommandSender sender, Command command, String label, String[] args) { if(label.equalsIgnoreCase("wand")) if((sender instanceof Player)) { sender.sendMessage(ChatColor.RED + "Je moet een in-game speler zijn om dat te doen!"); } else { if(sender.hasPermission("wand.wand")) { Player p = (Player)sender; ItemStack stack = new ItemStack(Material.BLAZE_ROD); ItemMeta stackMeta = stack.getItemMeta(); stackMeta.setDisplayName(ChatColor.BLACK + "Tandi" + ChatColor.DARK_BLUE + "cium " + ChatColor.BLACK + "Wand"); stack.setItemMeta(stackMeta); ChatUtitlities.sendMessage(p, "Je hebt nu de Tandicium Wand ontvangen!"); p.getInventory().addItem(stack); }else{ sender.sendMessage(ChatColor.RED + "Je hebt geen permissie om dit te doen!"); It's about the ChatUtitlities.sendMessage part. (The messages are Dutch by the way) Thanks, Pointless2Play
No, it's just 'The method sendMessage(Player, String) is undefined for the type ChatUtitlities' that's the error for ChatUtitlities, the rest show no error.
Spoiler: ChatUtitlities package me.kingdom.wand; import org.bukkit.entity.Player; import static org.bukkit.ChatColor.*; public class ChatUtitlities { public static void sendMessage(Player p, String msg) { p.sendMessage(starter() + msg); } public static String starter() { return GOLD + "[" + GRAY + "X" + GOLD + "] " + WHITE; } }
Gotta use Code (Java): return ChatColor.GOLD + "[" + ChatColor.GRAY + "X" + ChatColor.GOLD + "] " + ChatColor.WHITE;
Hmm that looks ok, did you import ChatUtilities in the class where the error is appearing? And if so is it the one from your plugin and not one from another library? Sent from my iPhone using Tapatalk
I think they have a static import on ChatColor which allow them to not do so i believe. Not sure though.
Could be wrong, but Unless you're extending a class, you need to access the class' static fields with <ClassName>.<FieldName> Edit: hadnt seen the static import. Remove the static import and use the full name. see if it works.
Basically forgot the ChatColor, that was it. Sorry, I'm new to coding. It's fixed now, thanks for the help.
https://gyazo.com/09a6e2ea0e4b165f321b88fe550f9653 Result: Code (Text): §cStatic§9 import§3 is§a a§0 thing They had the .*, meaning they originally thought it was a static import. They forgot the static tag, but the star is required for the static import to work. Smart guy
It is (made some research), but there is no need to use it here. Information: http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html @Pointless2Play , what'd you do which fixed it?
Did I say it was need for it? You are the only yelling at me for not knowing "how enums work", when I perfectly know how. This guy clearly had no idea. EDIT: This fixed it: They also forgot the static tag if they wanted to go for the static import. Guess they changed it.