diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/commands/SetTransferCommand.java b/AreaShop/src/main/java/me/wiefferink/areashop/commands/SetTransferCommand.java new file mode 100644 index 00000000..a1241e5f --- /dev/null +++ b/AreaShop/src/main/java/me/wiefferink/areashop/commands/SetTransferCommand.java @@ -0,0 +1,77 @@ +package me.wiefferink.areashop.commands; + +import jakarta.inject.Inject; +import jakarta.inject.Singleton; +import me.wiefferink.areashop.MessageBridge; +import me.wiefferink.areashop.managers.IFileManager; +import me.wiefferink.areashop.regions.GeneralRegion; +import org.bukkit.command.CommandSender; +import org.bukkit.plugin.Plugin; + +import java.util.ArrayList; +import java.util.List; + +@Singleton +public class SetTransferCommand extends CommandAreaShop { + + @Inject + private MessageBridge messageBridge; + @Inject + private IFileManager fileManager; + @Inject + private Plugin plugin; + + @Override + public String getCommandStart() { + return "areashop settransfer"; + } + + @Override + public String getHelp(CommandSender target) { + if (target.hasPermission("areashop.settransfer")) { + return "help-settransfer"; + } + return null; + } + + @Override + public void execute(CommandSender sender, String[] args) { + if (!sender.hasPermission("areashop.settransfer")) { + messageBridge.message(sender, "settransfer-noPermission"); + return; + } + if (args.length <= 2 || args[1] == null || args[2] == null) { + messageBridge.message(sender, "settransfer-help"); + return; + } + GeneralRegion region = fileManager.getRegion(args[1]); + if (region == null) { + messageBridge.message(sender, "settransfer-notRegistered", args[1]); + return; + } + boolean value; + if (args[2].equalsIgnoreCase("true")) { + value = true; + } else if (args[2].equalsIgnoreCase("false")) { + value = false; + } else { + messageBridge.message(sender, "settransfer-invalidSetting", args[2]); + return; + } + region.setTransferEnabled(value); + messageBridge.message(sender, "settransfer-success", args[2], region); + region.update(); + } + + @Override + public List getTabCompleteList(int toComplete, String[] start, CommandSender sender) { + List result = new ArrayList<>(); + if (toComplete == 2) { + result = fileManager.getRegionNames(); + } else if (toComplete == 3) { + result.add("true"); + result.add("false"); + } + return result; + } +} diff --git a/AreaShop/src/main/java/me/wiefferink/areashop/managers/CommandManager.java b/AreaShop/src/main/java/me/wiefferink/areashop/managers/CommandManager.java index 0f21d243..6d466656 100644 --- a/AreaShop/src/main/java/me/wiefferink/areashop/managers/CommandManager.java +++ b/AreaShop/src/main/java/me/wiefferink/areashop/managers/CommandManager.java @@ -29,6 +29,7 @@ import me.wiefferink.areashop.commands.ResellCommand; import me.wiefferink.areashop.commands.SchematiceventCommand; import me.wiefferink.areashop.commands.SellCommand; +import me.wiefferink.areashop.commands.SetTransferCommand; import me.wiefferink.areashop.commands.SetdurationCommand; import me.wiefferink.areashop.commands.SetlandlordCommand; import me.wiefferink.areashop.commands.SetownerCommand; @@ -85,6 +86,7 @@ public class CommandManager extends Manager implements CommandExecutor, TabCompl commands.add(injector.getInstance(SetpriceCommand.class)); commands.add(injector.getInstance(SetownerCommand.class)); commands.add(injector.getInstance(SetdurationCommand.class)); + commands.add(injector.getInstance(SetTransferCommand.class)); commands.add(injector.getInstance(ReloadCommand.class)); commands.add(injector.getInstance(GroupaddCommand.class)); commands.add(injector.getInstance(GroupdelCommand.class)); diff --git a/AreaShop/src/main/resources/lang/EN.yml b/AreaShop/src/main/resources/lang/EN.yml index 70b8b207..728264ca 100644 --- a/AreaShop/src/main/resources/lang/EN.yml +++ b/AreaShop/src/main/resources/lang/EN.yml @@ -80,6 +80,7 @@ help-reload: "%lang:helpCommand|/as reload|% Reload all files and update the reg help-setrestore: "%lang:helpCommand|/as setrestore|% Set restoring on/off and choose profile." help-setprice: "%lang:helpCommand|/as setprice|% Change the price of a region." help-setduration: "%lang:helpCommand|/as setduration|% Change the duration of a rent region." +help-settransfer: "%lang:helpCommand|/as settransfer|% Set transfer on/off." help-teleport: "%lang:helpCommand|/as tp|% Teleport to a rent/buy region." help-setteleport: "%lang:helpCommand|/as settp|% Set teleport position for a region." help-find: "%lang:helpCommand|/as find|% Find an empty buy or rent." @@ -313,6 +314,12 @@ setrestore-invalidSetting: "'%0%' is not a valid state, should be true, false or setrestore-success: "Successfully set the restore setting of %lang:region% to '%0%'." setrestore-successProfile: "Successfully set the restore setting of %lang:region% to '%0%' and the profile to '%1%'." +settransfer-help: "/as settransfer ." +settransfer-noPermission: "You don't have permission to change the transfer settings." +settransfer-notRegistered: "The specified region is not registered: %0%." +settransfer-invalidSetting: "'%0%' is not a valid state, should be true, false or general." +settransfer-success: "Successfully set the transfer setting of %lang:region% to '%0%'." + setprice-noPermission: "You don't have permission to change the price of a region." setprice-help: "/as setprice [region], the region you stand in will be used if not specified." setprice-notRegistered: "The specified region is not registered: %0%."