9
0
mirror of https://gitlab.com/SamB440/rpgregions-2.git synced 2026-01-06 15:41:35 +00:00

Add setting to icon commands to run via console

This commit is contained in:
SamB440
2023-12-11 15:41:51 +00:00
parent a44af7e32c
commit e4c0cccdd6
3 changed files with 9 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
package net.islandearth.rpgregions.command;
public record IconCommand(String command, CommandClickType clickType, int cooldown) {
public record IconCommand(String command, CommandClickType clickType, boolean console, int cooldown) {
public enum CommandClickType {
DISCOVERED,

View File

@@ -302,9 +302,13 @@ public class DiscoveryGUI extends RPGRegionsGUI {
return;
}
player.performCommand(iconCommand.command()
.replace("%region%", configuredRegion.getId())
.replace("%player%", player.getName()));
final String command = iconCommand.command().replace("%region%", configuredRegion.getId())
.replace("%player%", player.getName());
if (iconCommand.console()) {
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
} else {
player.performCommand(command);
}
if (iconCommand.cooldown() != 0) {
account.getCooldowns().add(RPGRegionsAccount.AccountCooldown.ICON_COMMAND);

View File

@@ -123,7 +123,7 @@ public class RPGRegionsManagers implements IRPGRegionsManagers {
Collections.singletonList(new ItemStackBuilder(Material.IRON_CHESTPLATE).build())));
final ConfiguredRegion configuredRegion = createExampleRegion(rewards, effects);
configuredRegion.getIconCommand().add(new IconCommand("say", IconCommand.CommandClickType.DISCOVERED, 0));
configuredRegion.getIconCommand().add(new IconCommand("say", IconCommand.CommandClickType.DISCOVERED, false, 0));
configuredRegion.save(plugin);
Stream<Path> files = Files.walk(Paths.get(folder.getPath()));