Fixes Presets & Copy Command

This commit is contained in:
OmniCypher 2016-02-08 17:08:58 -08:00
parent a3697e52f5
commit ea4beea1a2
4 changed files with 58 additions and 11 deletions

View file

@ -90,7 +90,8 @@ public class CopyCommand extends PKCommand {
HashMap<Integer, String> abilities = (HashMap<Integer, String>) orig.getAbilities().clone();
boolean boundAll = true;
for (int i = 1; i <= 9; i++) {
if (!target.canBend(CoreAbility.getAbility(abilities.get(i)))) {
CoreAbility coreAbil = CoreAbility.getAbility(abilities.get(i));
if (coreAbil != null && !target.canBind(coreAbil)) {
abilities.remove(i);
boundAll = false;
}

View file

@ -40,6 +40,12 @@ public class PresetCommand extends PKCommand {
}
Player player = (Player) sender;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
GeneralMethods.createBendingPlayer(((Player) player).getUniqueId(), player.getName());
bPlayer = BendingPlayer.getBendingPlayer(player);
}
//bending preset list
if (args.size() == 1) {
@ -86,6 +92,9 @@ public class PresetCommand extends PKCommand {
} else if (!Preset.externalPresetExists(name) && hasPermission(sender, "bind.external")) {
sender.sendMessage(ChatColor.RED + "No external preset with that name exists.");
return;
} else if (bPlayer.isPermaRemoved()) {
player.sendMessage(ChatColor.RED + "Your bending was permanently removed.");
return;
} else {
sender.sendMessage(ChatColor.RED + "You don't have a preset with that name.");
return;
@ -95,27 +104,66 @@ public class PresetCommand extends PKCommand {
if (!boundAll) {
sender.sendMessage(ChatColor.RED + "Some abilities were not bound because you cannot bend the required element.");
}
} else if (hasPermission(sender, "bind.external.other")) {
} else if (hasPermission(sender, "bind.external.assign") && Preset.externalPresetExists(name)) {
if (!Preset.externalPresetExists(name)) {
sender.sendMessage(ChatColor.RED + "No external preset with that name exists.");
return;
}
Player player2 = Bukkit.getPlayer(args.get(2));
if (player2 != null && player2.isOnline()) {
BendingPlayer bPlayer2 = BendingPlayer.getBendingPlayer(player2);
if (bPlayer2 == null) {
GeneralMethods.createBendingPlayer(((Player) player2).getUniqueId(), player2.getName());
bPlayer2 = BendingPlayer.getBendingPlayer(player2);
}
if (bPlayer2.isPermaRemoved()) {
player.sendMessage(ChatColor.RED + "Your bending was permanently removed.");
return;
}
boolean boundAll = Preset.bindExternalPreset(player2, name);
sender.sendMessage(ChatColor.GREEN + "The bound slots of " + ChatColor.YELLOW + player2.getName() + ChatColor.GREEN + " have been set to match the " + ChatColor.YELLOW + name + ChatColor.GREEN + " preset.");
player2.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match the " + ChatColor.YELLOW + name + ChatColor.GREEN + " preset.");
if (!boundAll) {
player2.sendMessage(ChatColor.RED + "Some abilities were not bound, either the preset");
player2.sendMessage(ChatColor.RED + "Some abilities were not bound, either the preset contains invalid abilities or you cannot bend the required elements.");
}
return;
} else {
sender.sendMessage(ChatColor.RED + "Player not found.");
}
} else if (hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) {
if (!Preset.presetExists(player, name)) {
sender.sendMessage(ChatColor.RED + "You don't have a preset with that name.");
return;
}
Player player2 = Bukkit.getPlayer(args.get(2));
if (player2 != null && player2.isOnline()) {
BendingPlayer bPlayer2 = BendingPlayer.getBendingPlayer(player2);
if (bPlayer2 == null) {
GeneralMethods.createBendingPlayer(((Player) player2).getUniqueId(), player2.getName());
bPlayer2 = BendingPlayer.getBendingPlayer(player2);
}
if (bPlayer2.isPermaRemoved()) {
player.sendMessage(ChatColor.RED + "Your bending was permanently removed.");
return;
}
Preset preset = Preset.getPreset(player, name);
boolean boundAll = Preset.bindPreset(player2, preset);
sender.sendMessage(ChatColor.GREEN + "The bound slots of " + ChatColor.YELLOW + player2.getName() + ChatColor.GREEN + " have been set to match your " + ChatColor.YELLOW + name + ChatColor.GREEN + " preset.");
player2.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match " + ChatColor.YELLOW + player.getName() + "'s " + name + ChatColor.GREEN + " preset.");
if (!boundAll) {
player2.sendMessage(ChatColor.RED + "Some abilities were not bound, either the preset contains invalid abilities or you cannot bend the required elements.");
}
return;
} else {
sender.sendMessage(ChatColor.RED + "Player not found.");
}
}
return;
} else if (Arrays.asList(createaliases).contains(args.get(0)) && hasPermission(sender, "create")) { //bending preset create name
int limit = GeneralMethods.getMaxPresets(player);
@ -127,11 +175,11 @@ public class PresetCommand extends PKCommand {
return;
}
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
return;
}
HashMap<Integer, String> abilities = (HashMap<Integer, String>) bPlayer.getAbilities().clone();
Preset preset = new Preset(player.getUniqueId(), name, abilities);
preset.save(player);
sender.sendMessage(ChatColor.GREEN + "Created preset with the name: " + ChatColor.YELLOW + name);
@ -139,5 +187,4 @@ public class PresetCommand extends PKCommand {
help(sender, false);
}
}
}
}

View file

@ -133,8 +133,6 @@ public class Preset {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
return false;
} else if (!presets.containsKey(player.getUniqueId())) {
return false;
}
@SuppressWarnings("unchecked")

View file

@ -33,6 +33,7 @@ permissions:
bending.command.give: true
bending.command.invincible: true
bending.command.check: true
bending.command.preset.bind.assign: true
bending.command.preset.bind.external: true
bending.command.preset.bind.external.other: true
bending.command.copy.assign: true