mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-01 22:14:45 +00:00
Contract Command
This commit is contained in:
1 parent
97c23b5dcc
commit
d188e2ceed
2 files changed
+71
-3
No files matched your search
@@ -30,17 +30,72 @@ public class ContractCommand implements CommandExecutor {
|
||||
UUID pID = p.getUniqueId();
|
||||
Map pData = (Map) Main.rolesData.getData(pID);
|
||||
|
||||
p.sendMessage(ChatColor.YELLOW + "Contract Command" );
|
||||
|
||||
if(!p.hasPermission("AlathraWar.UseRoles")) {
|
||||
p.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return false;
|
||||
}
|
||||
if(args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||
p.sendMessage(ChatColor.RED + "! "+ ChatColor.RESET + ChatColor.GOLD + "---- Contracts Help ----");
|
||||
p.sendMessage(ChatColor.RED + "! " + ChatColor.GREEN + "/contract list");
|
||||
if (p.hasPermission("AlathraWar.Admin")) {
|
||||
p.sendMessage(ChatColor.RED + "! " + ChatColor.GREEN + "/contract list <player>");
|
||||
}
|
||||
else {
|
||||
p.sendMessage(ChatColor.RED + "! " + ChatColor.GREEN + "/contract list");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(args[0].equalsIgnoreCase("list")) {
|
||||
UUID targetID;
|
||||
if(p.hasPermission("AlathraWar.Admin") && args.length > 1) {
|
||||
Player target = Bukkit.getPlayer(args[1]);
|
||||
String msgName;
|
||||
if(target != null) {
|
||||
targetID = target.getUniqueId();
|
||||
msgName = target.getDisplayName();
|
||||
}
|
||||
else {
|
||||
targetID = UUIDFetcher.getUUID(args[1]);
|
||||
if(targetID == null) {
|
||||
p.sendMessage(ChatColor.RED + "Please enter a valid player.");
|
||||
return false;
|
||||
}
|
||||
msgName = args[1];
|
||||
}
|
||||
}
|
||||
else {
|
||||
targetID = pID;
|
||||
}
|
||||
|
||||
if(targetID == null) {
|
||||
p.sendMessage("ERROR");
|
||||
return false;
|
||||
}
|
||||
Map tData = (Map) Main.rolesData.getData(targetID);
|
||||
Map<String, Object> tContracts = (Map<String, Object>) tData.get("Contracts");
|
||||
|
||||
if(tContracts.size() < 1) {
|
||||
if(pID == targetID) {
|
||||
p.sendMessage(ChatColor.GREEN + "You have " + ChatColor.GOLD + "0" + ChatColor.GREEN + " current contracts.");
|
||||
} else {
|
||||
p.sendMessage(ChatColor.GREEN + "They have " + ChatColor.GOLD + "0" + ChatColor.GREEN + " current contracts.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
p.sendMessage(ChatColor.GOLD + "Current Contracts:");
|
||||
for (String key : tContracts.keySet()) {
|
||||
Map<String,Object> Contract = (Map<String, Object>) tContracts.get(key);
|
||||
String ContractName = Bukkit.getOfflinePlayer(UUID.fromString(key)).getName();
|
||||
String ContractType = (String) Contract.get("Type");
|
||||
if(ContractType.equalsIgnoreCase("Assassin")) {
|
||||
p.sendMessage(ChatColor.GREEN + "- " + ContractName + " for " + ChatColor.DARK_PURPLE + Main.econ.format((double) Contract.get("Value")));
|
||||
}
|
||||
else if(ContractType.equalsIgnoreCase("Merc")) {
|
||||
p.sendMessage(ChatColor.GREEN + "- " + ContractName + " for " + ChatColor.DARK_AQUA + Main.econ.format((double) Contract.get("Value")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
p.sendMessage(ChatColor.RED + "Unknown sub-command. Do " + ChatColor.YELLOW + "/contract help" + ChatColor.RED + " for more info.");
|
||||
}
|
||||
|
||||
+13
@@ -101,6 +101,19 @@ public class CustomRoleTabCompletion implements TabCompleter {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (cmdName.equalsIgnoreCase("contract")) {
|
||||
if(args.length == 1) {
|
||||
completions.add("list");
|
||||
return completions;
|
||||
}
|
||||
else if(args.length == 2) {
|
||||
if(player.hasPermission("AlathraExtras.Admin")) {
|
||||
return null;
|
||||
} else {
|
||||
return completions;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user