Hey guys i want to make kinda Loterry system. and i need some help. What i want to do is if some player type /lottery [number 0-35] and if he have the Material diamond its will allow him to type and then there will be random numbers and if his number will be the last the player will get 3 diamonds. currectly the main is this script there is nothing in it. PHP: package me.lotto; import java.util.logging.Logger; import org.bukkit.command.Command;import org.bukkit.command.CommandSender;import org.bukkit.entity.Player;import org.bukkit.plugin.PluginDescriptionFile;import org.bukkit.plugin.java.JavaPlugin; public class Lotto extends JavaPlugin{ public final Logger logger = Logger.getLogger("MineCraft"); @Override public void onDisable() { PluginDescriptionFile p = this.getDescription(); this.logger.info(p.getName() + "V" + p.getVersion() + " Has Been Disabled!"); } @Override public void onEnable() { PluginDescriptionFile p = this.getDescription(); this.logger.info(p.getName() + "V" + p.getVersion() + " Has Been Enabled!"); } public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) { if(commandLabel.equalsIgnoreCase("lotto")){ Player player = (Player) sender; } return false; }}
1. To check if a player have diamond: Code: if(player.getInventory().contains(new ItemStack(Material.DIAMOND, 1))) { 2.To remove 1 diamond: Code: player.getInventory().removeItem(new ItemStack(Material.DIAMOND, 1)); For random numbers from 0-35 check this page: http://www.cs.geneseo.edu/~baldwin/reference/random.html
I have error in this lines PHP: if(player.getInventory().contains(new ItemStack(Material.DIAMOND, 1))) { player.getInventory().removeItem(new ItemStack(Material.DIAMOND, 1)); in .contains(new ItemStack....... and in the second line removeItem(new ItemStack....
Now i did that at the other line: PHP: player.getInventory().removeItem(Material.DIAMOND, 1)); and i got error on removeItem
Currectly i typed that: PHP: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[]args) { if(commandLabel.equalsIgnoreCase("lotto")){ Player player = (Player) sender; if(player.getInventory().contains(Material.DIAMOND, 1)) { player.getInventory().removeItem(Material.DIAMOND, 1); player.sendMessage(ChatColor.GREEN + "You have paid for the lottery Good Luck!"); }else{ player.sendMessage(ChatColor.RED + "You have no diamond to pay!"); } return false; }}} And the error is here. player.getInventory().removeItem(Material.DIAMOND, 1);
Could you please post the actual error in the server console? Saying "There is an error here" is not terribly useful if we don't know what the error is.
But there isnt error at the console the error is at the script.. i mean just line with error and its in this line:
I Imported it but its says there is no such import like that but now its doing errror just on ItemStack
I'm sorry but that doesn't really make sense. Are you saying that it throws an error when you try and compile the source code into a .jar file? or that it throws an error when you run it on the server?