mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Added option for Torrent revert & fixed Bloodbending NPE (#646)
* Added option for Torrent revert & fixed Bloodbending NPE * Fixed minor boo boo
This commit is contained in:
parent
e6850e8139
commit
51e2226f09
3 changed files with 55 additions and 36 deletions
|
@ -709,6 +709,8 @@ public class ConfigManager {
|
|||
config.addDefault("Abilities.Water.Torrent.MaxUpwardForce", 0.2);
|
||||
config.addDefault("Abilities.Water.Torrent.Interval", 30);
|
||||
config.addDefault("Abilities.Water.Torrent.Cooldown", 0);
|
||||
config.addDefault("Abilities.Water.Torrent.Revert", true);
|
||||
config.addDefault("Abilities.Water.Torrent.RevertTime", 60000);
|
||||
config.addDefault("Abilities.Water.Torrent.Wave.Radius", 12);
|
||||
config.addDefault("Abilities.Water.Torrent.Wave.Knockback", 1.5);
|
||||
config.addDefault("Abilities.Water.Torrent.Wave.Height", 1);
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Creature;
|
||||
|
@ -88,7 +89,7 @@ public class Bloodbending extends BloodAbility {
|
|||
} else {
|
||||
//Location location = GeneralMethods.getTargetedLocation(player, 6, getTransparentMaterial());
|
||||
//List<Entity> entities = GeneralMethods.getEntitiesAroundPoint(location, 1.5);
|
||||
List<Entity> entities = new ArrayList<Entity>();
|
||||
List<Entity> entities = new CopyOnWriteArrayList<Entity>();
|
||||
for (int i = 0; i < range; i++) {
|
||||
Location location = GeneralMethods.getTargetedLocation(player, i, getTransparentMaterial());
|
||||
entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7);
|
||||
|
|
|
@ -29,6 +29,7 @@ public class Torrent extends WaterAbility {
|
|||
|
||||
private static final double CLEANUP_RANGE = 50;
|
||||
private static final Map<TempBlock, Player> FROZEN_BLOCKS = new ConcurrentHashMap<>();
|
||||
private static final Map<TempBlock, Long> FROZEN_BLOCKS_DELAY = new ConcurrentHashMap<>();
|
||||
|
||||
private boolean sourceSelected;
|
||||
private boolean settingUp;
|
||||
|
@ -99,7 +100,8 @@ public class Torrent extends WaterAbility {
|
|||
}
|
||||
|
||||
time = System.currentTimeMillis();
|
||||
sourceBlock = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend());
|
||||
sourceBlock = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.LEFT_CLICK, true, true,
|
||||
bPlayer.canPlantbend());
|
||||
if (sourceBlock != null && !GeneralMethods.isRegionProtectedFromBuild(this, sourceBlock.getLocation())) {
|
||||
sourceSelected = true;
|
||||
start();
|
||||
|
@ -118,6 +120,7 @@ public class Torrent extends WaterAbility {
|
|||
if (isTransparent(player, block) && block.getType() != Material.ICE) {
|
||||
TempBlock tblock = new TempBlock(block, Material.ICE, (byte) 0);
|
||||
FROZEN_BLOCKS.put(tblock, player);
|
||||
FROZEN_BLOCKS_DELAY.put(tblock, System.currentTimeMillis());
|
||||
playIcebendingSound(block.getLocation());
|
||||
}
|
||||
}
|
||||
|
@ -222,8 +225,10 @@ public class Torrent extends WaterAbility {
|
|||
double dy = 0;
|
||||
double dz = Math.sin(phi) * radius;
|
||||
loc.add(dx, dy, dz);
|
||||
if(isWater(loc.getBlock()) && GeneralMethods.isAdjacentToThreeOrMoreSources(loc.getBlock())) {
|
||||
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, loc.getBlock().getLocation().clone().add(.5,.5,.5), 255.0);
|
||||
if (isWater(loc.getBlock()) && GeneralMethods.isAdjacentToThreeOrMoreSources(loc.getBlock())) {
|
||||
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(),
|
||||
(float) Math.random(), 0f, 5, loc.getBlock().getLocation().clone().add(.5, .5, .5),
|
||||
255.0);
|
||||
}
|
||||
loc.subtract(dx, dy, dz);
|
||||
}
|
||||
|
@ -330,7 +335,8 @@ public class Torrent extends WaterAbility {
|
|||
}
|
||||
|
||||
Block locBlock = location.getBlock();
|
||||
if (location.distanceSquared(player.getLocation()) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
|
||||
if (location.distanceSquared(player.getLocation()) > range * range
|
||||
|| GeneralMethods.isRegionProtectedFromBuild(this, location)) {
|
||||
if (layer < maxLayer) {
|
||||
if (freeze || layer < 1) {
|
||||
layer++;
|
||||
|
@ -362,7 +368,8 @@ public class Torrent extends WaterAbility {
|
|||
}
|
||||
if (locBlock.getLocation().distanceSquared(targetLoc) > 1) {
|
||||
if (isWater(locBlock)) {
|
||||
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, locBlock.getLocation().clone().add(.5,.5,.5), 255.0);
|
||||
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(),
|
||||
(float) Math.random(), 0f, 5, locBlock.getLocation().clone().add(.5, .5, .5), 255.0);
|
||||
}
|
||||
newBlocks.add(new TempBlock(locBlock, Material.STATIONARY_WATER, (byte) 8));
|
||||
} else {
|
||||
|
@ -390,11 +397,15 @@ public class Torrent extends WaterAbility {
|
|||
if (entity.getWorld() != block.getBlock().getWorld()) {
|
||||
continue;
|
||||
}
|
||||
if (entity.getLocation().distanceSquared(block.getLocation()) <= 1.5 * 1.5 && !affectedEntities.contains(entity)) {
|
||||
if (entity.getLocation().distanceSquared(block.getLocation()) <= 1.5 * 1.5
|
||||
&& !affectedEntities.contains(entity)) {
|
||||
if (i == 0) {
|
||||
affect(entity, dir);
|
||||
} else {
|
||||
affect(entity, GeneralMethods.getDirection(block.getLocation(), launchedBlocks.get(i - 1).getLocation()).normalize());
|
||||
affect(entity,
|
||||
GeneralMethods
|
||||
.getDirection(block.getLocation(), launchedBlocks.get(i - 1).getLocation())
|
||||
.normalize());
|
||||
}
|
||||
affectedEntities.add(entity);
|
||||
}
|
||||
|
@ -435,7 +446,8 @@ public class Torrent extends WaterAbility {
|
|||
if (entity.getWorld() != blockLoc.getWorld()) {
|
||||
continue;
|
||||
}
|
||||
if (!affectedEntities.contains(entity) && entity.getLocation().distanceSquared(blockLoc) <= 1.5 * 1.5) {
|
||||
if (!affectedEntities.contains(entity)
|
||||
&& entity.getLocation().distanceSquared(blockLoc) <= 1.5 * 1.5) {
|
||||
deflect(entity);
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +495,7 @@ public class Torrent extends WaterAbility {
|
|||
Location eyeLoc = player.getEyeLocation();
|
||||
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
|
||||
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
|
||||
if(block.getType() != Material.WATER) {
|
||||
if (block.getType() != Material.WATER) {
|
||||
block.setType(Material.STATIONARY_WATER);
|
||||
block.setData((byte) 8);
|
||||
}
|
||||
|
@ -577,6 +589,10 @@ public class Torrent extends WaterAbility {
|
|||
} else if (block.getBlock().getType() != Material.ICE) {
|
||||
FROZEN_BLOCKS.remove(block);
|
||||
continue;
|
||||
} else if (getConfig().getBoolean("Abilities.Water.Torrent.Revert") && System.currentTimeMillis()
|
||||
- FROZEN_BLOCKS_DELAY.get(block) > getConfig().getLong("Abilities.Water.Torrent.RevertTime")) {
|
||||
thaw(block);
|
||||
continue;
|
||||
} else if (!player.isOnline()) {
|
||||
thaw(block);
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue