Cherry pick pull requests from master

This commit is contained in:
Nathan Braun 2016-01-14 17:07:59 -08:00
parent d2bd987895
commit 0e6e41ad88
43 changed files with 382 additions and 192 deletions

View file

@ -109,7 +109,6 @@ public class BendingManager implements Runnable {
HorizontalVelocityTracker.updateAll();
handleCooldowns();
} catch (Exception e) {
GeneralMethods.stopBending();
e.printStackTrace();
}
}

View file

@ -101,7 +101,7 @@ public class BendingPlayer {
* @param cooldown The cooldown time
*/
public void addCooldown(String ability, long cooldown) {
PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, Result.ADDED);
PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, cooldown, Result.ADDED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.cooldowns.put(ability, cooldown + System.currentTimeMillis());
@ -148,20 +148,16 @@ public class BendingPlayer {
}
private boolean canBend(CoreAbility ability, boolean ignoreBinds, boolean ignoreCooldowns) {
if (ability == null) {
if (ability == null || ability.getPlayer() == null) {
return false;
}
List<String> disabledWorlds = getConfig().getStringList("Properties.DisabledWorlds");
Location location = null;
Location playerLoc = player.getLocation();
if (player != null) {
location = player.getLocation();
}
if (player == null || !player.isOnline() || player.isDead()) {
if (!player.isOnline() || player.isDead()) {
return false;
} else if (location != null && !location.getWorld().equals(player.getWorld())) {
} else if (ability.getLocation() != null && !ability.getLocation().getWorld().equals(player.getWorld())) {
return false;
} else if (!ignoreCooldowns && isOnCooldown(ability.getName())) {
return false;
@ -175,7 +171,7 @@ public class BendingPlayer {
return false;
}
if (!ignoreCooldowns && cooldowns.containsKey(name)) { // TODO: wtf is this
if (!ignoreCooldowns && cooldowns.containsKey(name)) {
if (cooldowns.get(name) + getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
return false;
}
@ -184,7 +180,7 @@ public class BendingPlayer {
if (isChiBlocked() || isParalyzed() || isBloodbended() || isControlledByMetalClips()) {
return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, ability.getName(), location)) {
} else if (GeneralMethods.isRegionProtectedFromBuild(player, ability.getName(), playerLoc)) {
return false;
} else if (ability instanceof FireAbility && BendingManager.events.get(player.getWorld()) != null
&& BendingManager.events.get(player.getWorld()).equalsIgnoreCase("SolarEclipse")) {
@ -555,7 +551,7 @@ public class BendingPlayer {
* @param ability The ability's cooldown to remove
*/
public void removeCooldown(String ability) {
PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, Result.REMOVED);
PlayerCooldownChangeEvent event = new PlayerCooldownChangeEvent(Bukkit.getPlayer(uuid), ability, 0, Result.REMOVED);
Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.cooldowns.remove(ability);
@ -664,11 +660,12 @@ public class BendingPlayer {
*
* @see #getBendingPlayer(UUID)
*/
public static BendingPlayer getBendingPlayer(String player) {
OfflinePlayer oPlayer = Bukkit.getPlayer(player);
if (player == null) {
oPlayer = Bukkit.getOfflinePlayer(oPlayer.getUniqueId());
public static BendingPlayer getBendingPlayer(String playerName) {
if (playerName == null) {
return null;
}
Player player = Bukkit.getPlayer(playerName);
OfflinePlayer oPlayer = player != null ? Bukkit.getOfflinePlayer(player.getUniqueId()) : null;
return getBendingPlayer(oPlayer);
}

View file

@ -185,7 +185,7 @@ public class PKListener implements Listener {
String append = "";
ChatColor color = null;
boolean chatEnabled = ProjectKorra.plugin.getConfig().getBoolean("Properties.Chat.Enable");
if ((player.hasPermission("bending.avatar") || bPlayer.getElements().size() > 1) && chatEnabled) {
if (bPlayer.getElements().size() > 1 && chatEnabled) {
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Avatar");
color = ChatColor.valueOf(plugin.getConfig().getString("Properties.Chat.Colors.Avatar"));
} else if (bPlayer.hasElement(Element.AIR) && chatEnabled) {
@ -203,11 +203,16 @@ public class PKListener implements Listener {
} else if (bPlayer.hasElement(Element.CHI) && chatEnabled) {
append = plugin.getConfig().getString("Properties.Chat.Prefixes.Chi");
color = Element.CHI.getColor();
} else {
append = "[Nonbender]";
color = ChatColor.WHITE;
}
if (chatEnabled) {
player.setDisplayName(player.getName());
player.setDisplayName(color + append + ChatColor.RESET + player.getDisplayName());
if(color != null) {
player.setDisplayName(color + append + ChatColor.RESET + player.getDisplayName());
}
}
// Handle the AirSpout/WaterSpout login glitches
@ -388,6 +393,9 @@ public class PKListener implements Listener {
} else if (element != null) {
append = plugin.getConfig().getString("Properties.Chat.Prefixes." + element.getName());
color = element.getColor();
} else {
append = "[Nonbender]";
color = ChatColor.WHITE;
}
if (chatEnabled) {
@ -1185,7 +1193,9 @@ public class PKListener implements Listener {
|| !abilName.equalsIgnoreCase("FireBlast")
|| !abilName.equalsIgnoreCase("EarthBlast")
|| !abilName.equalsIgnoreCase("WaterManipulation")) {
event.setCancelled(true);
if(!player.isSneaking()) {
event.setCancelled(true);
}
}
}

View file

@ -265,11 +265,11 @@ public abstract class EarthAbility extends BlockAbility {
@SuppressWarnings("deprecation")
public static Block getEarthSourceBlock(Player player, String abilityName, double range) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
Block testblock = player.getTargetBlock(getTransparentMaterialSet(), (int) range);
Block testBlock = player.getTargetBlock(getTransparentMaterialSet(), (int) range);
if (bPlayer == null) {
return null;
} else if (isEarthbendable(player, testblock) || isMetalbendable(player, testblock.getType())) {
return testblock;
} else if (isEarthbendable(player, testBlock) || isMetalbendable(player, testBlock.getType())) {
return testBlock;
}
Location location = player.getEyeLocation();
@ -383,7 +383,7 @@ public abstract class EarthAbility extends BlockAbility {
}
public static boolean isEarthbendable(Material material) {
return getConfig().getStringList("Properties.Earth.EarthbendableBlocks").contains(material.toString());
return isEarth(material) || isMetal(material) || isSand(material);
}
public static boolean isEarthbendable(Player player, Block block) {

View file

@ -58,6 +58,14 @@ public abstract class ElementalAbility extends CoreAbility {
return false;
}
public static boolean isEarth(Block block) {
return block != null ? isEarth(block.getType()) : false;
}
public static boolean isEarth(Material material) {
return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString());
}
public static boolean isFullMoon(World world) {
if (GeneralMethods.hasRPG()) {
return EventManager.marker.get(world).equalsIgnoreCase("FullMoon");
@ -70,11 +78,11 @@ public abstract class ElementalAbility extends CoreAbility {
return false;
}
}
public static boolean isIce(Block block) {
return isIce(block.getType());
}
public static boolean isIce(Material material) {
return material == Material.ICE || material == Material.PACKED_ICE;
}
@ -82,11 +90,11 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isLava(Block block) {
return block != null ? isLava(block.getType()) : false;
}
public static boolean isLava(Material material) {
return material == Material.LAVA || material == Material.STATIONARY_LAVA;
}
public static boolean isLunarEclipse(World world) {
if (world == null) {
return false;
@ -135,7 +143,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isNight(World world) {
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
return false;
@ -147,7 +155,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
@SuppressWarnings("deprecation")
public static boolean isPlant(Block block) {
if (block == null) {
@ -157,7 +165,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isPositiveEffect(PotionEffectType effect) {
for (PotionEffectType effect2 : POSITIVE_EFFECTS) {
if (effect2.equals(effect)) {
@ -167,19 +175,27 @@ public abstract class ElementalAbility extends CoreAbility {
return false;
}
public static boolean isSand(Block block) {
return block != null ? isSand(block.getType()) : false;
}
public static boolean isSand(Material material) {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
}
public static boolean isSozinsComet(World world) {
return world != null ? EventManager.marker.get(world).equalsIgnoreCase("SozinsComet") : false;
}
public static boolean isTransparent(Player player, Block block) {
return isTransparent(player, null, block);
}
@SuppressWarnings("deprecation")
public static boolean isTransparent(Player player, String abilityName, Block block) {
return Arrays.asList(TRANSPARENT_MATERIAL).contains(block.getTypeId())
&& !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
}
public static boolean isTransparentToEarthbending(Player player, Block block) {
return isTransparent(player, null, block);
}
public static boolean isUndead(Entity entity) {
if (entity == null) {

View file

@ -195,7 +195,7 @@ public abstract class WaterAbility extends BlockAbility {
}
public static boolean isIcebendable(Material material) {
if (material == Material.ICE) {
if (material == Material.ICE || material == Material.SNOW) {
return true;
} else if (material == Material.PACKED_ICE && canBendPackedIce()) {
return true;

View file

@ -34,8 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
public class AirBlast extends AirAbility {
private static final int MAX_TICKS = 10000;
private static final int ORIGIN_PARTICLE_COUNT = 4;
private static final double ORIGIN_SELECT_RANGE = 10;
private static final ConcurrentHashMap<Player, Location> ORIGINS = new ConcurrentHashMap<>();
private boolean canFlickLevers;
@ -45,7 +43,7 @@ public class AirBlast extends AirAbility {
private boolean isFromOtherOrigin;
private boolean showParticles;
private int ticks;
private int particleCount;
private int particles;
private long cooldown;
private double speedFactor;
private double range;
@ -111,6 +109,8 @@ public class AirBlast extends AirAbility {
}
private void setFields() {
this.particles = getConfig().getInt("Abilities.Air.AirBlast.Particles");
this.cooldown = getConfig().getLong("Abilities.Air.AirBlast.Cooldown");
this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed");
this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
@ -121,9 +121,7 @@ public class AirBlast extends AirAbility {
this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors");
this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons");
this.canCoolLava = getConfig().getBoolean("Abilities.Air.AirBlast.CanCoolLava");
this.particleCount = 6;
this.cooldown = GeneralMethods.getGlobalCooldown();
this.isFromOtherOrigin = false;
this.showParticles = true;
this.random = new Random();
@ -146,12 +144,12 @@ public class AirBlast extends AirAbility {
} else if (!bPlayer.canBendIgnoreCooldowns(getAbility("AirBlast"))) {
ORIGINS.remove(player);
return;
} else if (origin.distanceSquared(player.getEyeLocation()) > ORIGIN_SELECT_RANGE * ORIGIN_SELECT_RANGE) {
} else if (origin.distanceSquared(player.getEyeLocation()) > getSelectRange() * getSelectRange()) {
ORIGINS.remove(player);
return;
}
playAirbendingParticles(origin, ORIGIN_PARTICLE_COUNT);
playAirbendingParticles(origin, getSelectParticles());
}
public static void progressOrigins() {
@ -161,7 +159,7 @@ public class AirBlast extends AirAbility {
}
public static void setOrigin(Player player) {
Location location = GeneralMethods.getTargetedLocation(player, ORIGIN_SELECT_RANGE, GeneralMethods.NON_OPAQUE);
Location location = GeneralMethods.getTargetedLocation(player, getSelectRange(), GeneralMethods.NON_OPAQUE);
if (location.getBlock().isLiquid() || GeneralMethods.isSolid(location.getBlock())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", location)) {
@ -177,7 +175,7 @@ public class AirBlast extends AirAbility {
private void advanceLocation() {
if (showParticles) {
playAirbendingParticles(location, particleCount, 0.275F, 0.275F, 0.275F);
playAirbendingParticles(location, particles, 0.275F, 0.275F, 0.275F);
}
if (random.nextInt(4) == 0) {
playAirbendingSound(location);
@ -606,4 +604,20 @@ public class AirBlast extends AirAbility {
this.cooldown = cooldown;
}
public int getParticles() {
return particles;
}
public void setParticles(int particles) {
this.particles = particles;
}
public static int getSelectParticles() {
return getConfig().getInt("Abilities.Air.AirBlast.SelectParticles");
}
public static double getSelectRange() {
return getConfig().getInt("Abilities.Air.AirBlast.SelectRange");
}
}

View file

@ -15,18 +15,17 @@ import com.projectkorra.projectkorra.avatar.AvatarState;
public class AirBurst extends AirAbility {
private static final int CHARGED_SNEAK_PARTICLES = 10;
private static final double PARTICLES_PERCENTAGE = 50;
private boolean isCharged;
private boolean isFallBurst;
private int sneakParticles;
private float playerFallDistance;
private long chargeTime;
private double fallThreshold;
private double pushFactor;
private double damage;
private double blastAngleTheta;
private double blastAnglePhi;
private double blastAnglePhi;
private double particlePercentage;
private ArrayList<AirBlast> blasts;
private ArrayList<Entity> affectedEntities;
@ -39,13 +38,15 @@ public class AirBurst extends AirAbility {
this.isFallBurst = isFallBurst;
this.isCharged = false;
this.blastAnglePhi = 10;
this.blastAngleTheta = 10;
this.playerFallDistance = player.getFallDistance();
this.chargeTime = getConfig().getLong("Abilities.Air.AirBurst.ChargeTime");
this.fallThreshold = getConfig().getDouble("Abilities.Air.AirBurst.FallThreshold");
this.pushFactor = getConfig().getDouble("Abilities.Air.AirBurst.PushFactor");
this.damage = getConfig().getDouble("Abilities.Air.AirBurst.Damage");
this.blastAnglePhi = getConfig().getDouble("Abilities.Air.AirBurst.AnglePhi");
this.blastAngleTheta = getConfig().getDouble("Abilities.Air.AirBurst.AngleTheta");
this.sneakParticles = getConfig().getInt("Abilities.Air.AirBurst.SneakParticles");
this.particlePercentage = getConfig().getDouble("Abilities.Air.AirBurst.ParticlePercentage");
this.blasts = new ArrayList<>();
this.affectedEntities = new ArrayList<>();
@ -86,7 +87,7 @@ public class AirBurst extends AirAbility {
}
} else if (isCharged) {
Location location = player.getEyeLocation();
playAirbendingParticles(location, CHARGED_SNEAK_PARTICLES);
playAirbendingParticles(location, sneakParticles);
}
}
@ -149,7 +150,7 @@ public class AirBurst extends AirAbility {
int toggleTime = 0;
if (i % 4 != 0) {
toggleTime = (int) (i % (100 / PARTICLES_PERCENTAGE)) + 3;
toggleTime = (int) (i % (100 / particlePercentage)) + 3;
}
new BukkitRunnable() {
public void run() {

View file

@ -18,12 +18,8 @@ import java.util.Random;
public class AirScooter extends AirAbility {
private static final long SPIN_INTERVAL = 100;
private static final double SCOOTER_RADIUS = 1;
private static final double MAX_HEIGHT_FROM_GROUND = 7;
private double speed;
private double spinInterval;
private double interval;
private double radius;
private double maxHeightFromGround;
private Block floorblock;
@ -42,9 +38,9 @@ public class AirScooter extends AirAbility {
}
this.speed = getConfig().getDouble("Abilities.Air.AirScooter.Speed");
this.spinInterval = SPIN_INTERVAL;
this.radius = SCOOTER_RADIUS;
this.maxHeightFromGround = MAX_HEIGHT_FROM_GROUND;
this.interval = getConfig().getDouble("Abilities.Air.AirScooter.Interval");
this.radius = getConfig().getDouble("Abilities.Air.AirScooter.Radius");
this.maxHeightFromGround = getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround");
this.random = new Random();
this.angles = new ArrayList<>();
@ -87,8 +83,13 @@ public class AirScooter extends AirAbility {
@Override
public void progress() {
if (!bPlayer.canBendIgnoreCooldowns(this) || !player.isFlying()) {
remove();
return;
}
getFloor();
if (floorblock == null || !bPlayer.canBend(this) || !player.isFlying()) {
if (floorblock == null) {
remove();
return;
}
@ -97,7 +98,7 @@ public class AirScooter extends AirAbility {
velocity.setY(0);
velocity = velocity.clone().normalize().multiply(speed);
if (System.currentTimeMillis() > startTime + spinInterval) {
if (System.currentTimeMillis() > startTime + interval) {
if (player.getVelocity().length() < speed * .5) {
remove();
return;
@ -187,12 +188,12 @@ public class AirScooter extends AirAbility {
this.speed = speed;
}
public double getSpinInterval() {
return spinInterval;
public double getInterval() {
return interval;
}
public void setSpinInterval(double spinInterval) {
this.spinInterval = spinInterval;
public void setInterval(double interval) {
this.interval = interval;
}
public double getRadius() {

View file

@ -81,8 +81,8 @@ public class Suffocate extends AirAbility {
this.blind = getConfig().getInt("Abilities.Air.Suffocate.BlindPotentcy");
this.blindDelay = getConfig().getDouble("Abilities.Air.Suffocate.BlindDelay");
this.blindRepeat = getConfig().getDouble("Abilities.Air.Suffocate.BlindInterval");
this.targets = new ArrayList<LivingEntity>();
this.tasks = new ArrayList<BukkitRunnable>();
this.targets = new ArrayList<>();
this.tasks = new ArrayList<>();
if (bPlayer.isAvatarState()) {
cooldown = 0;
@ -109,12 +109,17 @@ public class Suffocate extends AirAbility {
}
}
} else {
Entity ent = GeneralMethods.getTargetedEntity(player, range);
if (ent != null && ent instanceof LivingEntity) {
targets.add((LivingEntity) ent);
Location location = GeneralMethods.getTargetedLocation(player, 6, getTransparentMaterial());
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, 1.5);
if (entities == null || entities.isEmpty()) {
return;
}
Entity target = entities.get(0);
if (target != null && target instanceof LivingEntity) {
targets.add((LivingEntity) target);
}
}
if (!canSuffocateUndead) {
for (int i = 0; i < targets.size(); i++) {
LivingEntity target = targets.get(i);

View file

@ -95,7 +95,10 @@ public class ChiCombo extends ChiAbility implements ComboAbility {
PARALYZED_ENTITIES.remove(entity);
for (ChiCombo combo : getAbilities(ChiCombo.class)) {
if (combo.target.equals(entity)) {
if (combo.target == null) {
combo.remove();
continue;
} else if (combo.target.equals(entity)) {
combo.remove();
}
}

View file

@ -114,7 +114,7 @@ public class BendingTabComplete implements TabCompleter {
}
List<String> abils = new ArrayList<String>();
for (CoreAbility coreAbil : CoreAbility.getAbilities()) {
if (bPlayer.canBind(coreAbil)) {
if (bPlayer.canBind(coreAbil) && !coreAbil.getName().toLowerCase().contains("click")) {
abils.add(coreAbil.getName());
}
}

View file

@ -78,7 +78,9 @@ public class PresetCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + "You don't have a preset with that name.");
return;
}
boolean boundAll = Preset.bindPreset(player, name);
Preset preset = Preset.getPreset(player, name);
boolean boundAll = Preset.bindPreset(player, preset);
sender.sendMessage(ChatColor.GREEN + "Your bound slots have been set to match the " + ChatColor.YELLOW + name + ChatColor.GREEN + " preset.");
if (!boundAll) {
sender.sendMessage(ChatColor.RED + "Some abilities were not bound because you cannot bend the required element.");
@ -100,7 +102,7 @@ public class PresetCommand extends PKCommand {
return;
HashMap<Integer, String> abilities = bPlayer.getAbilities();
Preset preset = new Preset(player.getUniqueId(), name, abilities);
preset.save();
preset.save(player);
sender.sendMessage(ChatColor.GREEN + "Created preset with the name: " + ChatColor.YELLOW + name);
} else {
help(sender, false);

View file

@ -72,7 +72,7 @@ public class WhoCommand extends PKCommand {
List<String> players = new ArrayList<String>();
for (Player player : Bukkit.getOnlinePlayers()) {
String playerName = player.getName();
String result = "";
String result = ChatColor.WHITE + playerName;
BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName);
if (bp == null) {
@ -185,7 +185,12 @@ public class WhoCommand extends PKCommand {
if (bPlayer != null) {
sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - ");
if (bPlayer.hasElement(Element.AIR)) {
sender.sendMessage(Element.AIR + "- Airbender");
if(bPlayer.isElementToggled(Element.AIR)) {
sender.sendMessage(Element.AIR.getColor() + "- Airbender");
} else {
sender.sendMessage(Element.AIR.getColor() + "" + ChatColor.STRIKETHROUGH + "- Airbender");
}
if (player_ != null && bPlayer.canUseFlight()) {
sender.sendMessage(Element.FLIGHT.getColor() + " Can Fly");
}
@ -194,7 +199,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.WATER)) {
sender.sendMessage(Element.WATER.getColor() + "- Waterbender");
if(bPlayer.isElementToggled(Element.WATER)) {
sender.sendMessage(Element.WATER.getColor() + "- Waterbender");
} else {
sender.sendMessage(Element.WATER.getColor() + "" + ChatColor.STRIKETHROUGH + "- Waterbender");
}
if (player_ != null && bPlayer.canPlantbend()) {
sender.sendMessage(Element.PLANT.getColor() + " Can Plantbend");
}
@ -213,7 +223,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.EARTH)) {
sender.sendMessage(Element.EARTH.getColor() + "- Earthbender");
if(bPlayer.isElementToggled(Element.EARTH)) {
sender.sendMessage(Element.EARTH.getColor() + "- Earthbender");
} else {
sender.sendMessage(Element.EARTH.getColor() + "" + ChatColor.STRIKETHROUGH + "- Earthbender");
}
if (player_ != null && bPlayer.canMetalbend()) {
sender.sendMessage(Element.METAL.getColor() + " Can Metalbend");
}
@ -225,7 +240,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.FIRE)) {
sender.sendMessage(Element.FIRE.getColor() + "- Firebender");
if(bPlayer.isElementToggled(Element.FIRE)) {
sender.sendMessage(Element.FIRE.getColor() + "- Firebender");
} else {
sender.sendMessage(Element.FIRE.getColor() + "" + ChatColor.STRIKETHROUGH + "- Firebender");
}
if (player_ != null && bPlayer.canCombustionbend()) {
sender.sendMessage(Element.COMBUSTION.getColor() + " Can Combustionbend");
}
@ -234,7 +254,11 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.CHI)) {
sender.sendMessage(Element.CHI.getColor() + "- ChiBlocker");
if(bPlayer.isElementToggled(Element.CHI)) {
sender.sendMessage(Element.CHI.getColor() + "- Chibender");
} else {
sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chibender");
}
}
UUID uuid = player.getUniqueId();

View file

@ -77,29 +77,35 @@ public class ConfigManager {
case DEFAULT:
config = defaultConfig.get();
ArrayList<String> earthbendable = new ArrayList<String>();
earthbendable.add("STONE");
earthbendable.add("CLAY");
earthbendable.add("COAL_ORE");
earthbendable.add("DIAMOND_ORE");
earthbendable.add("DIRT");
earthbendable.add("GOLD_ORE");
earthbendable.add("GRASS");
earthbendable.add("GRAVEL");
earthbendable.add("IRON_ORE");
earthbendable.add("LAPIS_ORE");
earthbendable.add("NETHERRACK");
earthbendable.add("QUARTZ_ORE");
earthbendable.add("REDSTONE_ORE");
earthbendable.add("SAND");
earthbendable.add("SANDSTONE");
earthbendable.add("RED_SANDSTONE");
earthbendable.add("MYCEL");
ArrayList<String> earths = new ArrayList<String>();
earths.add("STONE");
earths.add("CLAY");
earths.add("COAL_ORE");
earths.add("DIAMOND_ORE");
earths.add("DIRT");
earths.add("GOLD_ORE");
earths.add("GRASS");
earths.add("GRAVEL");
earths.add("IRON_ORE");
earths.add("LAPIS_ORE");
earths.add("NETHERRACK");
earths.add("QUARTZ_ORE");
earths.add("REDSTONE_ORE");
earths.add("SAND");
earths.add("SANDSTONE");
earths.add("RED_SANDSTONE");
earths.add("MYCEL");
ArrayList<String> metals = new ArrayList<String>();
metals.add("IRON_BLOCK");
metals.add("GOLD_BLOCK");
metals.add("QUARTZ_BLOCK");
ArrayList<String> sands = new ArrayList<String>();
sands.add("SAND");
sands.add("SANDSTONE");
sands.add("RED_SAND");
sands.add("RED_SANDSTONE");
config.addDefault("Properties.Chat.Enable", true);
config.addDefault("Properties.Chat.Format", "<name>: <message>");
@ -163,8 +169,9 @@ public class ConfigManager {
config.addDefault("Properties.Earth.SafeRevert", true);
config.addDefault("Properties.Earth.RevertCheckTime", 300000);
config.addDefault("Properties.Earth.CanBendWithWeapons", true);
config.addDefault("Properties.Earth.EarthbendableBlocks", earthbendable);
config.addDefault("Properties.Earth.EarthBlocks", earths);
config.addDefault("Properties.Earth.MetalBlocks", metals);
config.addDefault("Properties.Earth.SandBlocks", sands);
config.addDefault("Properties.Earth.MetalPowerFactor", 1.5);
config.addDefault("Properties.Earth.PlaySound", true);
@ -207,6 +214,10 @@ public class ConfigManager {
config.addDefault("Abilities.Air.AirBlast.Speed", 25);
config.addDefault("Abilities.Air.AirBlast.Range", 20);
config.addDefault("Abilities.Air.AirBlast.Radius", 2);
config.addDefault("Abilities.Air.AirBlast.SelectRange", 10);
config.addDefault("Abilities.Air.AirBlast.SelectParticles", 4);
config.addDefault("Abilities.Air.AirBlast.Particles", 6);
config.addDefault("Abilities.Air.AirBlast.Cooldown", 500);
config.addDefault("Abilities.Air.AirBlast.Push.Self", 2.5);
config.addDefault("Abilities.Air.AirBlast.Push.Entities", 3.5);
config.addDefault("Abilities.Air.AirBlast.CanFlickLevers", true);
@ -219,15 +230,22 @@ public class ConfigManager {
config.addDefault("Abilities.Air.AirBubble.Radius", 7);
config.addDefault("Abilities.Air.AirBurst.Enabled", true);
config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to launch a cone-shaped burst " + "of air in front of you, or click to release the burst in a sphere around you. " + "Additionally, having this ability selected when you land on the ground from a " + "large enough fall will create a burst of air around you.");
config.addDefault("Abilities.Air.AirBurst.Description", "AirBurst is one of the most powerful abilities in the airbender's arsenal. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to release the burst in a sphere around you " + "or click to launch a cone-shaped burst of air in front of you. " + "Additionally, having this ability selected when you land on the ground from a " + "large enough fall will create a burst of air around you.");
config.addDefault("Abilities.Air.AirBurst.FallThreshold", 10);
config.addDefault("Abilities.Air.AirBurst.PushFactor", 1.5);
config.addDefault("Abilities.Air.AirBurst.ChargeTime", 1750);
config.addDefault("Abilities.Air.AirBurst.Damage", 0);
config.addDefault("Abilities.Air.AirBurst.SneakParticles", 10);
config.addDefault("Abilities.Air.AirBurst.ParticlePercentage", 50);
config.addDefault("Abilities.Air.AirBurst.AnglePhi", 10);
config.addDefault("Abilities.Air.AirBurst.AngleTheta", 10);
config.addDefault("Abilities.Air.AirScooter.Enabled", true);
config.addDefault("Abilities.Air.AirScooter.Description", "AirScooter is a fast means of transportation. To use, sprint, jump then click with " + "this ability selected. You will hop on a scooter of air and be propelled forward " + "in the direction you're looking (you don't need to press anything). " + "This ability can be used to levitate above liquids, but it cannot go up steep slopes. " + "Any other actions will deactivate this ability.");
config.addDefault("Abilities.Air.AirScooter.Speed", .675);
config.addDefault("Abilities.Air.AirScooter.Speed", 0.675);
config.addDefault("Abilities.Air.AirScooter.Interval", 100);
config.addDefault("Abilities.Air.AirScooter.Radius", 1);
config.addDefault("Abilities.Air.AirScooter.MaxHeightFromGround", 7);
config.addDefault("Abilities.Air.Tornado.Enabled", true);
config.addDefault("Abilities.Air.Tornado.Description", "To use, simply sneak (default: shift). " + "This will create a swirling vortex at the targeted location. " + "Any creature or object caught in the vortex will be launched up " + "and out in some random direction. If another player gets caught " + "in the vortex, the launching effect is minimal. Tornado can " + "also be used to transport the user. If the user gets caught in his/her " + "own tornado, his movements are much more manageable. Provided the user doesn't " + "fall out of the vortex, it will take him to a maximum height and move him in " + "the general direction he's looking. Skilled airbenders can scale anything " + "with this ability.");
@ -315,7 +333,7 @@ public class ConfigManager {
config.addDefault("Abilities.Water.Bloodbending.Enabled", true);
config.addDefault("Abilities.Water.Bloodbending.Description", "This ability was made illegal for a reason. With this ability selected, sneak while " + "targetting something and you will bloodbend that target. Bloodbent targets cannot move, " + "bend or attack. You are free to control their actions by looking elsewhere - they will " + "be forced to move in that direction. Additionally, clicking while bloodbending will " + "launch that target off in the direction you're looking. " + "People who are capable of bloodbending are immune to your technique, and you are immune to theirs.");
config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight", false);
config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight", true);
config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true);
config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2);
config.addDefault("Abilities.Water.Bloodbending.Range", 10);
@ -484,6 +502,7 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.Catapult.Length", 6);
config.addDefault("Abilities.Earth.Catapult.Speed", 10);
config.addDefault("Abilities.Earth.Catapult.Push", 4);
config.addDefault("Abilities.Earth.Catapult.ShiftModifier", 2);
config.addDefault("Abilities.Earth.Collapse.Enabled", true);
config.addDefault("Abilities.Earth.Collapse.Description", " To use, simply left-click on an earthbendable block. " + "That block and the earthbendable blocks above it will be shoved " + "back into the earth below them, if they can. " + "This ability does have the capacity to trap something inside of it, " + "although it is incredibly difficult to do so. " + "Additionally, press sneak with this ability to affect an area around your targetted location - " + "all earth that can be moved downwards will be moved downwards. " + "This ability is especially risky or deadly in caves, depending on the " + "earthbender's goal and technique.");
@ -564,16 +583,6 @@ public class ConfigManager {
config.addDefault("Abilities.Earth.EarthSmash.FlightTimer", 3000);
config.addDefault("Abilities.Earth.EarthSmash.RemoveTimer", 30000);
// config.addDefault("Abilities.Earth.LavaSurge.Enabled", true);
// config.addDefault("Abilities.Earth.LavaSurge.Description", "LavaSurge is a fundamental move for any Lavabender out there. To use, simply sneak (Default: Shift) while looking at a source of Earth or Lava, then click in a direction. A surge of lava will swiftly travel towards the target you were pointing at, dealing moderate damage, a large knockback, and setting them on fire.");
// config.addDefault("Abilities.Earth.LavaSurge.Damage", 4);
// config.addDefault("Abilities.Earth.LavaSurge.Cooldown", 1000);
// config.addDefault("Abilities.Earth.LavaSurge.FractureRadius", 1);
// config.addDefault("Abilities.Earth.LavaSurge.PrepareRange", 7);
// config.addDefault("Abilities.Earth.LavaSurge.TravelRange", 15);
// config.addDefault("Abilities.Earth.LavaSurge.MaxLavaWaves", 10);
// config.addDefault("Abilities.Earth.LavaSurge.SourceCanBeEarth", true);
config.addDefault("Abilities.Earth.MetalClips.Enabled", true);
config.addDefault("Abilities.Earth.MetalClips.Description", "MetalClips has the potential to be both an offensive and a utility ability. To start, you must carry smelted Iron Ingots in your inventory. To apply the clips onto an entity, simply click at them. If the entity is a Zombie, a Skeleton, or a Player, the clips will form armor around the entity, giving you some control over them. Each additional clip will give you more control. If you have permission to do so, you may crush the entity against a wall with a 4th clip, hurting them. Without explicit permissions, you will only be able to strap three clips on your target. If the entity is not one of the above, the clip will simply do damage and fall to the ground, to be collected. Another permission requiring action is throwing entities. To do so, click while controlling a metalclipped entity");
config.addDefault("Abilities.Earth.MetalClips.Damage", 2);
@ -651,7 +660,7 @@ public class ConfigManager {
config.addDefault("Abilities.Fire.FireBlast.Charged.FireTicks", 4);
config.addDefault("Abilities.Fire.FireBurst.Enabled", true);
config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to launch a cone-shaped burst " + "of flames in front of you, or click to release the burst in a sphere around you. ");
config.addDefault("Abilities.Fire.FireBurst.Description", "FireBurst is a very powerful firebending ability. " + "To use, press and hold sneak to charge your burst. " + "Once charged, you can either release sneak to release the burst in a sphere around you or " + "click to launch a cone-shaped burst of flames in front of you.");
config.addDefault("Abilities.Fire.FireBurst.Damage", 2);
config.addDefault("Abilities.Fire.FireBurst.ChargeTime", 3500);
config.addDefault("Abilities.Fire.FireBurst.Range", 15);

View file

@ -19,6 +19,7 @@ public class Catapult extends EarthAbility {
private int distance;
private long cooldown;
private double push;
private double shiftModifier;
private Location origin;
private Location location;
private Vector direction;
@ -53,7 +54,7 @@ public class Catapult extends EarthAbility {
catapult = true;
}
if (player.isSneaking()) {
distance = distance / 2;
distance = (int) (distance / shiftModifier);
}
moving = true;
@ -79,6 +80,7 @@ public class Catapult extends EarthAbility {
private void setFields() {
this.length = getConfig().getInt("Abilities.Earth.Catapult.Length");
this.push = getConfig().getDouble("Abilities.Earth.Catapult.Push");
this.shiftModifier = getConfig().getDouble("Abilities.Earth.Catapult.ShiftModifier");
this.distance = 0;
this.cooldown = 0;
this.catapult = false;

View file

@ -39,8 +39,8 @@ public class EarthPassive {
return true;
}
if (EarthAbility.isEarthbendable(player, block) || ElementalAbility.isTransparentToEarthbending(player, block)) {
if (!ElementalAbility.isTransparentToEarthbending(player, block)) {
if (EarthAbility.isEarthbendable(player, block) || ElementalAbility.isTransparent(player, block)) {
if (!ElementalAbility.isTransparent(player, block)) {
MaterialData type = block.getState().getData();
if (GeneralMethods.isSolid(block.getRelative(BlockFace.DOWN))) {
if (type.getItemType() == Material.RED_SANDSTONE) {
@ -78,7 +78,7 @@ public class EarthPassive {
return true;
}
return EarthAbility.isEarthbendable(player, block) || EarthAbility.isTransparentToEarthbending(player, block);
return EarthAbility.isEarthbendable(player, block) || EarthAbility.isTransparent(player, block);
}
public static boolean isPassiveSand(Block block) {

View file

@ -70,7 +70,7 @@ public class EarthSmash extends EarthAbility {
this.shootAnimationCooldown = 25;
this.flightAnimationCooldown = 0;
this.liftAnimationCooldown = 30;
this.grabDetectionRadius = 2.5;
this.grabDetectionRadius = 3.5;
this.flightDetectionRadius = 3.8;
this.state = State.START;
this.allowGrab = getConfig().getBoolean("Abilities.Earth.EarthSmash.AllowGrab");

View file

@ -88,6 +88,7 @@ public class Shockwave extends EarthAbility {
Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta));
new Ripple(player, vector.normalize());
}
bPlayer.addCooldown(this);
}
public static void coneShockwave(Player player) {
@ -103,13 +104,14 @@ public class Shockwave extends EarthAbility {
new Ripple(player, vector.normalize());
}
}
shockWave.bPlayer.addCooldown(shockWave);
shockWave.remove();
}
}
}
@Override
public String getName() { // TODO: Shockwave getName() is being overridden by Ripple
public String getName() {
return "Shockwave";
}

View file

@ -6,17 +6,25 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public final class PlayerCooldownChangeEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
public static enum Result {
REMOVED, ADDED;
}
private static final HandlerList HANDLERS = new HandlerList();
private Player player;
private String ability;
private Result eventresult;
private boolean cancelled;
private long cooldown;
public PlayerCooldownChangeEvent(Player player, String abilityname, Result result) {
public PlayerCooldownChangeEvent(Player player, String abilityname, long cooldown, Result result) {
this.player = player;
this.ability = abilityname;
this.eventresult = result;
this.cancelled = false;
this.cooldown = cooldown;
}
public Player getPlayer() {
@ -30,6 +38,10 @@ public final class PlayerCooldownChangeEvent extends Event implements Cancellabl
public Result getResult() {
return eventresult;
}
public long getCooldown() {
return cooldown;
}
public boolean isCancelled() {
return cancelled;
@ -38,19 +50,17 @@ public final class PlayerCooldownChangeEvent extends Event implements Cancellabl
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
public void setCooldown(long cooldown) {
this.cooldown = cooldown;
}
public HandlerList getHandlers() {
return handlers;
return HANDLERS;
}
public static HandlerList getHandlerList() {
return handlers;
}
public static enum Result {
REMOVED, ADDED;
private Result() {
}
return HANDLERS;
}
}

View file

@ -32,6 +32,7 @@ public class FireBlast extends FireAbility {
private boolean powerFurnace;
private boolean showParticles;
private boolean dissipate;
private boolean isFireBurst;
private int ticks;
private long cooldown;
private double speedFactor;
@ -54,6 +55,7 @@ public class FireBlast extends FireAbility {
return;
}
this.isFireBurst = true;
this.safeBlocks = safeBlocks;
this.damage = damage;
this.powerFurnace = true;
@ -86,6 +88,7 @@ public class FireBlast extends FireAbility {
return;
}
this.isFireBurst = false;
this.powerFurnace = true;
this.showParticles = true;
this.radius = 2;
@ -260,7 +263,7 @@ public class FireBlast extends FireAbility {
@Override
public String getName() {
return "FireBlast";
return isFireBurst ? "FireBurst" : "FireBlast";
}
@Override
@ -410,5 +413,13 @@ public class FireBlast extends FireAbility {
public void setLocation(Location location) {
this.location = location;
}
public boolean isFireBurst() {
return isFireBurst;
}
public void setFireBurst(boolean isFireBurst) {
this.isFireBurst = isFireBurst;
}
}

View file

@ -87,8 +87,8 @@ public class FireBurst extends FireAbility {
}
}
}
bPlayer.addCooldown(this);
}
bPlayer.addCooldown(this);
remove();
}
@ -158,9 +158,8 @@ public class FireBurst extends FireAbility {
blasts.add(fblast);
}
}
bPlayer.addCooldown(this);
}
bPlayer.addCooldown(this);
remove();
handleSmoothParticles();
}

View file

@ -151,7 +151,7 @@ public class Lightning extends LightningAbility {
* @param block the block
* @return true if the block is transparent
*/
private boolean isTransparent(Player player, Block block) {
private boolean isTransparentForLightning(Player player, Block block) {
if (isTransparent(block)) {
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false;
@ -242,7 +242,7 @@ public class Lightning extends LightningAbility {
final Location dest = arc.getAnimationLocations().get(j + 1).getLocation().clone();
if (selfHitClose
&& player.getLocation().distanceSquared(iterLoc) < 9
&& !isTransparent(player, iterLoc.getBlock())
&& !isTransparentForLightning(player, iterLoc.getBlock())
&& !affectedEntities.contains(player)) {
affectedEntities.add(player);
electrocute(player);
@ -485,7 +485,7 @@ public class Lightning extends LightningAbility {
if (count > 5) {
this.cancel();
} else if (count == 1) {
if (!isTransparent(player, location.getBlock())) {
if (!isTransparentForLightning(player, location.getBlock())) {
arc.cancel();
return;
}

View file

@ -85,7 +85,7 @@ public class HorizontalVelocityTracker {
impactLocation = entity.getLocation();
for (Block b : blocks) {
if (GeneralMethods.isSolid(b) && (entity.getLocation().getBlock().getRelative(BlockFace.EAST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.NORTH, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.WEST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.SOUTH, 1).equals(b))) {
if (!ElementalAbility.isTransparentToEarthbending(instigator, b)) {
if (!ElementalAbility.isTransparent(instigator, b)) {
hasBeenDamaged = true;
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff, launchLocation, impactLocation, abil, e));
remove();

View file

@ -37,9 +37,9 @@ public class Preset {
static String updateQuery1 = "UPDATE pk_presets SET slot";
static String updateQuery2 = " = ? WHERE uuid = ? AND name = ?";
UUID uuid;
HashMap<Integer, String> abilities;
String name;
public UUID uuid;
public HashMap<Integer, String> abilities;
public String name;
/**
* Creates a new {@link Preset}
@ -107,6 +107,16 @@ public class Preset {
}
}.runTaskAsynchronously(ProjectKorra.plugin);
}
/**
* Reload a Player's Presets from those stored in memory.
*
* @param player The Player who's Presets should be unloaded
*/
public static void reloadPreset(Player player) {
unloadPreset(player);
loadPresets(player);
}
/**
* Binds the abilities from a Preset for the given Player.
@ -115,28 +125,18 @@ public class Preset {
* @param name The name of the Preset that should be bound
* @return True if all abilities were successfully bound, or false otherwise
*/
@SuppressWarnings("unchecked")
public static boolean bindPreset(Player player, String name) {
public static boolean bindPreset(Player player, Preset preset) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null)
if (bPlayer == null) {
return false;
if (!presets.containsKey(player.getUniqueId()))
} else if (!presets.containsKey(player.getUniqueId())) {
return false;
HashMap<Integer, String> abilities = null;
for (Preset preset : presets.get(player.getUniqueId())) {
if (preset.name.equalsIgnoreCase(name)) { // We found it
abilities = (HashMap<Integer, String>) preset.abilities.clone();
}
}
if (abilities == null) {
}
HashMap<Integer, String> abilities = preset.abilities;
boolean boundAll = true;
for (int i = 1; i <= 9; i++) {
String abilName = abilities.get(i);
CoreAbility coreAbil = CoreAbility.getAbility(abilName);
if (coreAbil != null && !bPlayer.canBind(coreAbil)) {
if (!bPlayer.canBind(CoreAbility.getAbility(abilities.get(i)))) {
abilities.remove(i);
boundAll = false;
}
@ -227,7 +227,7 @@ public class Preset {
/**
* Saves the Preset to the database.
*/
public void save() {
public void save(final Player player) {
try {
PreparedStatement ps = DBConnection.sql.getConnection().prepareStatement(loadNameQuery);
ps.setString(1, uuid.toString());
@ -262,5 +262,19 @@ public class Preset {
}
}.runTaskAsynchronously(ProjectKorra.plugin);
}
new BukkitRunnable() {
@Override
public void run() {
try {
Thread.sleep(1500);
reloadPreset(player);
}
catch (InterruptedException e) {
e.printStackTrace();
}
}
}.runTaskAsynchronously(ProjectKorra.plugin);
}
}

View file

@ -0,0 +1,61 @@
package com.projectkorra.projectkorra.util;
import org.bukkit.entity.Player;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import com.projectkorra.projectkorra.util.ReflectionHandler.PackageType;
public class ActionBar {
private static boolean initialised = false;
private static Constructor<?> chatSer;
private static Constructor<?> packetChat;
private static Method getHandle;
private static Field playerConnection;
private static Method sendPacket;
static {
try {
chatSer = ReflectionHandler.getConstructor(PackageType.MINECRAFT_SERVER.getClass("ChatComponentText"), String.class);
packetChat = PackageType.MINECRAFT_SERVER.getClass("PacketPlayOutChat").getConstructor(PackageType.MINECRAFT_SERVER.getClass("IChatBaseComponent"), byte.class);
getHandle = ReflectionHandler.getMethod("CraftPlayer", PackageType.CRAFTBUKKIT_ENTITY, "getHandle");
playerConnection = ReflectionHandler.getField("EntityPlayer", PackageType.MINECRAFT_SERVER, false, "playerConnection");
sendPacket = ReflectionHandler.getMethod(playerConnection.getType(), "sendPacket", PackageType.MINECRAFT_SERVER.getClass("Packet"));
initialised = true;
}
catch (ReflectiveOperationException e) {
initialised = false;
}
}
public static boolean isInitialised() {
return initialised;
}
public static boolean sendActionBar(String message, Player... p) {
if (!initialised) {
return false;
}
try {
Object o = chatSer.newInstance(message);
Object packet = packetChat.newInstance(o, (byte) 2);
sendTo(packet, p);
}
catch (ReflectiveOperationException e) {
e.printStackTrace();
initialised = false;
}
return initialised;
}
private static void sendTo(Object packet, Player... pl) throws ReflectiveOperationException {
for (Player p : pl) {
Object entityplayer = getHandle.invoke(p);
Object PlayerConnection = playerConnection.get(entityplayer);
sendPacket.invoke(PlayerConnection, packet);
}
}
}

View file

@ -68,8 +68,11 @@ public class RevertChecker implements Runnable {
}
public void run() {
if (!plugin.isEnabled()) {
return;
}
time = System.currentTimeMillis();
if (config.getBoolean("Properties.Earth.RevertEarthbending")) {
try {

View file

@ -20,6 +20,7 @@ import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class Bloodbending extends BloodAbility {
@ -84,7 +85,13 @@ public class Bloodbending extends BloodAbility {
}
}
} else {
Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
Location location = GeneralMethods.getTargetedLocation(player, 6, getTransparentMaterial());
List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, 1.5);
if (entities == null || entities.isEmpty()) {
return;
}
Entity target = entities.get(0);
if (target == null || !(target instanceof LivingEntity) || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation())) {
return;
} else if (target instanceof Player) {
@ -153,10 +160,10 @@ public class Bloodbending extends BloodAbility {
}
}
if (onlyUsableDuringMoon && !isFullMoon(player.getWorld())) {
if (onlyUsableDuringMoon && !isFullMoon(player.getWorld()) && !bPlayer.canBloodbendAtAnytime()) {
remove();
return;
} else if (canOnlyBeUsedAtNight && !isNight(player.getWorld())) {
} else if (canOnlyBeUsedAtNight && !isNight(player.getWorld()) && !bPlayer.canBloodbendAtAnytime()) {
remove();
return;
} else if (!bPlayer.canBendIgnoreCooldowns(this)) {
@ -165,7 +172,7 @@ public class Bloodbending extends BloodAbility {
}
if (bPlayer.isAvatarState()) {
ArrayList<Entity> entities = new ArrayList<Entity>();
ArrayList<Entity> entities = new ArrayList<>();
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) {
if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) {

View file

@ -255,7 +255,7 @@ public class IceBlast extends IceAbility {
source.revertBlock();
source = null;
if (isTransparentToEarthbending(player, block) && !block.isLiquid()) {
if (isTransparent(player, block) && !block.isLiquid()) {
GeneralMethods.breakBlock(block);
} else if (!isWater(block)) {
breakParticles(20);

View file

@ -163,7 +163,7 @@ public class IceSpikeBlast extends IceAbility {
}
source = null;
if (isTransparentToEarthbending(player, block) && !block.isLiquid()) {
if (isTransparent(player, block) && !block.isLiquid()) {
GeneralMethods.breakBlock(block);
} else if (!isWater(block)) {
remove();
@ -359,7 +359,7 @@ public class IceSpikeBlast extends IceAbility {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeLoc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
LivingEntity target = (LivingEntity) GeneralMethods.getTargetedEntity(player, range);
Location destination;

View file

@ -115,7 +115,7 @@ public class OctopusForm extends WaterAbility {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeLoc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER);
block.setData(FULL);
OctopusForm form = new OctopusForm(player);

View file

@ -84,7 +84,7 @@ public class SurgeWall extends WaterAbility {
Location eyeloc = player.getEyeLocation();
Block block = eyeloc.add(eyeloc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeloc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeloc.getBlock())) {
block.setType(Material.WATER);
block.setData(FULL);
@ -381,7 +381,7 @@ public class SurgeWall extends WaterAbility {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeLoc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER);
block.setData(FULL);

View file

@ -103,7 +103,7 @@ public class Torrent extends WaterAbility {
List<Block> ice = GeneralMethods.getBlocksAroundPoint(location, layer);
for (Block block : ice) {
if (isTransparentToEarthbending(player, block) && block.getType() != Material.ICE) {
if (isTransparent(player, block) && block.getType() != Material.ICE) {
TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 0);
FROZEN_BLOCKS.put(tblock, player);
playIcebendingSound(block.getLocation());
@ -186,7 +186,7 @@ public class Torrent extends WaterAbility {
source.revertBlock();
source = null;
Block block = location.getBlock();
if (!isTransparentToEarthbending(player, block) || block.isLiquid()) {
if (!isTransparent(player, block) || block.isLiquid()) {
remove();
return;
}
@ -271,10 +271,10 @@ public class Torrent extends WaterAbility {
Block block = blockloc.getBlock();
if (!doneBlocks.contains(block) && !GeneralMethods.isRegionProtectedFromBuild(this, blockloc)) {
if (isTransparentToEarthbending(player, block) && !block.isLiquid()) {
if (isTransparent(player, block) && !block.isLiquid()) {
launchedBlocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
doneBlocks.add(block);
} else if (!isTransparentToEarthbending(player, block)) {
} else if (!isTransparent(player, block)) {
break;
}
}
@ -316,7 +316,7 @@ public class Torrent extends WaterAbility {
remove();
return false;
}
} else if (!isTransparentToEarthbending(player, locBlock)) {
} else if (!isTransparent(player, locBlock)) {
if (layer < maxLayer) {
if (layer == 0) {
hurtEntities.clear();
@ -405,7 +405,7 @@ public class Torrent extends WaterAbility {
Block block = blockLoc.getBlock();
if (!doneBlocks.contains(block)) {
if (isTransparentToEarthbending(player, block) && !block.isLiquid()) {
if (isTransparent(player, block) && !block.isLiquid()) {
blocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
doneBlocks.add(block);
@ -460,7 +460,7 @@ public class Torrent extends WaterAbility {
if (WaterReturn.hasWaterBottle(player)) {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeLoc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER);
block.setData((byte) 0);
Torrent tor = new Torrent(player);

View file

@ -125,7 +125,7 @@ public class TorrentWave extends WaterAbility {
continue;
}
if (isTransparentToEarthbending(player, block)) {
if (isTransparent(player, block)) {
TempBlock tempBlock = new TempBlock(block, Material.STATIONARY_WATER, (byte) 8);
blocks.add(tempBlock);
torrentBlocks.add(block);

View file

@ -184,7 +184,7 @@ public class WaterArms extends WaterAbility {
}
private boolean canPlaceBlock(Block block) {
if (!isTransparentToEarthbending(player, block) && !(isWater(block) && TempBlock.isTempBlock(block))) {
if (!isTransparent(player, block) && !(isWater(block) && TempBlock.isTempBlock(block))) {
return false;
}
return true;

View file

@ -112,7 +112,7 @@ public class WaterArmsFreeze extends IceAbility {
}
private boolean canPlaceBlock(Block block) {
if (!isTransparentToEarthbending(player, block) && !((isWater(block) || isIcebendable(block)) && TempBlock.isTempBlock(block))) {
if (!isTransparent(player, block) && !((isWater(block)) && TempBlock.isTempBlock(block))) {
return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false;

View file

@ -214,7 +214,7 @@ public class WaterArmsSpear extends WaterAbility {
private void createIceBall() {
layer++;
for (Block block : GeneralMethods.getBlocksAroundPoint(location, layer)) {
if (isTransparentToEarthbending(player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) {
if (isTransparent(player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) {
playIcebendingSound(block.getLocation());
new TempBlock(block, Material.ICE, (byte) 0);
WaterArms.getBlockRevertTimes().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500));
@ -223,7 +223,7 @@ public class WaterArmsSpear extends WaterAbility {
}
private boolean canPlaceBlock(Block block) {
if (!isTransparentToEarthbending(player, block)
if (!isTransparent(player, block)
&& !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !WaterArms.getBlockRevertTimes().containsKey(block)))) {
return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {

View file

@ -226,7 +226,7 @@ public class WaterArmsWhip extends WaterAbility {
}
private boolean canPlaceBlock(Block block) {
if (!isTransparentToEarthbending(player, block) && !(isWater(block) && TempBlock.isTempBlock(block))) {
if (!isTransparent(player, block) && !(isWater(block) && TempBlock.isTempBlock(block))) {
return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false;

View file

@ -169,7 +169,7 @@ public class WaterCombo extends WaterAbility implements ComboAbility {
FireComboStream fstream = (FireComboStream) tasks.get(i);
Location loc = fstream.getLocation();
if (!isTransparentToEarthbending(player, loc.clone().add(0, 0.2, 0).getBlock())) {
if (!isTransparent(player, loc.clone().add(0, 0.2, 0).getBlock())) {
fstream.remove();
return;
}

View file

@ -262,7 +262,7 @@ public class WaterManipulation extends WaterAbility {
}
}
if (isTransparentToEarthbending(player, block) && !block.isLiquid()) {
if (isTransparent(player, block) && !block.isLiquid()) {
GeneralMethods.breakBlock(block);
} else if (block.getType() != Material.AIR && !isWater(block)) {
remove();
@ -479,7 +479,7 @@ public class WaterManipulation extends WaterAbility {
Location eyeLoc = player.getEyeLocation();
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparentToEarthbending(player, block) && isTransparentToEarthbending(player, eyeLoc.getBlock())) {
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
if (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) {
block.setType(Material.WATER);
block.setData((byte) 0);

View file

@ -36,7 +36,7 @@ public class WaterReturn extends WaterAbility {
this.range = getNightFactor(range);
if (bPlayer.canBend(this)) {
if (isTransparentToEarthbending(player, block) && !block.isLiquid() && hasEmptyWaterBottle()) {
if (isTransparent(player, block) && !block.isLiquid() && hasEmptyWaterBottle()) {
this.block = new TempBlock(block, Material.WATER, (byte) 0);
}
}
@ -75,7 +75,7 @@ public class WaterReturn extends WaterAbility {
}
Block newblock = location.getBlock();
if (isTransparentToEarthbending(player, newblock) && !newblock.isLiquid()) {
if (isTransparent(player, newblock) && !newblock.isLiquid()) {
block.revertBlock();
block = new TempBlock(newblock, Material.WATER, (byte) 0);
} else {

View file

@ -33,7 +33,7 @@ public class WaterSpoutWave extends WaterAbility {
RISE, TOWARD_PLAYER, CIRCLE, SHRINK
}
private static final ConcurrentHashMap<Block, TempBlock> FROZEN_BLOCKS = new ConcurrentHashMap<Block, TempBlock>();
private static final ConcurrentHashMap<Block, TempBlock> FROZEN_BLOCKS = new ConcurrentHashMap<>();
private double radius;
private boolean charging;
@ -429,7 +429,7 @@ public class WaterSpoutWave extends WaterAbility {
@Override
public String getName() {
return "WaterSpout";
return this.isIceWave() ? "IceWave" : "WaterSpout";
}
@Override

View file

@ -1,6 +1,6 @@
name: ProjectKorra
author: ProjectKorra
version: 1.8.0 BETA 6
version: 1.8.0 BETA 8
main: com.projectkorra.projectkorra.ProjectKorra
softdepend: [PreciousStones, WorldGuard, WorldEdit, Factions, MassiveCore, GriefPrevention, Towny, NoCheatPlus, LWC]
commands: