mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 19:50:37 +00:00
Merge pull request #382 from nathank33/master
CoreAbility Improvements and Bug Fixes
This commit is contained in:
commit
433ee0d700
8 changed files with 89 additions and 44 deletions
|
@ -737,7 +737,7 @@ public class PKListener implements Listener {
|
|||
} else {
|
||||
for (Element element : Element.getMainElements()) {
|
||||
if (bPlayer.hasElement(element)) {
|
||||
color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors." + element));
|
||||
color = element.getColor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,6 +191,13 @@ public abstract class CoreAbility implements Ability {
|
|||
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);;
|
||||
CoreAbility ability = (CoreAbility) clazz.cast(intConstr.newInstance());
|
||||
|
||||
if (ability != null && ability.getName() != null && ability.isEnabled()) {
|
||||
ABILITIES_BY_NAME.put(ability.getName().toLowerCase(), ability);
|
||||
if (ability == null || ability.getName() == null) {
|
||||
continue;
|
||||
} else if (!ability.isEnabled()) {
|
||||
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 (Error e) {
|
||||
|
@ -390,6 +425,7 @@ public abstract class CoreAbility implements Ability {
|
|||
ProjectKorra plugin = ProjectKorra.plugin;
|
||||
File path = new File(plugin.getDataFolder().toString() + folder);
|
||||
if (!path.exists()) {
|
||||
path.mkdir();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public class AbilityLoader<T> implements Listener {
|
|||
Class<?> clazz = null;
|
||||
try {
|
||||
clazz = Class.forName(className, true, loader);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | Error e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class AbilityLoader<T> implements Listener {
|
|||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (Exception | Error e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().log(Level.WARNING, "Unknown cause");
|
||||
plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load");
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
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.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.ComboAbility;
|
||||
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.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 {
|
||||
|
||||
private static final long CLEANUP_DELAY = 20 * 600;
|
||||
|
@ -271,9 +272,17 @@ public class ComboManager {
|
|||
*/
|
||||
public static ArrayList<String> getCombosForElement(Element element) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (String comboab : DESCRIPTIONS.keySet()) {
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(COMBO_ABILITIES.get(comboab).getAbilities().get(0).getAbilityName());
|
||||
if (coreAbil != null && coreAbil.getElement() == element) {
|
||||
for (String comboab : COMBO_ABILITIES.keySet()) {
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(comboab);
|
||||
if (coreAbil == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Element abilElement = coreAbil.getElement();
|
||||
if (abilElement instanceof SubElement) {
|
||||
abilElement = ((SubElement) abilElement).getParentElement();
|
||||
}
|
||||
if (abilElement == element) {
|
||||
list.add(comboab);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ public class AirFlight extends FlightAbility {
|
|||
} else {
|
||||
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(speed));
|
||||
}
|
||||
firstProgressIteration = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -46,10 +46,17 @@ public class DisplayCommand extends PKCommand {
|
|||
sender.sendMessage(color + "There are no " + elementName + " combos avaliable.");
|
||||
return;
|
||||
}
|
||||
for (String combomove : combos) {
|
||||
if (!sender.hasPermission("bending.ability." + combomove))
|
||||
for (String comboMove : combos) {
|
||||
ChatColor comboColor = color;
|
||||
if (!sender.hasPermission("bending.ability." + comboMove)) {
|
||||
continue;
|
||||
sender.sendMessage(color + combomove);
|
||||
}
|
||||
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
|
||||
if (coreAbil != null) {
|
||||
comboColor = coreAbil.getElement().getColor();
|
||||
}
|
||||
sender.sendMessage(comboColor + comboMove);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -108,6 +115,9 @@ public class DisplayCommand extends PKCommand {
|
|||
return;
|
||||
}
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability.isHiddenAbility()) {
|
||||
continue;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
if (GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||
|
|
|
@ -161,13 +161,6 @@ public class FireBlastCharged extends FireAbility {
|
|||
yield = AvatarState.getValue(yield);
|
||||
}
|
||||
|
||||
if (!bPlayer.isAvatarState()) {
|
||||
if (isDay(player.getWorld())) {
|
||||
yield = (float) getDayFactor(yield);
|
||||
}
|
||||
} else {
|
||||
yield = AvatarState.getValue(yield);
|
||||
}
|
||||
explosion.setYield((float) yield);
|
||||
EXPLOSIONS.put(explosion, this);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
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.ProjectKorra;
|
||||
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.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
|
||||
* 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) {
|
||||
super(player);
|
||||
Bukkit.broadcastMessage("Here 0");
|
||||
|
||||
this.ability = ability;
|
||||
|
||||
if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
|
||||
|
@ -211,7 +208,6 @@ public class FireCombo extends FireAbility implements ComboAbility {
|
|||
|
||||
@Override
|
||||
public void progress() {
|
||||
Bukkit.broadcastMessage("Progressing");
|
||||
progressCounter++;
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
BukkitRunnable br = tasks.get(i);
|
||||
|
|
Loading…
Reference in a new issue