mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-09-11 04:39:32 +00:00
commit
73834e3762
Binary file not shown.
Binary file not shown.
BIN
lib/Residence4.0.0.4.jar
Normal file
BIN
lib/Residence4.0.0.4.jar
Normal file
Binary file not shown.
|
@ -51,6 +51,7 @@ public class BendingPlayer {
|
|||
private String name;
|
||||
private ChiAbility stance;
|
||||
private ArrayList<Element> elements;
|
||||
private ArrayList<SubElement> subelements;
|
||||
private HashMap<Integer, String> abilities;
|
||||
private ConcurrentHashMap<String, Long> cooldowns;
|
||||
private ConcurrentHashMap<Element, Boolean> toggledElements;
|
||||
|
@ -64,11 +65,12 @@ public class BendingPlayer {
|
|||
* @param abilities The known abilities
|
||||
* @param permaRemoved The permanent removed status
|
||||
*/
|
||||
public BendingPlayer(UUID uuid, String playerName, ArrayList<Element> elements, HashMap<Integer, String> abilities,
|
||||
public BendingPlayer(UUID uuid, String playerName, ArrayList<Element> elements, ArrayList<SubElement> subelements, HashMap<Integer, String> abilities,
|
||||
boolean permaRemoved) {
|
||||
this.uuid = uuid;
|
||||
this.name = playerName;
|
||||
this.elements = elements;
|
||||
this.subelements = subelements;
|
||||
this.setAbilities(abilities);
|
||||
this.permaRemoved = permaRemoved;
|
||||
this.player = Bukkit.getPlayer(uuid);
|
||||
|
@ -112,11 +114,20 @@ public class BendingPlayer {
|
|||
/**
|
||||
* Adds an element to the {@link BendingPlayer}'s known list.
|
||||
*
|
||||
* @param e The element to add
|
||||
* @param element The element to add.
|
||||
*/
|
||||
public void addElement(Element element) {
|
||||
this.elements.add(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a subelement to the {@link BendingPlayer}'s known list.
|
||||
*
|
||||
* @param subelement The subelement to add.
|
||||
*/
|
||||
public void addSubElement(SubElement subelement) {
|
||||
this.subelements.add(subelement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets chiBlocked to true.
|
||||
|
@ -264,7 +275,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.earth.bloodbending"
|
||||
*/
|
||||
public boolean canBloodbend() {
|
||||
return player.hasPermission("bending.water.bloodbending");
|
||||
return subelements.contains(SubElement.BLOOD);
|
||||
}
|
||||
|
||||
public boolean canBloodbendAtAnytime() {
|
||||
|
@ -272,12 +283,11 @@ public class BendingPlayer {
|
|||
}
|
||||
|
||||
public boolean canCombustionbend() {
|
||||
return player.hasPermission("bending.fire.combustionbending");
|
||||
return subelements.contains(SubElement.COMBUSTION);
|
||||
}
|
||||
|
||||
public boolean canIcebend() {
|
||||
return player.hasPermission("bending.water.icebending");
|
||||
|
||||
return subelements.contains(SubElement.ICE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,11 +297,11 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.earth.lavabending"
|
||||
*/
|
||||
public boolean canLavabend() {
|
||||
return player.hasPermission("bending.earth.lavabending");
|
||||
return subelements.contains(SubElement.LAVA);
|
||||
}
|
||||
|
||||
public boolean canLightningbend() {
|
||||
return player.hasPermission("bending.fire.lightningbending");
|
||||
return subelements.contains(SubElement.LIGHTNING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,11 +311,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.earth.metalbending"
|
||||
*/
|
||||
public boolean canMetalbend() {
|
||||
return player.hasPermission("bending.earth.metalbending");
|
||||
}
|
||||
|
||||
public boolean canPackedIcebend() {
|
||||
return getConfig().getBoolean("Properties.Water.CanBendPackedIce");
|
||||
return subelements.contains(SubElement.METAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -315,7 +321,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.ability.plantbending"
|
||||
*/
|
||||
public boolean canPlantbend() {
|
||||
return player.hasPermission("bending.water.plantbending");
|
||||
return subelements.contains(SubElement.PLANT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,7 +331,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.earth.sandbending"
|
||||
*/
|
||||
public boolean canSandbend() {
|
||||
return player.hasPermission("bending.earth.sandbending");
|
||||
return subelements.contains(SubElement.SAND);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -334,7 +340,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.air.flight"
|
||||
*/
|
||||
public boolean canUseFlight() {
|
||||
return player.hasPermission("bending.air.flight");
|
||||
return subelements.contains(SubElement.FLIGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -344,7 +350,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.air.spiritualprojection"
|
||||
*/
|
||||
public boolean canUseSpiritualProjection() {
|
||||
return player.hasPermission("bending.air.spiritualprojection");
|
||||
return subelements.contains(SubElement.SPIRITUAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,7 +358,7 @@ public class BendingPlayer {
|
|||
* @return true If player has permission node "bending.water.healing"
|
||||
*/
|
||||
public boolean canWaterHeal() {
|
||||
return player.hasPermission("bending.water.healing");
|
||||
return subelements.contains(SubElement.HEALING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -361,7 +367,7 @@ public class BendingPlayer {
|
|||
* @return true If the player has permission to bend that subelement.
|
||||
*/
|
||||
public boolean canUseSubElement(SubElement sub) {
|
||||
return player.hasPermission("bending." + sub.getParentElement().getName().toLowerCase() + "." + sub.getName().toLowerCase());
|
||||
return subelements.contains(sub);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -485,6 +491,14 @@ public class BendingPlayer {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasSubElement(SubElement sub) {
|
||||
if (sub == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.subelements.contains(sub);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAvatarState() {
|
||||
return CoreAbility.hasAbility(player, AvatarState.class);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
import me.ryanhamshire.GriefPrevention.Claim;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import net.sacredlabyrinth.Phaed.PreciousStones.FieldFlag;
|
||||
|
@ -29,6 +27,7 @@ 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;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
|
@ -45,14 +44,11 @@ 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.command.Commands;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthBlast;
|
||||
import com.projectkorra.projectkorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.projectkorra.event.AbilityDamageEntityEvent;
|
||||
import com.projectkorra.projectkorra.event.BendingReloadEvent;
|
||||
import com.projectkorra.projectkorra.event.BindChangeEvent;
|
||||
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
|
||||
import com.projectkorra.projectkorra.firebending.Combustion;
|
||||
import com.projectkorra.projectkorra.firebending.FireBlast;
|
||||
import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||
|
@ -60,7 +56,6 @@ import com.projectkorra.projectkorra.firebending.FireShield;
|
|||
import com.projectkorra.projectkorra.object.Preset;
|
||||
import com.projectkorra.projectkorra.storage.DBConnection;
|
||||
import com.projectkorra.projectkorra.util.BlockCacheElement;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
import com.projectkorra.projectkorra.util.Flight;
|
||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||
import com.projectkorra.projectkorra.util.TempBlock;
|
||||
|
@ -86,8 +81,6 @@ import org.bukkit.entity.FallingSand;
|
|||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
@ -170,10 +163,7 @@ public class GeneralMethods {
|
|||
*/
|
||||
public static void bindAbility(Player player, String ability) {
|
||||
int slot = player.getInventory().getHeldItemSlot() + 1;
|
||||
BindChangeEvent event = new BindChangeEvent(player, ability, slot, true);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled())
|
||||
bindAbility(player, ability, slot);
|
||||
bindAbility(player, ability, slot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,22 +180,18 @@ public class GeneralMethods {
|
|||
return;
|
||||
}
|
||||
|
||||
BindChangeEvent event = new BindChangeEvent(player, ability, slot, true);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) {
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName());
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(ability);
|
||||
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
bPlayer.getAbilities().put(slot, ability);
|
||||
|
||||
if (coreAbil != null) {
|
||||
player.sendMessage(coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot)));
|
||||
}
|
||||
saveAbility(bPlayer, slot, ability);
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName());
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(ability);
|
||||
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
bPlayer.getAbilities().put(slot, ability);
|
||||
|
||||
if (coreAbil != null) {
|
||||
player.sendMessage(coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot)));
|
||||
}
|
||||
saveAbility(bPlayer, slot, ability);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,7 +276,7 @@ public class GeneralMethods {
|
|||
ResultSet rs2 = DBConnection.sql.readQuery("SELECT * FROM pk_players WHERE uuid = '" + uuid.toString() + "'");
|
||||
try {
|
||||
if (!rs2.next()) { // Data doesn't exist, we want a completely new player.
|
||||
new BendingPlayer(uuid, player, new ArrayList<Element>(), new HashMap<Integer, String>(), false);
|
||||
new BendingPlayer(uuid, player, new ArrayList<Element>(), new ArrayList<SubElement>(), new HashMap<Integer, String>(), false);
|
||||
DBConnection.sql.modifyQuery("INSERT INTO pk_players (uuid, player) VALUES ('" + uuid.toString() + "', '" + player + "')");
|
||||
ProjectKorra.log.info("Created new BendingPlayer for " + player);
|
||||
} else {
|
||||
|
@ -301,7 +287,7 @@ public class GeneralMethods {
|
|||
// They have changed names.
|
||||
ProjectKorra.log.info("Updating Player Name for " + player);
|
||||
}
|
||||
|
||||
String subelement = rs2.getString("subelement");
|
||||
String element = rs2.getString("element");
|
||||
String permaremoved = rs2.getString("permaremoved");
|
||||
boolean p = false;
|
||||
|
@ -334,6 +320,53 @@ public class GeneralMethods {
|
|||
}
|
||||
}
|
||||
}
|
||||
final ArrayList<SubElement> subelements = new ArrayList<SubElement>();
|
||||
if (subelement != null) {
|
||||
boolean hasAddon = subelement.contains(";");
|
||||
String[] split = subelement.split(";");
|
||||
if (split[0] != null) {
|
||||
if (split[0].contains("m")) {
|
||||
subelements.add(Element.METAL);
|
||||
}
|
||||
if (split[0].contains("v")) {
|
||||
subelements.add(Element.LAVA);
|
||||
}
|
||||
if (split[0].contains("s")) {
|
||||
subelements.add(Element.SAND);
|
||||
}
|
||||
if (split[0].contains("c")) {
|
||||
subelements.add(Element.COMBUSTION);
|
||||
}
|
||||
if (split[0].contains("l")) {
|
||||
subelements.add(Element.LIGHTNING);
|
||||
}
|
||||
if (split[0].contains("t")) {
|
||||
subelements.add(Element.SPIRITUAL);
|
||||
}
|
||||
if (split[0].contains("f")) {
|
||||
subelements.add(Element.FLIGHT);
|
||||
}
|
||||
if (split[0].contains("i")) {
|
||||
subelements.add(Element.ICE);
|
||||
}
|
||||
if (split[0].contains("h")) {
|
||||
subelements.add(Element.HEALING);
|
||||
}
|
||||
if (split[0].contains("b")) {
|
||||
subelements.add(Element.BLOOD);
|
||||
}
|
||||
if (split[0].contains("p")) {
|
||||
subelements.add(Element.PLANT);
|
||||
}
|
||||
if (hasAddon) {
|
||||
for (String addon : split[split.length - 1].split(",")) {
|
||||
if (Element.getElement(addon) != null && Element.getElement(addon) instanceof SubElement) {
|
||||
subelements.add((SubElement)Element.getElement(addon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final HashMap<Integer, String> abilities = new HashMap<Integer, String>();
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
|
@ -350,7 +383,7 @@ public class GeneralMethods {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new BendingPlayer(uuid, player, elements, abilities, boolean_p);
|
||||
new BendingPlayer(uuid, player, elements, subelements, abilities, boolean_p);
|
||||
}
|
||||
}.runTask(ProjectKorra.plugin);
|
||||
}
|
||||
|
@ -1465,7 +1498,12 @@ public class GeneralMethods {
|
|||
return;
|
||||
}
|
||||
String uuid = bPlayer.getUUIDString();
|
||||
|
||||
|
||||
BindChangeEvent event = new BindChangeEvent(Bukkit.getPlayer(UUID.fromString(uuid)), ability, slot, false);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
//Temp code to block modifications of binds, Should be replaced when bind event is added.
|
||||
if (MultiAbilityManager.playerAbilities.containsKey(Bukkit.getPlayer(bPlayer.getUUID()))) {
|
||||
return;
|
||||
|
@ -1510,6 +1548,61 @@ public class GeneralMethods {
|
|||
|
||||
DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'");
|
||||
}
|
||||
|
||||
public static void saveSubElements(BendingPlayer bPlayer) {
|
||||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
String uuid = bPlayer.getUUIDString();
|
||||
|
||||
StringBuilder subs = new StringBuilder();
|
||||
if (bPlayer.hasSubElement(Element.METAL)) {
|
||||
subs.append("m");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.LAVA)) {
|
||||
subs.append("v");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.SAND)) {
|
||||
subs.append("s");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.COMBUSTION)) {
|
||||
subs.append("c");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.LIGHTNING)) {
|
||||
subs.append("l");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.SPIRITUAL)) {
|
||||
subs.append("t");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.FLIGHT)) {
|
||||
subs.append("f");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.ICE)) {
|
||||
subs.append("i");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.HEALING)) {
|
||||
subs.append("h");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.BLOOD)) {
|
||||
subs.append("b");
|
||||
}
|
||||
if (bPlayer.hasSubElement(Element.PLANT)) {
|
||||
subs.append("p");
|
||||
}
|
||||
boolean hasAddon = false;
|
||||
for (Element element : bPlayer.getElements()) {
|
||||
if (!(element instanceof SubElement)) continue;
|
||||
if (Arrays.asList(Element.getAddonElements()).contains(element)) {
|
||||
if (!hasAddon) {
|
||||
hasAddon = true;
|
||||
subs.append(";");
|
||||
}
|
||||
subs.append(element.getName() + ",");
|
||||
}
|
||||
}
|
||||
|
||||
DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs + "' WHERE uuid = '" + uuid + "'");
|
||||
}
|
||||
|
||||
public static void savePermaRemoved(BendingPlayer bPlayer) {
|
||||
if (bPlayer == null) {
|
||||
|
|
|
@ -38,8 +38,8 @@ public class MultiAbilityManager {
|
|||
/**
|
||||
* Sets up a player's binds for a MultiAbility.
|
||||
*
|
||||
* @param player
|
||||
* @param multiAbility
|
||||
* @param player Player having the multiability bound
|
||||
* @param multiAbility MultiAbility being bound
|
||||
*/
|
||||
public static void bindMultiAbility(Player player, String multiAbility) {
|
||||
BindChangeEvent event = new BindChangeEvent(player, multiAbility, true);
|
||||
|
|
|
@ -2,10 +2,12 @@ package com.projectkorra.projectkorra.command;
|
|||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -26,6 +28,8 @@ public class AddCommand extends PKCommand {
|
|||
private String added;
|
||||
private String alreadyHasElementOther;
|
||||
private String alreadyHasElement;
|
||||
private String alreadyHasSubElementOther;
|
||||
private String alreadyHasSubElement;
|
||||
|
||||
public AddCommand() {
|
||||
super("add", "/bending add <Element> [Player]", ConfigManager.languageConfig.get().getString("Commands.Add.Description"), new String[] { "add", "a" });
|
||||
|
@ -36,6 +40,8 @@ public class AddCommand extends PKCommand {
|
|||
this.added = ConfigManager.languageConfig.get().getString("Commands.Add.SuccessfullyAdded");
|
||||
this.alreadyHasElementOther = ConfigManager.languageConfig.get().getString("Commands.Add.Other.AlreadyHasElement");
|
||||
this.alreadyHasElement = ConfigManager.languageConfig.get().getString("Commands.Add.AlreadyHasElement");
|
||||
this.alreadyHasSubElementOther = ConfigManager.languageConfig.get().getString("Commands.Add.Other.AlreadyHasSubElement");
|
||||
this.alreadyHasSubElement = ConfigManager.languageConfig.get().getString("Commands.Add.AlreadyHasSubElement");
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, List<String> args) {
|
||||
|
@ -96,6 +102,27 @@ public class AddCommand extends PKCommand {
|
|||
GeneralMethods.saveElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
|
||||
return;
|
||||
} else if (Arrays.asList(Element.getAllSubElements()).contains(element)) {
|
||||
SubElement sub = (SubElement) element;
|
||||
if (bPlayer.hasSubElement(sub)) {
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(ChatColor.RED + alreadyHasSubElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + alreadyHasSubElement);
|
||||
}
|
||||
return;
|
||||
}
|
||||
bPlayer.addSubElement(sub);
|
||||
ChatColor color = element.getColor();
|
||||
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(color + addedOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
|
||||
} else {
|
||||
target.sendMessage(color + added.replace("{element}", sub.getName() + sub.getType().getBender()));
|
||||
}
|
||||
GeneralMethods.saveSubElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.ADD));
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ package com.projectkorra.projectkorra.command;
|
|||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -27,7 +29,7 @@ public class ChooseCommand extends PKCommand {
|
|||
private String chosenOther;
|
||||
|
||||
public ChooseCommand() {
|
||||
super("choose", "/bending choose <Element> [Player]", ConfigManager.languageConfig.get().getString("Commands.Choose.Description"), new String[] { "choose", "ch" });
|
||||
super("choose", "/bending choose <Element/SubElement> [Player]", ConfigManager.languageConfig.get().getString("Commands.Choose.Description"), new String[] { "choose", "ch" });
|
||||
|
||||
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Choose.PlayerNotFound");
|
||||
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Choose.InvalidElement");
|
||||
|
@ -66,6 +68,12 @@ public class ChooseCommand extends PKCommand {
|
|||
}
|
||||
add(sender, (Player) sender, target);
|
||||
return;
|
||||
} else if (Arrays.asList(Element.getAllSubElements()).contains(target)) {
|
||||
SubElement sub = (SubElement) target;
|
||||
if (!hasPermission(sender, sub.getName())) {
|
||||
return;
|
||||
}
|
||||
add(sender, (Player) sender, sub);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + invalidElement);
|
||||
return;
|
||||
|
@ -104,20 +112,33 @@ public class ChooseCommand extends PKCommand {
|
|||
if (bPlayer == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
bPlayer.setElement(element);
|
||||
ChatColor color = element != null ? element.getColor() : null;
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(color + chosenOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender()));
|
||||
if (element instanceof SubElement) {
|
||||
SubElement sub = (SubElement) element;
|
||||
bPlayer.addSubElement(sub);
|
||||
ChatColor color = sub != null ? sub.getColor() : ChatColor.WHITE;
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(color + chosenOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
|
||||
} else {
|
||||
target.sendMessage(color + chosen.replace("{element}", sub.getName() + sub.getType().getBender()));
|
||||
}
|
||||
GeneralMethods.saveSubElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.CHOOSE));
|
||||
} else {
|
||||
target.sendMessage(color + chosen.replace("{element}", element.getName() + element.getType().getBender()));
|
||||
bPlayer.setElement(element);
|
||||
ChatColor color = element != null ? element.getColor() : ChatColor.WHITE;
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(color + chosenOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", element.getName() + element.getType().getBender()));
|
||||
} else {
|
||||
target.sendMessage(color + chosen.replace("{element}", element.getName() + element.getType().getBender()));
|
||||
}
|
||||
GeneralMethods.saveElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
|
||||
}
|
||||
|
||||
|
||||
|
||||
GeneralMethods.removeUnusableAbilities(target.getName());
|
||||
GeneralMethods.saveElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean isVowel(char c) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.command;
|
|||
|
||||
import com.projectkorra.projectkorra.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
|
@ -68,17 +69,26 @@ public class ImportCommand extends PKCommand {
|
|||
@SuppressWarnings("deprecation")
|
||||
UUID uuid = ProjectKorra.plugin.getServer().getOfflinePlayer(playername).getUniqueId();
|
||||
ArrayList<Element> elements = new ArrayList<Element>();
|
||||
ArrayList<SubElement> subs = new ArrayList<SubElement>();
|
||||
List<Integer> bendingTypes = bendingPlayers.getIntegerList(string + ".BendingTypes");
|
||||
boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved");
|
||||
Element[] mainElements = Element.getMainElements();
|
||||
Element[] allElements = Element.getAllElements();
|
||||
|
||||
for (int i : bendingTypes) {
|
||||
if (i < mainElements.length) {
|
||||
elements.add(mainElements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (Element e : allElements) {
|
||||
if (e instanceof SubElement) {
|
||||
SubElement s = (SubElement) e;
|
||||
subs.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
BendingPlayer bPlayer = new BendingPlayer(uuid, playername, elements, new HashMap<Integer, String>(), permaremoved);
|
||||
BendingPlayer bPlayer = new BendingPlayer(uuid, playername, elements, subs, new HashMap<Integer, String>(), permaremoved);
|
||||
bPlayers.add(bPlayer);
|
||||
}
|
||||
|
||||
|
|
|
@ -200,8 +200,10 @@ public class ConfigManager {
|
|||
config.addDefault("Commands.Add.PlayerNotFound", "That player could not be found.");
|
||||
config.addDefault("Commands.Add.InvalidElement", "You must specify a valid element.");
|
||||
config.addDefault("Commands.Add.AlreadyHasElement", "You already have that element!");
|
||||
config.addDefault("Commands.Add.AlreadyHasSubElement", "You already have that subelement!");
|
||||
config.addDefault("Commands.Add.Other.SuccessfullyAdded", "{target} is now also a {element}.");
|
||||
config.addDefault("Commands.Add.Other.AlreadyHasElement", "{target} already has that element!");
|
||||
config.addDefault("Commands.Add.Other.AlreadyHasSubElement", "{target} already has that subelement!");
|
||||
|
||||
config.addDefault("DeathMessages.Enabled", true);
|
||||
config.addDefault("DeathMessages.Default", "{victim} was slain by {attacker}'s {ability}");
|
||||
|
@ -1100,6 +1102,7 @@ public class ConfigManager {
|
|||
config.addDefault("Storage.MySQL.pass", "");
|
||||
config.addDefault("Storage.MySQL.db", "minecraft");
|
||||
config.addDefault("Storage.MySQL.user", "root");
|
||||
config.addDefault("Storage.MySQL.SubElementAdded", false);
|
||||
|
||||
config.addDefault("debug", false);
|
||||
|
||||
|
|
|
@ -12,9 +12,7 @@ public class ConfigType {
|
|||
public static final ConfigType DEFAULT = new ConfigType("Default");
|
||||
public static final ConfigType PRESETS = new ConfigType("Presets");
|
||||
public static final ConfigType LANGUAGE = new ConfigType("Language");
|
||||
public static final ConfigType[] CORE_TYPES = {DEFAULT, PRESETS, LANGUAGE};
|
||||
|
||||
private static List<ConfigType> addonTypes = new ArrayList<ConfigType>();
|
||||
public static final ConfigType[] CORE_TYPES = {DEFAULT, PRESETS, LANGUAGE};
|
||||
|
||||
private String string;
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.projectkorra.projectkorra.event;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class PlayerChangeSubElementEvent extends Event{
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private CommandSender sender;
|
||||
private Player target;
|
||||
private SubElement sub;
|
||||
private Result result;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sender the {@link CommandSender} who changed the player's bending
|
||||
* @param target the {@link Player} who's bending was changed
|
||||
* @param sub the {@link SubElement} that was changed to
|
||||
* @param result whether the element was chosen, added, removed, or permaremoved
|
||||
*/
|
||||
public PlayerChangeSubElementEvent(CommandSender sender, Player target, SubElement sub, Result result) {
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
this.sub = sub;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link CommandSender} who changed the player's bending
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link Player player} who's bending was changed
|
||||
*/
|
||||
public Player getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link Element element} that was affected
|
||||
*/
|
||||
public SubElement getSubElement() {
|
||||
return sub;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return whether the element was chosen, added, removed, or permaremoved
|
||||
*/
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static enum Result {
|
||||
CHOOSE, REMOVE, ADD, PERMAREMOVE;
|
||||
private Result() {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
package com.projectkorra.projectkorra.firebending;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
|
||||
import com.projectkorra.projectkorra.util.DamageHandler;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class FireDamageTimer {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.storage;
|
|||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
|
||||
public class DBConnection {
|
||||
|
||||
|
@ -13,6 +14,7 @@ public class DBConnection {
|
|||
public static String user;
|
||||
public static String pass;
|
||||
public static boolean isOpen = false;
|
||||
private static boolean subelement = ConfigManager.defaultConfig.get().getBoolean("Storage.MySQL.SubElementAdded");
|
||||
|
||||
public static void init() {
|
||||
if (ProjectKorra.plugin.getConfig().getString("Storage.engine").equalsIgnoreCase("mysql")) {
|
||||
|
@ -28,15 +30,20 @@ public class DBConnection {
|
|||
|
||||
if (!sql.tableExists("pk_players")) {
|
||||
ProjectKorra.log.info("Creating pk_players table");
|
||||
String query = "CREATE TABLE `pk_players` (" + "`uuid` varchar(36) NOT NULL," + "`player` varchar(16) NOT NULL," + "`element` varchar(255)," + "`permaremoved` varchar(5)," + "`slot1` varchar(255)," + "`slot2` varchar(255)," + "`slot3` varchar(255)," + "`slot4` varchar(255)," + "`slot5` varchar(255)," + "`slot6` varchar(255)," + "`slot7` varchar(255)," + "`slot8` varchar(255)," + "`slot9` varchar(255)," + " PRIMARY KEY (uuid));";
|
||||
String query = "CREATE TABLE `pk_players` (" + "`uuid` varchar(36) NOT NULL," + "`player` varchar(16) NOT NULL," + "`element` varchar(255)," + "`subelement` varchar(255)" + "`permaremoved` varchar(5)," + "`slot1` varchar(255)," + "`slot2` varchar(255)," + "`slot3` varchar(255)," + "`slot4` varchar(255)," + "`slot5` varchar(255)," + "`slot6` varchar(255)," + "`slot7` varchar(255)," + "`slot8` varchar(255)," + "`slot9` varchar(255)," + " PRIMARY KEY (uuid));";
|
||||
sql.modifyQuery(query);
|
||||
} else {
|
||||
if (!subelement) {
|
||||
sql.modifyQuery("ALTER TABLE `pk_players` ADD subelement varchar(255);");
|
||||
ConfigManager.defaultConfig.get().set("Storage.MySQL.SubElementAdded", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sql.tableExists("pk_presets")) {
|
||||
ProjectKorra.log.info("Creating pk_presets table");
|
||||
String query = "CREATE TABLE `pk_presets` (" + "`uuid` varchar(36) NOT NULL," + "`name` varchar(255) NOT NULL," + "`slot1` varchar(255)," + "`slot2` varchar(255)," + "`slot3` varchar(255)," + "`slot4` varchar(255)," + "`slot5` varchar(255)," + "`slot6` varchar(255)," + "`slot7` varchar(255)," + "`slot8` varchar(255)," + "`slot9` varchar(255)," + " PRIMARY KEY (uuid, name));";
|
||||
sql.modifyQuery(query);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sql = new SQLite(ProjectKorra.log, "Establishing SQLite Connection.", "projectkorra.db", ProjectKorra.plugin.getDataFolder().getAbsolutePath());
|
||||
if (((SQLite) sql).open() == null) {
|
||||
|
@ -48,8 +55,13 @@ public class DBConnection {
|
|||
isOpen = true;
|
||||
if (!sql.tableExists("pk_players")) {
|
||||
ProjectKorra.log.info("Creating pk_players table.");
|
||||
String query = "CREATE TABLE `pk_players` (" + "`uuid` TEXT(36) PRIMARY KEY," + "`player` TEXT(16)," + "`element` TEXT(255)," + "`permaremoved` TEXT(5)," + "`slot1` TEXT(255)," + "`slot2` TEXT(255)," + "`slot3` TEXT(255)," + "`slot4` TEXT(255)," + "`slot5` TEXT(255)," + "`slot6` TEXT(255)," + "`slot7` TEXT(255)," + "`slot8` TEXT(255)," + "`slot9` TEXT(255));";
|
||||
String query = "CREATE TABLE `pk_players` (" + "`uuid` TEXT(36) PRIMARY KEY," + "`player` TEXT(16)," + "`element` TEXT(255)," + "`subelement` TEXT(255)" + "`permaremoved` TEXT(5)," + "`slot1` TEXT(255)," + "`slot2` TEXT(255)," + "`slot3` TEXT(255)," + "`slot4` TEXT(255)," + "`slot5` TEXT(255)," + "`slot6` TEXT(255)," + "`slot7` TEXT(255)," + "`slot8` TEXT(255)," + "`slot9` TEXT(255));";
|
||||
sql.modifyQuery(query);
|
||||
} else {
|
||||
if (!subelement) {
|
||||
sql.modifyQuery("ALTER TABLE `pk_players` ADD subelement TEXT(255);");
|
||||
ConfigManager.defaultConfig.get().set("Storage.MySQL.SubElementAdded", true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sql.tableExists("pk_presets")) {
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package com.projectkorra.projectkorra.util;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.event.AbilityDamageEntityEvent;
|
||||
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
@ -7,16 +15,6 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
import com.projectkorra.projectkorra.command.Commands;
|
||||
import com.projectkorra.projectkorra.event.AbilityDamageEntityEvent;
|
||||
import com.projectkorra.projectkorra.event.EntityBendingDeathEvent;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
|
||||
|
||||
public class DamageHandler {
|
||||
|
||||
/**
|
||||
|
@ -53,7 +51,6 @@ public class DamageHandler {
|
|||
|
||||
((LivingEntity) entity).damage(damage, source);
|
||||
|
||||
System.out.println("calling regular damage");
|
||||
entity.setLastDamageCause(new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage));
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) {
|
||||
|
|
Loading…
Reference in a new issue