{"id":15175120,"url":"https://github.com/expdev07/commy","last_synced_at":"2025-10-26T09:30:56.158Z","repository":{"id":99615789,"uuid":"131878675","full_name":"ExpDev07/commy","owner":"ExpDev07","description":"💬 Introducing Commy, a simple yet powerful framework which simplifies the use of Plugin Messaging Channels.","archived":false,"fork":false,"pushed_at":"2020-12-14T21:46:16.000Z","size":535,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T18:02:14.273Z","etag":null,"topics":["bungeecord","framework","java","networking","plugins","spigot"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExpDev07.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2018-05-02T16:37:04.000Z","updated_at":"2024-03-21T18:34:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1129c3c-0af2-4b1d-8aea-311f5bc13280","html_url":"https://github.com/ExpDev07/commy","commit_stats":{"total_commits":62,"total_committers":5,"mean_commits":12.4,"dds":0.5161290322580645,"last_synced_commit":"ed46b7e8bf7450f87dcdc27166ae881b627c1217"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpDev07%2Fcommy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpDev07%2Fcommy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpDev07%2Fcommy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpDev07%2Fcommy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExpDev07","download_url":"https://codeload.github.com/ExpDev07/commy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238301235,"owners_count":19449404,"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":["bungeecord","framework","java","networking","plugins","spigot"],"created_at":"2024-09-27T12:03:17.665Z","updated_at":"2025-10-26T09:30:55.692Z","avatar_url":"https://github.com/ExpDev07.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Commy\n\nIntroducing **Commy**, a simple yet powerful framework which simplifies the use of [Plugin Messaging Channels](https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/).\n\n## Getting Started\n\nThese instructions will help you setup a plugin using _Commy_.\n\n### Prerequisites\n\nJava 8\n\nYou will need to download Maven, as the modules _commy-spigot_ and _commy-bungee_ needs to be shaded with their respective plugins.\n\n### Installing\n\nYour IDE most likely comes with maven pre-installed (like IntelliJ), but if it  doesn't you can [manually download Maven from here](https://maven.apache.org/download.cgi).\n\nAdd commy to your pom.xml file. **Note:** If you are making a Spigot plugin, use _commy-spigot_. If you are making a BungeeCord plugin, use _commy-bungee_.\n````xml\n\u003cproject\u003e\n    \u003crepositories\u003e\n        \u003crepository\u003e\n            \u003cid\u003eossrh\u003c/id\u003e\n            \u003cname\u003eCommy Repository\u003c/name\u003e\n            \u003curl\u003ehttps://oss.sonatype.org/content/groups/public/\u003c/url\u003e\n        \u003c/repository\u003e\n    \u003c/repositories\u003e\n    \n    \u003cdependencies\u003e\n        \u003c!-- Use this for any Spigot plugin --\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.expdev07\u003c/groupId\u003e\n            \u003cartifactId\u003ecommy-spigot\u003c/artifactId\u003e\n            \u003cversion\u003e1.4\u003c/version\u003e\n        \u003c/dependency\u003e\n        \u003c!-- Use this for any BungeeCord plugin --\u003e\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.expdev07\u003c/groupId\u003e\n            \u003cartifactId\u003ecommy-bungee\u003c/artifactId\u003e\n            \u003cversion\u003e1.4\u003c/version\u003e\n        \u003c/dependency\u003e\n    \u003c/dependencies\u003e\n\u003c/project\u003e\n````\n\nMaven repo can be found at [The Central Repository](https://search.maven.org/beta/search?q=g:com.github.expdev07). \n\n#### Shading\nThese dependencies are not packaged in Spigot or BungeeCord, so you have to manually shade them. It can be achieved by adding this to your pom.xml. Note that by default, gson will also be shaded. This is because it is not apparent in some Spigot versions, however, you can exclude gson from being shaded in by adding the configurations. [Here's how you use the Maven Shade Plugin](https://maven.apache.org/plugins/maven-shade-plugin/usage.html).\n\nIt is important that you have ``\u003cscope\u003eprovided\u003c/scope\u003e`` on the BungeeCord and Spigot dependency, otherwise they will also be shaded (which we do not want).\n\n#### Compile\nNow, to compile, just run ``mvn clean install``.\n\n## Examples\n\nYou will find some examples below on how to use **Commy** with Spigot and BungeeCord. \n\n_Please note that both commy-spigot and commy-bungee uses the same base-interface, which means that setting it up will be the same, just different implementations (e.g BungeeCommy instead of SpigotCommy)._\n\n### Bukkit/Spigot\n\nSetting up _Commy_ and assigning a default handler, a handler for intercepting a string message, and a handler for receiving a custom object. The default handler will be used when a message does not find its pipe. You can set it as null (not set it).\n```java\n/**\n * A simple Spigot plugin demonstrating the use of Commy\n */\npublic class SpigotPlugin extends JavaPlugin {\n\n    // Universal logger\n    static Logger logger;\n\n    // Pre-\"defining\" a commy at class-level\n    private SpigotCommy commy;\n\n    @Override\n    public void onEnable() {\n        logger = Bukkit.getLogger();\n\n        // Initialize commy, calling setup will start the engines\n        this.commy = new SpigotCommy(this);\n\n        // Adding handlers, you can add as many as you want\n        // The first parameter here is the \"pipe\" the handler will handle messages for\n        commy.addHandler(\"test\", new TestHandler());\n        commy.addHandler(\"test_msg\", new AbstractTestHandler());\n    }\n\n    /**\n     * A method demonstrating some usage\n     */\n    private void sendMessage() {\n        // Get a connection with a player\n        Connection\u003cPlayer\u003e connection = commy.getConnection(Bukkit.getPlayer(\"ExpDev\"));\n\n        // Now, there are many ways you can send a message\n        //   * You can just send a simple string\n        connection.sendMessage(\"test\", \"This is a message\");\n        //   * You can send a custom object!\n        connection.sendMessage(\"test\", new Object());\n        //   * You can send bytes like you normally would\n        //     Use our helper class \"BytesOutput\" to quickly write to an array\n        byte[] bytes = new BytesOutput()\n                .write(\"a string\", \"another string\")\n                .getBytes();\n        connection.sendMessage(\"test_proxy\", bytes);\n\n        // You can also \"quick send\" a message\n        commy.sendMessage(\"test_proxy\", \"Message to send\");\n    }\n\n    /**\n     * Handles a test message. The parameter of MessageHandler is the type\n     * of source we will communicate with, which for Spigot's case is\n     * always Player\n     */\n    private static class TestHandler extends StringMessageHandler\u003cPlayer\u003e {\n\n        @Override\n        public void handle(Connection\u003cPlayer\u003e conn, String tag, String message) {\n            // We know tag == test, otherwise it would have been intercepted through the default handler\n            logger.log(Level.INFO, \"Received a message through test from \" + conn.getSender().getName() + \": \" + message);\n\n            // Respond! Here, the source we're communicating with will need to have a handler for the \"test\"\n            // pipe, otherwise it will be rerouted to their default handler\n            conn.sendMessage(\"test\", \"I heard your test message and is sending this back through the \\\"test\\\" pipe\");\n        }\n    }\n\n    /**\n     * A simple handler to test out how to use the abstract handler to\n     * send objects over the pipes\n     */\n    private static class AbstractTestHandler implements AbstractMessageHandler\u003cPlayer, TestObject\u003e {\n\n        @Override\n        public void handle(Connection\u003cPlayer\u003e conn, String tag, TestObject message) {\n            // We received a \"TestObject\" object, manipulate it as you want\n            logger.log(Level.INFO, String.format(\n                    \"Received a %s through %s from %s\", message.getClass().getSimpleName(), tag, conn.getSender().getName())\n            );\n        }\n\n        @Override\n        public Class\u003cTestObject\u003e getMessageType() {\n            // This is important as generics is not available in run-time,\n            // which means this will have to manually be specified\n            return TestObject.class;\n        }\n\n    }\n\n}\n```\n\n### BungeeCord\n\nSetting up _Commy_ in a BungeeCord plugin, then sending a custom object/message once a test message is received.\n````java\n/**\n * A simple Bungee plugin demonstrating the use of Commy\n */\npublic class BungeePlugin extends Plugin {\n\n    // Universal logger\n    private static Logger logger;\n\n    // Pre-\"defining\" a commy at class-level\n    private BungeeCommy commy;\n\n    @Override\n    public void onEnable() {\n        logger = ProxyServer.getInstance().getLogger();\n\n        // Initialize commy, calling setup will\n        // start the engines\n        this.commy = new BungeeCommy(this);\n\n        // Adding handlers, you can add as many as you want\n        commy.addHandler(\"test\", new TestHandler());\n    }\n\n    /**\n     * Handles a test message\n     */\n    private static class TestHandler implements MessageHandler\u003cServerInfo\u003e {\n\n        @Override\n        public void handle(Connection\u003cServerInfo\u003e conn, String tag, byte[] message) {\n            // We know tag == test, otherwise it would have been intercepted through the default handler\n            logger.log(Level.INFO, (\"Received a message through test from \" + conn.getSender().getName() + \": \" + new String(message)));\n\n            // Or... if you sent bytes, you can manipulate it like you normally would\n            ByteArrayDataInput in = ByteStreams.newDataInput(message);\n            logger.log(Level.INFO, in.readUTF());\n            logger.log(Level.INFO, in.readUTF());\n\n            // Let's respond by sending them a TestObject\n            conn.sendMessage(\"test_msg\", new TestObject(\"ExpDev\", 2));\n        }\n    }\n\n}\n````\n\nFind more examples [for SpigotMC](spigot-plugin) and [for BungeeCord](bungee-plugin).\n\n## Deployment\n\nOnce you have shaded commy, all you have to do is put your plugin inside your _/plugins_ folder as regular.\n\n## Built With\n\n* [Gson](https://github.com/google/gson) - For deserialization/serialization of objects for sending over network.\n* [Maven](https://maven.apache.org/) - Dependency Management framework.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Authors\n\n* **Marius Richardsen** - *Initial work* - [ExpDev](https://github.com/ExpDev07)\n* **Tyler Grissom** - *Contributor* - [grisstyl](https://github.com/grisstyl)\n\nSee also the list of [contributors](https://github.com/ExpDev07/Commy/contributors) who participated in this project.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n\n## Acknowledgments\n\n* Dinnerbone for designing the Plugin Messaging Channels.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpdev07%2Fcommy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpdev07%2Fcommy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpdev07%2Fcommy/lists"}