Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heathlogancampbell/cobblegroovy
Allows you to script out features on a production server with no downtime, and low performance impact. Great for hunting down bug in production too
https://github.com/heathlogancampbell/cobblegroovy
bukkit groovy hotswap minecraft script
Last synced: 16 days ago
JSON representation
Allows you to script out features on a production server with no downtime, and low performance impact. Great for hunting down bug in production too
- Host: GitHub
- URL: https://github.com/heathlogancampbell/cobblegroovy
- Owner: HeathLoganCampbell
- Created: 2021-10-16T06:53:05.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-31T01:30:59.000Z (about 3 years ago)
- Last Synced: 2024-05-01T15:19:28.386Z (8 months ago)
- Topics: bukkit, groovy, hotswap, minecraft, script
- Language: Java
- Homepage:
- Size: 69.3 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# CobbleGroovy
Compile and execute programs on the fly with groovy scripts
ideally this will also pull from a git repo but currently
it listens to all changes plugins/CobbleGroovy/scriptsPre set up Script Environment:
https://github.com/HeathLoganCampbell/CobbleGroovy-Scripts## [CobbleSword Services Discord](https://discord.gg/grpktEEM8g)
## Example of working Groovy Script
```groovy
package scripts.globalimport dev.cobblesword.cobblegroovy.tools.CC
import me.lucko.helper.Commands
import me.lucko.helper.Events
import me.lucko.helper.Schedulers
import me.lucko.helper.hologram.BaseHologram
import me.lucko.helper.hologram.BukkitHologramFactory
import org.bukkit.Bukkit
import org.bukkit.ChatColor
import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.boss.BarColor
import org.bukkit.boss.BarFlag
import org.bukkit.boss.BarStyle
import org.bukkit.boss.BossBar
import org.bukkit.entity.Player
import org.bukkit.event.block.BlockPlaceEvent
import org.bukkit.event.player.AsyncPlayerChatEventCommands.create().assertPermission("example.command.yeet")
.assertPlayer()
.handler(sender -> {
sender.sender().sendMessage(ChatColor.RED.toString() + "Weeee")
BaseHologram hologram = new BukkitHologramFactory()
.newHologram(Position.of(sender.sender().getLocation()),
[
CC.red + "Hello world",
"I Am Iron Man"
])
hologram.spawn()BossBar bossBar = Bukkit.createBossBar("yeet world", BarColor.WHITE, BarStyle.SOLID, BarFlag.DARKEN_SKY)
bossBar.addPlayer(sender.sender())
}).registerAndBind(registry, "yeet")Schedulers.async().runRepeating(() -> {
Bukkit.broadcastMessage(CC.red + "Example")
}, 20, 20).bindWith(registry)Events.subscribe(BlockPlaceEvent.class).handler{
Block block = it.getBlock()
block.setType(Material.GOLD_BLOCK)
}.bindWith(registry)Events.subscribe(AsyncPlayerChatEvent.class).handler{
it.setFormat(CC.red + "%s: %s")
it.getPlayer().sendMessage("ABCCC")
}.bindWith(registry)Schedulers.async().runRepeating(() -> {
for (Player player : Bukkit.getOnlinePlayers())
{
player.setPlayerListName(" My Name Jeff ")
player.setPlayerListHeaderFooter("Header", "fotters")
}
}, 20, 20).bindWith(registry)
```## Commands
```groovy
Commands.create().handler { command ->
command.sender().sendMessage("Test")
}.register("Example")
```## Events
```groovy
Events.subscribe(InventoryCloseEvent.class).handler { event ->
def player = event.getPlayer()
player.sendMessage("Hello world")
}
```## Database
```groovy
Database.executeQuery("SELECT * FROM table WHERE id = ?",
{ statement -> statement.setInt(1, 1) },
{ result -> })Database.execute("DELETE FROM table", { statement -> })
```## CustomItems
```groovy
package scripts.globalimport dev.cobblesword.cobblegroovy.tools.CC
import dev.cobblesword.cobblegroovy.tools.item.CustomItem
import dev.cobblesword.cobblegroovy.tools.item.Items
import me.lucko.helper.Commands
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.block.Block
import org.bukkit.block.BlockFace
import org.bukkit.entity.Player
import org.bukkit.event.player.PlayerMoveEvent// create new item, cheese that when eld leaves a trail of sponges
CustomItem cheese = Items.create("CHEESE", Material.SPONGE)
.displayName(CC.bYellow + "Cheese")
.subscribe(PlayerMoveEvent.class, (e, item, customItem) -> {
Player player = e.getPlayer();
Location location = player.getLocation();
Block block = location.getBlock();
Block standingBlock = block.getRelative(BlockFace.DOWN);if (standingBlock.getType() != Material.AIR) {
standingBlock.setType(Material.SPONGE);
}
})
cheese.bindWith(registry)// Give new custom item
Commands.create().assertPlayer()
.handler{cmd ->
var sender = cmd.sender()
sender.getInventory().addItem(cheese.getItemStack())
}.registerAndBind(registry, "cheese")
```For more info on the api, look at lucko's helper repository's wiki