Fixed console commands in config slots

This commit is contained in:
often
2024-01-22 16:55:57 +03:00
parent 74a8dcea90
commit b6b4d7e2f8

View File

@@ -86,7 +86,7 @@ public class ConfigSlot extends CustomSlot {
for (String command : config.getStrings(configKey)) {
if (command.startsWith("console:")) {
commands.add(new CommandToDispatch(
StringUtils.removePrefix("console:", command),
StringUtils.removePrefix(command, "console:"),
true
));
} else {
@@ -127,12 +127,16 @@ public class ConfigSlot extends CustomSlot {
* @param player The player.
*/
void dispatch(@NotNull final Player player) {
System.out.println("DISPATCHING " + command);
if (console()) {
System.out.println("CONSOLE");
Bukkit.dispatchCommand(
Bukkit.getConsoleSender(),
command().replace("%player%", player.getName())
);
} else {
System.out.println("NON-CONSOLE");
Bukkit.dispatchCommand(
player,
command().replace("%player%", player.getName())