Hi, I am creating a plugin with a command called' /giveitem <item>' but, it is not working i do /giveitem iron_ore it does not work. i do /giveitem minecraft:iron_ore it does not work. here is my main class: Code: package me.hardboom.ultimate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import me.hardboom.ultimate.Gamerules; import org.bukkit.event.*; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin implements Listener { public void onEnable() { Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "\n\nUltimate has been activated\n\n"); Commands commands = new Commands(); getCommand(commands.cmd1).setExecutor(commands); Gamerules gamerules = new Gamerules(); gamerules.gamerules(); } public void onDisable() { Bukkit.getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "\n\nUltimate has been activated\n\n"); } } This is my Commands class Code: package me.hardboom.ultimate; 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.Listener; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import net.md_5.bungee.api.ChatColor; public class Commands implements Listener, CommandExecutor { public String cmd1 = "giveitem"; @Override public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { if(sender instanceof Player) { if(cmd.getName().equalsIgnoreCase(cmd1)) { Material item = Material.getMaterial(args[0]); if(item != null){ Inventory inv = ((Player)sender).getInventory(); inv.addItem(new ItemStack(item, 1)); return true; }else { sender.sendMessage(ChatColor.RED + args[0] + ChatColor.BLUE + " is not a valid item"); } }else { sender.sendMessage(ChatColor.RED + "Only players can use this command"); return true; } } return false; } } This is my gamerules class(Probably not relevant) Code: package me.hardboom.ultimate; import me.hardboom.ultimate.Commands; import org.bukkit.Bukkit; import org.bukkit.command.*; public class Gamerules { public void gamerules() { Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule doDaylightCycle false"); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "gamerule doWeatherCycle false"); Commands commands = new Commands(); } } here is my plugin.yml Code: name: Ultimate version: 1.0 main: me.hardboom.ultimate.Main commands: giveitem: usage: /<command> description: gives you an item
I'm sorry, I am relatively new to java and I do not understand, if you do not have time to explain, that is completely understandable uppercase for the item after /giveitem? IT WORKS Thank you! How do I mark this as solved? EDIT by Moderator: merged posts, please use the edit button instead of double posting.