mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Add /bending invincible
Makes you invincible to Bending damage.
This commit is contained in:
parent
f5b01d624c
commit
65f1b12fc0
12 changed files with 90 additions and 77 deletions
|
@ -6,8 +6,10 @@ import java.sql.SQLException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -61,11 +63,14 @@ public class Commands {
|
|||
String[] whoaliases = {"who", "w"};
|
||||
String[] importaliases = {"import", "i"};
|
||||
String[] givealiases = {"give", "g", "spawn"};
|
||||
String[] invinciblealiases = {"invincible", "inv"};
|
||||
|
||||
/*
|
||||
* Item Aliases
|
||||
*/
|
||||
|
||||
public static Set<String> invincible = new HashSet<String>();
|
||||
|
||||
String[] grapplinghookaliases = {"grapplinghook", "grapplehook", "hook", "ghook"};
|
||||
|
||||
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.");
|
||||
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 (!s.hasPermission("bending.command.give")) {
|
||||
s.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length < 3) {
|
||||
|
@ -1022,6 +1056,7 @@ public class Commands {
|
|||
s.sendMessage(ChatColor.YELLOW + "/bending version");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending who");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending give [Player] [Item] <Properties>");
|
||||
s.sendMessage(ChatColor.YELLOW + "/bending invincible");
|
||||
return true;
|
||||
}
|
||||
if (Arrays.asList(airaliases).contains(args[1].toLowerCase())) {
|
||||
|
@ -1064,6 +1099,11 @@ public class Commands {
|
|||
+ "Equalists in The Legend of Korra.");
|
||||
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())) {
|
||||
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."
|
||||
|
|
|
@ -242,6 +242,7 @@ public class Methods {
|
|||
public static boolean canBeBloodbent(Player player) {
|
||||
if (AvatarState.isAvatarState(player))
|
||||
return false;
|
||||
if (Commands.invincible.contains(player.getName())) return false;
|
||||
if (isChiBlocked(player.getName()))
|
||||
return true;
|
||||
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) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) return;
|
||||
}
|
||||
((LivingEntity) entity).damage(damage, player);
|
||||
((LivingEntity) entity).setLastDamageCause(
|
||||
new EntityDamageByEntityEvent(player, entity, DamageCause.CUSTOM, damage));
|
||||
|
|
|
@ -305,7 +305,9 @@ public class PKListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
|
||||
if (Commands.invincible.contains(event.getPlayer().getName()) {
|
||||
Commands.invincible.remove(event.getPlayer().getName());
|
||||
}
|
||||
BendingPlayer.players.remove(event.getPlayer().getName());
|
||||
if (EarthArmor.instances.containsKey(event.getPlayer())) {
|
||||
EarthArmor.removeEffect(event.getPlayer());
|
||||
|
|
|
@ -7,12 +7,14 @@ import org.bukkit.Effect;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Flight;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -150,12 +152,6 @@ public class AirBlast {
|
|||
instances.remove(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (player.isSneaking()
|
||||
// && Methods.getBendingAbility(player) == Abilities.AirBlast) {
|
||||
// new AirBlast(player);
|
||||
// }
|
||||
|
||||
Block block = location.getBlock();
|
||||
for (Block testblock : Methods.getBlocksAroundPoint(location, affectingradius)) {
|
||||
if (testblock.getType() == Material.FIRE) {
|
||||
|
@ -193,21 +189,12 @@ public class AirBlast {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Methods.verbose(location.distance(origin));
|
||||
if (location.distance(origin) > range) {
|
||||
// Methods.verbose(id);
|
||||
instances.remove(id);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Entity entity : Methods.getEntitiesAroundPoint(location, affectingradius)) {
|
||||
// if (source == null) {
|
||||
// if (affectedentities.contains(entity))
|
||||
// continue;
|
||||
// } else {
|
||||
// if (source.isAffectedEntity(entity))
|
||||
// continue;
|
||||
// }
|
||||
affect(entity);
|
||||
}
|
||||
|
||||
|
@ -218,16 +205,10 @@ public class AirBlast {
|
|||
|
||||
private void advanceLocation() {
|
||||
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));
|
||||
}
|
||||
|
||||
private void affect(Entity entity) {
|
||||
// if (source == null)
|
||||
// affectedentities.add(entity);
|
||||
// else
|
||||
// source.addAffectedEntity(entity);
|
||||
boolean isUser = entity.getEntityId() == player.getEntityId();
|
||||
|
||||
if (!isUser || otherorigin) {
|
||||
|
@ -263,22 +244,10 @@ public class AirBlast {
|
|||
} else {
|
||||
velocity.add(push.clone().multiply(factor * .5));
|
||||
}
|
||||
|
||||
// velocity =
|
||||
// velocity.clone().add(direction.clone().multiply(factor));
|
||||
// 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);
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) return;
|
||||
}
|
||||
|
||||
entity.setVelocity(velocity);
|
||||
entity.setFallDistance(0);
|
||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
|
@ -83,6 +84,12 @@ public class AirShield {
|
|||
velocity.setX(vx);
|
||||
velocity.setZ(vz);
|
||||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
velocity.multiply(radius / maxradius);
|
||||
entity.setVelocity(velocity);
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Flight;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -154,38 +155,6 @@ public class AirSuction {
|
|||
// continue;
|
||||
// affectedentities.add(entity);
|
||||
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();
|
||||
double max = maxspeed;
|
||||
double factor = pushfactor;
|
||||
|
@ -219,6 +188,10 @@ public class AirSuction {
|
|||
} else {
|
||||
velocity.add(push.clone().multiply(factor * .5));
|
||||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) continue;
|
||||
}
|
||||
entity.setVelocity(velocity);
|
||||
entity.setFallDistance(0);
|
||||
if (entity.getEntityId() != player.getEntityId()
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Flight;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -158,10 +159,6 @@ public class AirSwipe {
|
|||
return true;
|
||||
} else if (System.currentTimeMillis() >= time + maxchargetime) {
|
||||
Methods.playAirbendingParticles(player.getEyeLocation(), 10);
|
||||
// player.getWorld().playEffect(
|
||||
// player.getEyeLocation(),
|
||||
// Effect.SMOKE,
|
||||
// Methods.getIntCardinalDirection(player.getEyeLocation().getDirection()), 3);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -217,8 +214,6 @@ public class AirSwipe {
|
|||
}
|
||||
} else {
|
||||
Methods.playAirbendingParticles(location, 10);
|
||||
// location.getWorld().playEffect(location, Effect.SMOKE,
|
||||
// 4, (int) AirBlast.defaultrange);
|
||||
affectPeople(location, direction);
|
||||
}
|
||||
}
|
||||
|
@ -239,6 +234,9 @@ public class AirSwipe {
|
|||
if (Methods.isRegionProtectedFromBuild(player, "AirSwipe", entity.getLocation()))
|
||||
continue;
|
||||
if (entity.getEntityId() != player.getEntityId()) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) continue;
|
||||
}
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
entity.setVelocity(direction.multiply(AvatarState.getValue(pushfactor)));
|
||||
} else {
|
||||
|
|
|
@ -10,12 +10,14 @@ import org.bukkit.Location;
|
|||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.TempPotionEffect;
|
||||
|
@ -120,6 +122,10 @@ public class Suffocate {
|
|||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) {
|
||||
breakSuffocate(entity);
|
||||
continue;
|
||||
}
|
||||
if (AvatarState.isAvatarState((Player) entity)) {
|
||||
breakSuffocate(entity);
|
||||
continue;
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Flight;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -146,6 +147,10 @@ public class Tornado {
|
|||
vy = .6;
|
||||
}
|
||||
}
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) continue;
|
||||
}
|
||||
|
||||
Vector velocity = entity.getVelocity();
|
||||
velocity.setX(vx);
|
||||
|
|
|
@ -4,8 +4,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Element;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -33,6 +35,9 @@ public class Paralyze {
|
|||
cooldowns.remove(targetentity);
|
||||
}
|
||||
}
|
||||
if (targetentity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) targetentity).getName())) return;
|
||||
}
|
||||
paralyze(targetentity);
|
||||
cooldowns.put(targetentity, System.currentTimeMillis());
|
||||
}
|
||||
|
@ -43,7 +48,7 @@ public class Paralyze {
|
|||
if (entity instanceof Creature) {
|
||||
((Creature) entity).setTarget(null);
|
||||
}
|
||||
|
||||
|
||||
if (entity instanceof Player) {
|
||||
if(Suffocate.isChannelingSphere((Player) entity)) {
|
||||
Suffocate.remove((Player) entity);
|
||||
|
|
|
@ -7,12 +7,14 @@ import java.util.List;
|
|||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Snowball;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
||||
|
@ -63,6 +65,7 @@ public class Smokescreen {
|
|||
|
||||
public static void applyBlindness(Entity entity) {
|
||||
if (entity instanceof Player) {
|
||||
if (Commands.invincible.contains(((Player) entity).getName())) return;
|
||||
Player p = (Player) entity;
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, duration * 20, 2));
|
||||
blinded.put(p.getName(), System.currentTimeMillis());
|
||||
|
|
|
@ -23,6 +23,7 @@ permissions:
|
|||
bending.command.import: true
|
||||
bending.command.toggle.all: true
|
||||
bending.command.give: true
|
||||
bending.command.invincible: true
|
||||
bending.player:
|
||||
default: true
|
||||
description: Grants access to most abilities and basic commands.
|
||||
|
|
Loading…
Reference in a new issue