Hello, I am very new at bukkit plugin development. I was wondering if there was a way to create a plugin that rewarded the first 100 players (or IP's) that joined our server. I know that there is the hasPlayedBefore. But how would I go about restricting the 101 player from receiving a reward? Any help would be greatly appreciated!
I would register the names into a file and when the file gets to 100 names the server stops rewarding.
What is the code for registering players into a file? I am familiar with registering plugins but how would I put players into a file?
TheDef Instead of putting 100 names in a file (thats a lot of names ) I would just have one int. Every time a player joins, check if they hasPlayedBefore() and if they haven't, add one to the int. Code:java inti;@EventHandlerpublic void onPlayerJoin(PlayerJoinEvent e) {Player p = e.getPlayer();if (!p.hasPlayedBefore) {if (getConfig().contains("number")) {i = getConfig().getint("number");} else {i = 0;}i++;getConfig().set("number", i);}} That's only if you restart your server. If you don't restart your server, you have no need for the config file.
That makes sense, a little bit lighter on the server as well. Code:java if(i = 101){getPlayer.getInventory.clear()}else{getPlayer.getInventory.setItem()} Is this proper, as far as rewarding the first 100 players? Will this bit of code call upon the file containing the int?
fireblast709 Thanks for correcting my formatting. Does setItem only place an item in the currently selected slot?