mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Fixed & cleaned RemoveCommand
This commit is contained in:
parent
fe675fbfd9
commit
5797d7dc25
1 changed files with 61 additions and 38 deletions
|
@ -22,18 +22,24 @@ import java.util.List;
|
||||||
* Executor for /bending remove. Extends {@link PKCommand}.
|
* Executor for /bending remove. Extends {@link PKCommand}.
|
||||||
*/
|
*/
|
||||||
public class RemoveCommand extends PKCommand {
|
public class RemoveCommand extends PKCommand {
|
||||||
|
|
||||||
private String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline, wrongElementTarget,
|
private String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline, wrongElementTarget,
|
||||||
succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget, succesfullyRemovedAllElementsTargetConfirm;
|
succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget,
|
||||||
|
succesfullyRemovedAllElementsTargetConfirm;
|
||||||
|
|
||||||
public RemoveCommand() {
|
public RemoveCommand() {
|
||||||
super("remove", "/bending remove <Player> [Element]", ConfigManager.languageConfig.get().getString("Commands.Remove.Description"), new String[] { "remove", "rm" });
|
super("remove", "/bending remove <Player> [Element]",
|
||||||
|
ConfigManager.languageConfig.get().getString("Commands.Remove.Description"), new String[] { "remove", "rm" });
|
||||||
|
|
||||||
this.succesfullyRemovedElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.RemovedElement");
|
this.succesfullyRemovedElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.RemovedElement");
|
||||||
this.succesfullyRemovedAllElementsTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedAllElements");
|
this.succesfullyRemovedAllElementsTarget = ConfigManager.languageConfig.get()
|
||||||
this.succesfullyRemovedAllElementsTargetConfirm = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedAllElementsConfirm");
|
.getString("Commands.Remove.Other.RemovedAllElements");
|
||||||
this.succesfullyRemovedElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedElement");
|
this.succesfullyRemovedAllElementsTargetConfirm = ConfigManager.languageConfig.get()
|
||||||
this.succesfullyRemovedElementTargetConfirm = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedElementConfirm");
|
.getString("Commands.Remove.Other.RemovedAllElementsConfirm");
|
||||||
|
this.succesfullyRemovedElementTarget = ConfigManager.languageConfig.get()
|
||||||
|
.getString("Commands.Remove.Other.RemovedElement");
|
||||||
|
this.succesfullyRemovedElementTargetConfirm = ConfigManager.languageConfig.get()
|
||||||
|
.getString("Commands.Remove.Other.RemovedElementConfirm");
|
||||||
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Remove.InvalidElement");
|
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Remove.InvalidElement");
|
||||||
this.wrongElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.WrongElement");
|
this.wrongElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.WrongElement");
|
||||||
this.wrongElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.WrongElement");
|
this.wrongElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.WrongElement");
|
||||||
|
@ -58,25 +64,34 @@ public class RemoveCommand extends PKCommand {
|
||||||
senderBPlayer.getSubElements().remove(e);
|
senderBPlayer.getSubElements().remove(e);
|
||||||
GeneralMethods.saveSubElements(senderBPlayer);
|
GeneralMethods.saveSubElements(senderBPlayer);
|
||||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||||
sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}" , e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
|
.replace("{element}", e.getName() + e.getType().getBending())
|
||||||
} else sender.sendMessage(ChatColor.RED + invalidElement);
|
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
||||||
|
Bukkit.getServer().getPluginManager()
|
||||||
|
.callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e,
|
||||||
|
com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
|
||||||
|
} else
|
||||||
|
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||||
return;
|
return;
|
||||||
}
|
} else if (e instanceof Element) {
|
||||||
if (senderBPlayer.hasElement(e)) {
|
if (senderBPlayer.hasElement(e)) {
|
||||||
senderBPlayer.getElements().remove(e);
|
senderBPlayer.getElements().remove(e);
|
||||||
GeneralMethods.saveElements(senderBPlayer);
|
GeneralMethods.saveElements(senderBPlayer);
|
||||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||||
|
|
||||||
sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName()));
|
sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName()));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
|
Bukkit.getServer().getPluginManager()
|
||||||
return;
|
.callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
|
||||||
} else {
|
return;
|
||||||
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
} else
|
||||||
return;
|
sender.sendMessage(ChatColor.RED + wrongElementSelf);
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,10 +118,14 @@ public class RemoveCommand extends PKCommand {
|
||||||
bPlayer.getElements().remove(e);
|
bPlayer.getElements().remove(e);
|
||||||
GeneralMethods.saveElements(bPlayer);
|
GeneralMethods.saveElements(bPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneralMethods.removeUnusableAbilities(player.getName());
|
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||||
player.sendMessage(e.getColor() + this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
|
player.sendMessage(e.getColor()
|
||||||
sender.sendMessage(e.getColor() + this.succesfullyRemovedElementTarget.replace("{element}" , e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
+ this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending())
|
||||||
|
.replace("{sender}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
|
||||||
|
sender.sendMessage(e.getColor()
|
||||||
|
+ this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending())
|
||||||
|
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -116,16 +135,19 @@ public class RemoveCommand extends PKCommand {
|
||||||
GeneralMethods.saveElements(bPlayer);
|
GeneralMethods.saveElements(bPlayer);
|
||||||
GeneralMethods.saveSubElements(bPlayer);
|
GeneralMethods.saveSubElements(bPlayer);
|
||||||
GeneralMethods.removeUnusableAbilities(player.getName());
|
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||||
if (GeneralMethods.hasRPG()) RPGMethods.revokeAvatar(bPlayer.getUUID());
|
if (GeneralMethods.hasRPG())
|
||||||
sender.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW));
|
RPGMethods.revokeAvatar(bPlayer.getUUID());
|
||||||
player.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
|
sender.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}",
|
||||||
|
ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW));
|
||||||
|
player.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}",
|
||||||
|
ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the CommandSender has the permission 'bending.admin.remove'. If
|
* Checks if the CommandSender has the permission 'bending.admin.remove'. If not, it tells them
|
||||||
* not, it tells them they don't have permission to use the command.
|
* they don't have permission to use the command.
|
||||||
*
|
*
|
||||||
* @return True if they have the permission, false otherwise
|
* @return True if they have the permission, false otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -137,10 +159,11 @@ public class RemoveCommand extends PKCommand {
|
||||||
sender.sendMessage(super.noPermissionMessage);
|
sender.sendMessage(super.noPermissionMessage);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
|
protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
|
||||||
if (args.size() >= 2 || !sender.hasPermission("bending.command.remove")) return new ArrayList<String>();
|
if (args.size() >= 2 || !sender.hasPermission("bending.command.remove"))
|
||||||
|
return new ArrayList<String>();
|
||||||
List<String> l = new ArrayList<String>();
|
List<String> l = new ArrayList<String>();
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
@ -155,7 +178,7 @@ public class RemoveCommand extends PKCommand {
|
||||||
for (Element e : Element.getAddonElements()) {
|
for (Element e : Element.getAddonElements()) {
|
||||||
l.add(e.getName());
|
l.add(e.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
l.add("Blood");
|
l.add("Blood");
|
||||||
l.add("Combustion");
|
l.add("Combustion");
|
||||||
l.add("Flight");
|
l.add("Flight");
|
||||||
|
@ -167,11 +190,11 @@ public class RemoveCommand extends PKCommand {
|
||||||
l.add("Plant");
|
l.add("Plant");
|
||||||
l.add("Sand");
|
l.add("Sand");
|
||||||
l.add("Spiritual");
|
l.add("Spiritual");
|
||||||
|
|
||||||
for (SubElement e : Element.getAddonSubElements()) {
|
for (SubElement e : Element.getAddonSubElements()) {
|
||||||
l.add(e.getName());
|
l.add(e.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue