New branding stuff (#726)

This commit is contained in:
Sobki 2017-02-11 15:02:40 +10:00 committed by Christopher Martin
parent b2fcfc493a
commit 29a6cb8d05
18 changed files with 153 additions and 150 deletions

View file

@ -128,6 +128,10 @@ import com.sk89q.worldguard.protection.flags.DefaultFlag;
import me.ryanhamshire.GriefPrevention.Claim; import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.GriefPrevention; import me.ryanhamshire.GriefPrevention.GriefPrevention;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag; import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones; import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
@ -190,7 +194,7 @@ public class GeneralMethods {
*/ */
public static void bindAbility(Player player, String ability, int slot) { public static void bindAbility(Player player, String ability, int slot) {
if (MultiAbilityManager.playerAbilities.containsKey(player)) { if (MultiAbilityManager.playerAbilities.containsKey(player)) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + "You can't edit your binds right now!"); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + "You can't edit your binds right now!");
return; return;
} }
@ -203,7 +207,7 @@ public class GeneralMethods {
bPlayer.getAbilities().put(slot, ability); bPlayer.getAbilities().put(slot, ability);
if (coreAbil != null) { if (coreAbil != null) {
player.sendMessage(ConfigManager.getBrandingPrefix() + coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot))); GeneralMethods.sendBrandingMessage(player, coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot)));
} }
saveAbility(bPlayer, slot, ability); saveAbility(bPlayer, slot, ability);
} }
@ -1929,6 +1933,21 @@ public class GeneralMethods {
return loc.getWorld().spawnFallingBlock(loc, type, data); return loc.getWorld().spawnFallingBlock(loc, type, data);
} }
public static void sendBrandingMessage(CommandSender sender, String message) {
ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
color = color == null ? ChatColor.GOLD : color;
String prefix = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Prefix")) + color + "ProjectKorra" + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Suffix"));
if (!(sender instanceof Player)) {
sender.sendMessage(prefix + message);
} else {
TextComponent prefixComponent = new TextComponent(prefix);
TextComponent messageComponent = new TextComponent(message);
prefixComponent.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://projectkorra.com/"));
prefixComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(color + "Bending brought to you by ProjectKorra!\n" + color + "Click for more info.").create()));
((Player) sender).spigot().sendMessage(new TextComponent(prefixComponent, messageComponent));
}
}
public static void startCacheCleaner(final double period) { public static void startCacheCleaner(final double period) {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override

View file

@ -1036,7 +1036,7 @@ public class PKListener implements Listener {
if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.JoinMessage.Enabled")) { if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.JoinMessage.Enabled")) {
Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() {
public void run() { public void run() {
ChatColor color = ConfigManager.BRANDING_OPTIONS.get(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase()); ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
color = color == null ? ChatColor.GOLD : color; color = color == null ? ChatColor.GOLD : color;
String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder"); String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder"); String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder");

View file

@ -96,7 +96,7 @@ public class ProjectKorra extends JavaPlugin {
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override @Override
public void run() { public void run() {
ChatColor color = ConfigManager.BRANDING_OPTIONS.get(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase()); ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
color = color == null ? ChatColor.GOLD : color; color = color == null ? ChatColor.GOLD : color;
String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder"); String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder"); String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.BottomBorder");

View file

@ -63,7 +63,7 @@ public class AddCommand extends PKCommand {
} }
Player player = Bukkit.getPlayer(args.get(1)); Player player = Bukkit.getPlayer(args.get(1));
if (player == null) { if (player == null) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playerNotFound); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playerNotFound);
return; return;
} }
add(sender, player, args.get(0).toLowerCase()); add(sender, player, args.get(0).toLowerCase());
@ -90,15 +90,15 @@ public class AddCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(target); bPlayer = BendingPlayer.getBendingPlayer(target);
} }
if (bPlayer.isPermaRemoved()) { if (bPlayer.isPermaRemoved()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved"));
return; return;
} }
if (Arrays.asList(Element.getAllElements()).contains(e)) { if (Arrays.asList(Element.getAllElements()).contains(e)) {
if (bPlayer.hasElement(e)) { if (bPlayer.hasElement(e)) {
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + alreadyHasElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + alreadyHasElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + alreadyHasElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + alreadyHasElement);
} }
return; return;
} }
@ -114,17 +114,17 @@ public class AddCommand extends PKCommand {
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (e != Element.AIR && e != Element.EARTH) { if (e != Element.AIR && e != Element.EARTH) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender()));
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedCFW.replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedCFW.replace("{element}", e.getName() + e.getType().getBender()));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender()));
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedAE.replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedAE.replace("{element}", e.getName() + e.getType().getBender()));
} }
} else { } else {
if (e != Element.AIR && e != Element.EARTH) if (e != Element.AIR && e != Element.EARTH)
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedCFW.replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedCFW.replace("{element}", e.getName() + e.getType().getBender()));
else else
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedAE.replace("{element}", e.getName() + e.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedAE.replace("{element}", e.getName() + e.getType().getBender()));
} }
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
@ -135,9 +135,9 @@ public class AddCommand extends PKCommand {
SubElement sub = (SubElement) e; SubElement sub = (SubElement) e;
if (bPlayer.hasSubElement(sub)) { if (bPlayer.hasSubElement(sub)) {
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + alreadyHasSubElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + alreadyHasSubElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + alreadyHasSubElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + alreadyHasSubElement);
} }
return; return;
} }
@ -146,15 +146,15 @@ public class AddCommand extends PKCommand {
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (e != Element.AIR && e != Element.EARTH) if (e != Element.AIR && e != Element.EARTH)
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
else else
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
} else { } else {
if (e != Element.AIR && e != Element.EARTH) if (e != Element.AIR && e != Element.EARTH)
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedCFW.replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedCFW.replace("{element}", sub.getName() + sub.getType().getBender()));
else else
target.sendMessage(ConfigManager.getBrandingPrefix() + color + addedAE.replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + addedAE.replace("{element}", sub.getName() + sub.getType().getBender()));
} }
GeneralMethods.saveSubElements(bPlayer); GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.ADD)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.ADD));

