Pls my code is bad and the plugin not start Menu (main) Code (Text): package me.newpredator; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.plugin.java.JavaPlugin; public class Menu extends JavaPlugin { public static final Logger log = Logger.getLogger("Minecraft:"); public static Inventory inv = Bukkit.createInventory(null, 18, (ChatColor.translateAlternateColorCodes('&',Config.menuname))); public void onEnable() { log.log(Level.INFO, "Plugin Activated"); if (!Config.configFile.exists()) { Config.save(); } Config.load(); } public void onDisable() { log.log(Level.INFO, "Plugin Desactivated"); } @Override public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("menu")); Player p = (Player) sender; if (p.hasPermission("menu.open")){ if(args.length ==0); p.openInventory(inv); p.sendMessage(ChatColor.AQUA + "You are opening the inventory"); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F); }else{ p.sendMessage(ChatColor.RED + "You don´t have permission"); p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1.0F, 1.0F); return true; } return false; } } Config
Code (Text): package me.newpredator; import java.io.File; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.configuration.file.YamlConfiguration; public class Config { public static String menuname = "&bMenu"; public static final Logger log = Logger.getLogger("Minecraft:"); //Archive public static File configFile = new File("plugins/Menu/Config.yml"); public static void load() { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); menuname = config.getString("Menu.Name"); } public static void save() { YamlConfiguration config = new YamlConfiguration(); config.set("Menu.Name", menuname); try { config.save(configFile); Menu.log.log(Level.INFO, "Config enable"); } catch (Exception e) { Menu.log.log(Level.WARNING, "Error in configurate (0)", e.getMessage()); } } }
Please, we can never help you like this. Give information: what is the error, what for plugin are you making etc.
Yes I create the plugin.yml http://gyazo.com/f223defd54658745ad977dbf8cacd030 http://gyazo.com/52ab405fcb6cff1c97ea1ac7df122411
Probably is this your problem: Player p = (Player) sender;. Because you are casting it before you ever knows who that sender is. Make this if statement if (sender instanceof Player){do stuff}
That's bad practice, but also not inherently going to cause the plugin not to load in the first place.
Interestingly enough, that is a valid snippet, however it isn't doing what he expects. The underlying definition of an if statement in java is Code (Text): if ( condition ) statement The curly brackets commonly employed with if constructs denote a block, which is then used as the single 'statement' in the definition. If instead you write Code (Text): if ( condition ) ; The statement is interpreted as a lesser known java construct - ';' on its own is the 'empty statement' - it does nothing. This means while he was attempting to do something along the lines of Code (Text): if (p.hasPermission("menu.open") && args.length == 0) { p.openInventory(inv); p.sendMessage(ChatColor.AQUA + "You are opening the inventory"); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F); } else { p.sendMessage(ChatColor.RED + "You don´t have permission"); p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1.0F, 1.0F); return true; } He has actually written Code (Text): if (p.hasPermission("menu.open")) { if(args.length ==0) { // Let's just ignore this if statement } p.openInventory(inv); p.sendMessage(ChatColor.AQUA + "You are opening the inventory"); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F); } else { p.sendMessage(ChatColor.RED + "You don´t have permission"); p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1.0F, 1.0F); return true; } - flamin
If statements that end with: ';'. Sure, because that will have no effect on code whatsoever. EDIT: Ninja'd by @flamin_scotsman
Yes, however he has nothing before the semicolon, so your argument is moot. He is testing a condition, then doing nothing with it. - flamin
Code (Text): package me.newpredator; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Sound; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.Inventory; import org.bukkit.plugin.java.JavaPlugin; public class Menu extends JavaPlugin { public static final Logger log = Logger.getLogger("Minecraft:"); public static Inventory inv = Bukkit.createInventory(null, 18, (ChatColor.translateAlternateColorCodes('&',Config.menuname))); public void onEnable() { log.log(Level.INFO, "Plugin Activated"); if (!Config.configFile.exists()) { Config.save(); } Config.load(); } public void onDisable() { log.log(Level.INFO, "Plugin Desactivated"); } @Override public boolean onCommand (CommandSender sender, Command cmd, String label, String[] args) { if(cmd.getName().equalsIgnoreCase("menu")); Player p = (Player) sender; if (p.hasPermission("menu.open") && args.length == 0) { p.openInventory(inv); p.sendMessage(ChatColor.AQUA + "You are opening the inventory"); p.playSound(p.getLocation(), Sound.ENDERDRAGON_WINGS, 1.0F, 1.0F); } else { p.sendMessage(ChatColor.RED + "You don´t have permission"); p.playSound(p.getLocation(), Sound.VILLAGER_NO, 1.0F, 1.0F); return true; } return false; } } ?
<sigh..> Please look up the definition of an empty statement. The code given below, will print out as follows: 4 Is equal to 4. Because i is equal to c. PHP: int i = 4,c = 4; if(i == c) { System.out.println(i + " Is equal to " + c); } This will also print out "4 Is equal to 4." Even though we added the semicolon to the end. PHP: int i=4,c=4; if(i == c); { System.out.println(i + " Is equal to " + c); } Now... We changed the value of i, it now equals 44. When we run this code, it prints out 44 Is equal to 4. Which is NOT true. PHP: int i = 44,c = 4; if(i == c); { System.out.println(i + " Is equal to " + c); } Right from the documentation... http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.6 When testing a value, this is useless, and you should not do it. @TheGamesHawk2001
@Newpredator To start, remove this: PHP: public static final Logger log = Logger.getLogger("Minecraft:"); Don't use static unless you know what you are doing with it.