Problem: Every argument that I try doesn't work. I have done plenty of research on Google and went to a lot of web pages. Error: The operator && is undefined for the argument type(s) String, boolean What I have done: I have tried to replace && with &, =, ==, I just don't know what to put there. Line: 23 If you could help me that would be great! Java Code: Code: package me._CamPlayzMC_; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import net.minecraft.server.v1_10_R1.EnumItemSlot.Function; public class CamCraft extends JavaPlugin { @Override public void onEnable() { getLogger().info("CamCraft 1.0 enabled!"); } @Override public void onDisable() { } public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args[] ) { if (cmd.getName().equalsIgnoreCase("hello" && sender instanceof Player )) { Player player = (Player) sender; player.sendMessage("Hello, " +player.getName() + "Welcome to the server"); return true; } return false; } }
Move the parentheses after the instance of before the &&. Hate to say it, but learn java and some general programming before bukkit.
Bukkit logs your plugins for you. You don't need to log it twice. Your plugins shouldf follow the format "me.<name>.<project name>", and should be all lower case. If the method does nothing, remove it. And as has been said before: https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
Thank you so much! I plan on doing Java classes online. But thank you so much for the help and im sorry im not good at Java. - Cam
lol why is the args in onCommand defined as a 2 dimensional array? it should be Code: String[] args not Code: String[] args[]
It's combining the Java arrays with C arrays. C arrays are defined as Code: String args[] Java arrays are defined as Code: String[] args They both work in Java. (However I did not know you can combine them). But use the Java array definition.
@MCMastery It is actually a 2d array. Just check with your IDE But you are complety right with the rest!
Hello! Here is the code you can use to allow the &&'s to work. Code: package me._CamPlayzMC_.CamCraft; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; import net.minecraft.server.v1_10_R1.EnumItemSlot.Function; public class CamCraft extends JavaPlugin { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args ) { if (cmd.getName().equalsIgnoreCase("hello") && sender instanceof Player ) { Player player = (Player) sender; player.sendMessage("Hello, " +player.getName() + "Welcome to the server"); return true; } return false; } } If you copy this it should work.