mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Earthbending Methods
Just some methods for some of the Earthbending Abilities
This commit is contained in:
parent
b2f7e00083
commit
b45846be68
3 changed files with 251 additions and 13 deletions
15
.classpath
15
.classpath
|
@ -1,18 +1,9 @@
|
|||
<<<<<<< HEAD
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/LocalServer/BukkitForPlugins.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/Bending Plugins/TagAPI.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="C:/Users/Shawn/Documents/LocalServer/plugins/ProjectKorra/Abilities/RaiseEarth.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
=======
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre7"/>
|
||||
<classpathentry kind="lib" path="C:/Users/PhilipStephenson/Desktop/MineScape test server/craftbukkit-1.7.2-R0.3-20140131.210753-26.jar"/>
|
||||
<classpathentry kind="lib" path="C:/Users/PhilipStephenson/Downloads/TagAPI.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
>>>>>>> 44624cd18ebcbb8b5c2a56bf36e9d5c6a8974795
|
||||
|
|
116
src/com/projectkorra/ProjectKorra/Information.java
Normal file
116
src/com/projectkorra/ProjectKorra/Information.java
Normal file
|
@ -0,0 +1,116 @@
|
|||
package com.projectkorra.ProjectKorra;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class Information {
|
||||
|
||||
private Player player;
|
||||
private long time;
|
||||
private Block block;
|
||||
private Location location;
|
||||
private Material type;
|
||||
private int integer;
|
||||
private double value;
|
||||
private byte data;
|
||||
private String string;
|
||||
private BlockState state;
|
||||
|
||||
private static int ID = Integer.MIN_VALUE;
|
||||
private int id;
|
||||
|
||||
public Information() {
|
||||
id = ID++;
|
||||
if (ID >= Integer.MAX_VALUE) {
|
||||
ID = Integer.MIN_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setState(BlockState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public BlockState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setString(String string) {
|
||||
this.string = string;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public void setTime(long time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setType(Material type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setInteger(int integer) {
|
||||
this.integer = integer;
|
||||
}
|
||||
|
||||
public int getInteger() {
|
||||
return integer;
|
||||
}
|
||||
|
||||
public void setDouble(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public double getDouble() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setData(byte data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public byte getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
|
@ -9,6 +9,7 @@ import java.util.HashMap;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -30,6 +31,7 @@ import org.bukkit.util.Vector;
|
|||
import com.projectkorra.ProjectKorra.Ability.AbilityModule;
|
||||
import com.projectkorra.ProjectKorra.Ability.AbilityModuleManager;
|
||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||
import com.projectkorra.abilities.RaiseEarth.EarthColumn;
|
||||
|
||||
public class Methods {
|
||||
|
||||
|
@ -39,6 +41,10 @@ public class Methods {
|
|||
Methods.plugin = plugin;
|
||||
}
|
||||
|
||||
public static ConcurrentHashMap<Block, Information> movedearth = new ConcurrentHashMap<Block, Information>();
|
||||
public static ConcurrentHashMap<Integer, Information> tempair = new ConcurrentHashMap<Integer, Information>();
|
||||
public static ArrayList<Block> tempnophysics = new ArrayList<Block>();
|
||||
|
||||
public static boolean isBender(String player, Element element) {
|
||||
BendingPlayer bPlayer = getBendingPlayer(player);
|
||||
if (bPlayer.hasElement(element)) return true;
|
||||
|
@ -295,7 +301,7 @@ public class Methods {
|
|||
if (AbilityModuleManager.firebendingabilities.contains(ability)) return ChatColor.RED;
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
public static boolean isWater(Block block) {
|
||||
if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) return true;
|
||||
return false;
|
||||
|
@ -450,6 +456,42 @@ public class Methods {
|
|||
return 1;
|
||||
}
|
||||
|
||||
public static Block getEarthSourceBlock(Player player, double range) {
|
||||
Block testblock = player.getTargetBlock(getTransparentEarthbending(),
|
||||
(int) range);
|
||||
if (isEarthbendable(player, testblock))
|
||||
return testblock;
|
||||
Location location = player.getEyeLocation();
|
||||
Vector vector = location.getDirection().clone().normalize();
|
||||
for (double i = 0; i <= range; i++) {
|
||||
Block block = location.clone().add(vector.clone().multiply(i))
|
||||
.getBlock();
|
||||
// if (isRegionProtectedFromBuild(player, Abilities.RaiseEarth,
|
||||
// location))
|
||||
// continue;
|
||||
if (isEarthbendable(player, block)) {
|
||||
return block;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void removeRevertIndex(Block block) {
|
||||
if (movedearth.containsKey(block)) {
|
||||
Information info = movedearth.get(block);
|
||||
if (block.getType() == Material.SANDSTONE
|
||||
&& info.getType() == Material.SAND)
|
||||
block.setType(Material.SAND);
|
||||
if (isAbilityInstalled("RaiseEarth", "orion304")) {
|
||||
if (EarthColumn.blockInAllAffectedBlocks(block))
|
||||
EarthColumn.revertBlock(block);
|
||||
|
||||
EarthColumn.resetBlock(block);
|
||||
}
|
||||
movedearth.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
public static double waterbendingNightAugment(double value, World world) {
|
||||
if (isNight(world)) {
|
||||
return plugin.getConfig().getDouble("Properties.Water.NightFactor") * value;
|
||||
|
@ -474,6 +516,95 @@ public class Methods {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static Location getPointOnLine(Location origin, Location target,
|
||||
double distance) {
|
||||
return origin.clone().add(
|
||||
getDirection(origin, target).normalize().multiply(distance));
|
||||
|
||||
}
|
||||
|
||||
public static void breakBlock(Block block) {
|
||||
block.breakNaturally(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
public static void moveEarthBlock(Block source, Block target) {
|
||||
byte full = 0x0;
|
||||
Information info;
|
||||
if (movedearth.containsKey(source)) {
|
||||
// verbose("Moving something already moved.");
|
||||
info = movedearth.get(source);
|
||||
info.setTime(System.currentTimeMillis());
|
||||
movedearth.remove(source);
|
||||
movedearth.put(target, info);
|
||||
} else {
|
||||
// verbose("Moving something for the first time.");
|
||||
info = new Information();
|
||||
info.setBlock(source);
|
||||
// info.setType(source.getType());
|
||||
// info.setData(source.getData());
|
||||
info.setTime(System.currentTimeMillis());
|
||||
info.setState(source.getState());
|
||||
movedearth.put(target, info);
|
||||
}
|
||||
|
||||
if (isAdjacentToThreeOrMoreSources(source)) {
|
||||
source.setType(Material.WATER);
|
||||
source.setData(full);
|
||||
} else {
|
||||
source.setType(Material.AIR);
|
||||
}
|
||||
if (info.getState().getType() == Material.SAND) {
|
||||
target.setType(Material.SANDSTONE);
|
||||
} else {
|
||||
target.setType(info.getState().getType());
|
||||
target.setData(info.getState().getRawData());
|
||||
}
|
||||
}
|
||||
|
||||
public static void addTempAirBlock(Block block) {
|
||||
if (movedearth.containsKey(block)) {
|
||||
Information info = movedearth.get(block);
|
||||
block.setType(Material.AIR);
|
||||
info.setTime(System.currentTimeMillis());
|
||||
movedearth.remove(block);
|
||||
tempair.put(info.getID(), info);
|
||||
} else {
|
||||
Information info = new Information();
|
||||
info.setBlock(block);
|
||||
// info.setType(block.getType());
|
||||
// info.setData(block.getData());
|
||||
info.setState(block.getState());
|
||||
info.setTime(System.currentTimeMillis());
|
||||
block.setType(Material.AIR);
|
||||
tempair.put(info.getID(), info);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Vector getDirection(Location location, Location destination) {
|
||||
double x1, y1, z1;
|
||||
double x0, y0, z0;
|
||||
|
||||
x1 = destination.getX();
|
||||
y1 = destination.getY();
|
||||
z1 = destination.getZ();
|
||||
|
||||
x0 = location.getX();
|
||||
y0 = location.getY();
|
||||
z0 = location.getZ();
|
||||
|
||||
return new Vector(x1 - x0, y1 - y0, z1 - z0);
|
||||
|
||||
}
|
||||
|
||||
public static HashSet<Byte> getTransparentEarthbending() {
|
||||
HashSet<Byte> set = new HashSet<Byte>();
|
||||
for (int i : transparentToEarthbending) {
|
||||
set.add((byte) i);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
public static void damageEntity(Player player, Entity entity, double damage) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
((LivingEntity) entity).damage(damage, player);
|
||||
|
|
Loading…
Reference in a new issue