Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

README

        

# This project is still wip!

FHandler

project-image


FHandler is a simple annotation based command handler for Minecraft plugins. The library has support for bungeecord and spigot.

shields shields

πŸ’» 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