Skip to content

Commit

Permalink
custom item api example
Browse files Browse the repository at this point in the history
  • Loading branch information
HeathLoganCampbell committed Oct 21, 2021
1 parent d4f5eef commit 6056052
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,29 @@ Database.executeQuery("SELECT * FROM table WHERE id = ?",
Database.execute("DELETE FROM table", { statement -> })
```

## CustomItems
## CustomItems

```groovy
import dev.cobblesword.cobblegroovy.tools.CC
import me.lucko.helper.Events
import org.bukkit.Material
import org.bukkit.event.block.BlockBreakEvent
def lemonItem = CustomItem.create(Material.GOLD_BLOCK, "LEMON")
.displayName("Lemon")
.LoreSupplier { player, item ->
return [CC.red + "Sour", "Owner: " + item.getNBTString("owner")]
}
.onConsume { player, item ->
player.sendMessage("Too sour!")
}
.build()
Events.subscribe(BlockBreakEvent.class).handler{ e ->
Block block = e.getBlock()
if(block.getType() == Material.JUNGLE_LEAVES)
{
DropItem(lemonItem, block)
}
}
```

0 comments on commit 6056052

Please sign in to comment.