mirror of
https://github.com/YouHaveTrouble/PreventStabby.git
synced 2026-05-12 05:16:55 +00:00
command without arguments now acts as toggle subcommand
This commit is contained in:
@@ -134,25 +134,25 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<version>4.12.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.1.1</version>
|
||||
<version>4.2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<version>4.12.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.youhavetrouble.preventstabby.commands;
|
||||
import me.youhavetrouble.preventstabby.PreventStabby;
|
||||
import me.youhavetrouble.preventstabby.config.PreventStabbyPermission;
|
||||
import me.youhavetrouble.preventstabby.util.PluginMessages;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -23,7 +22,7 @@ public class HelpCommand {
|
||||
.append(Component.newline())
|
||||
.append(PluginMessages.MINIMESSAGE.deserialize("<blue>/pvp <aqua><bold>toggle</bold> <white>- toggles PvP status"));
|
||||
}
|
||||
PreventStabby.getAudiences().sender(sender).sendMessage(helpComponent, MessageType.SYSTEM);
|
||||
PreventStabby.getAudiences().sender(sender).sendMessage(helpComponent);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class MainCommand implements TabExecutor {
|
||||
private final HashMap<String, PreventStabbyPermission> subCommands = new HashMap<>();
|
||||
|
||||
public MainCommand() {
|
||||
subCommands.put("help", PreventStabbyPermission.COMMAND);
|
||||
subCommands.put("help", PreventStabbyPermission.COMMAND_HELP);
|
||||
subCommands.put("toggle", PreventStabbyPermission.COMMAND_TOGGLE);
|
||||
subCommands.put("on", PreventStabbyPermission.COMMAND_TOGGLE);
|
||||
subCommands.put("enable", PreventStabbyPermission.COMMAND_TOGGLE);
|
||||
@@ -36,7 +36,11 @@ public class MainCommand implements TabExecutor {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_permission());
|
||||
return true;
|
||||
}
|
||||
if (args.length >= 1) {
|
||||
if (args.length == 0) {
|
||||
PvpToggleCommand.toggle(sender, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "help":
|
||||
HelpCommand.help(sender, args);
|
||||
@@ -62,9 +66,6 @@ public class MainCommand implements TabExecutor {
|
||||
PluginMessages.sendMessage(sender, PreventStabby.getPlugin().getConfigCache().getNo_such_command());
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
HelpCommand.help(sender, args);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class PvpToggleCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
if (args.length <= 1) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (CombatTimer.isInCombat(player.getUniqueId())) {
|
||||
@@ -60,12 +60,6 @@ public class PvpToggleCommand {
|
||||
message = PreventStabby.getPlugin().getConfigCache().getPvp_disabled_other();
|
||||
}
|
||||
PluginMessages.sendMessage(sender, PluginMessages.parsePlayerName(player, message));
|
||||
} else {
|
||||
if (PreventStabbyPermission.COMMAND_TOGGLE_OTHERS.doesCommandSenderHave(sender)) {
|
||||
PluginMessages.sendMessage(sender, "Try /pvp toggle <player>");
|
||||
} else {
|
||||
PluginMessages.sendMessage(sender, "Try /pvp toggle");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,7 +8,9 @@ public enum PreventStabbyPermission {
|
||||
COMMAND_TOGGLE("command.toggle"),
|
||||
COMMAND_TOGGLE_OTHERS("command.toggle.others"),
|
||||
COMMAND_RELOAD("command.reload"),
|
||||
COMMAND_GLOBAL_TOGGLE("command.toggle.global");
|
||||
COMMAND_GLOBAL_TOGGLE("command.toggle.global"),
|
||||
|
||||
COMMAND_HELP("command.help");
|
||||
|
||||
private final String permission;
|
||||
PreventStabbyPermission(String permission) {
|
||||
|
||||
@@ -25,12 +25,20 @@ permissions:
|
||||
preventstabby.command.toggle:
|
||||
default: true
|
||||
description: Allows usage of /pvp <toggle/enable/disable> command
|
||||
children:
|
||||
preventstabby.command: true
|
||||
preventstabby.command.toggle.others:
|
||||
default: op
|
||||
description: Allows usage of /pvp <toggle/enable/disable> <player> command
|
||||
children:
|
||||
preventstabby.command: true
|
||||
preventstabby.command.toggle.global:
|
||||
default: op
|
||||
description: Allows usage of /pvp override <enabled/disabled/none> command
|
||||
children:
|
||||
preventstabby.command: true
|
||||
preventstabby.command.reload:
|
||||
default: op
|
||||
description: Allows usage of /pvp reload command
|
||||
children:
|
||||
preventstabby.command: true
|
||||
Reference in New Issue
Block a user