mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 19:50:37 +00:00
Completed Recode and added getters and setters.
This commit is contained in:
parent
706ee1cd8c
commit
50e83f6e35
1 changed files with 318 additions and 209 deletions
|
@ -11,9 +11,6 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.FallingBlock;
|
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.GeneralMethods;
|
import com.projectkorra.ProjectKorra.GeneralMethods;
|
||||||
|
@ -26,7 +23,7 @@ import com.projectkorra.ProjectKorra.firebending.FireMethods;
|
||||||
import com.projectkorra.ProjectKorra.firebending.Lightning;
|
import com.projectkorra.ProjectKorra.firebending.Lightning;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterArmsWhip.Whip;
|
import com.projectkorra.ProjectKorra.waterbending.WaterArmsWhip.Whip;
|
||||||
|
|
||||||
public class WaterArms{
|
public class WaterArms {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Arm Enum value for deciding which arm is being used.
|
* Arm Enum value for deciding which arm is being used.
|
||||||
|
@ -34,14 +31,14 @@ public class WaterArms{
|
||||||
public enum Arm {
|
public enum Arm {
|
||||||
Right, Left;
|
Right, Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
|
private static FileConfiguration config = ProjectKorra.plugin.getConfig();
|
||||||
|
|
||||||
public static ConcurrentHashMap<Player, WaterArms> instances = new ConcurrentHashMap<Player, WaterArms>();
|
public static ConcurrentHashMap<Player, WaterArms> instances = new ConcurrentHashMap<Player, WaterArms>();
|
||||||
public static ConcurrentHashMap<Block, Long> revert = new ConcurrentHashMap<Block, Long>();
|
public static ConcurrentHashMap<Block, Long> revert = new ConcurrentHashMap<Block, Long>();
|
||||||
public static ConcurrentHashMap<FallingBlock, Player> falling = new ConcurrentHashMap<FallingBlock, Player>();
|
|
||||||
|
private static Integer[] unbreakable = { 7, 8, 9, 10, 11, 49, 54, 90, 119,
|
||||||
private static Integer[] unbreakable = {7, 8, 9, 10, 11, 49, 54, 90, 119, 120, 130, 146};
|
120, 130, 146 };
|
||||||
|
|
||||||
private Player player;
|
private Player player;
|
||||||
private World world;
|
private World world;
|
||||||
|
@ -57,49 +54,78 @@ public class WaterArms{
|
||||||
|
|
||||||
private int lengthReduction = 0;
|
private int lengthReduction = 0;
|
||||||
|
|
||||||
private int initLength = config.getInt("Abilities.Water.WaterArms.Arms.InitialLength");
|
private int initLength = config
|
||||||
private int sourceGrabRange = config.getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange");
|
.getInt("Abilities.Water.WaterArms.Arms.InitialLength");
|
||||||
private int maxPunches = config.getInt("Abilities.Water.WaterArms.Arms.MaxAttacks");
|
private int sourceGrabRange = config
|
||||||
private int maxIceBlasts = config.getInt("Abilities.Water.WaterArms.Arms.MaxIceShots");
|
.getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange");
|
||||||
private int maxUses = config.getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage");
|
private int maxPunches = config
|
||||||
private long cooldown = config.getLong("Abilities.Water.WaterArms.Arms.cooldown");
|
.getInt("Abilities.Water.WaterArms.Arms.MaxAttacks");
|
||||||
private boolean canUsePlantSource = config.getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource");
|
private int maxIceBlasts = config
|
||||||
|
.getInt("Abilities.Water.WaterArms.Arms.MaxIceShots");
|
||||||
|
private int maxUses = config
|
||||||
|
.getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage");
|
||||||
|
private long cooldown = config
|
||||||
|
.getLong("Abilities.Water.WaterArms.Arms.Cooldown");
|
||||||
|
private boolean canUsePlantSource = config
|
||||||
|
.getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource");
|
||||||
|
|
||||||
private boolean lightningEnabled = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled");
|
private boolean lightningEnabled = config
|
||||||
private double lightningDamage = config.getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage");
|
.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled");
|
||||||
private boolean lightningKill = config.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser");
|
private double lightningDamage = config
|
||||||
|
.getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage");
|
||||||
private static double blockDamage = config.getDouble("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamage");
|
private boolean lightningKill = config
|
||||||
private static boolean pullBlocksDamageUser = config.getBoolean("Abilities.Water.WaterArms.WhipMode.Pull.BlockDamageUser");
|
.getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser");
|
||||||
|
|
||||||
|
private static String sneakMsg = config
|
||||||
|
.getString("Abilities.Water.WaterArms.SneakMessage");
|
||||||
|
|
||||||
private int selectedSlot = 0;
|
private int selectedSlot = 0;
|
||||||
private int freezeSlot = 4;
|
private int freezeSlot = 4;
|
||||||
|
|
||||||
private long lastClickTime;
|
private long lastClickTime;
|
||||||
|
|
||||||
public WaterArms(Player player){
|
public WaterArms(Player player) {
|
||||||
if(instances.containsKey(player)){
|
if (instances.containsKey(player)) {
|
||||||
if(player.isSneaking()){
|
if (player.isSneaking()) {
|
||||||
instances.get(player).prepareCancel();
|
instances.get(player).prepareCancel();
|
||||||
}else{
|
} else {
|
||||||
switch(player.getInventory().getHeldItemSlot()){
|
switch (player.getInventory().getHeldItemSlot()) {
|
||||||
case 0:
|
case 0:
|
||||||
new WaterArmsWhip(player, Whip.Pull);
|
if (player.hasPermission("bending.ability.WaterArms.Pull")) {
|
||||||
|
new WaterArmsWhip(player, Whip.Pull);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
new WaterArmsWhip(player, Whip.Punch);
|
if (player.hasPermission("bending.ability.WaterArms.Punch")) {
|
||||||
|
new WaterArmsWhip(player, Whip.Punch);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
new WaterArmsWhip(player, Whip.Grapple);
|
if (player
|
||||||
|
.hasPermission("bending.ability.WaterArms.Grapple")) {
|
||||||
|
new WaterArmsWhip(player, Whip.Grapple);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
new WaterArmsWhip(player, Whip.Grab);
|
if (player.hasPermission("bending.ability.WaterArms.Grab")) {
|
||||||
|
new WaterArmsWhip(player, Whip.Grab);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//new WaterArmsIce(player);
|
if (player
|
||||||
|
.hasPermission("bending.ability.WaterArms.Freeze")
|
||||||
|
&& WaterMethods.canIcebend(player)) {
|
||||||
|
new WaterArmsFreeze(player);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
//new WaterArmsSpear(player);
|
if (player.hasPermission("bending.ability.WaterArms.Spear")) {
|
||||||
|
if (WaterMethods.canIcebend(player)) {
|
||||||
|
new WaterArmsSpear(player, true);
|
||||||
|
} else {
|
||||||
|
new WaterArmsSpear(player, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -108,40 +134,50 @@ public class WaterArms{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.player = player;
|
this.player = player;
|
||||||
if(canUse(player) && prepare()){
|
if (canUse(player) && prepare()) {
|
||||||
world = player.getWorld();
|
world = player.getWorld();
|
||||||
instances.put(player, this);
|
instances.put(player, this);
|
||||||
MultiAbilityManager.bindMultiAbility(player, "WaterArms");
|
MultiAbilityManager.bindMultiAbility(player, "WaterArms");
|
||||||
if(ChatColor.stripColor(GeneralMethods.getBoundAbility(player)) == null){
|
if (ChatColor.stripColor(GeneralMethods.getBoundAbility(player)) == null) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " "
|
||||||
|
+ GeneralMethods.getBoundAbility(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canUse(Player player){
|
private boolean canUse(Player player) {
|
||||||
if(GeneralMethods.getBoundAbility(player) == null)
|
if (GeneralMethods.getBoundAbility(player) == null)
|
||||||
return false;
|
return false;
|
||||||
if(!GeneralMethods.canBend(player.getName(), "WaterArms"))
|
if (!GeneralMethods.canBend(player.getName(), "WaterArms"))
|
||||||
return false;
|
return false;
|
||||||
if(GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms", player.getLocation()))
|
if (GeneralMethods.isRegionProtectedFromBuild(player, "WaterArms",
|
||||||
|
player.getLocation()))
|
||||||
return false;
|
return false;
|
||||||
if(GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown("WaterArms"))
|
if (GeneralMethods.getBendingPlayer(player.getName()).isOnCooldown(
|
||||||
|
"WaterArms"))
|
||||||
return false;
|
return false;
|
||||||
if(GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterArms"))
|
if (GeneralMethods.getBoundAbility(player)
|
||||||
|
.equalsIgnoreCase("WaterArms"))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean prepare(){
|
private boolean prepare() {
|
||||||
Block sourceblock = WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource);
|
Block sourceblock = WaterMethods.getWaterSourceBlock(player,
|
||||||
if(sourceblock != null){
|
sourceGrabRange, canUsePlantSource);
|
||||||
if(WaterMethods.isPlant(sourceblock)){
|
if (sourceblock != null) {
|
||||||
|
if (WaterMethods.isPlant(sourceblock)) {
|
||||||
fullSource = false;
|
fullSource = false;
|
||||||
}
|
}
|
||||||
ParticleEffect.LARGE_SMOKE.display(WaterMethods.getWaterSourceBlock(player, sourceGrabRange, canUsePlantSource).getLocation().clone().add(0.5,0.5,0.5), 0, 0, 0, 0F, 4);
|
ParticleEffect.LARGE_SMOKE.display(
|
||||||
|
WaterMethods
|
||||||
|
.getWaterSourceBlock(player, sourceGrabRange,
|
||||||
|
canUsePlantSource).getLocation().clone()
|
||||||
|
.add(0.5, 0.5, 0.5), 0, 0, 0, 0F, 4);
|
||||||
return true;
|
return true;
|
||||||
}else if(WaterReturn.hasWaterBottle(player)){
|
} else if (WaterReturn.hasWaterBottle(player)) {
|
||||||
WaterReturn.emptyWaterBottle(player);
|
WaterReturn.emptyWaterBottle(player);
|
||||||
fullSource = false;
|
fullSource = false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -149,23 +185,24 @@ public class WaterArms{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void progress(){
|
private void progress() {
|
||||||
if (!instances.containsKey(player)){
|
if (!instances.containsKey(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(player.isDead() || !player.isOnline() || world != player.getWorld()){
|
if (player.isDead() || !player.isOnline() || world != player.getWorld()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!GeneralMethods.getBendingPlayer(player.getName()).isToggled()){
|
if (!GeneralMethods.getBendingPlayer(player.getName()).isToggled()) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")){
|
if (!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(maxPunches == 0 || maxUses == 0 || maxIceBlasts == 0 || (leftArmConsumed && rightArmConsumed)){
|
if (maxPunches == 0 || maxUses == 0 || maxIceBlasts == 0
|
||||||
|
|| (leftArmConsumed && rightArmConsumed)) {
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -174,54 +211,67 @@ public class WaterArms{
|
||||||
displayRightArm();
|
displayRightArm();
|
||||||
displayLeftArm();
|
displayLeftArm();
|
||||||
|
|
||||||
if(lightningEnabled)
|
if (lightningEnabled)
|
||||||
checkIfZapped();
|
checkIfZapped();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canPlaceBlock(Block block){
|
private boolean canPlaceBlock(Block block) {
|
||||||
if(!EarthMethods.isTransparentToEarthbending(player, block) && !(WaterMethods.isWater(block) && TempBlock.isTempBlock(block)))
|
if (!EarthMethods.isTransparentToEarthbending(player, block)
|
||||||
|
&& !(WaterMethods.isWater(block) && TempBlock
|
||||||
|
.isTempBlock(block)))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the right arm.
|
* Displays the right arm. Returns false if the arm cannot be fully
|
||||||
* Returns false if the arm cannot be fully displayed.
|
* displayed.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean displayRightArm(){
|
public boolean displayRightArm() {
|
||||||
if(rightArmConsumed)
|
if (rightArmConsumed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Location r1 = GeneralMethods.getRightSide(player.getLocation(), 1).add(0, 1.5, 0);
|
Location r1 = GeneralMethods.getRightSide(player.getLocation(), 1).add(
|
||||||
if(!canPlaceBlock(r1.getBlock()))
|
0, 1.5, 0);
|
||||||
|
if (!canPlaceBlock(r1.getBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!(getRightHandPos().getBlock().getLocation().equals(r1.getBlock().getLocation()))){
|
if (!(getRightHandPos().getBlock().getLocation().equals(r1.getBlock()
|
||||||
|
.getLocation()))) {
|
||||||
new TempBlock(r1.getBlock(), Material.STATIONARY_WATER, (byte) 5);
|
new TempBlock(r1.getBlock(), Material.STATIONARY_WATER, (byte) 5);
|
||||||
revert.put(r1.getBlock(), 0L);
|
revert.put(r1.getBlock(), 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location r2 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0);
|
Location r2 = GeneralMethods.getRightSide(player.getLocation(), 2).add(
|
||||||
if(!canPlaceBlock(r2.getBlock()))
|
0, 1.5, 0);
|
||||||
|
if (!canPlaceBlock(r2.getBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
new TempBlock(r2.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
new TempBlock(r2.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
||||||
revert.put(r2.getBlock(), 0L);
|
revert.put(r2.getBlock(), 0L);
|
||||||
|
|
||||||
for(int j = 0; j <= initLength; j++){
|
for (int j = 0; j <= initLength; j++) {
|
||||||
Location r3 = r2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld());
|
Location r3 = r2
|
||||||
if(!canPlaceBlock(r3.getBlock())){
|
.clone()
|
||||||
if(selectedSlot == freezeSlot && r3.getBlock().getType().equals(Material.ICE))
|
.toVector()
|
||||||
|
.add(player.getLocation().clone().getDirection()
|
||||||
|
.multiply(j)).toLocation(player.getWorld());
|
||||||
|
if (!canPlaceBlock(r3.getBlock())) {
|
||||||
|
if (selectedSlot == freezeSlot
|
||||||
|
&& r3.getBlock().getType().equals(Material.ICE))
|
||||||
continue;
|
continue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(j >= 1 && selectedSlot == freezeSlot){
|
if (j >= 1 && selectedSlot == freezeSlot
|
||||||
|
&& WaterMethods.canIcebend(player)) {
|
||||||
new TempBlock(r3.getBlock(), Material.ICE, (byte) 0);
|
new TempBlock(r3.getBlock(), Material.ICE, (byte) 0);
|
||||||
revert.put(r3.getBlock(), 0L);
|
revert.put(r3.getBlock(), 0L);
|
||||||
}else{
|
} else {
|
||||||
new TempBlock(r3.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
new TempBlock(r3.getBlock(), Material.STATIONARY_WATER,
|
||||||
|
(byte) 0);
|
||||||
revert.put(r3.getBlock(), 0L);
|
revert.put(r3.getBlock(), 0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,43 +280,54 @@ public class WaterArms{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the left arm.
|
* Displays the left arm. Returns false if the arm cannot be fully
|
||||||
* Returns false if the arm cannot be fully displayed.
|
* displayed.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean displayLeftArm(){
|
public boolean displayLeftArm() {
|
||||||
if(leftArmConsumed)
|
if (leftArmConsumed)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 1).add(0, 1.5, 0);
|
Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 1).add(
|
||||||
if(!canPlaceBlock(l1.getBlock()))
|
0, 1.5, 0);
|
||||||
|
if (!canPlaceBlock(l1.getBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(!(getLeftHandPos().getBlock().getLocation().equals(l1.getBlock().getLocation()))){
|
if (!(getLeftHandPos().getBlock().getLocation().equals(l1.getBlock()
|
||||||
|
.getLocation()))) {
|
||||||
new TempBlock(l1.getBlock(), Material.STATIONARY_WATER, (byte) 5);
|
new TempBlock(l1.getBlock(), Material.STATIONARY_WATER, (byte) 5);
|
||||||
revert.put(l1.getBlock(), 0L);
|
revert.put(l1.getBlock(), 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location l2 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0);
|
Location l2 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(
|
||||||
if(!canPlaceBlock(l2.getBlock()))
|
0, 1.5, 0);
|
||||||
|
if (!canPlaceBlock(l2.getBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
new TempBlock(l2.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
||||||
revert.put(l2.getBlock(), 0L);
|
revert.put(l2.getBlock(), 0L);
|
||||||
|
|
||||||
for(int j = 0; j <= initLength; j++){
|
for (int j = 0; j <= initLength; j++) {
|
||||||
Location l3 = l2.clone().toVector().add(player.getLocation().clone().getDirection().multiply(j)).toLocation(player.getWorld());
|
Location l3 = l2
|
||||||
if(!canPlaceBlock(l3.getBlock())){
|
.clone()
|
||||||
if(selectedSlot == freezeSlot && l3.getBlock().getType().equals(Material.ICE))
|
.toVector()
|
||||||
|
.add(player.getLocation().clone().getDirection()
|
||||||
|
.multiply(j)).toLocation(player.getWorld());
|
||||||
|
if (!canPlaceBlock(l3.getBlock())) {
|
||||||
|
if (selectedSlot == freezeSlot
|
||||||
|
&& l3.getBlock().getType().equals(Material.ICE))
|
||||||
continue;
|
continue;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(j >= 1 && selectedSlot == freezeSlot){
|
if (j >= 1 && selectedSlot == freezeSlot
|
||||||
|
&& WaterMethods.canIcebend(player)) {
|
||||||
new TempBlock(l3.getBlock(), Material.ICE, (byte) 0);
|
new TempBlock(l3.getBlock(), Material.ICE, (byte) 0);
|
||||||
revert.put(l3.getBlock(), 0L);
|
revert.put(l3.getBlock(), 0L);
|
||||||
}else{
|
} else {
|
||||||
new TempBlock(l3.getBlock(), Material.STATIONARY_WATER, (byte) 0);
|
new TempBlock(l3.getBlock(), Material.STATIONARY_WATER,
|
||||||
|
(byte) 0);
|
||||||
revert.put(l3.getBlock(), 0L);
|
revert.put(l3.getBlock(), 0L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,85 +337,81 @@ public class WaterArms{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate roughly where the player's right hand is.
|
* Calculate roughly where the player's right hand is.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Location getRightHandPos(){
|
private Location getRightHandPos() {
|
||||||
return GeneralMethods.getRightSide(player.getLocation(), .34).add(0, 1.5, 0);
|
return GeneralMethods.getRightSide(player.getLocation(), .34).add(0,
|
||||||
|
1.5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate roughly where the player's left hand is.
|
* Calculate roughly where the player's left hand is.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Location getLeftHandPos(){
|
private Location getLeftHandPos() {
|
||||||
return GeneralMethods.getLeftSide(player.getLocation(), .34).add(0, 1.5, 0);
|
return GeneralMethods.getLeftSide(player.getLocation(), .34).add(0,
|
||||||
|
1.5, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the location of the tip of the right arm, assuming it is fully extended.
|
* Returns the location of the tip of the right arm, assuming it is fully
|
||||||
* Use the displayRightArm() check to see if it is fully extended.
|
* extended. Use the displayRightArm() check to see if it is fully extended.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Location getRightArmEnd(){
|
public Location getRightArmEnd() {
|
||||||
Location r1 = GeneralMethods.getRightSide(player.getLocation(), 2).add(0, 1.5, 0);
|
Location r1 = GeneralMethods.getRightSide(player.getLocation(), 2).add(
|
||||||
return r1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength));
|
0, 1.5, 0);
|
||||||
|
return r1.clone().add(
|
||||||
|
player.getLocation().getDirection().normalize()
|
||||||
|
.multiply(initLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the location of the tip of the left arm assuming it is fully extended.
|
* Returns the location of the tip of the left arm assuming it is fully
|
||||||
* Use the displayLeftArm() check to see if it is fully extended.
|
* extended. Use the displayLeftArm() check to see if it is fully extended.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Location getLeftArmEnd(){
|
public Location getLeftArmEnd() {
|
||||||
Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(0, 1.5, 0);
|
Location l1 = GeneralMethods.getLeftSide(player.getLocation(), 2).add(
|
||||||
return l1.clone().add(player.getLocation().getDirection().normalize().multiply(initLength));
|
0, 1.5, 0);
|
||||||
|
return l1.clone().add(
|
||||||
|
player.getLocation().getDirection().normalize()
|
||||||
|
.multiply(initLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void progressRevert(boolean ignoreTime){
|
private static void progressRevert(boolean ignoreTime) {
|
||||||
for(Block block : revert.keySet()){
|
for (Block block : revert.keySet()) {
|
||||||
long time = revert.get(block);
|
long time = revert.get(block);
|
||||||
if(System.currentTimeMillis() > time || ignoreTime){
|
if (System.currentTimeMillis() > time || ignoreTime) {
|
||||||
if(TempBlock.isTempBlock(block))
|
if (TempBlock.isTempBlock(block))
|
||||||
TempBlock.revertBlock(block, Material.AIR);
|
TempBlock.revertBlock(block, Material.AIR);
|
||||||
revert.remove(block);
|
revert.remove(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void trackEntities(boolean remove){
|
|
||||||
for(FallingBlock fallingBlock : falling.keySet()){
|
|
||||||
if(remove){
|
|
||||||
fallingBlock.remove();
|
|
||||||
falling.remove(fallingBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!fallingBlock.isDead()){
|
private void checkIfZapped() {
|
||||||
for(Entity entity : GeneralMethods.getEntitiesAroundPoint(fallingBlock.getLocation(), 2.0)){
|
for (int i = 0; i < Lightning.instances.size(); i++) {
|
||||||
if(entity instanceof LivingEntity){
|
|
||||||
if(!pullBlocksDamageUser && entity.getEntityId() == falling.get(fallingBlock).getEntityId())
|
|
||||||
continue;
|
|
||||||
GeneralMethods.damageEntity(falling.get(fallingBlock), entity, blockDamage);
|
|
||||||
fallingBlock.remove();
|
|
||||||
falling.remove(fallingBlock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkIfZapped(){
|
|
||||||
for (int i = 0; i < Lightning.instances.size(); i++){
|
|
||||||
Lightning l = Lightning.instances.get(i);
|
Lightning l = Lightning.instances.get(i);
|
||||||
for(Lightning.Arc arc : l.getArcs()){
|
for (Lightning.Arc arc : l.getArcs()) {
|
||||||
for(Block arm : revert.keySet()){
|
for (Block arm : revert.keySet()) {
|
||||||
for(Location loc : arc.getPoints()){
|
for (Location loc : arc.getPoints()) {
|
||||||
if(arm.getLocation().getWorld() == loc.getWorld() && loc.distance(arm.getLocation()) <= 2.5){
|
if (arm.getLocation().getWorld() == loc.getWorld()
|
||||||
for(Location l1 : getOffsetLocations(4, arm.getLocation(), 1.25))
|
&& loc.distance(arm.getLocation()) <= 2.5) {
|
||||||
|
for (Location l1 : getOffsetLocations(4,
|
||||||
|
arm.getLocation(), 1.25))
|
||||||
FireMethods.playLightningbendingParticle(l1);
|
FireMethods.playLightningbendingParticle(l1);
|
||||||
if(lightningKill)
|
if (lightningKill)
|
||||||
GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, 60D);
|
GeneralMethods.damageEntity(Lightning.instances
|
||||||
|
.get(i).getPlayer(), player, 60D);
|
||||||
else
|
else
|
||||||
GeneralMethods.damageEntity(Lightning.instances.get(i).getPlayer(), player, lightningDamage);
|
GeneralMethods.damageEntity(Lightning.instances
|
||||||
|
.get(i).getPlayer(), player,
|
||||||
|
lightningDamage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,70 +419,87 @@ public class WaterArms{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Location> getOffsetLocations(int amount, Location location, double offset){
|
private static List<Location> getOffsetLocations(int amount,
|
||||||
|
Location location, double offset) {
|
||||||
List<Location> locations = new ArrayList<Location>();
|
List<Location> locations = new ArrayList<Location>();
|
||||||
for(int i = 0; i < amount; i++)
|
for (int i = 0; i < amount; i++)
|
||||||
locations.add(location.clone().add((float) (Math.random()*offset), (float) (Math.random()*offset), (float) (Math.random()*offset)));
|
locations.add(location.clone().add(
|
||||||
|
(float) (Math.random() * offset),
|
||||||
|
(float) (Math.random() * offset),
|
||||||
|
(float) (Math.random() * offset)));
|
||||||
return locations;
|
return locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(Player player){
|
public static void remove(Player player) {
|
||||||
if(instances.containsKey(player))
|
if (instances.containsKey(player))
|
||||||
instances.get(player).remove();
|
instances.get(player).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(){
|
public void remove() {
|
||||||
MultiAbilityManager.unbindMultiAbility(player);
|
MultiAbilityManager.unbindMultiAbility(player);
|
||||||
if(player.isOnline())
|
if (player.isOnline())
|
||||||
GeneralMethods.getBendingPlayer(player.getName()).addCooldown("WaterArms", cooldown);
|
GeneralMethods.getBendingPlayer(player.getName()).addCooldown(
|
||||||
|
"WaterArms", cooldown);
|
||||||
instances.remove(player);
|
instances.remove(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void prepareCancel(){
|
public void prepareCancel() {
|
||||||
if(System.currentTimeMillis() < lastClickTime + 500L){
|
if (System.currentTimeMillis() < lastClickTime + 500L) {
|
||||||
remove();
|
remove();
|
||||||
}else{
|
} else {
|
||||||
lastClickTime = System.currentTimeMillis();
|
lastClickTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void progressAll(){
|
public static void progressAll() {
|
||||||
progressRevert(false);
|
progressRevert(false);
|
||||||
trackEntities(false);
|
for (Player p : instances.keySet())
|
||||||
for(Player p : instances.keySet())
|
|
||||||
instances.get(p).progress();
|
instances.get(p).progress();
|
||||||
WaterArmsWhip.progressAll();
|
WaterArmsWhip.progressAll();
|
||||||
|
WaterArmsFreeze.progressAll();
|
||||||
|
WaterArmsSpear.progressAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removeAll(){
|
public static void removeAll() {
|
||||||
progressRevert(true);
|
progressRevert(true);
|
||||||
trackEntities(true);
|
|
||||||
revert.clear();
|
revert.clear();
|
||||||
falling.clear();
|
|
||||||
instances.clear();
|
instances.clear();
|
||||||
WaterArmsWhip.removeAll();
|
WaterArmsWhip.removeAll();
|
||||||
|
WaterArmsFreeze.removeAll();
|
||||||
|
WaterArmsSpear.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public static boolean isUnbreakable(Block block) {
|
public static boolean isUnbreakable(Block block) {
|
||||||
if (Arrays.asList(unbreakable).contains(block.getTypeId())) return true;
|
if (Arrays.asList(unbreakable).contains(block.getTypeId()))
|
||||||
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void displayBoundMsg(Player player){
|
||||||
|
player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " "
|
||||||
|
+ GeneralMethods.getBoundAbility(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayBoundMsg(){
|
||||||
|
player.sendMessage(WaterMethods.getWaterColor() + sneakMsg + " "
|
||||||
|
+ GeneralMethods.getBoundAbility(player));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the active arm of the player.
|
* Returns the active arm of the player.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Arm getActiveArm(){
|
public Arm getActiveArm() {
|
||||||
return activeArm;
|
return activeArm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches the active arm of a player.
|
* Switches the active arm of a player.
|
||||||
*/
|
*/
|
||||||
public void switchActiveArm(){
|
public void switchActiveArm() {
|
||||||
if(activeArm.equals(Arm.Right))
|
if (activeArm.equals(Arm.Right))
|
||||||
activeArm = Arm.Left;
|
activeArm = Arm.Left;
|
||||||
else
|
else
|
||||||
activeArm = Arm.Right;
|
activeArm = Arm.Right;
|
||||||
|
@ -433,25 +507,26 @@ public class WaterArms{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switches to the most suitable arm for the player.
|
* Switches to the most suitable arm for the player.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Arm switchPreferredArm(){
|
public Arm switchPreferredArm() {
|
||||||
switchActiveArm();
|
switchActiveArm();
|
||||||
if(activeArm.equals(Arm.Left)){
|
if (activeArm.equals(Arm.Left)) {
|
||||||
if(!displayLeftArm()){
|
if (!displayLeftArm()) {
|
||||||
switchActiveArm();
|
switchActiveArm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(activeArm.equals(Arm.Right)){
|
if (activeArm.equals(Arm.Right)) {
|
||||||
if(!displayRightArm()){
|
if (!displayRightArm()) {
|
||||||
switchActiveArm();
|
switchActiveArm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return getActiveArm();
|
return getActiveArm();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canDisplayCurrentArm(){
|
public boolean canDisplayActiveArm() {
|
||||||
switch(activeArm){
|
switch (activeArm) {
|
||||||
case Left:
|
case Left:
|
||||||
return displayLeftArm();
|
return displayLeftArm();
|
||||||
case Right:
|
case Right:
|
||||||
|
@ -460,81 +535,115 @@ public class WaterArms{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Player getPlayer(){
|
public Location getActiveArmEnd() {
|
||||||
|
switch (activeArm) {
|
||||||
|
case Left:
|
||||||
|
return getLeftArmEnd();
|
||||||
|
case Right:
|
||||||
|
return getRightArmEnd();
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPlayer(Player player) {
|
||||||
|
if (instances.containsKey(player)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player getPlayer() {
|
||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isFullSource(){
|
public Boolean isFullSource() {
|
||||||
return fullSource;
|
return fullSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getLengthReduction(){
|
public boolean getLeftArmConsumed() {
|
||||||
|
return leftArmConsumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftArmConsumed(boolean consumed) {
|
||||||
|
this.leftArmConsumed = consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getRightArmConsumed() {
|
||||||
|
return rightArmConsumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightArmConsumed(boolean consumed) {
|
||||||
|
this.rightArmConsumed = consumed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLengthReduction() {
|
||||||
return lengthReduction;
|
return lengthReduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLengthReduction(int lengthReduction){
|
public void setLengthReduction(int lengthReduction) {
|
||||||
this.lengthReduction = lengthReduction;
|
this.lengthReduction = lengthReduction;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxPunches(){
|
public Integer getMaxPunches() {
|
||||||
return maxPunches;
|
return maxPunches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxPunches(int maxPunches){
|
public void setMaxPunches(int maxPunches) {
|
||||||
this.maxPunches = maxPunches;
|
this.maxPunches = maxPunches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxUses(){
|
public Integer getMaxUses() {
|
||||||
return maxUses;
|
return maxUses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxUses(int maxUses){
|
public void setMaxUses(int maxUses) {
|
||||||
this.maxUses = maxUses;
|
this.maxUses = maxUses;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxIceBlasts(){
|
public Integer getMaxIceBlasts() {
|
||||||
return maxIceBlasts;
|
return maxIceBlasts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxIceBlasts(int maxIceBlasts){
|
public void setMaxIceBlasts(int maxIceBlasts) {
|
||||||
this.maxIceBlasts = maxIceBlasts;
|
this.maxIceBlasts = maxIceBlasts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canLightningDamage(){
|
public boolean canLightningDamage() {
|
||||||
return lightningEnabled;
|
return lightningEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanLightningDamage(boolean lightningEnabled){
|
public void setCanLightningDamage(boolean lightningEnabled) {
|
||||||
this.lightningEnabled = lightningEnabled;
|
this.lightningEnabled = lightningEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getLightningDamage(){
|
public double getLightningDamage() {
|
||||||
return lightningDamage;
|
return lightningDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLightningDamage(double lightningDamage){
|
public void setLightningDamage(double lightningDamage) {
|
||||||
this.lightningDamage = lightningDamage;
|
this.lightningDamage = lightningDamage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLeftArmCooldown(){
|
public boolean isLeftArmCooldown() {
|
||||||
return cooldownLeft;
|
return cooldownLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftArmCooldown(boolean cooldown){
|
public void setLeftArmCooldown(boolean cooldown) {
|
||||||
this.cooldownLeft = cooldown;
|
this.cooldownLeft = cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRightArmCooldown(){
|
public boolean isRightArmCooldown() {
|
||||||
return cooldownRight;
|
return cooldownRight;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightArmCooldown(boolean cooldown){
|
public void setRightArmCooldown(boolean cooldown) {
|
||||||
this.cooldownRight = cooldown;
|
this.cooldownRight = cooldown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setActiveArmCooldown(boolean cooldown){
|
public void setActiveArmCooldown(boolean cooldown) {
|
||||||
switch(activeArm){
|
switch (activeArm) {
|
||||||
case Left:
|
case Left:
|
||||||
setLeftArmCooldown(cooldown);
|
setLeftArmCooldown(cooldown);
|
||||||
return;
|
return;
|
||||||
|
@ -545,7 +654,7 @@ public class WaterArms{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCooldown() {
|
public long getCooldown() {
|
||||||
return cooldown;
|
return cooldown;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue