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) {
if (ability == null || !player.isOnline()) {
if (ability == null || !player.isOnline() || !ability.isEnabled()) {
return false;
} else if (!player.hasPermission("bending.ability." + ability.getName())) {
return false;

View file

@ -384,7 +384,7 @@ public class GeneralMethods {
for (int i = 1; i <= 9; 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);
}
}

View file

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

View file

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

View file

@ -33,7 +33,7 @@ public class FireBlast extends FireAbility {
private boolean powerFurnace;
private boolean showParticles;
private boolean dissipate;
private boolean isFireBurst;
private boolean isFireBurst = false;
private int ticks;
private long cooldown;
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.ClickType;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.ParticleEffect;
import com.projectkorra.projectkorra.util.TempBlock;
import org.bukkit.Location;
@ -23,7 +24,7 @@ import java.util.Random;
public class OctopusForm extends WaterAbility {
private static final byte FULL = 0;
private static final byte FULL = 8;
private boolean sourceSelected;
private boolean settingUp;
@ -64,6 +65,7 @@ public class OctopusForm extends WaterAbility {
}
if (!bPlayer.canBend(this)) {
remove();
return;
}
@ -295,10 +297,13 @@ public class OctopusForm extends WaterAbility {
double rtheta = Math.toRadians(theta);
Block block = location.clone().add(new Vector(radius * Math.cos(rtheta), 0, radius * Math.sin(rtheta))).getBlock();
if (!doneBlocks.contains(block)) {
addWater(block);
addBaseWater(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();
eyeDir.setY(0);
@ -367,7 +372,6 @@ public class OctopusForm extends WaterAbility {
}
private void addWater(Block block) {
clearNearbyWater(block);
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return;
}
@ -378,20 +382,27 @@ public class OctopusForm extends WaterAbility {
if (!blocks.contains(tblock)) {
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);
}
} 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));
}
}
private void clearNearbyWater(Block block) {
BlockFace[] faces = { BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.DOWN };
for (BlockFace face : faces) {
Block relBlock = block.getRelative(face);
if (isWater(relBlock) && !TempBlock.isTempBlock(relBlock)) {
PhaseChangeFreeze.freeze(player, relBlock);
}
private void addBaseWater(Block block) {
freezeBellow(block);
addWater(block);
}
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)) {
Torrent.thaw(block);
return;
} else if (WaterArmsSpear.canThaw(block)) {
WaterArmsSpear.thaw(block);
return;
}
WaterSpoutWave.thaw(block);

View file

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

View file

@ -341,6 +341,16 @@ public class WaterArms extends WaterAbility {
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() {
@ -407,6 +417,7 @@ public class WaterArms extends WaterAbility {
public static void removeAllCleanup() {
progressRevert(true);
BLOCK_REVERT_TIMES.clear();
WaterArmsSpear.getIceBlocks().clear();
WaterArmsWhip.removeAllCleanup();
}

View file

@ -18,9 +18,12 @@ import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
public class WaterArmsSpear extends WaterAbility {
private static final ConcurrentHashMap<Block, Long> ICE_BLOCKS = new ConcurrentHashMap<Block, Long>();
private boolean hitEntity;
private boolean canFreeze;
private boolean usageCooldownEnabled;
@ -182,7 +185,7 @@ public class WaterArmsSpear extends WaterAbility {
}
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();
location = location.add(direction.clone().multiply(1));
@ -201,29 +204,41 @@ public class WaterArmsSpear extends WaterAbility {
Block block = spearLocations.get(i).getBlock();
if (canPlaceBlock(block)) {
playIcebendingSound(block.getLocation());
if (WaterArms.getBlockRevertTimes().containsKey(block)) {
WaterArms.getBlockRevertTimes().remove(block);
if (getIceBlocks().containsKey(block)) {
getIceBlocks().remove(block);
}
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() {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, spearSphere)) {
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));
getIceBlocks().put(block, System.currentTimeMillis() + spearDuration + (long) (Math.random() * 500));
}
}
}
private boolean canPlaceBlock(Block 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;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false;
@ -451,4 +466,8 @@ public class WaterArmsSpear extends WaterAbility {
this.location = location;
}
public static ConcurrentHashMap<Block, Long> getIceBlocks() {
return ICE_BLOCKS;
}
}