Merge pull request #140 from jedk1/deathmsgs

Death Message Fixes
This commit is contained in:
MistPhizzle 2015-06-10 04:25:52 -04:00
commit e88f56d5c2
3 changed files with 32 additions and 14 deletions

View file

@ -408,12 +408,14 @@ public class GeneralMethods {
if (Bukkit.getPluginManager().isPluginEnabled("NoCheatPlus")) {
NCPExemptionManager.exemptPermanently(player, CheckType.FIGHT_REACH);
}
if (((LivingEntity) entity).getHealth() - damage <= 0 && entity instanceof Player) {
if (((LivingEntity) entity).getHealth() - damage <= 0 && entity instanceof Player && !entity.isDead()) {
if (ability == null) {
ability = getLastUsedAbility(player);
ability = getLastUsedAbility(player, true);
}
if (ability != null && !ability.isEmpty()) {
PlayerBendingDeathEvent event = new PlayerBendingDeathEvent((Player) entity, player, ability, damage);
Bukkit.getServer().getPluginManager().callEvent(event);
}
PlayerBendingDeathEvent event = new PlayerBendingDeathEvent((Player) entity, player, ability, damage);
Bukkit.getServer().getPluginManager().callEvent(event);
}
((LivingEntity) entity).damage(damage, player);
((LivingEntity) entity).setLastDamageCause(
@ -429,10 +431,10 @@ public class GeneralMethods {
* @param player
* @return
*/
public static String getLastUsedAbility(Player player){
public static String getLastUsedAbility(Player player, boolean checkCombos){
List<AbilityInformation> lastUsedAbility = ComboManager.getRecentlyUsedAbilities(player, 1);
if (!lastUsedAbility.isEmpty()) {
if(ComboManager.checkForValidCombo(player) != null){
if(ComboManager.checkForValidCombo(player) != null && checkCombos){
return ComboManager.checkForValidCombo(player).getName();
}else {
return lastUsedAbility.get(0).getAbilityName();

View file

@ -1068,6 +1068,15 @@ public class PKListener implements Listener {
public void onPlayerBendingDeath(PlayerBendingDeathEvent event) {
if (event.getAbility() != null && !event.getAbility().isEmpty() && ConfigManager.deathMsgConfig.getConfig().getBoolean("Properties.Enabled")) {
bendingDeathPlayer.put(event.getVictim(), event.getAbility());
final Player player = event.getVictim();
new BukkitRunnable() {
@Override
public void run () {
bendingDeathPlayer.remove(player);
}
}.runTaskLater(ProjectKorra.plugin, 20);
}
}
@ -1113,13 +1122,20 @@ public class PKListener implements Listener {
if (bendingDeathPlayer.containsKey(event.getEntity())) {
String message = ConfigManager.deathMsgConfig.getConfig().getString("Properties.Default");
String ability = bendingDeathPlayer.get(event.getEntity());
String element = GeneralMethods.getAbilityElement(ability).name();
if(ConfigManager.deathMsgConfig.getConfig().contains(element + "." + ability)){
String element = null;
if (GeneralMethods.abilityExists(ability)) {
element = GeneralMethods.getAbilityElement(ability).name();
}
if (ComboManager.checkForValidCombo(event.getEntity().getKiller()).getName().equalsIgnoreCase(ability)) {
element = GeneralMethods.getAbilityElement(GeneralMethods.getLastUsedAbility(event.getEntity().getKiller(), false)).name();
ability = element + "Combo";
}
if (ConfigManager.deathMsgConfig.getConfig().contains(element + "." + ability)) {
message = ConfigManager.deathMsgConfig.getConfig().getString(element + "." + ability);
}
message = message.replace("{victim}", event.getEntity().getName())
.replace("{attacker}", event.getEntity().getKiller().getName())
.replace("{ability}", GeneralMethods.getAbilityColor(ability) + ability);
.replace("{ability}", GeneralMethods.getAbilityColor(GeneralMethods.getLastUsedAbility(event.getEntity().getKiller(), false)) + ability);
event.setDeathMessage(message);
bendingDeathPlayer.remove(event.getEntity());
}

View file

@ -32,7 +32,7 @@ public class ConfigManager {
config.addDefault("Air.AirBurst", "{victim} was thrown down by {attacker}'s {ability}");
config.addDefault("Air.AirSwipe", "{victim} was struck by {attacker}'s {ability}");
config.addDefault("Air.Suffocate", "{victim} was asphyxiated by {attacker}'s {ability}");
config.addDefault("Air.Combo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Air.AirCombo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Water.IceBlast", "{victim} was shattered by {attacker}'s {ability}");
config.addDefault("Water.Torrent", "{victim} was taken down by {attacker}'s {ability}");
@ -41,7 +41,7 @@ public class ConfigManager {
config.addDefault("Water.WaterArms", "{victim} was too slow for {attacker}'s {ability}");
config.addDefault("Water.OctopusForm", "{victim} was slapped by {attacker}'s {ability}");
config.addDefault("Water.Bloodbending", "{victim} was destroyed by {attacker}'s {ability}");
config.addDefault("Water.Combo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Water.WaterCombo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Earth.Collapse", "{victim} was suffocated by {attacker}'s {ability}");
config.addDefault("Earth.EarthBlast", "{victim} was broken apart by {attacker}'s {ability}");
@ -49,7 +49,7 @@ public class ConfigManager {
config.addDefault("Earth.LavaFlow", "{victim} was caught in by {attacker}'s {ability}");
config.addDefault("Earth.MetalClips", "{victim} was too slow for {attacker}'s {ability}");
config.addDefault("Earth.Shockwave", "{victim} was blown away by {attacker}'s {ability}");
config.addDefault("Earth.Combo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Earth.EarthCombo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Fire.FireBlast", "{victim} was burnt by {attacker}'s {ability}");
config.addDefault("Fire.Blaze", "{victim} was burned alive by {attacker}'s {ability}");
@ -58,12 +58,12 @@ public class ConfigManager {
config.addDefault("Fire.Combustion", "{victim} was shot down by {attacker}'s {ability}");
config.addDefault("Fire.FireBurst", "{victim} was blown apart by {attacker}'s {ability}");
config.addDefault("Fire.FireShield", "{victim} scorched theirself on {attacker}'s {ability}");
config.addDefault("Fire.Combo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Fire.FireCombo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Chi.QuickStrike", "{victim} was struck down by {attacker}'s {ability}");
config.addDefault("Chi.SwiftKick", "{victim} was kicked to the floor by {attacker}'s {ability}");
config.addDefault("Chi.RapidPunch", "{victim} took all the hits against {attacker}'s {ability}");
config.addDefault("Chi.Combo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.addDefault("Chi.ChiCombo", "{victim} was overwhelmed by {attacker}'s skill {ability}");
config.options().copyDefaults(true);
deathMsgConfig.saveConfig();