mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-12 03:59:06 +00:00
Improve AddonAbility plugin Support, Bug Fixes
AirFlight sneak not removing ability. Removed FireCombo debug messages. /b display fix for AvatarAbilities. AvatarState charged fireblast radius fix. Protect old addons from breaking the AbilityLoader.
This commit is contained in:
parent
9624b95104
commit
04b98238e2
8 changed files with 89 additions and 44 deletions
|
@ -737,7 +737,7 @@ public class PKListener implements Listener {
|
||||||
} else {
|
} else {
|
||||||
for (Element element : Element.getMainElements()) {
|
for (Element element : Element.getMainElements()) {
|
||||||
if (bPlayer.hasElement(element)) {
|
if (bPlayer.hasElement(element)) {
|
||||||
color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors." + element));
|
color = element.getColor();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,13 @@ public abstract class CoreAbility implements Ability {
|
||||||
abil.remove();
|
abil.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (CoreAbility coreAbility : ABILITIES_BY_NAME.values()) {
|
||||||
|
if (coreAbility instanceof AddonAbility) {
|
||||||
|
AddonAbility addon = (AddonAbility) coreAbility;
|
||||||
|
addon.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,10 +371,38 @@ public abstract class CoreAbility implements Ability {
|
||||||
Constructor<?> intConstr = rf.newConstructorForSerialization(clazz, objDef);;
|
Constructor<?> intConstr = rf.newConstructorForSerialization(clazz, objDef);;
|
||||||
CoreAbility ability = (CoreAbility) clazz.cast(intConstr.newInstance());
|
CoreAbility ability = (CoreAbility) clazz.cast(intConstr.newInstance());
|
||||||
|
|
||||||
if (ability != null && ability.getName() != null && ability.isEnabled()) {
|
if (ability == null || ability.getName() == null) {
|
||||||
ABILITIES_BY_NAME.put(ability.getName().toLowerCase(), ability);
|
continue;
|
||||||
} else if (!ability.isEnabled()) {
|
} else if (!ability.isEnabled()) {
|
||||||
plugin.getLogger().info(ability.getName() + " is disabled");
|
plugin.getLogger().info(ability.getName() + " is disabled");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String name = ability.getName();
|
||||||
|
ABILITIES_BY_NAME.put(ability.getName().toLowerCase(), ability);
|
||||||
|
|
||||||
|
if (ability instanceof ComboAbility) {
|
||||||
|
ComboAbility combo = (ComboAbility) ability;
|
||||||
|
if (combo.getCombination() != null) {
|
||||||
|
ComboManager.getComboAbilities().put(name, new ComboManager.ComboAbilityInfo(name, combo.getCombination(), combo));
|
||||||
|
ComboManager.getDescriptions().put(name, ability.getDescription());
|
||||||
|
ComboManager.getInstructions().put(name, combo.getInstructions());
|
||||||
|
String author = "";
|
||||||
|
if (ability instanceof AddonAbility) {
|
||||||
|
author = ((AddonAbility) ability).getAuthor();
|
||||||
|
}
|
||||||
|
ComboManager.getAuthors().put(name, author);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ability instanceof MultiAbility) {
|
||||||
|
MultiAbility multiAbil = (MultiAbility) ability;
|
||||||
|
MultiAbilityManager.multiAbilityList.add(new MultiAbilityInfo(name, multiAbil.getMultiAbilities()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ability instanceof AddonAbility) {
|
||||||
|
AddonAbility addon = (AddonAbility) ability;
|
||||||
|
addon.load();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
|
@ -390,6 +425,7 @@ public abstract class CoreAbility implements Ability {
|
||||||
ProjectKorra plugin = ProjectKorra.plugin;
|
ProjectKorra plugin = ProjectKorra.plugin;
|
||||||
File path = new File(plugin.getDataFolder().toString() + folder);
|
File path = new File(plugin.getDataFolder().toString() + folder);
|
||||||
if (!path.exists()) {
|
if (!path.exists()) {
|
||||||
|
path.mkdir();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class AbilityLoader<T> implements Listener {
|
||||||
Class<?> clazz = null;
|
Class<?> clazz = null;
|
||||||
try {
|
try {
|
||||||
clazz = Class.forName(className, true, loader);
|
clazz = Class.forName(className, true, loader);
|
||||||
} catch (Exception e) {
|
} catch (Exception | Error e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class AbilityLoader<T> implements Listener {
|
||||||
plugin.getServer().getPluginManager().callEvent(event);
|
plugin.getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception | Error e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
plugin.getLogger().log(Level.WARNING, "Unknown cause");
|
plugin.getLogger().log(Level.WARNING, "Unknown cause");
|
||||||
plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load");
|
plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load");
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
package com.projectkorra.projectkorra.ability.util;
|
package com.projectkorra.projectkorra.ability.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.BendingPlayer;
|
import com.projectkorra.projectkorra.BendingPlayer;
|
||||||
import com.projectkorra.projectkorra.Element;
|
import com.projectkorra.projectkorra.Element;
|
||||||
|
import com.projectkorra.projectkorra.Element.SubElement;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.ComboAbility;
|
import com.projectkorra.projectkorra.ability.ComboAbility;
|
||||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||||
|
@ -11,14 +20,6 @@ import com.projectkorra.projectkorra.firebending.FireCombo;
|
||||||
import com.projectkorra.projectkorra.util.ClickType;
|
import com.projectkorra.projectkorra.util.ClickType;
|
||||||
import com.projectkorra.projectkorra.waterbending.WaterCombo;
|
import com.projectkorra.projectkorra.waterbending.WaterCombo;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
|
|
||||||
public class ComboManager {
|
public class ComboManager {
|
||||||
|
|
||||||
private static final long CLEANUP_DELAY = 20 * 600;
|
private static final long CLEANUP_DELAY = 20 * 600;
|
||||||
|
@ -271,9 +272,17 @@ public class ComboManager {
|
||||||
*/
|
*/
|
||||||
public static ArrayList<String> getCombosForElement(Element element) {
|
public static ArrayList<String> getCombosForElement(Element element) {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
for (String comboab : DESCRIPTIONS.keySet()) {
|
for (String comboab : COMBO_ABILITIES.keySet()) {
|
||||||
CoreAbility coreAbil = CoreAbility.getAbility(COMBO_ABILITIES.get(comboab).getAbilities().get(0).getAbilityName());
|
CoreAbility coreAbil = CoreAbility.getAbility(comboab);
|
||||||
if (coreAbil != null && coreAbil.getElement() == element) {
|
if (coreAbil == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Element abilElement = coreAbil.getElement();
|
||||||
|
if (abilElement instanceof SubElement) {
|
||||||
|
abilElement = ((SubElement) abilElement).getParentElement();
|
||||||
|
}
|
||||||
|
if (abilElement == element) {
|
||||||
list.add(comboab);
|
list.add(comboab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ public class AirFlight extends FlightAbility {
|
||||||
} else {
|
} else {
|
||||||
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(speed));
|
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(speed));
|
||||||
}
|
}
|
||||||
|
firstProgressIteration = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,10 +46,17 @@ public class DisplayCommand extends PKCommand {
|
||||||
sender.sendMessage(color + "There are no " + elementName + " combos avaliable.");
|
sender.sendMessage(color + "There are no " + elementName + " combos avaliable.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (String combomove : combos) {
|
for (String comboMove : combos) {
|
||||||
if (!sender.hasPermission("bending.ability." + combomove))
|
ChatColor comboColor = color;
|
||||||
|
if (!sender.hasPermission("bending.ability." + comboMove)) {
|
||||||
continue;
|
continue;
|
||||||
sender.sendMessage(color + combomove);
|
}
|
||||||
|
|
||||||
|
CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
|
||||||
|
if (coreAbil != null) {
|
||||||
|
comboColor = coreAbil.getElement().getColor();
|
||||||
|
}
|
||||||
|
sender.sendMessage(comboColor + comboMove);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -108,6 +115,9 @@ public class DisplayCommand extends PKCommand {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (CoreAbility ability : abilities) {
|
for (CoreAbility ability : abilities) {
|
||||||
|
if (ability.isHiddenAbility()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (GeneralMethods.canView((Player) sender, ability.getName())) {
|
if (GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||||
|
|
|
@ -161,13 +161,6 @@ public class FireBlastCharged extends FireAbility {
|
||||||
yield = AvatarState.getValue(yield);
|
yield = AvatarState.getValue(yield);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!bPlayer.isAvatarState()) {
|
|
||||||
if (isDay(player.getWorld())) {
|
|
||||||
yield = (float) getDayFactor(yield);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
yield = AvatarState.getValue(yield);
|
|
||||||
}
|
|
||||||
explosion.setYield((float) yield);
|
explosion.setYield((float) yield);
|
||||||
EXPLOSIONS.put(explosion, this);
|
EXPLOSIONS.put(explosion, this);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,19 @@
|
||||||
package com.projectkorra.projectkorra.firebending;
|
package com.projectkorra.projectkorra.firebending;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Effect;
|
||||||
|
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.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import com.projectkorra.projectkorra.GeneralMethods;
|
import com.projectkorra.projectkorra.GeneralMethods;
|
||||||
import com.projectkorra.projectkorra.ProjectKorra;
|
import com.projectkorra.projectkorra.ProjectKorra;
|
||||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||||
|
@ -13,21 +27,6 @@ import com.projectkorra.projectkorra.command.Commands;
|
||||||
import com.projectkorra.projectkorra.util.ClickType;
|
import com.projectkorra.projectkorra.util.ClickType;
|
||||||
import com.projectkorra.projectkorra.util.ParticleEffect;
|
import com.projectkorra.projectkorra.util.ParticleEffect;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
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.entity.Entity;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO: Combo classes should eventually be rewritten so that each combo is treated
|
* TODO: Combo classes should eventually be rewritten so that each combo is treated
|
||||||
* as an individual ability. In the mean time, we will just place "fake"
|
* as an individual ability. In the mean time, we will just place "fake"
|
||||||
|
@ -72,8 +71,6 @@ public class FireCombo extends FireAbility implements ComboAbility {
|
||||||
|
|
||||||
public FireCombo(Player player, String ability) {
|
public FireCombo(Player player, String ability) {
|
||||||
super(player);
|
super(player);
|
||||||
Bukkit.broadcastMessage("Here 0");
|
|
||||||
|
|
||||||
this.ability = ability;
|
this.ability = ability;
|
||||||
|
|
||||||
if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
||||||
|
@ -211,7 +208,6 @@ public class FireCombo extends FireAbility implements ComboAbility {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void progress() {
|
public void progress() {
|
||||||
Bukkit.broadcastMessage("Progressing");
|
|
||||||
progressCounter++;
|
progressCounter++;
|
||||||
for (int i = 0; i < tasks.size(); i++) {
|
for (int i = 0; i < tasks.size(); i++) {
|
||||||
BukkitRunnable br = tasks.get(i);
|
BukkitRunnable br = tasks.get(i);
|
||||||
|
|
Loading…
Reference in a new issue