{"id":22674501,"url":"https://github.com/heathlogancampbell/cobblegroovy","last_synced_at":"2025-04-12T13:36:30.866Z","repository":{"id":46351052,"uuid":"417745318","full_name":"HeathLoganCampbell/CobbleGroovy","owner":"HeathLoganCampbell","description":"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","archived":false,"fork":false,"pushed_at":"2025-03-23T04:05:09.000Z","size":87,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-26T08:11:18.275Z","etag":null,"topics":["bukkit","groovy","hotswap","minecraft","script"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HeathLoganCampbell.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-16T06:53:05.000Z","updated_at":"2025-03-23T04:05:12.000Z","dependencies_parsed_at":"2022-09-22T09:10:26.243Z","dependency_job_id":null,"html_url":"https://github.com/HeathLoganCampbell/CobbleGroovy","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeathLoganCampbell%2FCobbleGroovy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeathLoganCampbell%2FCobbleGroovy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeathLoganCampbell%2FCobbleGroovy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HeathLoganCampbell%2FCobbleGroovy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HeathLoganCampbell","download_url":"https://codeload.github.com/HeathLoganCampbell/CobbleGroovy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248573983,"owners_count":21126937,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bukkit","groovy","hotswap","minecraft","script"],"created_at":"2024-12-09T17:16:51.845Z","updated_at":"2025-04-12T13:36:30.855Z","avatar_url":"https://github.com/HeathLoganCampbell.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CobbleGroovy\nCompile and execute programs on the fly with groovy scripts\nideally this will also pull from a git repo but currently \nit listens to all changes plugins/CobbleGroovy/scripts\n\nPre set up Script Environment:\nhttps://github.com/HeathLoganCampbell/CobbleGroovy-Scripts\n\n## [CobbleSword Services Discord](https://discord.gg/grpktEEM8g)\n\n## How it works\n* Init.Groovy gets called, this is where you set up your watch files\n\n\n## Example of working Groovy Script\n```groovy\npackage scripts.global\n\nimport dev.cobblesword.cobblegroovy.tools.CC\nimport me.lucko.helper.Commands\nimport me.lucko.helper.Events\nimport me.lucko.helper.Schedulers\nimport me.lucko.helper.hologram.BaseHologram\nimport me.lucko.helper.hologram.BukkitHologramFactory\nimport org.bukkit.Bukkit\nimport org.bukkit.ChatColor\nimport org.bukkit.Material\nimport org.bukkit.block.Block\nimport org.bukkit.boss.BarColor\nimport org.bukkit.boss.BarFlag\nimport org.bukkit.boss.BarStyle\nimport org.bukkit.boss.BossBar\nimport org.bukkit.entity.Player\nimport org.bukkit.event.block.BlockPlaceEvent\nimport org.bukkit.event.player.AsyncPlayerChatEvent\n\nCommands.create().assertPermission(\"example.command.yeet\")\n                .assertPlayer()\n                 .handler(sender -\u003e {\n                     sender.sender().sendMessage(ChatColor.RED.toString() + \"Weeee\")\n                     BaseHologram hologram = new BukkitHologramFactory()\n                             .newHologram(Position.of(sender.sender().getLocation()),\n                                     [\n                                             CC.red + \"Hello world\",\n                                             \"I Am Iron Man\"\n                                     ])\n                     hologram.spawn()\n\n                     BossBar bossBar = Bukkit.createBossBar(\"yeet world\", BarColor.WHITE, BarStyle.SOLID, BarFlag.DARKEN_SKY)\n                     bossBar.addPlayer(sender.sender())\n                 }).registerAndBind(registry, \"yeet\")\n\n\nSchedulers.async().runRepeating(() -\u003e {\n    Bukkit.broadcastMessage(CC.red + \"Example\")\n}, 20, 20).bindWith(registry)\n\nEvents.subscribe(BlockPlaceEvent.class).handler{\n    Block block = it.getBlock()\n    block.setType(Material.GOLD_BLOCK)\n}.bindWith(registry)\n\nEvents.subscribe(AsyncPlayerChatEvent.class).handler{\n    it.setFormat(CC.red + \"%s: %s\")\n    it.getPlayer().sendMessage(\"ABCCC\")\n}.bindWith(registry)\n\nSchedulers.async().runRepeating(() -\u003e {\n    for (Player player : Bukkit.getOnlinePlayers())\n    {\n        player.setPlayerListName(\" My Name Jeff \")\n        player.setPlayerListHeaderFooter(\"Header\", \"fotters\")\n    }\n}, 20, 20).bindWith(registry)\n```\n\n\n## Commands\n```groovy\nCommands.create().handler { command -\u003e \n    command.sender().sendMessage(\"Test\")\n}.register(\"Example\")\n```\n\n## Events\n```groovy \nEvents.subscribe(InventoryCloseEvent.class).handler { event -\u003e\n    def player = event.getPlayer()\n    player.sendMessage(\"Hello world\")\n}\n```\n\n\n## Database\n```groovy\nDatabase.executeQuery(\"SELECT * FROM table WHERE id = ?\", \n    { statement -\u003e statement.setInt(1, 1) }, \n    { result -\u003e })\n\nDatabase.execute(\"DELETE FROM table\", { statement -\u003e })\n```\n\n## CustomItems\n\n```groovy\npackage scripts.global\n\nimport dev.cobblesword.cobblegroovy.tools.CC\n\nimport dev.cobblesword.cobblegroovy.tools.item.Items\nimport me.lucko.helper.Commands\nimport org.bukkit.Location\nimport org.bukkit.Material\nimport org.bukkit.block.Block\nimport org.bukkit.block.BlockFace\nimport org.bukkit.entity.Player\nimport org.bukkit.event.player.PlayerMoveEvent\n\n// create new item, cheese that when eld leaves a trail of sponges\nCustomItem cheese = Items.create(\"CHEESE\", Material.SPONGE)\n        .displayName(CC.bYellow + \"Cheese\")\n        .subscribe(PlayerMoveEvent.class, (e, item, customItem) -\u003e {\n            Player player = e.getPlayer();\n            Location location = player.getLocation();\n            Block block = location.getBlock();\n            Block standingBlock = block.getRelative(BlockFace.DOWN);\n\n            if (standingBlock.getType() != Material.AIR) {\n                standingBlock.setType(Material.SPONGE);\n            }\n        })\ncheese.bindWith(registry)\n\n// Give new custom item\nCommands.create().assertPlayer()\n        .handler { cmd -\u003e\n            var sender = cmd.sender()\n            sender.getInventory().addItem(cheese.getItemStack())\n        }.registerAndBind(registry, \"cheese\")\n```\n\nFor more info on the api, look at lucko's helper repository's wiki\n\n## Future improvement\nTo get rid of `.bindWith(registry)` being scrattered everywhere, we need to add our own wrappers to Events, Commands, Schedulers and call Events.init(registry) once the file starts to be read and Events.complete() once the file is finished. the limitation here is we cannot have any registered events async or delayed.\n\n```\nclass Events\n{\n  private static GroovyScript currentGroovyScript;\n\n  public static void init(GroovyScript currentGroovyScript)\n  {\n     currentGroovyScript = currentGroovyScript;\n  }\n\n  public static void complete()\n  {\n    currentGroovyScript = null;\n  }\n\n  public static void subscribe(class class, EventPriority eventPriority)\n  {\n    if(currentGroovyScript == null) throw exception;\n    Events.subscribe(class, eventPriority).bindWith(currentGroovyScript)\n  }\n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheathlogancampbell%2Fcobblegroovy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fheathlogancampbell%2Fcobblegroovy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fheathlogancampbell%2Fcobblegroovy/lists"}