{"id":13510915,"url":"https://github.com/NucleoidMC/stimuli","last_synced_at":"2025-03-30T19:30:34.777Z","repository":{"id":37862856,"uuid":"367173206","full_name":"NucleoidMC/stimuli","owner":"NucleoidMC","description":"Library for working server-side events with the ability to filter by event source","archived":false,"fork":false,"pushed_at":"2025-03-27T18:45:14.000Z","size":470,"stargazers_count":17,"open_issues_count":13,"forks_count":20,"subscribers_count":1,"default_branch":"1.21.4","last_synced_at":"2025-03-27T19:39:45.077Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NucleoidMC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-05-13T20:58:47.000Z","updated_at":"2025-03-27T18:45:18.000Z","dependencies_parsed_at":"2024-01-16T12:46:20.640Z","dependency_job_id":"8682dbcb-2f97-4cd1-ac8a-30508e201854","html_url":"https://github.com/NucleoidMC/stimuli","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Fstimuli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Fstimuli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Fstimuli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NucleoidMC%2Fstimuli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NucleoidMC","download_url":"https://codeload.github.com/NucleoidMC/stimuli/tar.gz/refs/heads/1.21.4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246368595,"owners_count":20766052,"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":[],"created_at":"2024-08-01T03:00:21.961Z","updated_at":"2025-03-30T19:30:34.762Z","avatar_url":"https://github.com/NucleoidMC.png","language":"Java","funding_links":[],"categories":["API \u0026 Libraries"],"sub_categories":[],"readme":"# Stimuli\nStimuli is a library that allows working with server-side events while being able to filter events by their source.\nThis makes Stimuli useful for general additional server-side event use, but also a very powerful tool in setting up\nbehavior local to a specific part of the world.\n\n## Using\n\n### Adding to Gradle\nTo add Stimuli to your Gradle project, add the Nucleoid Maven repository and Stimuli dependency.\n`STIMULI_VERSION` should be replaced with the latest version from [Maven](https://maven.nucleoid.xyz/xyz/nucleoid/stimuli).\n```gradle\nrepositories {\n  maven { url = 'https://maven.nucleoid.xyz/' }\n  maven { url = \"https://jitpack.io\" }\n}\n\ndependencies {\n  // ...\n  modImplementation 'xyz.nucleoid:stimuli:STIMULI_VERSION'\n}\n```\n\n### Registering events globally\nThe simplest usage of the mod involves registering global events without a filter. Global event listeners can be\nregistered through `Stimuli.global()`. \n\n```java\nStimuli.global().listen(PlayerChatEvent.EVENT, (sender, message, messageType) -\u003e {\n    sender.sendMessage(Text.literal(\"You shall not speak!\"), false);\n    return EventResult.DENY;\n});\n```\n\nThis example registers a listener to the `PlayerChatEvent` event and returns `EventResult.DENY` in order to cancel\nfurther processing of the chat event.\n\nIf an event you need is not currently implemented, please consider [submitting a Pull Request](https://github.com/NucleoidMC/stimuli/compare)!\n\n### Registering events with a filtered source\nCapturing events with a filtered source is a little more complicated. The basis of receiving events with a filter is an\n`EventListenerSelector`: a listener selector returns an iterator of event listeners given an event source and event type.\n\nThe simplest case is returning events based on a single filter, and Stimuli provides an implementation for this case.\n\nFor example:\n```java\n// create a filter that only accepts positions within the overworld between (0; 0; 0) and (16; 256; 16)\nEventFilter filter = EventFilter.box(World.OVERWORLD, new BlockPos(0, 0, 0), new BlockPos(16, 256, 16));\n\n// create a map of event type to listener \u0026 deny block breaking\nEventListenerMap listeners = new EventListenerMap();\nlisteners.listen(BlockBreakEvent.EVENT, (player, world, pos) -\u003e EventResult.DENY);\n\n// register our event listener selector so that our events get called\nStimuli.registerSelector(new SimpleListenerSelector(filter, listeners));\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNucleoidMC%2Fstimuli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FNucleoidMC%2Fstimuli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FNucleoidMC%2Fstimuli/lists"}