mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
Merge pull request #63 from nathank33/master
Bug Fixes, Config Options, Performance Improvements
This commit is contained in:
commit
9fa27b0504
14 changed files with 154 additions and 14 deletions
|
@ -116,6 +116,10 @@ public class BendingPlayer {
|
|||
public boolean isChiBlocked() {
|
||||
return blockedChi;
|
||||
}
|
||||
|
||||
public boolean isToggled() {
|
||||
return isToggled;
|
||||
}
|
||||
|
||||
public void setAbilities(HashMap<Integer, String> abilities) {
|
||||
this.abilities = abilities;
|
||||
|
|
|
@ -231,6 +231,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Air.AirCombo.Twister.Radius", 3.5);
|
||||
config.addDefault("Abilities.Air.AirCombo.Twister.RemoveDelay", 1500);
|
||||
config.addDefault("Abilities.Air.AirCombo.Twister.Cooldown", 10000);
|
||||
config.addDefault("Abilities.Air.AirCombo.Twister.DegreesPerParticle", 7);
|
||||
config.addDefault("Abilities.Air.AirCombo.Twister.HeightPerParticle", 1.25);
|
||||
config.addDefault("Abilities.Air.AirCombo.AirStream.Speed", 0.5);
|
||||
config.addDefault("Abilities.Air.AirCombo.AirStream.Range", 40);
|
||||
config.addDefault("Abilities.Air.AirCombo.AirStream.EntityDuration", 4000);
|
||||
|
@ -255,6 +257,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs", true);
|
||||
config.addDefault("Abilities.Water.Bloodbending.ThrowFactor", 2);
|
||||
config.addDefault("Abilities.Water.Bloodbending.Range", 10);
|
||||
config.addDefault("Abilities.Water.Bloodbending.HoldTime", 0);
|
||||
config.addDefault("Abilities.Water.Bloodbending.Cooldown", 0);
|
||||
config.addDefault("Abilities.Water.Bloodbending.CanOnlyBeUsedDuringFullMoon", false);
|
||||
|
||||
config.addDefault("Abilities.Water.HealingWaters.Enabled", true);
|
||||
|
|
|
@ -1114,10 +1114,10 @@ public class Methods {
|
|||
&& WaterManipulation.canPhysicsChange(blocki))
|
||||
sources++;
|
||||
if (FreezeMelt.frozenblocks.containsKey(blocki)) {
|
||||
if (FreezeMelt.frozenblocks.get(blocki) == full)
|
||||
sources++;
|
||||
//if (FreezeMelt.frozenblocks.get(blocki) == full)
|
||||
//sources++;
|
||||
} else if (blocki.getType() == Material.ICE) {
|
||||
sources++;
|
||||
//sources++;
|
||||
}
|
||||
}
|
||||
if (sources >= 2)
|
||||
|
|
|
@ -68,7 +68,7 @@ public class Preset {
|
|||
if (!presets.containsKey(player.getUniqueId())) return;
|
||||
for (Preset preset: presets.get(player.getUniqueId())) {
|
||||
if (preset.name.equalsIgnoreCase(name)) { // We found it
|
||||
bPlayer.setAbilities(preset.abilities);
|
||||
bPlayer.setAbilities((HashMap<Integer, String>) preset.abilities.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ public class AirBlast {
|
|||
private double damage = 0;
|
||||
private boolean otherorigin = false;
|
||||
private int ticks = 0;
|
||||
private boolean showParticles = true;
|
||||
|
||||
private ArrayList<Block> affectedlevers = new ArrayList<Block>();
|
||||
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
|
||||
|
@ -205,7 +206,8 @@ public class AirBlast {
|
|||
}
|
||||
|
||||
private void advanceLocation() {
|
||||
Methods.playAirbendingParticles(location, 10);
|
||||
if (showParticles)
|
||||
Methods.playAirbendingParticles(location, 10);
|
||||
if (Methods.rand.nextInt(4) == 0) {
|
||||
Methods.playAirbendingSound(location);
|
||||
}
|
||||
|
@ -273,6 +275,14 @@ public class AirBlast {
|
|||
public void setDamage(double dmg) {
|
||||
this.damage = dmg;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean show) {
|
||||
this.showParticles = show;
|
||||
}
|
||||
|
||||
public boolean getShowParticles() {
|
||||
return this.showParticles;
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (int id : instances.keySet())
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
|
@ -17,6 +18,7 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
|||
public class AirBurst {
|
||||
|
||||
private static ConcurrentHashMap<Player, AirBurst> instances = new ConcurrentHashMap<Player, AirBurst>();
|
||||
private static double PARTICLES_PERCENTAGE = 50;
|
||||
|
||||
static FileConfiguration config = ProjectKorra.plugin.getConfig();
|
||||
|
||||
|
@ -30,7 +32,7 @@ public class AirBurst {
|
|||
private long starttime;
|
||||
private long chargetime = config.getLong("Abilities.Air.AirBurst.ChargeTime");
|
||||
private boolean charged = false;
|
||||
|
||||
private ArrayList<AirBlast> blasts = new ArrayList<AirBlast>();
|
||||
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
|
||||
|
||||
public AirBurst(Player player) {
|
||||
|
@ -98,11 +100,14 @@ public class AirBurst {
|
|||
AirBlast blast = new AirBlast(location, direction.normalize(), player,
|
||||
pushfactor, this);
|
||||
blast.setDamage(damage);
|
||||
blast.setShowParticles(false);
|
||||
blasts.add(blast);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
||||
instances.remove(player);
|
||||
handleSmoothParticles();
|
||||
}
|
||||
|
||||
public static void fallBurst(Player player) {
|
||||
|
@ -185,6 +190,20 @@ public class AirBurst {
|
|||
// .getDirection()), 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmoothParticles() {
|
||||
for (int i = 0; i < blasts.size(); i++) {
|
||||
final AirBlast blast = blasts.get(i);
|
||||
int toggleTime = 0;
|
||||
if (i % 4 != 0)
|
||||
toggleTime = (int) (i % (100 / PARTICLES_PERCENTAGE)) + 3;
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
blast.setShowParticles(true);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, toggleTime);
|
||||
}
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Player player : instances.keySet())
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.bukkit.util.Vector;
|
|||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.ComboManager.ClickType;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Flight;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -38,6 +39,10 @@ public class AirCombo {
|
|||
.getDouble("Abilities.Air.AirCombo.Twister.Height");
|
||||
public static double TWISTER_RADIUS = ProjectKorra.plugin.getConfig()
|
||||
.getDouble("Abilities.Air.AirCombo.Twister.Radius");
|
||||
public static double TWISTER_DEGREE_PER_PARTICLE = ProjectKorra.plugin.getConfig()
|
||||
.getDouble("Abilities.Air.AirCombo.Twister.DegreesPerParticle");
|
||||
public static double TWISTER_HEIGHT_PER_PARTICLE = ProjectKorra.plugin.getConfig()
|
||||
.getDouble("Abilities.Air.AirCombo.Twister.HeightPerParticle");
|
||||
public static long TWISTER_REMOVE_DELAY = ProjectKorra.plugin.getConfig()
|
||||
.getLong("Abilities.Air.AirCombo.Twister.RemoveDelay");
|
||||
public static long TWISTER_COOLDOWN = ProjectKorra.plugin.getConfig()
|
||||
|
@ -101,6 +106,10 @@ public class AirCombo {
|
|||
if (Methods.isRegionProtectedFromBuild(player, "AirBlast",
|
||||
player.getLocation()))
|
||||
return;
|
||||
if (Commands.isToggledForAll)
|
||||
return;
|
||||
if (!Methods.getBendingPlayer(player.getName()).isToggled())
|
||||
return;
|
||||
time = System.currentTimeMillis();
|
||||
this.player = player;
|
||||
this.ability = ability;
|
||||
|
@ -189,12 +198,12 @@ public class AirCombo {
|
|||
return;
|
||||
}
|
||||
currentLoc.setY(topBlock.getLocation().getY());
|
||||
|
||||
|
||||
double height = TWISTER_HEIGHT;
|
||||
double radius = TWISTER_RADIUS;
|
||||
for (double y = 0; y < height; y += 1.25) {
|
||||
for (double y = 0; y < height; y += TWISTER_HEIGHT_PER_PARTICLE) {
|
||||
double animRadius = ((radius / height) * y);
|
||||
for (int i = -180; i <= 180; i += 7) {
|
||||
for (double i = -180; i <= 180; i += TWISTER_DEGREE_PER_PARTICLE) {
|
||||
Vector animDir = Methods.rotateXZ(new Vector(1, 0, 1), i);
|
||||
Location animLoc = currentLoc.clone().add(
|
||||
animDir.multiply(animRadius));
|
||||
|
|
|
@ -53,6 +53,7 @@ public class FireBlast {
|
|||
private int ticks = 0;
|
||||
private double range = RANGE;
|
||||
private double damage = DAMAGE;
|
||||
private boolean showParticles = true;
|
||||
|
||||
public FireBlast(Player player) {
|
||||
BendingPlayer bPlayer = Methods.getBendingPlayer(player.getName());
|
||||
|
@ -168,7 +169,8 @@ public class FireBlast {
|
|||
}
|
||||
|
||||
private void advanceLocation() {
|
||||
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 0, (int) range);
|
||||
if (showParticles)
|
||||
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 0, (int) range);
|
||||
location = location.add(direction.clone().multiply(speedfactor));
|
||||
if (rand.nextInt(4) == 0) {
|
||||
Methods.playFirebendingSound(location);
|
||||
|
@ -196,6 +198,10 @@ public class FireBlast {
|
|||
public void setRange(double range) {
|
||||
this.range = range;
|
||||
}
|
||||
|
||||
public void setShowParticles(boolean show) {
|
||||
this.showParticles = show;
|
||||
}
|
||||
|
||||
public static boolean progress(int ID) {
|
||||
if (instances.containsKey(ID))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.projectkorra.ProjectKorra.firebending;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -7,6 +8,7 @@ import org.bukkit.Effect;
|
|||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
|
@ -16,6 +18,7 @@ import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
|||
|
||||
public class FireBurst {
|
||||
private static ConcurrentHashMap<Player, FireBurst> instances = new ConcurrentHashMap<Player, FireBurst>();
|
||||
private static double PARTICLES_PERCENTAGE = 5;
|
||||
|
||||
private Player player;
|
||||
private long starttime;
|
||||
|
@ -25,6 +28,7 @@ public class FireBurst {
|
|||
private double deltheta = 10;
|
||||
private double delphi = 10;
|
||||
private boolean charged = false;
|
||||
private ArrayList<FireBlast> blasts = new ArrayList<FireBlast>();
|
||||
|
||||
public FireBurst(Player player) {
|
||||
BendingPlayer bPlayer = Methods.getBendingPlayer(player.getName());
|
||||
|
@ -96,11 +100,14 @@ public class FireBurst {
|
|||
Vector direction = new Vector(x, z, y);
|
||||
FireBlast fblast = new FireBlast(location, direction.normalize(), player, damage, safeblocks);
|
||||
fblast.setRange(this.range);
|
||||
fblast.setShowParticles(false);
|
||||
blasts.add(fblast);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Methods.verbose("--" + AirBlast.instances.size() + "--");
|
||||
instances.remove(player);
|
||||
handleSmoothParticles();
|
||||
}
|
||||
|
||||
private void progress() {
|
||||
|
@ -134,6 +141,23 @@ public class FireBurst {
|
|||
location.getWorld().playEffect(location, Effect.MOBSPAWNER_FLAMES, 4, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleSmoothParticles() {
|
||||
/*
|
||||
* To combat the sphere FireBurst lag we are only going to show a certain
|
||||
* percentage of FireBurst particles at a time per tick. As the bursts spread out
|
||||
* then we can show more at a time.
|
||||
*/
|
||||
for (int i = 0; i < blasts.size(); i++) {
|
||||
final FireBlast fblast = blasts.get(i);
|
||||
int toggleTime = (int) (i % (100 / PARTICLES_PERCENTAGE));
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
fblast.setShowParticles(true);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, toggleTime);
|
||||
}
|
||||
}
|
||||
|
||||
public static void progressAll() {
|
||||
for (Player player : instances.keySet())
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.bukkit.util.Vector;
|
|||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.ComboManager.ClickType;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.Ability.AvatarState;
|
||||
|
@ -100,11 +101,16 @@ public class FireCombo {
|
|||
private long cooldown = 0;
|
||||
|
||||
public FireCombo(Player player, String ability) {
|
||||
// Dont' call Methods.canBind directly, it doesn't let you combo as fast
|
||||
if (!enabled || !player.hasPermission("bending.ability.FireCombo"))
|
||||
return;
|
||||
if (Methods.isRegionProtectedFromBuild(player, "Blaze",
|
||||
player.getLocation()))
|
||||
return;
|
||||
if (Commands.isToggledForAll)
|
||||
return;
|
||||
if (!Methods.getBendingPlayer(player.getName()).isToggled())
|
||||
return;
|
||||
time = System.currentTimeMillis();
|
||||
this.player = player;
|
||||
this.ability = ability;
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.potion.PotionEffect;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.TempPotionEffect;
|
||||
|
@ -29,8 +30,11 @@ public class Bloodbending {
|
|||
private static boolean canBeUsedOnUndead = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs");
|
||||
private static final boolean onlyUsableDuringMoon = ProjectKorra.plugin.getConfig().getBoolean("Abilities.Water.Bloodbending.CanOnlyBeUsedDuringFullMoon");
|
||||
private int range = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.Range");
|
||||
|
||||
private long HOLD_TIME = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.HoldTime");
|
||||
private long COOLDOWN = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.Bloodbending.Cooldown");
|
||||
|
||||
private Player player;
|
||||
private long time;
|
||||
|
||||
public Bloodbending(Player player) {
|
||||
if (instances.containsKey(player)) {
|
||||
|
@ -46,6 +50,11 @@ public class Bloodbending {
|
|||
if (onlyUsableDuringMoon && !Methods.isFullMoon(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BendingPlayer bplayer = Methods.getBendingPlayer(player.getName());
|
||||
if (bplayer.isOnCooldown("Bloodbending") && !AvatarState.isAvatarState(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
range = (int) Methods.waterbendingNightAugment(range, player.getWorld());
|
||||
if (AvatarState.isAvatarState(player)) {
|
||||
|
@ -83,7 +92,11 @@ public class Bloodbending {
|
|||
Methods.breakBreathbendingHold(target);
|
||||
targetentities.put(target, target.getLocation().clone());
|
||||
}
|
||||
if (targetentities.size() > 0) {
|
||||
bplayer.addCooldown("Bloodbending", COOLDOWN);
|
||||
}
|
||||
this.player = player;
|
||||
this.time = System.currentTimeMillis();
|
||||
instances.put(player, this);
|
||||
}
|
||||
|
||||
|
@ -114,6 +127,11 @@ public class Bloodbending {
|
|||
remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (HOLD_TIME > 0 && System.currentTimeMillis() - this.time > HOLD_TIME) {
|
||||
remove(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!canBeUsedOnUndead) {
|
||||
for (Entity entity: targetentities.keySet()) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.Location;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
|
@ -18,6 +19,11 @@ public class FreezeMelt {
|
|||
|
||||
public static final int defaultrange = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.PhaseChange.Range");
|
||||
public static final int defaultradius = ProjectKorra.plugin.getConfig().getInt("Abilities.Water.PhaseChange.Radius");
|
||||
|
||||
public static final int OVERLOADING_LIMIT = 1000;
|
||||
public static boolean overloading = false;
|
||||
public static int overloadCounter = 0;
|
||||
|
||||
|
||||
public FreezeMelt(Player player) {
|
||||
|
||||
|
@ -67,9 +73,34 @@ public class FreezeMelt {
|
|||
}
|
||||
|
||||
public static void handleFrozenBlocks() {
|
||||
for (Block block : frozenblocks.keySet()) {
|
||||
if (canThaw(block))
|
||||
thaw(block);
|
||||
int size = frozenblocks.keySet().size();
|
||||
overloadCounter++;
|
||||
overloadCounter %= 10;
|
||||
if (overloadCounter == 0)
|
||||
overloading = size > OVERLOADING_LIMIT ? true : false;
|
||||
|
||||
// We only want to run this method once every 10 ticks if we are overloading.
|
||||
if (overloading && overloadCounter != 0)
|
||||
return;
|
||||
|
||||
if (overloading) {
|
||||
int i = 0;
|
||||
for (Block block : frozenblocks.keySet()) {
|
||||
final Block fblock = block;
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
if (canThaw(fblock))
|
||||
thaw(fblock);
|
||||
}
|
||||
}.runTaskLater(ProjectKorra.plugin, i % 10);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Block block : frozenblocks.keySet()) {
|
||||
if (canThaw(block))
|
||||
thaw(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.ProjectKorra.BendingPlayer;
|
||||
import com.projectkorra.ProjectKorra.Commands;
|
||||
import com.projectkorra.ProjectKorra.Methods;
|
||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||
import com.projectkorra.ProjectKorra.TempBlock;
|
||||
|
@ -83,6 +84,10 @@ public class WaterCombo {
|
|||
if (Methods.isRegionProtectedFromBuild(player, "WaterManipulation",
|
||||
player.getLocation()))
|
||||
return;
|
||||
if (Commands.isToggledForAll)
|
||||
return;
|
||||
if (!Methods.getBendingPlayer(player.getName()).isToggled())
|
||||
return;
|
||||
time = System.currentTimeMillis();
|
||||
this.player = player;
|
||||
this.ability = ability;
|
||||
|
|
|
@ -176,6 +176,8 @@ Abilities:
|
|||
Radius: 3.5
|
||||
RemoveDelay: 1500
|
||||
Cooldown: 10000
|
||||
DegreesPerParticle: 9
|
||||
HeightPerParticle: 2.0
|
||||
AirStream:
|
||||
Speed: 0.5
|
||||
Range: 40
|
||||
|
@ -199,6 +201,8 @@ Abilities:
|
|||
CanOnlyBeUsedDuringFullMoon: false
|
||||
ThrowFactor: 2
|
||||
Range: 10
|
||||
HoldTime: 2000
|
||||
Cooldown: 4000
|
||||
HealingWaters:
|
||||
Enabled: true
|
||||
Description: "To use, the bender must be at least partially submerged in water. If the user is not sneaking, this ability will automatically begin working provided the user has it selected. If the user is sneaking, he/she is channeling the healing to their target in front of them. In order for this channel to be successful, the user and the target must be at least partially submerged in water."
|
||||
|
|
Loading…
Reference in a new issue