Ported commands to new configuration system

This commit is contained in:
Alexander Meech 2019-08-16 16:53:28 -04:00
parent b1d5130309
commit c4185ef178
61 changed files with 737 additions and 248 deletions

View file

@ -5,7 +5,6 @@ import java.util.ArrayList;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public interface ComboAbility {

View file

@ -20,25 +20,18 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.jar.JarFile;
import sun.reflect.ReflectionFactory;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.commons.lang3.tuple.Pair;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import co.aikar.timings.lib.MCTiming;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.reflect.ClassPath;
import com.google.common.reflect.ClassPath.ClassInfo;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
@ -55,8 +48,6 @@ import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.attribute.AttributeModifier;
import com.projectkorra.projectkorra.attribute.AttributePriority;
import com.projectkorra.projectkorra.configuration.better.Config;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.event.AbilityEndEvent;
import com.projectkorra.projectkorra.event.AbilityProgressEvent;
@ -64,6 +55,9 @@ import com.projectkorra.projectkorra.event.AbilityStartEvent;
import com.projectkorra.projectkorra.util.FlightHandler;
import com.projectkorra.projectkorra.util.TimeUtil;
import co.aikar.timings.lib.MCTiming;
import sun.reflect.ReflectionFactory;
/**
* CoreAbility provides default implementation of an Ability, including methods
* to control the life cycle of a specific instance. CoreAbility also provides a
@ -80,7 +74,7 @@ import com.projectkorra.projectkorra.util.TimeUtil;
* @see #registerAddonAbilities(String)
* @see #registerPluginAbilities(JavaPlugin, String)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
@SuppressWarnings({ "rawtypes", "unchecked", "unlikely-arg-type", "restriction" })
public abstract class CoreAbility<C extends AbilityConfig> implements Ability {
private static final Set<CoreAbility> INSTANCES = Collections.newSetFromMap(new ConcurrentHashMap<CoreAbility, Boolean>());

View file

@ -14,6 +14,7 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
*
* @see CollisionManager
*/
@SuppressWarnings("rawtypes")
public class Collision {
private CoreAbility abilityFirst;
private CoreAbility abilitySecond;

View file

@ -60,6 +60,7 @@ import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast;
* @see Collision
* @see CollisionManager
*/
@SuppressWarnings("rawtypes")
public class CollisionInitializer {
private final CollisionManager collisionManager;

View file

@ -33,6 +33,7 @@ import com.projectkorra.projectkorra.event.AbilityCollisionEvent;
* cancelled, abilityFirst.handleCollision, and finally
* abilitySecond.handleCollision.
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CollisionManager {
/*

View file

@ -21,6 +21,7 @@ import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers;
import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.ReflectionHandler;
@SuppressWarnings("rawtypes")
public class ComboManager {
private static final long CLEANUP_DELAY = 20 * 60;
private static final Map<String, ArrayList<AbilityInformation>> RECENTLY_USED = new ConcurrentHashMap<>();

View file

@ -15,6 +15,7 @@ import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
@SuppressWarnings({ "rawtypes", "unlikely-arg-type" })
public class PassiveManager {
private static final Map<String, CoreAbility> PASSIVES = new HashMap<>();

View file

@ -13,7 +13,9 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.AddCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
@ -21,7 +23,7 @@ import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
/**
* Executor for /bending add. Extends {@link PKCommand}.
*/
public class AddCommand extends PKCommand {
public class AddCommand extends PKCommand<AddCommandConfig> {
private final String playerNotFound;
private final String invalidElement;
@ -38,23 +40,23 @@ public class AddCommand extends PKCommand {
private final String alreadyHasAllElementsOther;
private final String alreadyHasAllElements;
public AddCommand() {
super("add", "/bending add <Element/SubElement> [Player]", ConfigManager.languageConfig.get().getString("Commands.Add.Description"), new String[] { "add", "a" });
public AddCommand(final AddCommandConfig config) {
super(config, "add", "/bending add <Element/SubElement> [Player]", config.Description, new String[] { "add", "a" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Add.PlayerNotFound");
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Add.InvalidElement");
this.addedOtherCFW = ConfigManager.languageConfig.get().getString("Commands.Add.Other.SuccessfullyAddedCFW");
this.addedOtherAE = ConfigManager.languageConfig.get().getString("Commands.Add.Other.SuccessfullyAddedAE");
this.addedCFW = ConfigManager.languageConfig.get().getString("Commands.Add.SuccessfullyAddedCFW");
this.addedAE = ConfigManager.languageConfig.get().getString("Commands.Add.SuccessfullyAddedAE");
this.addedOtherAll = ConfigManager.languageConfig.get().getString("Commands.Add.Other.SuccessfullyAddedAll");
this.addedAll = ConfigManager.languageConfig.get().getString("Commands.Add.SuccessfullyAddedAll");
this.alreadyHasElementOther = ConfigManager.languageConfig.get().getString("Commands.Add.Other.AlreadyHasElement");
this.alreadyHasElement = ConfigManager.languageConfig.get().getString("Commands.Add.AlreadyHasElement");
this.alreadyHasSubElementOther = ConfigManager.languageConfig.get().getString("Commands.Add.Other.AlreadyHasSubElement");
this.alreadyHasSubElement = ConfigManager.languageConfig.get().getString("Commands.Add.AlreadyHasSubElement");
this.alreadyHasAllElementsOther = ConfigManager.languageConfig.get().getString("Commands.Add.Other.AlreadyHasAllElements");
this.alreadyHasAllElements = ConfigManager.languageConfig.get().getString("Commands.Add.AlreadyHasAllElements");
this.playerNotFound = config.PlayerNotFound;
this.invalidElement = config.InvalidElement;
this.addedOtherCFW = config.SuccessfullyAddedCFW_Other;
this.addedOtherAE = config.SuccessfullyAddedAE_Other;
this.addedCFW = config.SuccessfullyAddedCFW;
this.addedAE = config.SuccessfullyAddedAE;
this.addedOtherAll = config.SuccessfullyAddedAll_Other;
this.addedAll = config.SuccessfullyAddedAll;
this.alreadyHasElementOther = config.AlreadyHasElement_Other;
this.alreadyHasElement = config.AlreadyHasElement;
this.alreadyHasSubElementOther = config.AlreadyHasSubElement_Other;
this.alreadyHasSubElement = config.AlreadyHasSubElement;
this.alreadyHasAllElementsOther = config.AlreadyHasAllElements_Other;
this.alreadyHasAllElements = config.AlreadyHasAllElements;
}
@Override
@ -94,7 +96,7 @@ public class AddCommand extends PKCommand {
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
bPlayer = BendingPlayer.getBendingPlayer(target);
} else if (bPlayer.isPermaRemoved()) { // ignore permabanned users.
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other);
return;
}

View file

@ -12,8 +12,8 @@ import org.bukkit.command.TabCompleter;
/**
* Completes tabbing for the bending command/subcommands.
*
* @author StrangeOne101
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public class BendingTabComplete implements TabCompleter {
@Override

View file

@ -16,14 +16,13 @@ import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ComboAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.BindCommandConfig;
/**
* Executor for /bending bind. Extends {@link PKCommand}.
*/
@SuppressWarnings("rawtypes")
public class BindCommand extends PKCommand {
public class BindCommand extends PKCommand<BindCommandConfig> {
private final String abilityDoesntExist;
private final String wrongNumber;
@ -34,17 +33,17 @@ public class BindCommand extends PKCommand {
private final String noSubElement;
private final String unbindable;
public BindCommand() {
super("bind", "/bending bind <Ability> [Slot]", ConfigManager.getConfig(BindCommandConfig.class).Description, new String[] { "bind", "b" });
public BindCommand(final BindCommandConfig config) {
super(config, "bind", "/bending bind <Ability> [Slot]", config.Description, new String[] { "bind", "b" });
this.abilityDoesntExist = ConfigManager.getConfig(BindCommandConfig.class).AbilityDoesntExistMessage;
this.wrongNumber = ConfigManager.getConfig(BindCommandConfig.class).WrongNumberMessage;
this.loadingInfo = ConfigManager.getConfig(BindCommandConfig.class).LoadingInfoMessage;
this.toggledElementOff = ConfigManager.getConfig(BindCommandConfig.class).ElementToggledOffMessage;
this.noElement = ConfigManager.getConfig(BindCommandConfig.class).NoElementMessage;
this.noElementAE = ConfigManager.getConfig(BindCommandConfig.class).NoElementMessageAE;
this.noSubElement = ConfigManager.getConfig(BindCommandConfig.class).NoSubElementMessage;
this.unbindable = ConfigManager.getConfig(BindCommandConfig.class).UnbindableMessage;
this.abilityDoesntExist = config.AbilityDoesntExistMessage;
this.wrongNumber = config.WrongNumberMessage;
this.loadingInfo = config.LoadingInfoMessage;
this.toggledElementOff = config.ElementToggledOffMessage;
this.noElement = config.NoElementMessage;
this.noElementAE = config.NoElementMessageAE;
this.noSubElement = config.NoSubElementMessage;
this.unbindable = config.UnbindableMessage;
}
@Override

View file

@ -6,25 +6,25 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CheckCommandConfig;
/**
* Executor for /bending check. Extends {@link PKCommand}.
*/
public class CheckCommand extends PKCommand {
public class CheckCommand extends PKCommand<CheckCommandConfig> {
private final String newVersionAvailable;
private final String curVersion;
private final String newVersion;
private final String upToDate;
public CheckCommand() {
super("check", "/bending check", ConfigManager.languageConfig.get().getString("Commands.Check.Description"), new String[] { "check", "chk" });
public CheckCommand(final CheckCommandConfig config) {
super(config, "check", "/bending check", config.Description, new String[] { "check", "chk" });
this.newVersionAvailable = ConfigManager.languageConfig.get().getString("Commands.Check.NewVersionAvailable");
this.curVersion = ConfigManager.languageConfig.get().getString("Commands.Check.CurrentVersion");
this.newVersion = ConfigManager.languageConfig.get().getString("Commands.Check.LatestVersion");
this.upToDate = ConfigManager.languageConfig.get().getString("Commands.Check.UpToDate");
this.newVersionAvailable = config.NewVersionAvailable;
this.curVersion = config.CurrentVersion;
this.newVersion = config.LatestVersion;
this.upToDate = config.UpToDate;
}
@Override

View file

@ -14,7 +14,10 @@ import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ChooseCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
@ -23,7 +26,7 @@ import com.projectkorra.projectkorra.util.TimeUtil;
/**
* Executor for /bending choose. Extends {@link PKCommand}.
*/
public class ChooseCommand extends PKCommand {
public class ChooseCommand extends PKCommand<ChooseCommandConfig> {
private final String invalidElement;
private final String playerNotFound;
@ -34,17 +37,17 @@ public class ChooseCommand extends PKCommand {
private final String chosenOtherAE;
private final long cooldown;
public ChooseCommand() {
super("choose", "/bending choose <Element> [Player]", ConfigManager.languageConfig.get().getString("Commands.Choose.Description"), new String[] { "choose", "ch" });
public ChooseCommand(final ChooseCommandConfig config) {
super(config, "choose", "/bending choose <Element> [Player]", config.Description, new String[] { "choose", "ch" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Choose.PlayerNotFound");
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Choose.InvalidElement");
this.onCooldown = ConfigManager.languageConfig.get().getString("Commands.Choose.OnCooldown");
this.chosenCFW = ConfigManager.languageConfig.get().getString("Commands.Choose.SuccessfullyChosenCFW");
this.chosenAE = ConfigManager.languageConfig.get().getString("Commands.Choose.SuccessfullyChosenAE");
this.chosenOtherCFW = ConfigManager.languageConfig.get().getString("Commands.Choose.Other.SuccessfullyChosenCFW");
this.chosenOtherAE = ConfigManager.languageConfig.get().getString("Commands.Choose.Other.SuccessfullyChosenAE");
this.cooldown = ConfigManager.defaultConfig.get().getLong("Properties.ChooseCooldown");
this.playerNotFound = config.PlayerNotFound;
this.invalidElement = config.InvalidElement;
this.onCooldown = config.OnCooldown;
this.chosenCFW = config.SuccessfullyChosenCFW;
this.chosenAE = config.SuccessfullyChosenAE;
this.chosenOtherCFW = config.SuccessfullyChosenCFW_Other;
this.chosenOtherAE = config.SuccessfullyChosenAE_Other;
this.cooldown = ConfigManager.getConfig(GeneralPropertiesConfig.class).ChooseCooldown;
}
@Override
@ -62,7 +65,7 @@ public class ChooseCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
}
if (bPlayer.isPermaRemoved()) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved);
return;
}
if (!bPlayer.getElements().isEmpty() && !sender.hasPermission("bending.command.rechoose")) {

View file

@ -11,12 +11,12 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ClearCommandConfig;
/**
* Executor for /bending clear. Extends {@link PKCommand}.
*/
public class ClearCommand extends PKCommand {
public class ClearCommand extends PKCommand<ClearCommandConfig> {
private final String cantEditBinds;
private final String cleared;
@ -24,14 +24,14 @@ public class ClearCommand extends PKCommand {
private final String clearedSlot;
private final String alreadyEmpty;
public ClearCommand() {
super("clear", "/bending clear [Slot]", ConfigManager.languageConfig.get().getString("Commands.Clear.Description"), new String[] { "clear", "cl", "c" });
public ClearCommand(final ClearCommandConfig config) {
super(config, "clear", "/bending clear [Slot]", config.Description, new String[] { "clear", "cl", "c" });
this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Clear.CantEditBinds");
this.cleared = ConfigManager.languageConfig.get().getString("Commands.Clear.Cleared");
this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Clear.WrongNumber");
this.clearedSlot = ConfigManager.languageConfig.get().getString("Commands.Clear.ClearedSlot");
this.alreadyEmpty = ConfigManager.languageConfig.get().getString("Commands.Clear.AlreadyEmpty");
this.cantEditBinds = config.CantEditBinds;
this.cleared = config.Cleared;
this.wrongNumber = config.WrongNumber;
this.clearedSlot = config.ClearedSlot;
this.alreadyEmpty = config.AlreadyEmpty;
}
@Override

View file

@ -10,7 +10,27 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.AddCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.BindCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CheckCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ChooseCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ClearCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CopyCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.DebugCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.DisplayCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.HelpCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.InvincibleCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.PermaremoveCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.PresetCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ReloadCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.RemoveCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.StatsCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ToggleCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.VersionCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.commands.WhoCommandConfig;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Commands {
private final ProjectKorra plugin;
@ -77,24 +97,24 @@ public class Commands {
/**
* Set of all of the Classes which extend Command
*/
new AddCommand();
new BindCommand();
new CheckCommand();
new ChooseCommand();
new ClearCommand();
new CopyCommand();
new DebugCommand();
new DisplayCommand();
new HelpCommand();
new InvincibleCommand();
new PermaremoveCommand();
new PresetCommand();
new ReloadCommand();
new RemoveCommand();
new StatsCommand();
new ToggleCommand();
new VersionCommand();
new WhoCommand();
new AddCommand(ConfigManager.getConfig(AddCommandConfig.class));
new BindCommand(ConfigManager.getConfig(BindCommandConfig.class));
new CheckCommand(ConfigManager.getConfig(CheckCommandConfig.class));
new ChooseCommand(ConfigManager.getConfig(ChooseCommandConfig.class));
new ClearCommand(ConfigManager.getConfig(ClearCommandConfig.class));
new CopyCommand(ConfigManager.getConfig(CopyCommandConfig.class));
new DebugCommand(ConfigManager.getConfig(DebugCommandConfig.class));
new DisplayCommand(ConfigManager.getConfig(DisplayCommandConfig.class));
new HelpCommand(ConfigManager.getConfig(HelpCommandConfig.class));
new InvincibleCommand(ConfigManager.getConfig(InvincibleCommandConfig.class));
new PermaremoveCommand(ConfigManager.getConfig(PermaremoveCommandConfig.class));
new PresetCommand(ConfigManager.getConfig(PresetCommandConfig.class));
new ReloadCommand(ConfigManager.getConfig(ReloadCommandConfig.class));
new RemoveCommand(ConfigManager.getConfig(RemoveCommandConfig.class));
new StatsCommand(ConfigManager.getConfig(StatsCommandConfig.class));
new ToggleCommand(ConfigManager.getConfig(ToggleCommandConfig.class));
new VersionCommand(ConfigManager.getConfig(VersionCommandConfig.class));
new WhoCommand(ConfigManager.getConfig(WhoCommandConfig.class));
final CommandExecutor exe = (s, c, label, args) -> {
if (Arrays.asList(commandaliases).contains(label.toLowerCase())) {

View file

@ -13,22 +13,25 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CopyCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
public class CopyCommand extends PKCommand {
@SuppressWarnings({ "rawtypes", "unchecked" })
public class CopyCommand extends PKCommand<CopyCommandConfig> {
private final String playerNotFound;
private final String copied;
private final String failedToBindAll;
private final String copiedOther;
public CopyCommand() {
super("copy", "/bending copy <Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Copy.Description"), new String[] { "copy", "co" });
public CopyCommand(final CopyCommandConfig config) {
super(config, "copy", "/bending copy <Player> [Player]", config.Description, new String[] { "copy", "co" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Copy.PlayerNotFound");
this.copied = ConfigManager.languageConfig.get().getString("Commands.Copy.SuccessfullyCopied");
this.failedToBindAll = ConfigManager.languageConfig.get().getString("Commands.Copy.FailedToBindAll");
this.copiedOther = ConfigManager.languageConfig.get().getString("Commands.Copy.Other.SuccessfullyCopied");
this.playerNotFound = config.PlayerNotFound;
this.copied = config.SuccessfullyCopied;
this.failedToBindAll = config.FailedToBindAll;
this.copiedOther = config.SuccessfullyCopied_Other;
}
@Override
@ -90,9 +93,9 @@ public class CopyCommand extends PKCommand {
}
if (orig.isPermaRemoved()) {
if (self) {
GeneralMethods.sendBrandingMessage(player, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved"));
GeneralMethods.sendBrandingMessage(player, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved);
} else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other);
}
return false;
}

View file

@ -6,15 +6,15 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.DebugCommandConfig;
/**
* Executor for /bending debug. Extends {@link PKCommand}.
*/
public class DebugCommand extends PKCommand {
public class DebugCommand extends PKCommand<DebugCommandConfig> {
public DebugCommand() {
super("debug", "/bending debug", ConfigManager.languageConfig.get().getString("Commands.Debug.Description"), new String[] { "debug", "de" });
public DebugCommand(final DebugCommandConfig config) {
super(config, "debug", "/bending debug", config.Description, new String[] { "debug", "de" });
}
@Override
@ -27,7 +27,7 @@ public class DebugCommand extends PKCommand {
}
GeneralMethods.runDebug();
sender.sendMessage(ChatColor.GREEN + ConfigManager.languageConfig.get().getString("Commands.Debug.SuccessfullyExported"));
sender.sendMessage(ChatColor.GREEN + config.SuccessfullyExported);
}
/**

View file

@ -20,12 +20,15 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.SubAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.DisplayCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
/**
* Executor for /bending display. Extends {@link PKCommand}.
*/
public class DisplayCommand extends PKCommand {
@SuppressWarnings("rawtypes")
public class DisplayCommand extends PKCommand<DisplayCommandConfig> {
private final String noCombosAvailable;
private final String noPassivesAvailable;
@ -34,15 +37,15 @@ public class DisplayCommand extends PKCommand {
private final String noAbilitiesAvailable;
private final String noBinds;
public DisplayCommand() {
super("display", "/bending display <Element>", ConfigManager.languageConfig.get().getString("Commands.Display.Description"), new String[] { "display", "dis", "d" });
public DisplayCommand(final DisplayCommandConfig config) {
super(config, "display", "/bending display <Element>", config.Description, new String[] { "display", "dis", "d" });
this.noCombosAvailable = ConfigManager.languageConfig.get().getString("Commands.Display.NoCombosAvailable");
this.noPassivesAvailable = ConfigManager.languageConfig.get().getString("Commands.Display.NoPassivesAvailable");
this.noAbilitiesAvailable = ConfigManager.languageConfig.get().getString("Commands.Display.NoAbilitiesAvailable");
this.invalidArgument = ConfigManager.languageConfig.get().getString("Commands.Display.InvalidArgument");
this.playersOnly = ConfigManager.languageConfig.get().getString("Commands.Display.PlayersOnly");
this.noBinds = ConfigManager.languageConfig.get().getString("Commands.Display.NoBinds");
this.noCombosAvailable = config.NoCombosAvailable;
this.noPassivesAvailable = config.NoPassivesAvailable;
this.noAbilitiesAvailable = config.NoAbilitiesAvailable;
this.invalidArgument = config.InvalidArgument;
this.playersOnly = ConfigManager.getConfig(CommandPropertiesConfig.class).MustBePlayer;
this.noBinds = config.NoBinds;
}
@Override

View file

@ -16,12 +16,20 @@ import com.projectkorra.projectkorra.ability.ComboAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.HelpCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.AirPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.AvatarPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.ChiPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.EarthPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.FirePropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig;
/**
* Executor for /bending help. Extends {@link PKCommand}.
*/
public class HelpCommand extends PKCommand {
@SuppressWarnings("rawtypes")
public class HelpCommand extends PKCommand<HelpCommandConfig> {
private final String required;
private final String optional;
@ -39,24 +47,24 @@ public class HelpCommand extends PKCommand {
private final String spiritsUsage;
private final String itemsUsage;
public HelpCommand() {
super("help", "/bending help <Page/Topic>", ConfigManager.languageConfig.get().getString("Commands.Help.Description"), new String[] { "help", "h" });
public HelpCommand(final HelpCommandConfig config) {
super(config, "help", "/bending help <Page/Topic>", config.Description, new String[] { "help", "h" });
this.required = ConfigManager.languageConfig.get().getString("Commands.Help.Required");
this.optional = ConfigManager.languageConfig.get().getString("Commands.Help.Optional");
this.properUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ProperUsage");
this.learnMore = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.LearnMore");
this.air = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Air");
this.water = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Water");
this.earth = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Earth");
this.fire = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Fire");
this.chi = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Chi");
this.avatar = ConfigManager.languageConfig.get().getString("Commands.Help.Elements.Avatar");
this.invalidTopic = ConfigManager.languageConfig.get().getString("Commands.Help.InvalidTopic");
this.usage = ConfigManager.languageConfig.get().getString("Commands.Help.Usage");
this.rpgUsage = ConfigManager.languageConfig.get().getString("Command.Help.RPGUsage");
this.spiritsUsage = ConfigManager.languageConfig.get().getString("Commands.Help.SpiritsUsage");
this.itemsUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ItemsUsage");
this.required = config.Required;
this.optional = config.Optional;
this.properUsage = config.ProperUsage;
this.learnMore = config.LearnMore;
this.air = ConfigManager.getConfig(AirPropertiesConfig.class).Description;
this.water = ConfigManager.getConfig(WaterPropertiesConfig.class).Description;
this.earth = ConfigManager.getConfig(EarthPropertiesConfig.class).Description;
this.fire = ConfigManager.getConfig(FirePropertiesConfig.class).Description;
this.chi = ConfigManager.getConfig(ChiPropertiesConfig.class).Description;
this.avatar = ConfigManager.getConfig(AvatarPropertiesConfig.class).Description;
this.invalidTopic = config.InvalidTopic;
this.usage = config.Usage;
this.rpgUsage = config.RPGUsage;
this.spiritsUsage = config.SpiritsUsage;
this.itemsUsage = config.ItemsUsage;
}
@Override

View file

@ -6,15 +6,15 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.InvincibleCommandConfig;
/**
* Executor for /bending invincible. Extends {@link PKCommand}.
*/
public class InvincibleCommand extends PKCommand {
public class InvincibleCommand extends PKCommand<InvincibleCommandConfig> {
public InvincibleCommand() {
super("invincible", "/bending invincible", ConfigManager.languageConfig.get().getString("Commands.Invincible.Description"), new String[] { "invincible", "inv", "i" });
public InvincibleCommand(final InvincibleCommandConfig config) {
super(config, "invincible", "/bending invincible", config.Description, new String[] { "invincible", "inv", "i" });
}
@ -26,10 +26,10 @@ public class InvincibleCommand extends PKCommand {
if (!Commands.invincible.contains(sender.getName())) {
Commands.invincible.add(sender.getName());
GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOn"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.GREEN + config.ToggledOn);
} else {
Commands.invincible.remove(sender.getName());
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Invincible.ToggledOff"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + config.ToggledOff);
}
}

View file

@ -14,15 +14,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
/**
* Abstract representation of a command executor. Implements {@link SubCommand}.
*
* @author kingbirdy
*
*/
public abstract class PKCommand implements SubCommand {
@SuppressWarnings("rawtypes")
public abstract class PKCommand<C extends CommandConfig> implements SubCommand<C> {
protected String noPermissionMessage, mustBePlayerMessage;
@ -43,19 +45,25 @@ public abstract class PKCommand implements SubCommand {
* String[] of all possible aliases of the command.
*/
private final String[] aliases;
/**
* Language config of the command
*/
protected final C config;
/**
* List of all command executors which extends PKCommand
*/
public static Map<String, PKCommand> instances = new HashMap<String, PKCommand>();
public PKCommand(final String name, final String properUse, final String description, final String[] aliases) {
public PKCommand(final C config, final String name, final String properUse, final String description, final String[] aliases) {
this.name = name;
this.properUse = properUse;
this.description = description;
this.aliases = aliases;
this.config = config;
this.noPermissionMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.NoPermission");
this.mustBePlayerMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.MustBePlayer");
CommandPropertiesConfig properties = ConfigManager.getConfig(CommandPropertiesConfig.class);
this.noPermissionMessage = ChatColor.RED + properties.NoPermission;
this.mustBePlayerMessage = ChatColor.RED + properties.MustBePlayer;
instances.put(name, this);
}
@ -79,6 +87,11 @@ public abstract class PKCommand implements SubCommand {
public String[] getAliases() {
return this.aliases;
}
@Override
public C getLanguageConfig() {
return this.config;
}
@Override
public void help(final CommandSender sender, final boolean description) {

View file

@ -10,14 +10,14 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.PermaremoveCommandConfig;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
/**
* Executor for /bending permaremove. Extends {@link PKCommand}.
*/
public class PermaremoveCommand extends PKCommand {
public class PermaremoveCommand extends PKCommand<PermaremoveCommandConfig> {
private final String playerIsOffline;
private final String restored;
@ -25,14 +25,14 @@ public class PermaremoveCommand extends PKCommand {
private final String removed;
private final String removedConfirm;
public PermaremoveCommand() {
super("permaremove", "/bending permaremove <Player>", ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Description"), new String[] { "permaremove", "premove", "permremove", "pr" });
public PermaremoveCommand(final PermaremoveCommandConfig config) {
super(config, "permaremove", "/bending permaremove <Player>", config.Description, new String[] { "permaremove", "premove", "permremove", "pr" });
this.playerIsOffline = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.PlayerOffline");
this.restored = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Restored");
this.restoredConfirm = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.RestoredConfirm");
this.removed = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Removed");
this.removedConfirm = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.RemovedConfirm");
this.playerIsOffline = config.PlayerOffline;
this.restored = config.Restored;
this.restoredConfirm = config.Restored_Other;
this.removed = config.Removed;
this.removedConfirm = config.Removed_Other;
}
@Override

View file

@ -2,7 +2,6 @@ package com.projectkorra.projectkorra.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
@ -13,13 +12,15 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.util.MultiAbilityManager;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.PresetCommandConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.CommandPropertiesConfig;
import com.projectkorra.projectkorra.object.Preset;
/**
* Executor for /bending preset. Extends {@link PKCommand}.
*/
public class PresetCommand extends PKCommand {
public class PresetCommand extends PKCommand<PresetCommandConfig> {
private static final String[] createaliases = { "create", "c", "save" };
private static final String[] deletealiases = { "delete", "d", "del" };
@ -41,23 +42,23 @@ public class PresetCommand extends PKCommand {
private final String createdNewPreset;
private final String cantEditBinds;
public PresetCommand() {
super("preset", "/bending preset <Bind/Create/Delete/List> [Preset]", ConfigManager.languageConfig.get().getString("Commands.Preset.Description"), new String[] { "preset", "presets", "pre", "set", "p" });
public PresetCommand(final PresetCommandConfig config) {
super(config, "preset", "/bending preset <Bind/Create/Delete/List> [Preset]", config.Description, new String[] { "preset", "presets", "pre", "set", "p" });
this.noPresets = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresets");
this.noPresetName = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresetName");
this.deletePreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Delete");
this.noPresetNameExternal = ConfigManager.languageConfig.get().getString("Commands.Preset.External.NoPresetName");
this.bendingRemoved = ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved");
this.bound = ConfigManager.languageConfig.get().getString("Commands.Preset.SuccesfullyBound");
this.failedToBindAll = ConfigManager.languageConfig.get().getString("Commands.Preset.FailedToBindAll");
this.bendingRemovedOther = ConfigManager.languageConfig.get().getString("Commands.Preset.Other.BendingPermanentlyRemoved");
this.boundOtherConfirm = ConfigManager.languageConfig.get().getString("Commands.Preset.Other.SuccesfullyBoundConfirm");
this.succesfullyCopied = ConfigManager.languageConfig.get().getString("Commands.Preset.SuccesfullyCopied");
this.reachedMax = ConfigManager.languageConfig.get().getString("Commands.Preset.MaxPresets");
this.alreadyExists = ConfigManager.languageConfig.get().getString("Commands.Preset.AlreadyExists");
this.createdNewPreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Created");
this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Preset.CantEditBinds");
this.noPresets = config.NoPresets;
this.noPresetName = config.NoPresetName;
this.deletePreset = config.Delete;
this.noPresetNameExternal = config.NoPresetName_External;
this.bendingRemoved = ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved;
this.bound = config.SuccessfullyBound;
this.failedToBindAll = config.FailedToBindAll;
this.bendingRemovedOther = ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other;
this.boundOtherConfirm = config.SuccessfullyBound_Other;
this.succesfullyCopied = config.SuccessfullyCopied;
this.reachedMax = config.MaxPresets;
this.alreadyExists = config.AlreadyExists;
this.createdNewPreset = config.Created;
this.cantEditBinds = config.CantEditBinds;
}
@Override
@ -173,7 +174,7 @@ public class PresetCommand extends PKCommand {
}
return;
} else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + config.PlayerNotFound);
}
} else if (this.hasPermission(sender, "bind.assign") && Preset.presetExists(player, name)) {
if (!Preset.presetExists(player, name)) {
@ -203,7 +204,7 @@ public class PresetCommand extends PKCommand {
}
return;
} else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.PlayerNotFound"));
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + config.PlayerNotFound);
}
}
} else if (Arrays.asList(createaliases).contains(args.get(0)) && this.hasPermission(sender, "create")) { // bending preset create name.

View file

@ -6,15 +6,15 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ReloadCommandConfig;
/**
* Executor for /bending reload. Extends {@link PKCommand}.
*/
public class ReloadCommand extends PKCommand {
public class ReloadCommand extends PKCommand<ReloadCommandConfig> {
public ReloadCommand() {
super("reload", "/bending reload", ConfigManager.languageConfig.get().getString("Commands.Reload.Description"), new String[] { "reload", "r" });
public ReloadCommand(final ReloadCommandConfig config) {
super(config, "reload", "/bending reload", config.Description, new String[] { "reload", "r" });
}
@Override
@ -23,7 +23,7 @@ public class ReloadCommand extends PKCommand {
return;
}
GeneralMethods.reloadPlugin(sender);
sender.sendMessage(ChatColor.AQUA + ConfigManager.languageConfig.get().getString("Commands.Reload.SuccessfullyReloaded"));
sender.sendMessage(ChatColor.AQUA + config.SuccessfullyReloaded);
}
}

View file

@ -12,7 +12,7 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.RemoveCommandConfig;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
@ -20,22 +20,22 @@ import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
/**
* Executor for /bending remove. Extends {@link PKCommand}.
*/
public class RemoveCommand extends PKCommand {
public class RemoveCommand extends PKCommand<RemoveCommandConfig> {
private final String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline, wrongElementTarget, succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget, succesfullyRemovedAllElementsTargetConfirm;
public RemoveCommand() {
super("remove", "/bending remove <Player> [Element]", ConfigManager.languageConfig.get().getString("Commands.Remove.Description"), new String[] { "remove", "rm" });
public RemoveCommand(final RemoveCommandConfig config) {
super(config, "remove", "/bending remove <Player> [Element]", config.Description, new String[] { "remove", "rm" });
this.succesfullyRemovedElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.RemovedElement");
this.succesfullyRemovedAllElementsTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedAllElements");
this.succesfullyRemovedAllElementsTargetConfirm = ConfigManager.languageConfig.get().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.wrongElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.WrongElement");
this.wrongElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.WrongElement");
this.playerOffline = ConfigManager.languageConfig.get().getString("Commands.Remove.PlayerOffline");
this.succesfullyRemovedElementSelf = config.RemovedElement;
this.succesfullyRemovedAllElementsTarget = config.RemovedAllElements_ByOther;
this.succesfullyRemovedAllElementsTargetConfirm = config.RemovedAllElements_Other;
this.succesfullyRemovedElementTarget = config.RemovedElement_ByOther;
this.succesfullyRemovedElementTargetConfirm = config.RemovedAllElements_Other;
this.invalidElement = config.InvalidElement;
this.wrongElementSelf = config.WrongElement;
this.wrongElementTarget = config.WrongElement_Other;
this.playerOffline = config.PlayerOffline;
}
@Override

View file

@ -20,12 +20,13 @@ import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.StatsCommandConfig;
import com.projectkorra.projectkorra.storage.DBConnection;
import com.projectkorra.projectkorra.util.Statistic;
import com.projectkorra.projectkorra.util.StatisticsMethods;
public class StatsCommand extends PKCommand {
@SuppressWarnings("rawtypes")
public class StatsCommand extends PKCommand<StatsCommandConfig> {
private static final String[] getaliases = { "get", "g" };
private static final String[] leaderboardaliases = { "leaderboard", "lb", "l" };
@ -35,13 +36,13 @@ public class StatsCommand extends PKCommand {
private final String invalidStatistic;
private final String invalidPlayer;
public StatsCommand() {
super("stats", "/bending stats <get/leaderboard> <ability/element/all> <statistic> [player/page]", ConfigManager.languageConfig.get().getString("Commands.Stats.Description"), new String[] { "statistics", "stats" });
public StatsCommand(final StatsCommandConfig config) {
super(config, "stats", "/bending stats <get/leaderboard> <ability/element/all> <statistic> [player/page]", config.Description, new String[] { "statistics", "stats" });
this.invalidLookup = ConfigManager.languageConfig.get().getString("Commands.Stats.InvalidLookup");
this.invalidSearchType = ConfigManager.languageConfig.get().getString("Commands.Stats.InvalidSearchType");
this.invalidStatistic = ConfigManager.languageConfig.get().getString("Commands.Stats.InvalidStatistic");
this.invalidPlayer = ConfigManager.languageConfig.get().getString("Commands.Stats.InvalidPlayer");
this.invalidLookup = config.InvalidLookup;
this.invalidSearchType = config.InvalidSearchType;
this.invalidStatistic = config.InvalidStatistic;
this.invalidPlayer = config.InvalidPlayer;
}
@Override

View file

@ -4,10 +4,12 @@ import java.util.List;
import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.configuration.better.configs.commands.CommandConfig;
/**
* Interface representation of a command executor.
*/
public interface SubCommand {
public interface SubCommand<C extends CommandConfig> {
/**
* Gets the name of the command.
*
@ -36,6 +38,12 @@ public interface SubCommand {
* @return the description
*/
public String getDescription();
/**
* Gets the language config of the command.
* @return the config
*/
public C getLanguageConfig();
/**
* Outputs the correct usage, and optionally the description, of a command

View file

@ -7,41 +7,38 @@ import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.ToggleCommandConfig;
/**
* Executor for /bending toggle. Extends {@link PKCommand}.
*/
public class ToggleCommand extends PKCommand {
public class ToggleCommand extends PKCommand<ToggleCommandConfig> {
private final String toggledOffForAll, toggleOffSelf, toggleOnSelf, toggleOffAll, toggleOnAll, toggledOffSingleElement, toggledOnSingleElement, wrongElementOther, toggledOnOtherElementConfirm, toggledOffOtherElementConfirm, toggledOnOtherElement, toggledOffOtherElement, wrongElement, notFound;
public ToggleCommand() {
super("toggle", "/bending toggle <All/Element/Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Toggle.Description"), new String[] { "toggle", "t" });
public ToggleCommand(final ToggleCommandConfig config) {
super(config, "toggle", "/bending toggle <All/Element/Player> [Player]", config.Description, new String[] { "toggle", "t" });
final FileConfiguration c = ConfigManager.languageConfig.get();
this.toggledOffForAll = c.getString("Commands.Toggle.All.ToggledOffForAll");
this.toggleOffSelf = c.getString("Commands.Toggle.ToggledOff");
this.toggleOnSelf = c.getString("Commands.Toggle.ToggledOn");
this.toggleOffAll = c.getString("Commands.Toggle.All.ToggleOff");
this.toggleOnAll = c.getString("Commands.Toggle.All.ToggleOn");
this.toggledOffSingleElement = c.getString("Commands.Toggle.ToggleOffSingleElement");
this.toggledOnSingleElement = c.getString("Commands.Toggle.ToggleOnSingleElement");
this.wrongElementOther = c.getString("Commands.Toggle.Other.WrongElement");
this.toggledOnOtherElementConfirm = c.getString("Commands.Toggle.Other.ToggledOnElementConfirm");
this.toggledOffOtherElementConfirm = c.getString("Commands.Toggle.Other.ToggledOffElementConfirm");
this.toggledOnOtherElement = c.getString("Commands.Toggle.Other.ToggledOnElementByOther");
this.toggledOffOtherElement = c.getString("Commands.Toggle.Other.ToggledOffElementByOther");
this.wrongElement = c.getString("Commands.Toggle.WrongElement");
this.notFound = c.getString("Commands.Toggle.Other.PlayerNotFound");
this.toggledOffForAll = config.ToggledOffForAll;
this.toggleOffSelf = config.ToggledOff;
this.toggleOnSelf = config.ToggledOn;
this.toggleOffAll = config.ToggledOff_All;
this.toggleOnAll = config.ToggledOn_All;
this.toggledOffSingleElement = config.ToggledOffSingleElement;
this.toggledOnSingleElement = config.ToggledOnSingleElement;
this.wrongElementOther = config.WrongElement_Other;
this.toggledOnOtherElementConfirm = config.ToggledOn_Other;
this.toggledOffOtherElementConfirm = config.ToggledOff_Other;
this.toggledOnOtherElement = config.ToggledOn_ByOther;
this.toggledOffOtherElement = config.ToggledOff_ByOther;
this.wrongElement = config.WrongElement;
this.notFound = config.PlayerNotFound;
}
@Override

View file

@ -7,15 +7,15 @@ import org.bukkit.command.CommandSender;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.VersionCommandConfig;
/**
* Executor for /bending version. Extends {@link PKCommand}.
*/
public class VersionCommand extends PKCommand {
public class VersionCommand extends PKCommand<VersionCommandConfig> {
public VersionCommand() {
super("version", "/bending version", ConfigManager.languageConfig.get().getString("Commands.Version.Description"), new String[] { "version", "v" });
public VersionCommand(final VersionCommandConfig config) {
super(config, "version", "/bending version", config.Description, new String[] { "version", "v" });
}
@Override

View file

@ -9,6 +9,7 @@ import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -28,25 +29,26 @@ import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.commands.WhoCommandConfig;
/**
* Executor for /bending who. Extends {@link PKCommand}.
*/
public class WhoCommand extends PKCommand {
@SuppressWarnings({ "rawtypes", "deprecation" })
public class WhoCommand extends PKCommand<WhoCommandConfig> {
/**
* Map storage of all ProjectKorra staffs' UUIDs and titles
*/
final Map<String, String> staff = new HashMap<>();
final Map<String, String> staff = Collections.synchronizedMap(new HashMap<>());
private final String databaseOverload, noPlayersOnline, playerOffline;
public WhoCommand() {
super("who", "/bending who [Page/Player]", ConfigManager.languageConfig.get().getString("Commands.Who.Description"), new String[] { "who", "w" });
public WhoCommand(final WhoCommandConfig config) {
super(config, "who", "/bending who [Page/Player]", config.Description, new String[] { "who", "w" });
this.databaseOverload = ConfigManager.languageConfig.get().getString("Commands.Who.DatabaseOverload");
this.noPlayersOnline = ConfigManager.languageConfig.get().getString("Commands.Who.NoPlayersOnline");
this.playerOffline = ConfigManager.languageConfig.get().getString("Commands.Who.PlayerOffline");
this.databaseOverload = config.DatabaseOverload;
this.noPlayersOnline = config.NoPlayersOnline;
this.playerOffline = config.PlayerOffline;
new BukkitRunnable() {
@Override

View file

@ -0,0 +1,29 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class AddCommandConfig extends CommandConfig {
public final String PlayerNotFound = "";
public final String InvalidElement = "";
public final String SuccessfullyAddedCFW_Other = "";
public final String SuccessfullyAddedCFW = "";
public final String SuccessfullyAddedAE_Other = "";
public final String SuccessfullyAddedAE = "";
public final String SuccessfullyAddedAll_Other = "";
public final String SuccessfullyAddedAll = "";
public final String AlreadyHasElement_Other = "";
public final String AlreadyHasElement = "";
public final String AlreadyHasSubElement_Other = "";
public final String AlreadyHasSubElement = "";
public final String AlreadyHasAllElements_Other = "";
public final String AlreadyHasAllElements = "";
public AddCommandConfig() {
super("");
}
@Override
public String getName() {
return "Add";
}
}

View file

@ -1,10 +1,7 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
import com.projectkorra.projectkorra.configuration.better.Config;
public class BindCommandConfig extends CommandConfig {
public class BindCommandConfig implements Config {
public final String Description = "";
public final String SuccessfullyBoundMessage = "";
public final String AbilityDoesntExistMessage = "";
public final String WrongNumberMessage = "";
@ -15,14 +12,13 @@ public class BindCommandConfig implements Config {
public final String NoSubElementMessage = "";
public final String UnbindableMessage = "";
public BindCommandConfig() {
super("");
}
@Override
public String getName() {
return "Bind";
}
@Override
public String[] getParents() {
return new String[] { "Commands" };
}
}

View file

@ -0,0 +1,19 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class CheckCommandConfig extends CommandConfig {
public final String NewVersionAvailable = "";
public final String CurrentVersion = "";
public final String LatestVersion = "";
public final String UpToDate = "";
public CheckCommandConfig() {
super("");
}
@Override
public String getName() {
return "Check";
}
}

View file

@ -0,0 +1,22 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class ChooseCommandConfig extends CommandConfig {
public final String PlayerNotFound = "";
public final String InvalidElement = "";
public final String OnCooldown = "";
public final String SuccessfullyChosenCFW_Other = "";
public final String SuccessfullyChosenCFW = "";
public final String SuccessfullyChosenAE_Other = "";
public final String SuccessfullyChosenAE = "";
public ChooseCommandConfig() {
super("");
}
@Override
public String getName() {
return "Choose";
}
}

View file

@ -0,0 +1,20 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class ClearCommandConfig extends CommandConfig {
public final String CantEditBinds = "";
public final String Cleared = "";
public final String WrongNumber = "";
public final String ClearedSlot = "";
public final String AlreadyEmpty = "";
public ClearCommandConfig() {
super("");
}
@Override
public String getName() {
return "Clear";
}
}

View file

@ -0,0 +1,18 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
import com.projectkorra.projectkorra.configuration.better.Config;
public abstract class CommandConfig implements Config {
public final String Description;
public CommandConfig(String description) {
Description = description;
}
@Override
public String[] getParents() {
return new String[] { "Commands" };
}
}

View file

@ -0,0 +1,19 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class CopyCommandConfig extends CommandConfig {
public final String PlayerNotFound = "";
public final String SuccessfullyCopied = "";
public final String SuccessfullyCopied_Other = "";
public final String FailedToBindAll = "";
public CopyCommandConfig() {
super("");
}
@Override
public String getName() {
return "Copy";
}
}

View file

@ -0,0 +1,16 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class DebugCommandConfig extends CommandConfig {
public final String SuccessfullyExported = "";
public DebugCommandConfig() {
super("");
}
@Override
public String getName() {
return "Debug";
}
}

View file

@ -0,0 +1,20 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class DisplayCommandConfig extends CommandConfig {
public final String NoCombosAvailable = "";
public final String NoPassivesAvailable = "";
public final String NoAbilitiesAvailable = "";
public final String InvalidArgument = "";
public final String NoBinds = "";
public DisplayCommandConfig() {
super("");
}
@Override
public String getName() {
return "Display";
}
}

View file

@ -0,0 +1,24 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class HelpCommandConfig extends CommandConfig {
public final String Required = "";
public final String Optional = "";
public final String ProperUsage = "";
public final String LearnMore = "";
public final String InvalidTopic = "";
public final String Usage = "";
public final String RPGUsage = "";
public final String SpiritsUsage = "";
public final String ItemsUsage = "";
public HelpCommandConfig() {
super("");
}
@Override
public String getName() {
return "Help";
}
}

View file

@ -0,0 +1,17 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class InvincibleCommandConfig extends CommandConfig {
public final String ToggledOn = "";
public final String ToggledOff = "";
public InvincibleCommandConfig() {
super("");
}
@Override
public String getName() {
return "Invincible";
}
}

View file

@ -0,0 +1,20 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class PermaremoveCommandConfig extends CommandConfig {
public final String PlayerOffline = "";
public final String Restored = "";
public final String Restored_Other = "";
public final String Removed = "";
public final String Removed_Other = "";
public PermaremoveCommandConfig() {
super("");
}
@Override
public String getName() {
return "Permaremove";
}
}

View file

@ -0,0 +1,28 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class PresetCommandConfig extends CommandConfig {
public final String NoPresets = "";
public final String NoPresetName = "";
public final String NoPresetName_External = "";
public final String Delete = "";
public final String SuccessfullyBound = "";
public final String SuccessfullyBound_Other = "";
public final String FailedToBindAll = "";
public final String SuccessfullyCopied = "";
public final String MaxPresets = "";
public final String AlreadyExists = "";
public final String Created = "";
public final String CantEditBinds = "";
public final String PlayerNotFound = "";
public PresetCommandConfig() {
super("");
}
@Override
public String getName() {
return "Preset";
}
}

View file

@ -0,0 +1,16 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class ReloadCommandConfig extends CommandConfig {
public final String SuccessfullyReloaded = "";
public ReloadCommandConfig() {
super("");
}
@Override
public String getName() {
return "Reload";
}
}

View file

@ -0,0 +1,24 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class RemoveCommandConfig extends CommandConfig {
public final String RemovedElement = "";
public final String RemovedElement_Other = "";
public final String RemovedElement_ByOther = "";
public final String RemovedAllElements_Other = "";
public final String RemovedAllElements_ByOther = "";
public final String InvalidElement = "";
public final String WrongElement = "";
public final String WrongElement_Other = "";
public final String PlayerOffline = "";
public RemoveCommandConfig() {
super("");
}
@Override
public String getName() {
return "Remove";
}
}

View file

@ -0,0 +1,19 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class StatsCommandConfig extends CommandConfig {
public final String InvalidLookup = "";
public final String InvalidSearchType = "";
public final String InvalidStatistic = "";
public final String InvalidPlayer = "";
public StatsCommandConfig() {
super("");
}
@Override
public String getName() {
return "Stats";
}
}

View file

@ -0,0 +1,33 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class ToggleCommandConfig extends CommandConfig {
public final String ToggledOn = "";
public final String ToggledOn_ByOther = "";
public final String ToggledOn_Other = "";
public final String ToggledOn_All = "";
public final String ToggledOff = "";
public final String ToggledOff_ByOther = "";
public final String ToggledOff_Other = "";
public final String ToggledOff_All = "";
public final String ToggledOffForAll = "";
public final String ToggledOffSingleElement = "";
public final String ToggledOffSingleElement_ByOther = "";
public final String ToggledOffSingleElement_Other = "";
public final String ToggledOnSingleElement = "";
public final String ToggledOnSingleElement_ByOther = "";
public final String ToggledOnSingleElement_Other = "";
public final String WrongElement = "";
public final String WrongElement_Other = "";
public final String PlayerNotFound = "";
public ToggleCommandConfig() {
super("");
}
@Override
public String getName() {
return "Toggle";
}
}

View file

@ -0,0 +1,14 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class VersionCommandConfig extends CommandConfig {
public VersionCommandConfig() {
super("");
}
@Override
public String getName() {
return "Version";
}
}

View file

@ -0,0 +1,18 @@
package com.projectkorra.projectkorra.configuration.better.configs.commands;
public class WhoCommandConfig extends CommandConfig {
public final String DatabaseOverload = "";
public final String NoPlayersOnline = "";
public final String PlayerOffline = "";
public WhoCommandConfig() {
super("");
}
@Override
public String getName() {
return "Who";
}
}

View file

@ -7,6 +7,8 @@ import com.projectkorra.projectkorra.util.ParticleEffect;
public class AirPropertiesConfig implements Config {
public final String Description = "";
public final ParticleEffect Particles = ParticleEffect.SPELL;
public final boolean PlaySound = true;

View file

@ -0,0 +1,19 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import com.projectkorra.projectkorra.configuration.better.Config;
public class AvatarPropertiesConfig implements Config {
public final String Description = "";
@Override
public String getName() {
return "Avatar";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -4,6 +4,8 @@ import com.projectkorra.projectkorra.configuration.better.Config;
public class ChiPropertiesConfig implements Config {
public final String Description = "";
public final double BlockChiChance = 0;
public final long BlockChiDuration = 0;

View file

@ -0,0 +1,23 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import com.projectkorra.projectkorra.configuration.better.Config;
public class CommandPropertiesConfig implements Config {
public final String NoPermission = "";
public final String MustBePlayer = "";
public final String BendingPermanentlyRemoved = "";
public final String BendingPermanentlyRemoved_Other = "";
@Override
public String getName() {
return "Command";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -7,6 +7,8 @@ import com.projectkorra.projectkorra.configuration.better.Config;
public class EarthPropertiesConfig implements Config {
public final String Description = "";
public final Material[] EarthBlocks = {};
public final boolean RevertEarthbending = true;

View file

@ -7,6 +7,8 @@ import com.projectkorra.projectkorra.util.ParticleEffect;
public class FirePropertiesConfig implements Config {
public final String Description = "";
public final boolean Griefing = true;
public final long RevertTicks = 0;
public final double DayFactor = 0;

View file

@ -18,6 +18,8 @@ public class GeneralPropertiesConfig implements Config {
public final long GlobalCooldown = 0;
public final long ChooseCooldown = 0;
public final boolean TogglePassivesWithAllBending = true;
public final int MaxPresets = 0;

View file

@ -7,6 +7,8 @@ import com.projectkorra.projectkorra.configuration.better.Config;
public class WaterPropertiesConfig implements Config {
public final String Description = "";
public final Material[] WaterBlocks = {};
public final double NightFactor = 0;

View file

@ -19,6 +19,7 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
* @author Simplicitee
*
*/
@SuppressWarnings("rawtypes")
public class MovementHandler {
public static Set<MovementHandler> handlers = new HashSet<>();

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.util;
import com.projectkorra.projectkorra.ability.CoreAbility;
@SuppressWarnings("rawtypes")
public enum Statistic {
PLAYER_KILLS("PlayerKills", "player kills"), PLAYER_DAMAGE("PlayerDamage", "player damage"), TOTAL_KILLS("TotalKills", "total kills"), TOTAL_DAMAGE("TotalDamage", "total damage");

View file

@ -18,6 +18,7 @@ import com.projectkorra.projectkorra.storage.DBConnection;
import com.projectkorra.projectkorra.storage.MySQL;
import com.projectkorra.projectkorra.storage.SQLite;
@SuppressWarnings("rawtypes")
public class StatisticsManager extends Manager implements Runnable {
/**

View file

@ -12,6 +12,7 @@ import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.storage.DBConnection;
@SuppressWarnings("rawtypes")
public class StatisticsMethods {
/**

View file

@ -17,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import com.projectkorra.projectkorra.ability.CoreAbility;
@SuppressWarnings("rawtypes")
public class TempArmor {
private static Map<LivingEntity, PriorityQueue<TempArmor>> INSTANCES = new ConcurrentHashMap<>();