View file

@ -49,7 +49,7 @@ public class BindCommand extends PKCommand {
CoreAbility coreAbil = CoreAbility.getAbility(args.get(0)); CoreAbility coreAbil = CoreAbility.getAbility(args.get(0));
if (coreAbil == null || coreAbil.isHiddenAbility() || !coreAbil.isEnabled()) { if (coreAbil == null || coreAbil.isHiddenAbility() || !coreAbil.isEnabled()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + abilityDoesntExist.replace("{ability}", args.get(0))); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + abilityDoesntExist.replace("{ability}", args.get(0)));
return; return;
} }
@ -64,7 +64,7 @@ public class BindCommand extends PKCommand {
bind(sender, args.get(0), Integer.parseInt(args.get(1))); bind(sender, args.get(0), Integer.parseInt(args.get(1)));
} }
catch (NumberFormatException ex) { catch (NumberFormatException ex) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongNumber);
} }
} }
} }
@ -73,33 +73,33 @@ public class BindCommand extends PKCommand {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
return; return;
} else if (slot < 1 || slot > 9) { } else if (slot < 1 || slot > 9) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongNumber);
return; return;
} }
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer((Player) sender); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer((Player) sender);
CoreAbility coreAbil = CoreAbility.getAbility(ability); CoreAbility coreAbil = CoreAbility.getAbility(ability);
if (bPlayer == null) { if (bPlayer == null) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + loadingInfo); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + loadingInfo);
return; return;
} else if (coreAbil == null || !bPlayer.canBind(coreAbil)) { } else if (coreAbil == null || !bPlayer.canBind(coreAbil)) {
if (coreAbil != null && coreAbil.getElement() != Element.AVATAR && !bPlayer.hasElement(coreAbil.getElement())) { if (coreAbil != null && coreAbil.getElement() != Element.AVATAR && !bPlayer.hasElement(coreAbil.getElement())) {
if (coreAbil.getElement() instanceof SubElement) { if (coreAbil.getElement() instanceof SubElement) {
SubElement sub = (SubElement) coreAbil.getElement(); SubElement sub = (SubElement) coreAbil.getElement();
if (!bPlayer.hasElement(sub.getParentElement())) { if (!bPlayer.hasElement(sub.getParentElement())) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ("AEIOUaeiou".indexOf(sub.getParentElement().getName().charAt(0)) > -1 ? this.noElementAE : this.noElement).replace("{element}", sub.getParentElement().getName() + sub.getParentElement().getType().getBender())); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ("AEIOUaeiou".indexOf(sub.getParentElement().getName().charAt(0)) > -1 ? this.noElementAE : this.noElement).replace("{element}", sub.getParentElement().getName() + sub.getParentElement().getType().getBender()));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noSubElement.replace("{subelement}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBending())); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noSubElement.replace("{subelement}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBending()));
} }
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ("AEIOUaeiou".indexOf(coreAbil.getElement().getName().charAt(0)) > -1 ? this.noElementAE : this.noElement).replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender())); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ("AEIOUaeiou".indexOf(coreAbil.getElement().getName().charAt(0)) > -1 ? this.noElementAE : this.noElement).replace("{element}", coreAbil.getElement().getName() + coreAbil.getElement().getType().getBender()));
} }
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + super.noPermissionMessage);
} }
return; return;
} else if (!bPlayer.isElementToggled(coreAbil.getElement())) { } else if (!bPlayer.isElementToggled(coreAbil.getElement())) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggledElementOff); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + toggledElementOff);
} }
String name = coreAbil != null ? coreAbil.getName() : null; String name = coreAbil != null ? coreAbil.getName() : null;

View file

