Drain is a well-documented library for
Spigot and Bukkit plugins that helps you to develop your plugins faster and easier. It includes many functionalities to make your development life easier.
If one of your plugins needs Drain, just put the JAR into your plugins directory.
publicboolean onCommand
(CommandSender commandSender, Command command,
String s,
String[] strings
){ if(commandSender
instanceof Player
){ Player player
=(Player
) sender
; if(player.
hasPermission("command.heal")){ player.
setHealth(20); returntrue; }else{ player.
sendMessage("§cYou are not allowed to do this!"); returnfalse; } }else{ commandSender.
sendMessage("§cThis command is player-only!"); returnfalse; } } }
With Drain, you can focus on the essential part of your command and significantly shorten your code.
A /heal command with Drain:
Code (Java):
new DynamicCommandBuilder
("heal",
this) .
setPlayerOnly(true) .
setPermission("command.heal") .
setPermissionErrorMessage("§cYou are not allowed to do this!") .
setExecutor(data
->((Player
) data.
getSender()).
setHealth(20)) .
build();
Apart from that, Drain offers other features, like useful annotations and classes. Head over to our
wiki to learn more!
Feel free to test it out! The source code is available over on GitHub. If you need help, join our Discord server and create a ticket.