Add /bending invincible

Makes you invincible to Bending damage.
This commit is contained in:
MistPhizzle 2014-09-01 16:04:42 -04:00
parent f5b01d624c
commit 65f1b12fc0
12 changed files with 90 additions and 77 deletions

View file

@ -6,8 +6,10 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -61,11 +63,14 @@ public class Commands {
String[] whoaliases = {"who", "w"}; String[] whoaliases = {"who", "w"};
String[] importaliases = {"import", "i"}; String[] importaliases = {"import", "i"};
String[] givealiases = {"give", "g", "spawn"}; String[] givealiases = {"give", "g", "spawn"};
String[] invinciblealiases = {"invincible", "inv"};
/* /*
* Item Aliases * Item Aliases
*/ */
public static Set<String> invincible = new HashSet<String>();
String[] grapplinghookaliases = {"grapplinghook", "grapplehook", "hook", "ghook"}; String[] grapplinghookaliases = {"grapplinghook", "grapplehook", "hook", "ghook"};
public static boolean debug = ProjectKorra.plugin.getConfig().getBoolean("debug"); public static boolean debug = ProjectKorra.plugin.getConfig().getBoolean("debug");
@ -86,9 +91,38 @@ public class Commands {
s.sendMessage(ChatColor.RED + "/bending bind [Ability] # " + ChatColor.YELLOW + "Bind an ability."); s.sendMessage(ChatColor.RED + "/bending bind [Ability] # " + ChatColor.YELLOW + "Bind an ability.");
return true; return true;
} }
if (Arrays.asList(invinciblealiases).contains(args[0].toLowerCase())) {
if (!s.hasPermission("bending.command.invincible")) {
s.sendMessage(ChatColor.RED + "You don't have permission to do that.");
return true;
}
if (!(s instanceof Player)) {
s.sendMessage(ChatColor.RED + "This command is only usable by players.");
return true;
}
if (args.length != 1) {
s.sendMessage(ChatColor.GOLD + "Proper Usage: /bending invincible");
return true;
}
if (!invincible.contains(s.getName())) {
/*
* Player is not invincible.
*/
invincible.add(s.getName());
s.sendMessage(ChatColor.GREEN + "You are now invincible to all bending damage and effects. Use this command again to disable this.");
return true;
} else {
invincible.remove(s.getName());
s.sendMessage(ChatColor.RED + "You are no longer invincible to all bending damage and effects.");
}
}
if (Arrays.asList(givealiases).contains(args[0].toLowerCase())) { if (Arrays.asList(givealiases).contains(args[0].toLowerCase())) {
if (!s.hasPermission("bending.command.give")) { if (!s.hasPermission("bending.command.give")) {
s.sendMessage(ChatColor.RED + "You don't have permission to do that."); s.sendMessage(ChatColor.RED + "You don't have permission to do that.");
return true;
} }
if (args.length < 3) { if (args.length < 3) {
@ -1022,6 +1056,7 @@ public class Commands {
s.sendMessage(ChatColor.YELLOW + "/bending version"); s.sendMessage(ChatColor.YELLOW + "/bending version");
s.sendMessage(ChatColor.YELLOW + "/bending who"); s.sendMessage(ChatColor.YELLOW + "/bending who");
s.sendMessage(ChatColor.YELLOW + "/bending give [Player] [Item] <Properties>"); s.sendMessage(ChatColor.YELLOW + "/bending give [Player] [Item] <Properties>");
s.sendMessage(ChatColor.YELLOW + "/bending invincible");
return true; return true;
} }
if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) { if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) {
@ -1064,6 +1099,11 @@ public class Commands {
+ "Equalists in The Legend of Korra."); + "Equalists in The Legend of Korra.");
s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y"); s.sendMessage(ChatColor.YELLOW + "Learn More: " + ChatColor.DARK_AQUA + "http://tinyurl.com/mkp9n6y");
} }
if (Arrays.asList(invinciblealiases).contains(args[1].toLowerCase())) {
s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending invincible");
s.sendMessage(ChatColor.YELLOW + "This command will make you impervious to all Bending damage. Once you "
+ "use this command, you will stay invincible until you either log off, or use this command again.");
}
if (Arrays.asList(importaliases).contains(args[1].toLowerCase())) { if (Arrays.asList(importaliases).contains(args[1].toLowerCase())) {
s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending import"); s.sendMessage(ChatColor.GOLD + "Proper Usage: " + ChatColor.DARK_AQUA + "/bending import");
s.sendMessage(ChatColor.YELLOW + "This command will import your old bendingPlayers.yml from the Bending plugin." s.sendMessage(ChatColor.YELLOW + "This command will import your old bendingPlayers.yml from the Bending plugin."

View file

@ -242,6 +242,7 @@ public class Methods {
public static boolean canBeBloodbent(Player player) { public static boolean canBeBloodbent(Player player) {
if (AvatarState.isAvatarState(player)) if (AvatarState.isAvatarState(player))
return false; return false;
if (Commands.invincible.contains(player.getName())) return false;
if (isChiBlocked(player.getName())) if (isChiBlocked(player.getName()))
return true; return true;
if (canBend(player.getName(), "Bloodbending") && Methods.getBendingPlayer(player.getName()).isToggled) if (canBend(player.getName(), "Bloodbending") && Methods.getBendingPlayer(player.getName()).isToggled)
@ -382,6 +383,9 @@ public class Methods {
*/ */
public static void damageEntity(Player player, Entity entity, double damage) { public static void damageEntity(Player player, Entity entity, double damage) {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) return;
}
((LivingEntity) entity).damage(damage, player); ((LivingEntity) entity).damage(damage, player);
((LivingEntity) entity).setLastDamageCause( ((LivingEntity) entity).setLastDamageCause(
new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage)); new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage));

View file

@ -305,7 +305,9 @@ public class PKListener implements Listener {
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
if (Commands.invincible.contains(event.getPlayer().getName()) {
Commands.invincible.remove(event.getPlayer().getName());
}
BendingPlayer.players.remove(event.getPlayer().getName()); BendingPlayer.players.remove(event.getPlayer().getName());
if (EarthArmor.instances.containsKey(event.getPlayer())) { if (EarthArmor.instances.containsKey(event.getPlayer())) {
EarthArmor.removeEffect(event.getPlayer()); EarthArmor.removeEffect(event.getPlayer());

View file

@ -7,12 +7,14 @@ import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.configuration.MemorySection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.BendingPlayer; import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Flight; import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -150,12 +152,6 @@ public class AirBlast {
instances.remove(id); instances.remove(id);
return false; return false;
} }
// if (player.isSneaking()
// && Methods.getBendingAbility(player) == Abilities.AirBlast) {
// new AirBlast(player);
// }
Block block = location.getBlock(); Block block = location.getBlock();
for (Block testblock : Methods.getBlocksAroundPoint(location, affectingradius)) { for (Block testblock : Methods.getBlocksAroundPoint(location, affectingradius)) {
if (testblock.getType() == Material.FIRE) { if (testblock.getType() == Material.FIRE) {
@ -193,21 +189,12 @@ public class AirBlast {
return false; return false;
} }
// Methods.verbose(location.distance(origin));
if (location.distance(origin) > range) { if (location.distance(origin) > range) {
// Methods.verbose(id);
instances.remove(id); instances.remove(id);
return false; return false;
} }
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) { for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
// if (source == null) {
// if (affectedentities.contains(entity))
// continue;
// } else {
// if (source.isAffectedEntity(entity))
// continue;
// }
affect(entity); affect(entity);
} }
@ -218,16 +205,10 @@ public class AirBlast {
private void advanceLocation() { private void advanceLocation() {
Methods.playAirbendingParticles(location, 10); Methods.playAirbendingParticles(location, 10);
// ParticleEffect.SPELL.display(location, (float)0, (float)0, (float)0, (float)speed, (int)20);
// location.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
location = location.add(direction.clone().multiply(speedfactor)); location = location.add(direction.clone().multiply(speedfactor));
} }
private void affect(Entity entity) { private void affect(Entity entity) {
// if (source == null)
// affectedentities.add(entity);
// else
// source.addAffectedEntity(entity);
boolean isUser = entity.getEntityId() == player.getEntityId(); boolean isUser = entity.getEntityId() == player.getEntityId();
if (!isUser || otherorigin) { if (!isUser || otherorigin) {
@ -263,22 +244,10 @@ public class AirBlast {
} else { } else {
velocity.add(push.clone().multiply(factor * .5)); velocity.add(push.clone().multiply(factor * .5));
} }
// velocity = if (entity instanceof Player) {
// velocity.clone().add(direction.clone().multiply(factor)); if (Commands.invincible.contains(((Player) entity).getName())) return;
// double newmag = Math.abs(velocity.getY()); }
// if (newmag > mag) {
// if (mag > max) {
// velocity = velocity.clone().multiply(mag / newmag);
// } else if (newmag > max) {
// velocity = velocity.clone().multiply(max / newmag);
// }
// }
//
// velocity.multiply(1 - location.distance(origin) / (2 * range));
//
// if (entity instanceof Player)
// velocity.multiply(2);
entity.setVelocity(velocity); entity.setVelocity(velocity);
entity.setFallDistance(0); entity.setFallDistance(0);

View file

@ -9,6 +9,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Ability.AvatarState; import com.projectkorra.ProjectKorra.Ability.AvatarState;
@ -83,6 +84,12 @@ public class AirShield {
velocity.setX(vx); velocity.setX(vx);
velocity.setZ(vz); velocity.setZ(vz);
} }
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
continue;
}
}
velocity.multiply(radius / maxradius); velocity.multiply(radius / maxradius);
entity.setVelocity(velocity); entity.setVelocity(velocity);

View file

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.BendingPlayer; import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Flight; import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -154,38 +155,6 @@ public class AirSuction {
// continue; // continue;
// affectedentities.add(entity); // affectedentities.add(entity);
if (entity.getEntityId() != player.getEntityId() || otherorigin) { if (entity.getEntityId() != player.getEntityId() || otherorigin) {
// Vector velocity = entity.getVelocity();
// double mag = Math.abs(velocity.getY());
// double max = maxspeed;
// if (AvatarState.isAvatarState(player)) {
// max = AvatarState.getValue(maxspeed);
// velocity = velocity.clone().add(
// direction.clone().multiply(
// AvatarState.getValue(pushfactor)));
// double newmag = Math.abs(velocity.getY());
// if (newmag > mag) {
// if (mag > max) {
// velocity = velocity.clone().multiply(mag / newmag);
// } else if (newmag > max) {
// velocity = velocity.clone().multiply(max / newmag);
// }
// }
// } else {
// velocity = velocity.clone().add(
// direction.clone().multiply(pushfactor));
// double newmag = Math.abs(velocity.getY());
// if (newmag > mag) {
// if (mag > max) {
// velocity = velocity.clone().multiply(mag / newmag);
// } else if (newmag > max) {
// velocity = velocity.clone().multiply(max / newmag);
// }
// }
// }
// if (entity instanceof Player)
// velocity.multiply(2);
// entity.setVelocity(velocity);
// entity.setFallDistance(0);
Vector velocity = entity.getVelocity(); Vector velocity = entity.getVelocity();
double max = maxspeed; double max = maxspeed;
double factor = pushfactor; double factor = pushfactor;
@ -219,6 +188,10 @@ public class AirSuction {
} else { } else {
velocity.add(push.clone().multiply(factor * .5)); velocity.add(push.clone().multiply(factor * .5));
} }
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) continue;
}
entity.setVelocity(velocity); entity.setVelocity(velocity);
entity.setFallDistance(0); entity.setFallDistance(0);
if (entity.getEntityId() != player.getEntityId() if (entity.getEntityId() != player.getEntityId()

View file

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.BendingPlayer; import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Flight; import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -158,10 +159,6 @@ public class AirSwipe {
return true; return true;
} else if (System.currentTimeMillis() >= time + maxchargetime) { } else if (System.currentTimeMillis() >= time + maxchargetime) {
Methods.playAirbendingParticles(player.getEyeLocation(), 10); Methods.playAirbendingParticles(player.getEyeLocation(), 10);
// player.getWorld().playEffect(
// player.getEyeLocation(),
// Effect.SMOKE,
// Methods.getIntCardinalDirection(player.getEyeLocation().getDirection()), 3);
} }
} }
return true; return true;
@ -217,8 +214,6 @@ public class AirSwipe {
} }
} else { } else {
Methods.playAirbendingParticles(location, 10); Methods.playAirbendingParticles(location, 10);
// location.getWorld().playEffect(location, Effect.SMOKE,
// 4, (int) AirBlast.defaultrange);
affectPeople(location, direction); affectPeople(location, direction);
} }
} }
@ -239,6 +234,9 @@ public class AirSwipe {
if (Methods.isRegionProtectedFromBuild(player, "AirSwipe", entity.getLocation())) if (Methods.isRegionProtectedFromBuild(player, "AirSwipe", entity.getLocation()))
continue; continue;
if (entity.getEntityId() != player.getEntityId()) { if (entity.getEntityId() != player.getEntityId()) {
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) continue;
}
if (AvatarState.isAvatarState(player)) { if (AvatarState.isAvatarState(player)) {
entity.setVelocity(direction.multiply(AvatarState.getValue(pushfactor))); entity.setVelocity(direction.multiply(AvatarState.getValue(pushfactor)));
} else { } else {

View file

@ -10,12 +10,14 @@ import org.bukkit.Location;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.TempPotionEffect; import com.projectkorra.ProjectKorra.TempPotionEffect;
@ -120,6 +122,10 @@ public class Suffocate {
} }
if (entity instanceof Player) { if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) {
breakSuffocate(entity);
continue;
}
if (AvatarState.isAvatarState((Player) entity)) { if (AvatarState.isAvatarState((Player) entity)) {
breakSuffocate(entity); breakSuffocate(entity);
continue; continue;

View file

@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Flight; import com.projectkorra.ProjectKorra.Flight;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -146,6 +147,10 @@ public class Tornado {
vy = .6; vy = .6;
} }
} }
if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) continue;
}
Vector velocity = entity.getVelocity(); Vector velocity = entity.getVelocity();
velocity.setX(vx); velocity.setX(vx);

View file

@ -4,8 +4,10 @@ import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.entity.Creature; import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Element; import com.projectkorra.ProjectKorra.Element;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -33,6 +35,9 @@ public class Paralyze {
cooldowns.remove(targetentity); cooldowns.remove(targetentity);
} }
} }
if (targetentity instanceof Player) {
if (Commands.invincible.contains(((Player) targetentity).getName())) return;
}
paralyze(targetentity); paralyze(targetentity);
cooldowns.put(targetentity, System.currentTimeMillis()); cooldowns.put(targetentity, System.currentTimeMillis());
} }
@ -43,7 +48,7 @@ public class Paralyze {
if (entity instanceof Creature) { if (entity instanceof Creature) {
((Creature) entity).setTarget(null); ((Creature) entity).setTarget(null);
} }
if (entity instanceof Player) { if (entity instanceof Player) {
if(Suffocate.isChannelingSphere((Player) entity)) { if(Suffocate.isChannelingSphere((Player) entity)) {
Suffocate.remove((Player) entity); Suffocate.remove((Player) entity);

View file

@ -7,12 +7,14 @@ import java.util.List;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Snowball; import org.bukkit.entity.Snowball;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import com.projectkorra.ProjectKorra.BendingPlayer; import com.projectkorra.ProjectKorra.BendingPlayer;
import com.projectkorra.ProjectKorra.Commands;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
@ -63,6 +65,7 @@ public class Smokescreen {
public static void applyBlindness(Entity entity) { public static void applyBlindness(Entity entity) {
if (entity instanceof Player) { if (entity instanceof Player) {
if (Commands.invincible.contains(((Player) entity).getName())) return;
Player p = (Player) entity; Player p = (Player) entity;
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration * 20, 2)); p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration * 20, 2));
blinded.put(p.getName(), System.currentTimeMillis()); blinded.put(p.getName(), System.currentTimeMillis());

View file

@ -23,6 +23,7 @@ permissions:
bending.command.import: true bending.command.import: true
bending.command.toggle.all: true bending.command.toggle.all: true
bending.command.give: true bending.command.give: true
bending.command.invincible: true
bending.player: bending.player:
default: true default: true
description: Grants access to most abilities and basic commands. description: Grants access to most abilities and basic commands.