@ -57,12 +57,12 @@ public class ChooseCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(sender.getName()); bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
} }
if (bPlayer.isPermaRemoved()) { if (bPlayer.isPermaRemoved()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved"));
return; return;
} }
if (!bPlayer.getElements().isEmpty() && !sender.hasPermission("bending.command.rechoose")) { if (!bPlayer.getElements().isEmpty() && !sender.hasPermission("bending.command.rechoose")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
@ -84,17 +84,17 @@ public class ChooseCommand extends PKCommand {
add(sender, (Player) sender, targetElement); add(sender, (Player) sender, targetElement);
return; return;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + invalidElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + invalidElement);
return; return;
} }
} else if (args.size() == 2) { } else if (args.size() == 2) {
if (!sender.hasPermission("bending.admin.choose")) { if (!sender.hasPermission("bending.admin.choose")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return; return;
} }
Player target = ProjectKorra.plugin.getServer().getPlayer(args.get(1)); Player target = ProjectKorra.plugin.getServer().getPlayer(args.get(1));
if (target == null || !target.isOnline()) { if (target == null || !target.isOnline()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playerNotFound); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playerNotFound);
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
@ -113,7 +113,7 @@ public class ChooseCommand extends PKCommand {
add(sender, target, targetElement); add(sender, target, targetElement);
return; return;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + invalidElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + invalidElement);
} }
} }
} }
@ -136,9 +136,9 @@ public class ChooseCommand extends PKCommand {
bPlayer.addSubElement(sub); bPlayer.addSubElement(sub);
ChatColor color = sub != null ? sub.getColor() : ChatColor.WHITE; ChatColor color = sub != null ? sub.getColor() : ChatColor.WHITE;
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + chosenOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
} else { } else {
target.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenCFW.replace("{element}", sub.getName() + sub.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + chosenCFW.replace("{element}", sub.getName() + sub.getType().getBender()));
} }
GeneralMethods.saveSubElements(bPlayer); GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.CHOOSE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.CHOOSE));
@ -154,14 +154,14 @@ public class ChooseCommand extends PKCommand {
ChatColor color = element != null ? element.getColor() : ChatColor.WHITE; ChatColor color = element != null ? element.getColor() : ChatColor.WHITE;
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (element != Element.AIR && element != Element.EARTH) if (element != Element.AIR && element != Element.EARTH)
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + chosenOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender()));
else else
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + chosenOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender()));
} else { } else {
if (element != Element.AIR && element != Element.EARTH) if (element != Element.AIR && element != Element.EARTH)
target.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenCFW.replace("{element}", element.getName() + element.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + chosenCFW.replace("{element}", element.getName() + element.getType().getBender()));
else else
target.sendMessage(ConfigManager.getBrandingPrefix() + color + chosenAE.replace("{element}", element.getName() + element.getType().getBender())); GeneralMethods.sendBrandingMessage(target, color + chosenAE.replace("{element}", element.getName() + element.getType().getBender()));
} }
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer); GeneralMethods.saveSubElements(bPlayer);

View file

@ -39,7 +39,7 @@ public class ClearCommand extends PKCommand {
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1) || !isPlayer(sender)) { if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 1) || !isPlayer(sender)) {
return; return;
} else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) { } else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + cantEditBinds); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + cantEditBinds);
return; return;
} }
@ -53,23 +53,23 @@ public class ClearCommand extends PKCommand {
for (int i = 1; i <= 9; i++) { for (int i = 1; i <= 9; i++) {
GeneralMethods.saveAbility(bPlayer, i, null); GeneralMethods.saveAbility(bPlayer, i, null);
} }
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.YELLOW + cleared); GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + cleared);
} else if (args.size() == 1) { } else if (args.size() == 1) {
try { try {
int slot = Integer.parseInt(args.get(0)); int slot = Integer.parseInt(args.get(0));
if (slot < 1 || slot > 9) { if (slot < 1 || slot > 9) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongNumber);
} }
if (bPlayer.getAbilities().get(slot) != null) { if (bPlayer.getAbilities().get(slot) != null) {
bPlayer.getAbilities().remove(slot); bPlayer.getAbilities().remove(slot);
GeneralMethods.saveAbility(bPlayer, slot, null); GeneralMethods.saveAbility(bPlayer, slot, null);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.YELLOW + clearedSlot.replace("{slot}", String.valueOf(slot))); GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + clearedSlot.replace("{slot}", String.valueOf(slot)));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.YELLOW + alreadyEmpty); GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + alreadyEmpty);
} }
} }
catch (NumberFormatException e) { catch (NumberFormatException e) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongNumber); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongNumber);
} }
} }
} }

View file

@ -43,18 +43,18 @@ public class CopyCommand extends PKCommand {
Player orig = Bukkit.getPlayer(args.get(0)); Player orig = Bukkit.getPlayer(args.get(0));
if (orig == null || !orig.isOnline()) { if (orig == null || !orig.isOnline()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playerNotFound); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playerNotFound);
return; return;
} }
boolean boundAll = assignAbilities(sender, orig, (Player) sender, true); boolean boundAll = assignAbilities(sender, orig, (Player) sender, true);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + failedToBindAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + failedToBindAll);
} }
} else if (args.size() == 2) { } else if (args.size() == 2) {
if (!hasPermission(sender, "assign")) { if (!hasPermission(sender, "assign")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return; return;
} }
@ -62,15 +62,15 @@ public class CopyCommand extends PKCommand {
Player target = ProjectKorra.plugin.getServer().getPlayer(args.get(1)); Player target = ProjectKorra.plugin.getServer().getPlayer(args.get(1));
if ((orig == null || !orig.isOnline()) || (target == null || !target.isOnline())) { if ((orig == null || !orig.isOnline()) || (target == null || !target.isOnline())) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playerNotFound); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playerNotFound);
return; return;
} }
boolean boundAll = assignAbilities(sender, orig, target, false); boolean boundAll = assignAbilities(sender, orig, target, false);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + copiedOther.replace("{target1}", ChatColor.YELLOW + target.getName() + ChatColor.GREEN).replace("{target2}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + copiedOther.replace("{target1}", ChatColor.YELLOW + target.getName() + ChatColor.GREEN).replace("{target2}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN));
target.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(target, ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + failedToBindAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + failedToBindAll);
} }
} }
} }
@ -91,9 +91,9 @@ public class CopyCommand extends PKCommand {
} }
if (orig.isPermaRemoved()) { if (orig.isPermaRemoved()) {
if (self) { if (self) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved")); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved"));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved"));
} }
return false; return false;
} }

