{"id":20010003,"url":"https://github.com/conclube/eventbuilder","last_synced_at":"2025-05-04T19:35:58.684Z","repository":{"id":119220825,"uuid":"301867833","full_name":"conclube/EventBuilder","owner":"conclube","description":"Functional event listener builder for bukkit events.","archived":false,"fork":false,"pushed_at":"2020-10-08T14:16:42.000Z","size":127,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T11:38:36.430Z","etag":null,"topics":["bukkit","hacktoberfest","java","minecraft","spigot"],"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/conclube.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,"governance":null}},"created_at":"2020-10-06T22:18:34.000Z","updated_at":"2024-12-15T12:38:34.000Z","dependencies_parsed_at":"2023-09-21T08:00:29.722Z","dependency_job_id":null,"html_url":"https://github.com/conclube/EventBuilder","commit_stats":null,"previous_names":["conclube/eventbuilder"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conclube%2FEventBuilder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conclube%2FEventBuilder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conclube%2FEventBuilder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/conclube%2FEventBuilder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/conclube","download_url":"https://codeload.github.com/conclube/EventBuilder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252390780,"owners_count":21740384,"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","hacktoberfest","java","minecraft","spigot"],"created_at":"2024-11-13T07:17:56.156Z","updated_at":"2025-05-04T19:35:58.246Z","avatar_url":"https://github.com/conclube.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EventBuilder\nFunctional event listener builder for bukkit events.\n\n## Setup\nTo use this, you will have to shade it into your jar.\n\n```gradle\nrepositories {\n  mavenCentral()\n  maven {url 'http://repo.bristermitten.me/repository/maven-releases/'}\n}\n\ndependencies {\n  implementation 'me.conclure:event-builder:1.1.1'\n}\n```\n\n## Usage\n\n### Get Started\nYou will start everything with the class `EventBuilders`.\nThen call `EventBuilders.create(Class\u003cT extends Event\u003e)` which will give you an `EventBuilder\u003cT extends Event\u003e`.\n\n```java\nEventBuilder\u003cPlayerJoinEvent\u003e eventBuilder = EventBuilders.create(PlayerJoinEvent.class);\n```\n\n**NOTE**: You may not use event classes which doesn't have the static method `#getHandlerList()`.\n\n\u003cbr\u003e\n\nTo assign an action to the builder, simply call `EventBuilder\u003cT extends Event\u003e#execute(Consumer\u003cT\u003e)`.\n\n```java\neventBuilder.execute(event -\u003e event.setJoinMessage(\"Someone joined.\"));\n```\n\n\u003cbr\u003e\n\nThen we can get the an `EventHandler\u003cT extends Event\u003e` by calling `EventBuilder\u003cT extends Event\u003e#build()` that won't allow any modifications to it's actions.\nYou may now set the event priority by `EventHandler\u003cT extends Event\u003e#eventPriority(EventPriority)` \nand if handler should ignore cancelled by `EventHandler\u003cT extends Event\u003e#ignoreCancelled(boolean)`.\n\n```java\nEventHandler\u003cPlayerJoinEvent\u003e eventHandler = eventBuilder.build()\n  .ignoreCancelled(true)\n  .eventPriority(EventPriority.MONITOR);\n```\n\n\u003cbr\u003e\n\nYou can then register the event handler by calling `EventHandler\u003cT extends Event\u003e#register(Plugin)` which will give you an `EventSubscription\u003cT extends Event\u003e`.\nOnce you have gotten the subscription you won't be able to modify anything. The plugin instance should be your own.\n\n```java\nEventSubscription\u003cPlayerJoinEvent\u003e eventSubscription = eventHandler.register(myPluginInstance);\n```\n\n\u003cbr\u003e\n\nIf you prefer, you may also chain all the methods as a builder pattern.\n\n```java\nEventSubscription\u003cPlayerJoinEvent\u003e eventSubscription = EventBuilders.create(PlayerJoinEvent.class)\n  .execute(event -\u003e event.setJoinMessage(\"Someone joined.\"))\n  .build()\n  .ignoreCancelled(true)\n  .eventPriority(EventPriority.MONITOR)\n  .register(myPluginInstance);\n```\n\n**NOTE**: You can skip calling `#build()` and instead call `#register(Plugin)` directly, \nthat will set ignoreCancelled to false and eventPriority to NORMAL.\n\n\u003cbr\u003e\n\nIt's recommended to unregister the subscription when your plugin is disabling `JavaPlugin#onDisable()`.\n\n```java\n\n@Override\npublic void onDisable() {\n  eventSubscription.unregister();\n}\n\n```\n\n### Advanced\nNow let's look into more functionalites you can utilize.\nFirstly you can use a `Predicate\u003cT extends Event\u003e` as a filter.\nThis will cause all actions declared under the filter to not execute if the filter doesn't return true.\n\n```java\nEventBuilder\u003cPlayerJoinEvent\u003e eventBuilder = EventBuilders.create(PlayerJoinEvent.class)\n  .filter(event -\u003e !event.isAsynchronous())\n  .execute(event -\u003e event.setJoinMessage(\"Someone joined.\")); //Will only run if the event isn't async\n```\n\n\u003cbr\u003e\n\nThere is also `EventBuilder\u003cT extend Event\u003e#unregisterIf(Predicate\u003cT\u003e)` which instead of filtering will unregister the event subscription if the predicate is true.\n\n```java\neventBuilder.unregisterIf(Event::isAsynchronous);\n```\n\n**NOTE**: Any actions declared underneath it will still run that time.\n\n\u003cbr\u003e\n\nYou can also utilize `EventBuilder\u003cT extend Event\u003e#executeIf(Predicate\u003cT\u003e,Consumer\u003cT\u003e)`.\nThe consumer will only run if the predicate is true. The predicate won't apply to any other actions else than the consumer declared after it \nalbeit filters above it will still apply.\n\n```java\n//Will only run if the event is async\neventBuilder.executeIf(event -\u003e event.isAsynchronous(), event.setJoinMessage(\"Nobody joined.\"));\n```\n\n```java\neventBuilder.filter(event -\u003e event.getPlayer().hasPlayerBefore())\n\n  //Will only run if the event is async and if the player has played before\n  .executeIf(event -\u003e event.isAsynchronous(), event.setJoinMessage(\"Nobody joined.\"));\n```\n\n```java\neventBuilder.filter(event -\u003e event.getPlayer().hasPlayedBefore())\n\n  //Will only run if the event is async and if the player has played before\n  .executeIf(event -\u003e event.isAsynchronous(), event.setJoinMessage(\"Nobody joined.\"))\n\n  //Will only run if the player has played before\n  .execute(event -\u003e event.setJoinMessage(\"An OG player joined.\"));\n```\n\n## Contributions\nThis project is open for any pull requests that has reasonable changes. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconclube%2Feventbuilder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconclube%2Feventbuilder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconclube%2Feventbuilder/lists"}