Im just getting back into coding when i came across something i am stuck at. Code: package WarnCommand.kyle; import java.util.logging.Logger; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class Main extends JavaPlugin implements Listener { public final Logger logger = Logger.getLogger("Minecraft"); SettingsManger settings = SettingsManger.getInstance(); public void onEnable(){ Bukkit.getPluginManager().registerEvents(this, this); //getCommand("SStick").setExecutor(new SStick()); // getCommand("StStick").setExecutor(new StStick()); } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player p = (Player)sender; Inventory pi = p.getInventory(); if (commandLabel.equalsIgnoreCase("warn")) { if (args.length == 0){ p.sendMessage("§c/warn - A Warning System"); p.sendMessage("§aWarn Types:"); p.sendMessage("§3SF"); p.sendMessage("§3Caps"); p.sendMessage("§3Spamming"); p.sendMessage(" "); p.sendMessage("§aHow to warn a player"); p.sendMessage("§3/Warn <name> <reason>"); p.sendMessage("§3Examples:"); p.sendMessage("§3/Warn KoolzSkillz SF"); p.sendMessage("§3/Warn KoolzSkillz Caps"); p.sendMessage("§3/Warn KoolzSkillz Swearing"); return true; } if (args.length == 1) { Player tp = p.getServer().getPlayer(args[0]); tp.sendMessage("§3You Have Been Warned For SF, Dont Do It Again"); }} return false; } }
@Assist it doesnt work, it doesnt even have an error it just says /warn in white note the fist one works fine 'its the '/warn KoolzSkillz
Did you add the command to the plugin.yml file? Also don't forget to check if the sender is actually a player.
@KoolzSkillz what is the exact command you type in. As the code is now, the only reason it would ever print that is if you used more than 1 argument.
@KoolzSkillz You're returning false. Also, instead of putting: Code: if (args.length == 0) { } if (args.length == 1) { } Use Code: if (args.length == 0) { } else if (args.length == 1) { } Also, remember to check before casting!!! Code: // CHECK BEFORE CASTING!!!! if (sender instanceof Player) { Player player = (Player) sender; } else { sender.sendMessage("You're not a player!"); } You can't get a console's inventory... Make sure to indent and format your code. If you're using Eclipse it's CTRL + Shift + F. Also make sure that TP isn't null. Don't use commandLabel. Use if (cmd.getName().equalsIgnoreCase(""))