View file

@ -83,7 +83,7 @@ public class DisplayCommand extends PKCommand {
ArrayList<String> combos = ComboManager.getCombosForElement(element); ArrayList<String> combos = ComboManager.getCombosForElement(element);
if (combos.isEmpty()) { if (combos.isEmpty()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + noCombosAvailable.replace("{element}", element.getName())); GeneralMethods.sendBrandingMessage(sender, color + noCombosAvailable.replace("{element}", element.getName()));
return; return;
} }
for (String comboMove : combos) { for (String comboMove : combos) {
@ -125,7 +125,7 @@ public class DisplayCommand extends PKCommand {
Set<String> passives = PassiveManager.getPassivesForElement(element); Set<String> passives = PassiveManager.getPassivesForElement(element);
if (passives.isEmpty()) { if (passives.isEmpty()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + noPassivesAvailable.replace("{element}", element.getName())); GeneralMethods.sendBrandingMessage(sender, color + noPassivesAvailable.replace("{element}", element.getName()));
return; return;
} }
for (String passiveAbil : passives) { for (String passiveAbil : passives) {
@ -172,7 +172,7 @@ public class DisplayCommand extends PKCommand {
if (args.size() == 0) { if (args.size() == 0) {
//bending display //bending display
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playersOnly); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playersOnly);
return; return;
} }
displayBinds(sender); displayBinds(sender);

View file

@ -53,11 +53,11 @@ public class ImportCommand extends PKCommand {
if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) { if (!hasPermission(sender) || !correctLength(sender, args.size(), 0, 0)) {
return; return;
} else if (!GeneralMethods.isImportEnabled()) { } else if (!GeneralMethods.isImportEnabled()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.disabled); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.disabled);
return; return;
} }
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.preparingData); sender.sendMessage(ChatColor.GREEN + this.preparingData);
File bendingPlayersFile = new File(".", "converted.yml"); File bendingPlayersFile = new File(".", "converted.yml");
FileConfiguration bendingPlayers = YamlConfiguration.loadConfiguration(bendingPlayersFile); FileConfiguration bendingPlayers = YamlConfiguration.loadConfiguration(bendingPlayersFile);

View file

@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.command;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
import java.util.List; import java.util.List;
@ -25,10 +26,10 @@ public class InvincibleCommand extends PKCommand {
if (!Commands.invincible.contains(sender.getName())) { if (!Commands.invincible.contains(sender.getName())) {
Commands.invincible.add(sender.getName()); Commands.invincible.add(sender.getName());
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOn")); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOn"));
} else { } else {
Commands.invincible.remove(sender.getName()); Commands.invincible.remove(sender.getName());
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOff")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOff"));
} }
} }

View file

