Skip to content

Commit

Permalink
Add args check and add README
Browse files Browse the repository at this point in the history
Close #1
  • Loading branch information
SrBedrock committed Jun 4, 2023
1 parent 8637137 commit 994da82
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 4 deletions.
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# PluginsControl
# PluginsControl

## Description

This plugin allows you to control which plugins have to be enabled for the server continues running.

## Installation

1. Download the plugin from [here](<toggle|on|off|list>
2. Put the plugin in the `plugins` folder of your server.
3. Restart the server.
4. Add plugins to the list with `/pluginscontrol add <plugin>`.
5. Enable the plugin with `/pluginscontrol enable`.

## Configuration

| Option | Description |
|-----------|-------------------------------------------------------|
| `enabled` | Whether the plugin is enabled or not. |
| `plugins` | List of plugins to be enabled when the server starts. |

## Commands

| Command | Sub Command | Description |
|--------------------------------|-------------------|----------------------------------|
| `/pluginscontrol \| plcontrol` | `add <plugin>` | Add a plugin to the list. |
| `/pluginscontrol \| plcontrol` | `remove <plugin>` | Remove a plugin from the list. |
| `/pluginscontrol \| plcontrol` | `enable \| on` | Enable PluginControl. |
| `/pluginscontrol \| plcontrol` | `disable \| off` | Disable PluginControl. |
| `/pluginscontrol \| plcontrol` | `toggle` | Enable or disable PluginControl. |
| `/pluginscontrol \| plcontrol` | `list` | List all plugins in the list. |

## Permissions

| Permissions | Description |
|----------------------|------------------------------------|
| `pluginscontrol.use` | Permission to use all [[commands]] |
16 changes: 14 additions & 2 deletions src/main/java/com/armamc/plugincontrol/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotN
}
case "disable", "off" -> {
Config.setEnabled(false);
sender.sendMessage(Component.text("[PluginControl] Desativado funcionalidades do plugin...")
sender.sendMessage(Component.text("[PluginControl] Desativando funcionalidades do plugin...")
.color(NamedTextColor.GREEN));
return true;
}
Expand All @@ -43,12 +43,16 @@ public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotN
sender.sendMessage(Component.text("[PluginControl] Ativando funcionalidades do plugin...")
.color(NamedTextColor.GREEN));
} else {
sender.sendMessage(Component.text("[PluginControl] Desativado funcionalidades do plugin...")
sender.sendMessage(Component.text("[PluginControl] Desativando funcionalidades do plugin...")
.color(NamedTextColor.GREEN));
}
return true;
}
case "add" -> {
if (args.length < 2 || args[1].isBlank() || args.length >= 3) {
sender.sendMessage(Component.text("[PluginControl] Use /plugincontrol add <plugin-name>").color(NamedTextColor.RED));
return true;
}
if (Config.addPlugin(args[1])) {
sender.sendMessage(Component.text(MessageFormat.format("[PluginControl] Plugin {0} adicionado!", args[1]))
.color(NamedTextColor.GREEN));
Expand All @@ -59,6 +63,14 @@ public boolean onCommand(@NotNull CommandSender sender, org.bukkit.command.@NotN
return true;
}
case "remove" -> {
if (Config.getPluginList().isEmpty()) {
sender.sendMessage(Component.text("[PluginControl] Nenhum plugin adicionado!").color(NamedTextColor.RED));
return true;
}
if (args.length < 2 || args[1].isBlank() || args.length >= 3) {
sender.sendMessage(Component.text("[PluginControl] Use /plugincontrol remove <plugin-name>").color(NamedTextColor.RED));
return true;
}
if (Config.removePlugin(args[1])) {
sender.sendMessage(Component.text("[PluginControl] Plugin " + args[1] + " removido!").color(NamedTextColor.GREEN));
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ website: https://armnamc.com
commands:
plugincontrol:
description: "Command to manage PluginControl"
usage: "/<command> <add|remove|toggle|on|off|list>"
usage: "/<command> <add|remove [plugin-name]> | <toggle|on|off|list>"
aliases: [pc, plcontrol]
permission: plugincontrol.use
permission-message: "You do not have permission to use this command"

0 comments on commit 994da82

Please sign in to comment.