Merge pull request #500 from StrangeOne101/master

Various Fixes
This commit is contained in:
OmniCypher 2016-06-11 22:17:58 -07:00 committed by GitHub
commit 3ac4736e44
10 changed files with 66 additions and 22 deletions

View file

@ -248,7 +248,7 @@ public class BendingPlayer {
} }
public boolean canBind(CoreAbility ability) { public boolean canBind(CoreAbility ability) {
if (ability == null || !player.isOnline()) { if (ability == null || !player.isOnline() || !ability.isEnabled()) {
return false; return false;
} else if (!player.hasPermission("bending.ability." + ability.getName())) { } else if (!player.hasPermission("bending.ability." + ability.getName())) {
return false; return false;

View file

@ -384,7 +384,7 @@ public class GeneralMethods {
for (int i = 1; i <= 9; i++) { for (int i = 1; i <= 9; i++) {
String slot = rs2.getString("slot" + i); String slot = rs2.getString("slot" + i);
if (slot != null && !slot.equalsIgnoreCase("null")) { if (slot != null && !slot.equalsIgnoreCase("null") && CoreAbility.getAbility(slot) != null && CoreAbility.getAbility(slot).isEnabled()) {
abilities.put(i, slot); abilities.put(i, slot);
} }
} }

View file

@ -517,7 +517,7 @@ public abstract class CoreAbility implements Ability {
String tag = null; String tag = null;
if (this instanceof ComboAbility) { if (this instanceof ComboAbility) {
tag = "Abilities." + elementName + "." + elementName + "Combo" + ".Enabled"; tag = "Abilities." + elementName + "." + elementName + "Combo." + getName() + ".Enabled";
} else { } else {
tag = "Abilities." + elementName + "." + getName() + ".Enabled"; tag = "Abilities." + elementName + "." + getName() + ".Enabled";
} }

View file

@ -40,7 +40,7 @@ public class BindCommand extends PKCommand {
} }
CoreAbility coreAbil = CoreAbility.getAbility(args.get(0)); CoreAbility coreAbil = CoreAbility.getAbility(args.get(0));
if (coreAbil == null || coreAbil.isHiddenAbility()) { if (coreAbil == null || coreAbil.isHiddenAbility() || !coreAbil.isEnabled()) {
sender.sendMessage(ChatColor.RED + abilityDoesntExist); sender.sendMessage(ChatColor.RED + abilityDoesntExist);
return; return;
} }

View file

@ -33,7 +33,7 @@ public class FireBlast extends FireAbility {
private boolean powerFurnace; private boolean powerFurnace;
private boolean showParticles; private boolean showParticles;
private boolean dissipate; private boolean dissipate;
private boolean isFireBurst; private boolean isFireBurst = false;
private int ticks; private int ticks;
private long cooldown; private long cooldown;
private double speedFactor; private double speedFactor;

View file

@ -7,6 +7,7 @@ import com.projectkorra.projectkorra.avatar.AvatarState;
import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location; import org.bukkit.Location;
@ -23,7 +24,7 @@ import java.util.Random;
public class OctopusForm extends WaterAbility { public class OctopusForm extends WaterAbility {
private static final byte FULL = 0; private static final byte FULL = 8;
private boolean sourceSelected; private boolean sourceSelected;
private boolean settingUp; private boolean settingUp;
@ -64,6 +65,7 @@ public class OctopusForm extends WaterAbility {
} }
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
remove();
return; return;
} }
@ -295,10 +297,13 @@ public class OctopusForm extends WaterAbility {
double rtheta = Math.toRadians(theta); double rtheta = Math.toRadians(theta);
Block block = location.clone().add(new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta))).getBlock(); Block block = location.clone().add(new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta))).getBlock();
if (!doneBlocks.contains(block)) { if (!doneBlocks.contains(block)) {
addWater(block); addBaseWater(block);
doneBlocks.add(block); doneBlocks.add(block);
} }
} }
for (int i = 0; i < 9; i++) {
freezeBellow(player.getLocation().add(i / 3 - 1, 0, i % 3 - 1).getBlock());
}
Vector eyeDir = player.getEyeLocation().getDirection(); Vector eyeDir = player.getEyeLocation().getDirection();
eyeDir.setY(0); eyeDir.setY(0);
@ -367,7 +372,6 @@ public class OctopusForm extends WaterAbility {
} }
private void addWater(Block block) { private void addWater(Block block) {
clearNearbyWater(block);
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return; return;
} }
@ -378,20 +382,27 @@ public class OctopusForm extends WaterAbility {
if (!blocks.contains(tblock)) { if (!blocks.contains(tblock)) {
tblock.setType(Material.WATER, FULL); tblock.setType(Material.WATER, FULL);
} }
if (isWater(block) && !TempBlock.isTempBlock(block)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, block.getLocation().clone().add(0.5, 0.5, 0.5), 257D);
}
newBlocks.add(tblock); newBlocks.add(tblock);
} }
} else if (isWaterbendable(player, block) || block.getType() == Material.FIRE || block.getType() == Material.AIR) { } else if (isWaterbendable(player, block) || block.getType() == Material.FIRE || block.getType() == Material.AIR) {
if (isWater(block) && !TempBlock.isTempBlock(block)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, block.getLocation().clone().add(0.5, 0.5, 0.5), 257D);
}
newBlocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8)); newBlocks.add(new TempBlock(block, Material.STATIONARY_WATER, (byte) 8));
} }
} }
private void clearNearbyWater(Block block) { private void addBaseWater(Block block) {
BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.DOWN }; freezeBellow(block);
for (BlockFace face : faces) { addWater(block);
Block relBlock = block.getRelative(face);
if (isWater(relBlock) && !TempBlock.isTempBlock(relBlock)) {
PhaseChangeFreeze.freeze(player, relBlock);
} }
private void freezeBellow(Block block) {
if (isWater(block.getRelative(BlockFace.DOWN)) && !GeneralMethods.isSolid(block) && !isWater(block)) {//&& !TempBlock.isTempBlock(block)) {
PhaseChangeFreeze.freeze(player, block.getRelative(BlockFace.DOWN));
} }
} }