@ -13,6 +13,7 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
/** /**
@ -112,7 +113,7 @@ public abstract class PKCommand implements SubCommand {
if (sender.hasPermission("bending.command." + name + "." + extra)) { if (sender.hasPermission("bending.command." + name + "." + extra)) {
return true; return true;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + this.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, this.noPermissionMessage);
return false; return false;
} }
} }
@ -147,7 +148,7 @@ public abstract class PKCommand implements SubCommand {
if (sender instanceof Player) { if (sender instanceof Player) {
return true; return true;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + this.mustBePlayerMessage); GeneralMethods.sendBrandingMessage(sender, this.mustBePlayerMessage);
return false; return false;
} }
} }

View file

@ -56,7 +56,7 @@ public class PermaremoveCommand extends PKCommand {
private void permaremove(CommandSender sender, String target) { private void permaremove(CommandSender sender, String target) {
Player player = Bukkit.getPlayer(target); Player player = Bukkit.getPlayer(target);
if (player == null) { if (player == null) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.playerIsOffline); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.playerIsOffline);
return; return;
} }
@ -69,18 +69,18 @@ public class PermaremoveCommand extends PKCommand {
if (bPlayer.isPermaRemoved()) { if (bPlayer.isPermaRemoved()) {
bPlayer.setPermaRemoved(false); bPlayer.setPermaRemoved(false);
GeneralMethods.savePermaRemoved(bPlayer); GeneralMethods.savePermaRemoved(bPlayer);
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.restored); GeneralMethods.sendBrandingMessage(player, ChatColor.GREEN + this.restored);
if (!(sender instanceof Player) || !sender.getName().equalsIgnoreCase(target)) if (!(sender instanceof Player) || !sender.getName().equalsIgnoreCase(target))
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.restoredConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + this.restoredConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.GREEN));
} else { } else {
bPlayer.getElements().clear(); bPlayer.getElements().clear();
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
bPlayer.setPermaRemoved(true); bPlayer.setPermaRemoved(true);
GeneralMethods.savePermaRemoved(bPlayer); GeneralMethods.savePermaRemoved(bPlayer);
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.removed); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + this.removed);
if (!(sender instanceof Player) || !sender.getName().equalsIgnoreCase(target)) if (!(sender instanceof Player) || !sender.getName().equalsIgnoreCase(target))
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.removedConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.RED)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.removedConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.RED));
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.PERMAREMOVE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.PERMAREMOVE));
} }
} }
@ -94,7 +94,7 @@ public class PermaremoveCommand extends PKCommand {
@Override @Override
public boolean hasPermission(CommandSender sender) { public boolean hasPermission(CommandSender sender) {
if (!sender.hasPermission("bending.admin.permaremove")) { if (!sender.hasPermission("bending.admin.permaremove")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return false; return false;
} }
return true; return true;

View file

@ -66,7 +66,7 @@ public class PresetCommand extends PKCommand {
if (!isPlayer(sender) || !correctLength(sender, args.size(), 1, 3)) { if (!isPlayer(sender) || !correctLength(sender, args.size(), 1, 3)) {
return; return;
} else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) { } else if (MultiAbilityManager.hasMultiAbilityBound((Player) sender)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + this.cantEditBinds); GeneralMethods.sendBrandingMessage(sender, this.cantEditBinds);
return; return;
} }
@ -85,7 +85,7 @@ public class PresetCommand extends PKCommand {
List<String> presetNames = new ArrayList<String>(); List<String> presetNames = new ArrayList<String>();
if (presets == null || presets.isEmpty()) { if (presets == null || presets.isEmpty()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresets); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresets);
return; return;
} }
@ -104,7 +104,7 @@ public class PresetCommand extends PKCommand {
String name = args.get(1); String name = args.get(1);
if (Arrays.asList(deletealiases).contains(args.get(0)) && hasPermission(sender, "delete")) { //bending preset delete name if (Arrays.asList(deletealiases).contains(args.get(0)) && hasPermission(sender, "delete")) { //bending preset delete name
if (!Preset.presetExists(player, name)) { if (!Preset.presetExists(player, name)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresetName); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
return; return;
} }
@ -121,23 +121,23 @@ public class PresetCommand extends PKCommand {
} else if (Preset.externalPresetExists(name) && hasPermission(sender, "bind.external")) { } else if (Preset.externalPresetExists(name) && hasPermission(sender, "bind.external")) {
boundAll = Preset.bindExternalPreset(player, name); boundAll = Preset.bindExternalPreset(player, name);
} else if (!Preset.externalPresetExists(name) && hasPermission(sender, "bind.external")) { } else if (!Preset.externalPresetExists(name) && hasPermission(sender, "bind.external")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresetNameExternal); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetNameExternal);
return; return;
} else if (bPlayer.isPermaRemoved()) { } else if (bPlayer.isPermaRemoved()) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.bendingRemoved); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + this.bendingRemoved);
return; return;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresetName); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
return; return;
} }
sender.sendMessage(ChatColor.GREEN + bound.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN)); sender.sendMessage(ChatColor.GREEN + bound.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.failedToBindAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.failedToBindAll);
} }
} else if (hasPermission(sender, "bind.external.assign") && Preset.externalPresetExists(name)) { } else if (hasPermission(sender, "bind.external.assign") && Preset.externalPresetExists(name)) {
if (!Preset.externalPresetExists(name)) { if (!Preset.externalPresetExists(name)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresetNameExternal); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetNameExternal);
return; return;
} }
@ -150,23 +150,23 @@ public class PresetCommand extends PKCommand {
bPlayer2 = BendingPlayer.getBendingPlayer(player2); bPlayer2 = BendingPlayer.getBendingPlayer(player2);
} }
if (bPlayer2.isPermaRemoved()) { if (bPlayer2.isPermaRemoved()) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.bendingRemovedOther); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + this.bendingRemovedOther);
return; return;
} }
boolean boundAll = Preset.bindExternalPreset(player2, name); boolean boundAll = Preset.bindExternalPreset(player2, name);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.boundOtherConfirm.replace("{target}", ChatColor.YELLOW + player2.getName() + ChatColor.GREEN).replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN + ChatColor.YELLOW)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + this.boundOtherConfirm.replace("{target}", ChatColor.YELLOW + player2.getName() + ChatColor.GREEN).replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN + ChatColor.YELLOW));
player2.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.bound.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(player2, ChatColor.GREEN + this.bound.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
player2.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.failedToBindAll); GeneralMethods.sendBrandingMessage(player2, ChatColor.RED + this.failedToBindAll);
} }
return; return;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound"));
} }
} else if (hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) { } else if (hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) {
if (!Preset.presetExists(player, name)) { if (!Preset.presetExists(player, name)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.noPresetName); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
return; return;
} }
@ -179,30 +179,30 @@ public class PresetCommand extends PKCommand {
bPlayer2 = BendingPlayer.getBendingPlayer(player2); bPlayer2 = BendingPlayer.getBendingPlayer(player2);
} }
if (bPlayer2.isPermaRemoved()) { if (bPlayer2.isPermaRemoved()) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.bendingRemovedOther); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + this.bendingRemovedOther);
return; return;
} }
Preset preset = Preset.getPreset(player, name); Preset preset = Preset.getPreset(player, name);
boolean boundAll = Preset.bindPreset(player2, preset); boolean boundAll = Preset.bindPreset(player2, preset);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.boundOtherConfirm.replace("{target}", ChatColor.YELLOW + player2.getName() + ChatColor.GREEN).replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN + ChatColor.YELLOW)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + this.boundOtherConfirm.replace("{target}", ChatColor.YELLOW + player2.getName() + ChatColor.GREEN).replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN + ChatColor.YELLOW));
player2.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.succesfullyCopied.replace("{target}", ChatColor.YELLOW + player.getName() + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(player2, ChatColor.GREEN + this.succesfullyCopied.replace("{target}", ChatColor.YELLOW + player.getName() + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
player2.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.failedToBindAll); GeneralMethods.sendBrandingMessage(player2, ChatColor.RED + this.failedToBindAll);
} }
return; return;
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound")); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound"));
} }
} }
} else if (Arrays.asList(createaliases).contains(args.get(0)) && hasPermission(sender, "create")) { //bending preset create name } else if (Arrays.asList(createaliases).contains(args.get(0)) && hasPermission(sender, "create")) { //bending preset create name
int limit = GeneralMethods.getMaxPresets(player); int limit = GeneralMethods.getMaxPresets(player);
if (Preset.presets.get(player) != null && Preset.presets.get(player).size() >= limit) { if (Preset.presets.get(player) != null && Preset.presets.get(player).size() >= limit) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.reachedMax); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.reachedMax);
return; return;
} else if (Preset.presetExists(player, name)) { } else if (Preset.presetExists(player, name)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + this.alreadyExists); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyExists);
return; return;
} }
@ -213,7 +213,7 @@ public class PresetCommand extends PKCommand {
Preset preset = new Preset(player.getUniqueId(), name, abilities); Preset preset = new Preset(player.getUniqueId(), name, abilities);
preset.save(player); preset.save(player);
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + this.createdNewPreset.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + this.createdNewPreset.replace("{name}", ChatColor.YELLOW + name + ChatColor.GREEN));
} else { } else {
help(sender, false); help(sender, false);
} }

View file

@ -61,10 +61,10 @@ 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(ConfigManager.getBrandingPrefix() + e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor())); GeneralMethods.sendBrandingMessage(sender, e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending()).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)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
} else } else
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongElementSelf); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongElementSelf);
return; return;
} else if (e instanceof Element) { } else if (e instanceof Element) {
if (senderBPlayer.hasElement(e)) { if (senderBPlayer.hasElement(e)) {
@ -75,22 +75,22 @@ public class RemoveCommand extends PKCommand {
GeneralMethods.saveElements(senderBPlayer); GeneralMethods.saveElements(senderBPlayer);
GeneralMethods.removeUnusableAbilities(sender.getName()); GeneralMethods.removeUnusableAbilities(sender.getName());
sender.sendMessage(ConfigManager.getBrandingPrefix() + e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending())); GeneralMethods.sendBrandingMessage(sender, e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending()));
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
return; return;
} else } else
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongElementSelf); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongElementSelf);
{ {
return; return;
} }
} }
} else } else
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + invalidElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + invalidElement);
{ {
return; return;
} }
} }
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + playerOffline); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + playerOffline);
return; return;
} else { } else {
help(sender, false); help(sender, false);
@ -107,7 +107,7 @@ public class RemoveCommand extends PKCommand {
Element e = Element.fromString(args.get(1)); Element e = Element.fromString(args.get(1));
if (e != null) { if (e != null) {
if (!bPlayer.hasElement(e)) { if (!bPlayer.hasElement(e)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.DARK_RED + wrongElementTarget.replace("{target}", player.getName())); GeneralMethods.sendBrandingMessage(sender, ChatColor.DARK_RED + wrongElementTarget.replace("{target}", player.getName()));
return; return;
} }
if (e instanceof SubElement) { if (e instanceof SubElement) {
@ -119,8 +119,8 @@ public class RemoveCommand extends PKCommand {
} }
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
player.sendMessage(ConfigManager.getBrandingPrefix() + e.getColor() + this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor())); GeneralMethods.sendBrandingMessage(player, e.getColor() + this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
sender.sendMessage(ConfigManager.getBrandingPrefix() + e.getColor() + this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending()).replace("{target}", ChatColor.DARK_AQUA + player.getName() + e.getColor())); GeneralMethods.sendBrandingMessage(sender, e.getColor() + this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending()).replace("{target}", ChatColor.DARK_AQUA + player.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;
} }
@ -133,8 +133,9 @@ public class RemoveCommand extends PKCommand {
if (GeneralMethods.hasRPG()) if (GeneralMethods.hasRPG())
RPGMethods.revokeAvatar(bPlayer.getUUID()); RPGMethods.revokeAvatar(bPlayer.getUUID());
if (!player.getName().equalsIgnoreCase(sender.getName())) if (!player.getName().equalsIgnoreCase(sender.getName()))
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW)); GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW));
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
GeneralMethods.sendBrandingMessage(player, 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));
} }
} }
@ -150,7 +151,7 @@ public class RemoveCommand extends PKCommand {
if (sender.hasPermission("bending.admin." + getName())) { if (sender.hasPermission("bending.admin." + getName())) {
return true; return true;
} }
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return false; return false;
} }

View file

@ -61,7 +61,7 @@ public class ToggleCommand extends PKCommand {
return; return;
} }
if (Commands.isToggledForAll) { if (Commands.isToggledForAll) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggledOffForAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + toggledOffForAll);
return; return;
} }
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName()); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
@ -70,10 +70,10 @@ public class ToggleCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(sender.getName()); bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
} }
if (bPlayer.isToggled()) { if (bPlayer.isToggled()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggleOffSelf); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + toggleOffSelf);
bPlayer.toggleBending(); bPlayer.toggleBending();
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + toggleOnSelf); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + toggleOnSelf);
bPlayer.toggleBending(); bPlayer.toggleBending();
} }
} else if (args.size() == 1) { } else if (args.size() == 1) {
@ -81,21 +81,21 @@ public class ToggleCommand extends PKCommand {
if (Commands.isToggledForAll) { // Bending is toggled off for all players. if (Commands.isToggledForAll) { // Bending is toggled off for all players.
Commands.isToggledForAll = false; Commands.isToggledForAll = false;
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + toggleOnAll); GeneralMethods.sendBrandingMessage(player, ChatColor.GREEN + toggleOnAll);
} }
if (!(sender instanceof Player)) if (!(sender instanceof Player))
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GREEN + toggleOnAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + toggleOnAll);
} else { } else {
Commands.isToggledForAll = true; Commands.isToggledForAll = true;
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggleOffAll); GeneralMethods.sendBrandingMessage(player, ChatColor.RED + toggleOffAll);
} }
if (!(sender instanceof Player)) if (!(sender instanceof Player))
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggleOffAll); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + toggleOffAll);
} }
} else if (sender instanceof Player && args.size() == 1 && Element.fromString(args.get(0)) != null && !(Element.fromString(args.get(0)) instanceof SubElement)) { } else if (sender instanceof Player && args.size() == 1 && Element.fromString(args.get(0)) != null && !(Element.fromString(args.get(0)) instanceof SubElement)) {
if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) { if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongElement);
return; return;
} }
Element e = Element.fromString(args.get(0)); Element e = Element.fromString(args.get(0));
@ -104,9 +104,9 @@ public class ToggleCommand extends PKCommand {
bPlayer.toggleElement(e); bPlayer.toggleElement(e);
if (bPlayer.isElementToggled(e)) { if (bPlayer.isElementToggled(e)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + toggledOnSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); GeneralMethods.sendBrandingMessage(sender, color + toggledOnSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + toggledOffSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); GeneralMethods.sendBrandingMessage(sender, color + toggledOffSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")));
} }
} else { } else {
help(sender, false); help(sender, false);
@ -117,11 +117,11 @@ public class ToggleCommand extends PKCommand {
if (!hasAdminPermission(sender)) if (!hasAdminPermission(sender))
return; return;
if (target == null) { if (target == null) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + notFound); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + notFound);
return; return;
} }
if (!BendingPlayer.getBendingPlayer(target.getName()).hasElement(Element.fromString(args.get(0)))) { if (!BendingPlayer.getBendingPlayer(target.getName()).hasElement(Element.fromString(args.get(0)))) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + wrongElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
return; return;
} }
Element e = Element.fromString(args.get(0)); Element e = Element.fromString(args.get(0));
@ -129,11 +129,11 @@ public class ToggleCommand extends PKCommand {
ChatColor color = e != null ? e.getColor() : null; ChatColor color = e != null ? e.getColor() : null;
if (bPlayer.isElementToggled(e)) { if (bPlayer.isElementToggled(e)) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + this.toggledOffOtherElementConfirm.replace("{target}", target.getName()).replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); GeneralMethods.sendBrandingMessage(sender, color + this.toggledOffOtherElementConfirm.replace("{target}", target.getName()).replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")));
target.sendMessage(ConfigManager.getBrandingPrefix() + color + this.toggledOffOtherElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")).replace("{sender}", ChatColor.DARK_AQUA + sender.getName())); GeneralMethods.sendBrandingMessage(target, color + this.toggledOffOtherElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")).replace("{sender}", ChatColor.DARK_AQUA + sender.getName()));
} else { } else {
sender.sendMessage(ConfigManager.getBrandingPrefix() + color + this.toggledOnOtherElementConfirm.replace("{target}", target.getName()).replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); GeneralMethods.sendBrandingMessage(sender, color + this.toggledOnOtherElementConfirm.replace("{target}", target.getName()).replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")));
target.sendMessage(ConfigManager.getBrandingPrefix() + color + this.toggledOnOtherElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")).replace("{sender}", ChatColor.DARK_AQUA + sender.getName())); GeneralMethods.sendBrandingMessage(target, color + this.toggledOnOtherElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")).replace("{sender}", ChatColor.DARK_AQUA + sender.getName()));
} }
bPlayer.toggleElement(e); bPlayer.toggleElement(e);
} else { } else {
@ -143,7 +143,7 @@ public class ToggleCommand extends PKCommand {
public boolean hasAdminPermission(CommandSender sender) { public boolean hasAdminPermission(CommandSender sender) {
if (!sender.hasPermission("bending.admin.toggle")) { if (!sender.hasPermission("bending.admin.toggle")) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + super.noPermissionMessage); GeneralMethods.sendBrandingMessage(sender, super.noPermissionMessage);
return false; return false;
} }
return true; return true;

View file

@ -128,7 +128,7 @@ public class WhoCommand extends PKCommand {
players.add(result); players.add(result);
} }
if (players.isEmpty()) { if (players.isEmpty()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + noPlayersOnline); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + noPlayersOnline);
} else { } else {
for (String s : getPage(players, ChatColor.GOLD + "Players:", page, true)) { for (String s : getPage(players, ChatColor.GOLD + "Players:", page, true)) {
sender.sendMessage(s); sender.sendMessage(s);
@ -148,11 +148,11 @@ public class WhoCommand extends PKCommand {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
final OfflinePlayer player = Bukkit.getOfflinePlayer(playerName); final OfflinePlayer player = Bukkit.getOfflinePlayer(playerName);
if (player == null || !player.hasPlayedBefore() && !player.isOnline()) { if (player == null || !player.hasPlayedBefore() && !player.isOnline()) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + "Player not found!"); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + "Player not found!");
return; return;
} }
if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) { if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) {
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.GRAY + playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY).replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY)); GeneralMethods.sendBrandingMessage(sender, ChatColor.GRAY + playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY).replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY));
} }
Player player_ = (Player) (player.isOnline() ? player : null); Player player_ = (Player) (player.isOnline() ? player : null);
@ -167,7 +167,7 @@ public class WhoCommand extends PKCommand {
final long delay = 200L; final long delay = 200L;
while (!BendingPlayer.getPlayers().containsKey(player.getUniqueId())) { while (!BendingPlayer.getPlayers().containsKey(player.getUniqueId())) {
if (count > 5 * (1000 / delay)) { //After 5 seconds of waiting, tell the user the database is busy and to try again in a few seconds. if (count > 5 * (1000 / delay)) { //After 5 seconds of waiting, tell the user the database is busy and to try again in a few seconds.
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.DARK_RED + databaseOverload); GeneralMethods.sendBrandingMessage(sender, ChatColor.DARK_RED + databaseOverload);
break; break;
} }
count++; count++;
@ -176,7 +176,7 @@ public class WhoCommand extends PKCommand {
} }
catch (InterruptedException e) { catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.DARK_RED + databaseOverload); GeneralMethods.sendBrandingMessage(sender, ChatColor.DARK_RED + databaseOverload);
break; break;
} }
} }

View file

@ -1,17 +1,12 @@
package com.projectkorra.projectkorra.configuration; package com.projectkorra.projectkorra.configuration;
import org.bukkit.ChatColor;
import org.bukkit.configuration.file.FileConfiguration;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map; import org.bukkit.configuration.file.FileConfiguration;
public class ConfigManager { public class ConfigManager {
public static final Map<String, ChatColor> BRANDING_OPTIONS = new HashMap<>();
public static Config presetConfig; public static Config presetConfig;
public static Config defaultConfig; public static Config defaultConfig;
public static Config languageConfig; public static Config languageConfig;
@ -23,14 +18,6 @@ public class ConfigManager {
configCheck(ConfigType.DEFAULT); configCheck(ConfigType.DEFAULT);
configCheck(ConfigType.LANGUAGE); configCheck(ConfigType.LANGUAGE);
configCheck(ConfigType.PRESETS); configCheck(ConfigType.PRESETS);
BRANDING_OPTIONS.put("GOLD", ChatColor.GOLD);
BRANDING_OPTIONS.put("AQUA", ChatColor.AQUA);
BRANDING_OPTIONS.put("YELLOW", ChatColor.YELLOW);
BRANDING_OPTIONS.put("RED", ChatColor.RED);
BRANDING_OPTIONS.put("GREEN", ChatColor.GREEN);
BRANDING_OPTIONS.put("PINK", ChatColor.LIGHT_PURPLE);
BRANDING_OPTIONS.put("PURPLE", ChatColor.DARK_PURPLE);
} }
public static void configCheck(ConfigType type) { public static void configCheck(ConfigType type) {
@ -1312,10 +1299,4 @@ public class ConfigManager {
public static FileConfiguration getConfig() { public static FileConfiguration getConfig() {
return ConfigManager.defaultConfig.get(); return ConfigManager.defaultConfig.get();
} }
public static String getBrandingPrefix() {
ChatColor color = BRANDING_OPTIONS.get(languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
color = color == null ? ChatColor.GOLD : color;
return ChatColor.translateAlternateColorCodes('&', languageConfig.get().getString("Chat.Branding.ChatPrefix.Prefix")) + color + "ProjectKorra" + ChatColor.translateAlternateColorCodes('&', languageConfig.get().getString("Chat.Branding.ChatPrefix.Suffix"));
}
} }