Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fedox-die-ente/fhandler
FHandler is a simple annotation based command handler for Minecraft plugins. The library has support for bungeecord and spigot.
https://github.com/fedox-die-ente/fhandler
bungeecord cmdhandler commandhandler minecraft minecraft-handler plugin spigot
Last synced: 3 months ago
JSON representation
FHandler is a simple annotation based command handler for Minecraft plugins. The library has support for bungeecord and spigot.
- Host: GitHub
- URL: https://github.com/fedox-die-ente/fhandler
- Owner: Fedox-die-Ente
- License: agpl-3.0
- Created: 2024-06-28T19:55:51.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-07-26T00:35:21.000Z (6 months ago)
- Last Synced: 2024-10-11T03:40:37.915Z (3 months ago)
- Topics: bungeecord, cmdhandler, commandhandler, minecraft, minecraft-handler, plugin, spigot
- Language: Java
- Homepage:
- Size: 87.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# This project is still wip!
FHandler
FHandler is a simple annotation based command handler for Minecraft plugins. The library has support for bungeecord and spigot.
π» Built with
Technologies used in the project:
* [Java](https://www.java.com/de/)
* [Spigot](https://www.spigotmc.org/wiki/spigot-installation/)
* [BungeeCord](https://github.com/SpigotMC/BungeeCord)π§βπ» Examples
1. Create a instance of the FHandler
```java
@Override
public void onEnable() {
FConfiguration config = null;
try {
config = FHandler.getFConfiguration()
.setInstance(this)
.setScope(FScope.SPIGOT)
.build();
} catch (FHandlerException e) {
e.printStackTrace();
}
}
```2. Register commands via the instance
```java
@Override
public void onEnable() {
FConfiguration config = null;
try {
config = FHandler.getFConfiguration()
.setInstance(this)
.setScope(FScope.SPIGOT)
.build();
} catch (FHandlerException e) {
e.printStackTrace();
}if (config != null) {
CommandRegistrar commandRegistrar = config.getCommandRegistrar();
commandRegistrar.getSpigotRegistrar().register(TestCommand.class);
}
}
```3. Create a command:
```java
public class MSGCommand {@Command("msg")
public void msg(@Sender CommandSender sender, @Name("player") String player, @Name("message") String message) {
Player t = Bukkit.getPlayer(player);
Player p = (Player) sender;if (t == null) {
sender.sendMessage("Player not found!");
return;
}t.sendMessage(message);
sender.sendMessage("Message sent to " + player + "!");t.setMetadata("replyTo", new FixedMetadataValue(TestPlugin.getInstance(), p.getName()));
p.setMetadata("replyTo", new FixedMetadataValue(TestPlugin.getInstance(), t.getName()));
}@Command("r")
public void r(@Sender CommandSender sender, @Name("message") String message) {
Player p = (Player) sender;
MetadataValue replyTo = p.getMetadata("replyTo").getFirst();
Player t = Bukkit.getPlayer(replyTo.asString());if (t == null) {
sender.sendMessage("Player not found!");
return;
}t.sendMessage(message);
sender.sendMessage("Message sent to " + t.getName() + "!");
}}
```π€΅ Credits
- [Fedox-die-Ente](https://github.com/Fedox-die-Ente) - Creator of the project
- [Austria7](https://github.com/Austria7) - Contributor and helper of the projectπ‘οΈ License:
This project is licensed under the [AGPL-3.0](LICENSE)
πLike my work?
Leave a β on this repository :D