View file

@ -81,6 +81,9 @@ public class PhaseChangeMelt extends IceAbility {
} else if (!Torrent.canThaw(block)) { } else if (!Torrent.canThaw(block)) {
Torrent.thaw(block); Torrent.thaw(block);
return; return;
} else if (WaterArmsSpear.canThaw(block)) {
WaterArmsSpear.thaw(block);
return;
} }
WaterSpoutWave.thaw(block); WaterSpoutWave.thaw(block);

View file

@ -473,7 +473,7 @@ public class Torrent extends WaterAbility {
Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock(); Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock();
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) { if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
block.setType(Material.WATER); block.setType(Material.WATER);
block.setData((byte) 0); block.setData((byte) 8);
Torrent tor = new Torrent(player); Torrent tor = new Torrent(player);
if (tor.sourceSelected || tor.settingUp) { if (tor.sourceSelected || tor.settingUp) {

View file

@ -341,6 +341,16 @@ public class WaterArms extends WaterAbility {
BLOCK_REVERT_TIMES.remove(block); BLOCK_REVERT_TIMES.remove(block);
} }
} }
for (Block block : WaterArmsSpear.getIceBlocks().keySet()) {
long time = WaterArmsSpear.getIceBlocks().get(block);
if (System.currentTimeMillis() > time || ignoreTime) {
if (TempBlock.isTempBlock(block)) {
TempBlock.revertBlock(block, Material.AIR);
}
WaterArmsSpear.getIceBlocks().remove(block);
}
}
} }
private void checkIfZapped() { private void checkIfZapped() {
@ -407,6 +417,7 @@ public class WaterArms extends WaterAbility {
public static void removeAllCleanup() { public static void removeAllCleanup() {
progressRevert(true); progressRevert(true);
BLOCK_REVERT_TIMES.clear(); BLOCK_REVERT_TIMES.clear();
WaterArmsSpear.getIceBlocks().clear();
WaterArmsWhip.removeAllCleanup(); WaterArmsWhip.removeAllCleanup();
} }

View file

@ -18,9 +18,12 @@ import org.bukkit.util.Vector;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class WaterArmsSpear extends WaterAbility { public class WaterArmsSpear extends WaterAbility {
private static final ConcurrentHashMap<Block, Long> ICE_BLOCKS = new ConcurrentHashMap<Block, Long>();
private boolean hitEntity; private boolean hitEntity;
private boolean canFreeze; private boolean canFreeze;
private boolean usageCooldownEnabled; private boolean usageCooldownEnabled;
@ -182,7 +185,7 @@ public class WaterArmsSpear extends WaterAbility {
} }
new TempBlock(location.getBlock(), Material.STATIONARY_WATER, (byte) 8); new TempBlock(location.getBlock(), Material.STATIONARY_WATER, (byte) 8);
WaterArms.getBlockRevertTimes().put(location.getBlock(), System.currentTimeMillis() + 600L); getIceBlocks().put(location.getBlock(), System.currentTimeMillis() + 600L);
Vector direction = GeneralMethods.getDirection(initLocation, GeneralMethods.getTargetedLocation(player, spearRange, new Integer[] { 8, 9, 79, 174 })).normalize(); Vector direction = GeneralMethods.getDirection(initLocation, GeneralMethods.getTargetedLocation(player, spearRange, new Integer[] { 8, 9, 79, 174 })).normalize();
location = location.add(direction.clone().multiply(1)); location = location.add(direction.clone().multiply(1));
@ -201,29 +204,41 @@ public class WaterArmsSpear extends WaterAbility {
Block block = spearLocations.get(i).getBlock(); Block block = spearLocations.get(i).getBlock();
if (canPlaceBlock(block)) { if (canPlaceBlock(block)) {
playIcebendingSound(block.getLocation()); playIcebendingSound(block.getLocation());
if (WaterArms.getBlockRevertTimes().containsKey(block)) { if (getIceBlocks().containsKey(block)) {
WaterArms.getBlockRevertTimes().remove(block); getIceBlocks().remove(block);
} }
new TempBlock(block, Material.ICE, (byte) 0); new TempBlock(block, Material.ICE, (byte) 0);
WaterArms.getBlockRevertTimes().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); getIceBlocks().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500));
} }
} }
} }
} }
public static boolean canThaw(Block block) {
return getIceBlocks().containsKey(block) && block.getType() == Material.ICE;
}
public static void thaw(Block block) {
if (canThaw(block)) {
getIceBlocks().remove(block);
block.setType(Material.AIR);
}
}
private void createIceBall() { private void createIceBall() {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, spearSphere)) { for (Block block : GeneralMethods.getBlocksAroundPoint(location, spearSphere)) {
if (isTransparent(player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) { if (isTransparent(player, block) && block.getType() != Material.ICE && !WaterArms.isUnbreakable(block)) {
playIcebendingSound(block.getLocation()); playIcebendingSound(block.getLocation());
new TempBlock(block, Material.ICE, (byte) 0); new TempBlock(block, Material.ICE, (byte) 0);
WaterArms.getBlockRevertTimes().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500)); getIceBlocks().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500));
} }
} }
} }
private boolean canPlaceBlock(Block block) { private boolean canPlaceBlock(Block block) {
if (!isTransparent(player, block) if (!isTransparent(player, block)
&& !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !WaterArms.getBlockRevertTimes().containsKey(block)))) { && !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) {
return false; return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { } else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false; return false;
@ -451,4 +466,8 @@ public class WaterArmsSpear extends WaterAbility {
this.location = location; this.location = location;
} }
public static ConcurrentHashMap<Block, Long> getIceBlocks() {
return ICE_BLOCKS;
}
} }