Hello guys, i am making a plugin where a player gets a certain reward when he kills another player. Right now there are 2 rewards: Exp and Item. I want to add an amount to the item i give to the player but i haven't really figured out how yet. Any ideas (sorry if my code is bad but i am learning java ) Code:java public class ExpKills extends JavaPlugin implements Listener { public void onEnable(){ PluginManager pm = getServer().getPluginManager(); pm.registerEvents(this, this); saveDefaultConfig(); } @EventHandler public void PlayerDeath(PlayerDeathEvent e){ Player killer = e.getEntity().getKiller(); Player killed = e.getEntity(); ItemStack item = new ItemStack(Material.getMaterial(this.getConfig().getString("item-per-kill"))); int amount = item.getAmount() * this.getConfig().getInt("amount-item") ; if(killer instanceof Player) { }else{ return; } if(this.getConfig().getBoolean("Exp") == true) { killer.giveExpLevels(this.getConfig().getInt("exp-per-kill")); killer.sendMessage(ChatColor.GOLD + "You killed " + killed.getDisplayName() + ChatColor.GOLD + " and gained " + this.getConfig().getInt("exp-per-kill") + ChatColor.GOLD + " level(s)!"); } if(this.getConfig().getBoolean("item") == true); killer.getInventory().addItem(item); //how can i add the amount? (sorry new to java) killer.sendMessage(ChatColor.GOLD + "You killed " + killed.getDisplayName() +ChatColor.GOLD+ " and earned " + this.getConfig().getInt("amount-item") + ChatColor.GOLD + " " + this.getConfig().getString("item-per-kill") + ChatColor.GOLD + " !"); }}
this should help you out http://jd.bukkit.org/rb/doxygen/d9/da1/classorg_1_1bukkit_1_1inventory_1_1ItemStack.html
Hello, since you found the solution please mark thread as solved. Also some efficiency and time saving tips 1. You could have a boolean called whatever that on enable loads from config so on death event you don't have to do do getconfig.betboolean("") that also makes it easier for the server too, 2. To save you some time you don't have to add boolean == true/false as if condition justt use if(boolean){ //this will work only of boolean is true If you want a if for false boolean use the ! Operator }