I am making a plugin for someone and i need to know how to give everyone an item in the server i have everything else here is the code so far Code: package me.wolfmaster.Give; import java.util.logging.Logger; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.plugin.java.JavaPlugin; public class Main extends JavaPlugin{ public final Logger logger = Logger.getLogger("Minecraft"); public void onEnable(){ logger.info("Give All Has Been Enabled!"); } public void onDisable(){ logger.info("Give All Has Been Disabled!"); } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){ Player player = (Player) sender; if(commandLabel.equalsIgnoreCase("giveall")); if(sender.hasPermission("giveall.allow")); } } All i need to know is the give all command part and then i can finish the code by myself
There should be some way to choose to "select" every player on the server, you know like you did there, Player player = (Player) sender; There should be something that choose all players on the server, I don't remember.
Code: for(int i = 0;i<all.lenght;i++){ all[i].youractionhere(); } https://www.google.com/search?q=java loops
would it be possible for me just to use the normal give command and it work? i CAN make them, i have a basic level and i learn as i go along EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Well then when someone normally says a loop you should of got it but ok. Also as far as i know the give command will not work with all the players (Never tried) Do this Code:Java Player[] all = Bukkit.getOnlinePlayers(); for(Player ply1 : all){ ply1.getInventory().addItem(new ItemStack(Material.APPLE)); }
what about: Code: for(Player player : Bukkit.getServer().getOnlinePlayers{ //give items to players in here eg: player.getInventory().addItem(new ItemStack(Material.DIAMOND, 64); } That itterates through each player on the server.
ahh right, simple enough thats what i was going to do but i didnt know whether it would work or not EDIT by Moderator: merged posts, please use the edit button instead of double posting.