Open Ziden opened 12 years ago
It will be implemented for blocks when i add them to ui.
could u explain this better ? maybe a simple code snipper, would be great
thanx alot for your attention !
Sorry i forgot to reply. You mean for destroying block? It would be sth like this (not tested):
import cz.ogion.ultraitems.*
public class BlockListener extends org.bukkit.event.block.BlockListener {
ItemManager itemManager = new ItemManager();
@Override
public void onBlockBreak(BlockBreakEvent event) {
UICustomItem item = itemManager.getItem(itemName);
Integer amount = 1;
if (item != null && event.getBlock().getType() == Material.COAL_ORE) {
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
event.getBlock().getLocation().getWorld().dropItemNaturally(event.getBlock().getLocation(), new SpoutItemStack(item, amount));
}
}
}
hmm on blockBreak ? Isnt it a item ? Im confused hehe
my real intetion is to make a sign, for example, on player interact, he gets a custom item, so i would need to create an ItemStack with that Custom Item and land it into the player inventory.
PS: think i just got it, with that SpoutItemStack heh :D
ill do my tryouts, thanx for your help, keep up the good work on this awesome plugin !!!!
You are alright it's SpoutItemStack.
how could i check, in another plugin, if the item in hand for example, is a custom item ? A cast ?
thanx alot for yout help
i couldnt find SpoutItemStack class btw
itemManager.getItem(player.getItemInHand()) == null
It's in dev spoutapi
im.getItem(itemInHand) is aways returning null, even if i have the item in hand thanx for your time !
ItemStack itemInHand = event.getPlayer().getItemInHand(); ItemManager im = new ItemManager(instancia.getUl()); // return UltraItems javaplugin
Actually i didn't realized it creates new manager. It should be sth like this then:
Plugin ui = this.getServer().getPluginManager().getPlugin("UltraItems");
if (ui != null) {
if(ui.itemManager.getItem(player.getItemInHand()) == null) {
player.chat("I am holding ultraitem");
}
}
Although i will focus on SpoutMaterials now so i won't keep this plugin anymore.
Lets say for example, i would want that if the player touch a block, i would want to drop a ultraitem.
How would i do that ?
Thanx for your attention !