forked from NLthijs48/AreaShop
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
AreaShop/src/main/java/me/wiefferink/areashop/commands/SetTransferCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String> getTabCompleteList(int toComplete, String[] start, CommandSender sender) { | ||
List<String> result = new ArrayList<>(); | ||
if (toComplete == 2) { | ||
result = fileManager.getRegionNames(); | ||
} else if (toComplete == 3) { | ||
result.add("true"); | ||
result.add("false"); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters