mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-11 11:40:40 +00:00
EarthGrab
This commit is contained in:
parent
edada84fa2
commit
767c99ed65
4 changed files with 166 additions and 0 deletions
|
@ -275,6 +275,11 @@ public class ConfigManager {
|
||||||
config.addDefault("Abilities.Earth.Earthblast.Damage", 4);
|
config.addDefault("Abilities.Earth.Earthblast.Damage", 4);
|
||||||
config.addDefault("Abilities.Earth.EarthBlast.Push", 0.3);
|
config.addDefault("Abilities.Earth.EarthBlast.Push", 0.3);
|
||||||
|
|
||||||
|
config.addDefault("Abilities.Earth.EarthGrab.Enabled", true);
|
||||||
|
config.addDefault("Abilities.Earth.EarthGrab.Description", "To use, simply left-click while targeting a creature within range. "
|
||||||
|
+ "This ability will erect a circle of earth to trap the creature in.");
|
||||||
|
config.addDefault("Abilities.Earth.EarthGrab.Range", 15);
|
||||||
|
|
||||||
config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true);
|
config.addDefault("Abilities.Earth.RaiseEarth.Enabled", true);
|
||||||
config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. "
|
config.addDefault("Abilities.Earth.RaiseEarth.Description", "To use, simply left-click on an earthbendable block. "
|
||||||
+ "A column of earth will shoot upwards from that location. "
|
+ "A column of earth will shoot upwards from that location. "
|
||||||
|
|
|
@ -66,6 +66,7 @@ import com.projectkorra.ProjectKorra.earthbending.CompactColumn;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthArmor;
|
import com.projectkorra.ProjectKorra.earthbending.EarthArmor;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
import com.projectkorra.ProjectKorra.earthbending.EarthBlast;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
import com.projectkorra.ProjectKorra.earthbending.EarthColumn;
|
||||||
|
import com.projectkorra.ProjectKorra.earthbending.EarthGrab;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthWall;
|
import com.projectkorra.ProjectKorra.earthbending.EarthWall;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.Shockwave;
|
import com.projectkorra.ProjectKorra.earthbending.Shockwave;
|
||||||
|
@ -248,6 +249,9 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("Shockwave")) {
|
if (abil.equalsIgnoreCase("Shockwave")) {
|
||||||
new Shockwave(player);
|
new Shockwave(player);
|
||||||
}
|
}
|
||||||
|
if (abil.equalsIgnoreCase("EarthGrab")) {
|
||||||
|
EarthGrab.EarthGrabSelf(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Methods.isFireAbility(abil)) {
|
if (Methods.isFireAbility(abil)) {
|
||||||
|
@ -501,6 +505,10 @@ public class PKListener implements Listener {
|
||||||
if (abil.equalsIgnoreCase("EarthArmor")) {
|
if (abil.equalsIgnoreCase("EarthArmor")) {
|
||||||
new EarthArmor(player);
|
new EarthArmor(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abil.equalsIgnoreCase("EarthGrab")) {
|
||||||
|
new EarthGrab(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Methods.isFireAbility(abil)) {
|
if (Methods.isFireAbility(abil)) {
|
||||||
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
|
if (Methods.isWeapon(player.getItemInHand().getType()) && !plugin.getConfig().getBoolean("Properties.Fire.CanBendWithWeapons")) {
|
||||||
|
|
149
src/com/projectkorra/ProjectKorra/earthbending/EarthGrab.java
Normal file
149
src/com/projectkorra/ProjectKorra/earthbending/EarthGrab.java
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
package com.projectkorra.ProjectKorra.earthbending;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import com.projectkorra.ProjectKorra.Methods;
|
||||||
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
|
|
||||||
|
public class EarthGrab {
|
||||||
|
|
||||||
|
private static double range = ProjectKorra.plugin.getConfig().getDouble("Abilities.Earth.EarthGrab.Range");
|
||||||
|
public static Map<String, Long> cooldowns = new HashMap<String, Long>();
|
||||||
|
|
||||||
|
public EarthGrab(Player player) {
|
||||||
|
// Methods.verbose("initiating");
|
||||||
|
if (cooldowns.containsKey(player.getName())) {
|
||||||
|
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location origin = player.getEyeLocation();
|
||||||
|
Vector direction = origin.getDirection();
|
||||||
|
double lowestdistance = range + 1;
|
||||||
|
Entity closestentity = null;
|
||||||
|
for (Entity entity : Methods.getEntitiesAroundPoint(origin, range)) {
|
||||||
|
if (Methods.getDistanceFromLine(direction, origin,
|
||||||
|
entity.getLocation()) <= 3
|
||||||
|
&& (entity instanceof LivingEntity)
|
||||||
|
&& (entity.getEntityId() != player.getEntityId())) {
|
||||||
|
double distance = origin.distance(entity.getLocation());
|
||||||
|
if (distance < lowestdistance) {
|
||||||
|
closestentity = entity;
|
||||||
|
lowestdistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (closestentity != null) {
|
||||||
|
// Methods.verbose("grabbing");
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
Location location = closestentity.getLocation();
|
||||||
|
Location loc1 = location.clone();
|
||||||
|
Location loc2 = location.clone();
|
||||||
|
Location testloc, testloc2;
|
||||||
|
double factor = 3;
|
||||||
|
double factor2 = 4;
|
||||||
|
int height1 = 3;
|
||||||
|
int height2 = 2;
|
||||||
|
for (double angle = 0; angle <= 360; angle += 20) {
|
||||||
|
testloc = loc1.clone().add(
|
||||||
|
factor * Math.cos(Math.toRadians(angle)), 1,
|
||||||
|
factor * Math.sin(Math.toRadians(angle)));
|
||||||
|
testloc2 = loc2.clone().add(
|
||||||
|
factor2 * Math.cos(Math.toRadians(angle)), 1,
|
||||||
|
factor2 * Math.sin(Math.toRadians(angle)));
|
||||||
|
for (int y = 0; y < EarthColumn.standardheight - height1; y++) {
|
||||||
|
testloc = testloc.clone().add(0, -1, 0);
|
||||||
|
if (Methods.isEarthbendable(player, testloc.getBlock())) {
|
||||||
|
if (!blocks.contains(testloc.getBlock())) {
|
||||||
|
new EarthColumn(player, testloc, height1 + y - 1);
|
||||||
|
}
|
||||||
|
blocks.add(testloc.getBlock());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y = 0; y < EarthColumn.standardheight - height2; y++) {
|
||||||
|
testloc2 = testloc2.clone().add(0, -1, 0);
|
||||||
|
if (Methods.isEarthbendable(player, testloc2.getBlock())) {
|
||||||
|
if (!blocks.contains(testloc2.getBlock())) {
|
||||||
|
new EarthColumn(player, testloc2, height2 + y - 1);
|
||||||
|
}
|
||||||
|
blocks.add(testloc2.getBlock());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!blocks.isEmpty())
|
||||||
|
cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void EarthGrabSelf(Player player) {
|
||||||
|
if (cooldowns.containsKey(player.getName())) {
|
||||||
|
if (cooldowns.get(player.getName()) + ProjectKorra.plugin.getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
cooldowns.remove(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity closestentity = player;
|
||||||
|
|
||||||
|
if (closestentity != null) {
|
||||||
|
// Methods.verbose("grabbing");
|
||||||
|
ArrayList<Block> blocks = new ArrayList<Block>();
|
||||||
|
Location location = closestentity.getLocation();
|
||||||
|
Location loc1 = location.clone();
|
||||||
|
Location loc2 = location.clone();
|
||||||
|
Location testloc, testloc2;
|
||||||
|
double factor = 3;
|
||||||
|
double factor2 = 4;
|
||||||
|
int height1 = 3;
|
||||||
|
int height2 = 2;
|
||||||
|
for (double angle = 0; angle <= 360; angle += 20) {
|
||||||
|
testloc = loc1.clone().add(
|
||||||
|
factor * Math.cos(Math.toRadians(angle)), 1,
|
||||||
|
factor * Math.sin(Math.toRadians(angle)));
|
||||||
|
testloc2 = loc2.clone().add(
|
||||||
|
factor2 * Math.cos(Math.toRadians(angle)), 1,
|
||||||
|
factor2 * Math.sin(Math.toRadians(angle)));
|
||||||
|
for (int y = 0; y < EarthColumn.standardheight - height1; y++) {
|
||||||
|
testloc = testloc.clone().add(0, -1, 0);
|
||||||
|
if (Methods.isEarthbendable(player, testloc.getBlock())) {
|
||||||
|
if (!blocks.contains(testloc.getBlock())) {
|
||||||
|
new EarthColumn(player, testloc, height1 + y - 1);
|
||||||
|
}
|
||||||
|
blocks.add(testloc.getBlock());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y = 0; y < EarthColumn.standardheight - height2; y++) {
|
||||||
|
testloc2 = testloc2.clone().add(0, -1, 0);
|
||||||
|
if (Methods.isEarthbendable(player, testloc2.getBlock())) {
|
||||||
|
if (!blocks.contains(testloc2.getBlock())) {
|
||||||
|
new EarthColumn(player, testloc2, height2 + y - 1);
|
||||||
|
}
|
||||||
|
blocks.add(testloc2.getBlock());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!blocks.isEmpty())
|
||||||
|
cooldowns.put(player.getName(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -185,6 +185,10 @@ Abilities:
|
||||||
Revert: true
|
Revert: true
|
||||||
Damage: 4
|
Damage: 4
|
||||||
Push: 0.3
|
Push: 0.3
|
||||||
|
EarthGrab:
|
||||||
|
Enabled: true
|
||||||
|
Description: "To use, simply left-click while targeting a creature within range. This ability will erect a circle of earth to trap the creature in."
|
||||||
|
Range: 15
|
||||||
RaiseEarth:
|
RaiseEarth:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it."
|
Description: "To use, simply left-click on an earthbendable block. A column of earth will shoot upwards from that location. Anything in the way of the column will be brought up with it, leaving talented benders the ability to trap brainless entities up there. Additionally, simply sneak (default shift) looking at an earthbendable block. A wall of earth will shoot upwards from that location. Anything in the way of the wall will be brought up with it."
|
||||||
|
|
Loading…
Reference in a new issue