mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Merge branch 'master' of https://github.com/ProjectKorra/ProjectKorra.git
This commit is contained in:
commit
50f0915137
11 changed files with 147 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
||||||
package com.projectkorra.ProjectKorra.Ability;
|
package com.projectkorra.ProjectKorra.Ability;
|
||||||
|
|
||||||
import Utilities.AbilityLoadable;
|
import com.projectkorra.ProjectKorra.Utilities.AbilityLoadable;
|
||||||
|
|
||||||
public class AbilityModule extends AbilityLoadable implements Cloneable {
|
public class AbilityModule extends AbilityLoadable implements Cloneable {
|
||||||
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ import java.util.List;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.Element;
|
import com.projectkorra.ProjectKorra.Element;
|
||||||
import com.projectkorra.ProjectKorra.ProjectKorra;
|
import com.projectkorra.ProjectKorra.ProjectKorra;
|
||||||
|
import com.projectkorra.ProjectKorra.Utilities.AbilityLoader;
|
||||||
|
|
||||||
import Utilities.AbilityLoader;
|
|
||||||
|
|
||||||
public class AbilityModuleManager {
|
public class AbilityModuleManager {
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.bukkit.WorldType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.airbending.AirPassive;
|
import com.projectkorra.ProjectKorra.airbending.AirPassive;
|
||||||
import com.projectkorra.ProjectKorra.airbending.chiblocking.ChiPassive;
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
import com.projectkorra.ProjectKorra.firebending.FirePassive;
|
import com.projectkorra.ProjectKorra.firebending.FirePassive;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.Plantbending;
|
import com.projectkorra.ProjectKorra.waterbending.Plantbending;
|
||||||
|
|
|
@ -378,6 +378,34 @@ public class Methods {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Vector rotateVectorAroundVector(Vector axis, Vector rotator,
|
||||||
|
double degrees) {
|
||||||
|
double angle = Math.toRadians(degrees);
|
||||||
|
Vector rotation = axis.clone();
|
||||||
|
Vector rotate = rotator.clone();
|
||||||
|
rotation = rotation.normalize();
|
||||||
|
|
||||||
|
Vector thirdaxis = rotation.crossProduct(rotate).normalize()
|
||||||
|
.multiply(rotate.length());
|
||||||
|
|
||||||
|
return rotate.multiply(Math.cos(angle)).add(
|
||||||
|
thirdaxis.multiply(Math.sin(angle)));
|
||||||
|
|
||||||
|
// return new Vector(x, z, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vector getOrthogonalVector(Vector axis, double degrees,
|
||||||
|
double length) {
|
||||||
|
|
||||||
|
Vector ortho = new Vector(axis.getY(), -axis.getX(), 0);
|
||||||
|
ortho = ortho.normalize();
|
||||||
|
ortho = ortho.multiply(length);
|
||||||
|
|
||||||
|
return rotateVectorAroundVector(axis, ortho, degrees);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isWeapon(Material mat) {
|
public static boolean isWeapon(Material mat) {
|
||||||
if (mat == null) return false;
|
if (mat == null) return false;
|
||||||
if (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE
|
if (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE
|
||||||
|
|
|
@ -1,17 +1,25 @@
|
||||||
package com.projectkorra.ProjectKorra;
|
package com.projectkorra.ProjectKorra;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockFadeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import com.projectkorra.ProjectKorra.airbending.chiblocking.ChiPassive;
|
import com.projectkorra.ProjectKorra.chiblocking.ChiPassive;
|
||||||
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
import com.projectkorra.ProjectKorra.earthbending.EarthPassive;
|
||||||
|
import com.projectkorra.ProjectKorra.firebending.Enflamed;
|
||||||
|
import com.projectkorra.ProjectKorra.firebending.FireStream;
|
||||||
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
import com.projectkorra.ProjectKorra.waterbending.WaterPassive;
|
||||||
|
|
||||||
public class PKListener implements Listener {
|
public class PKListener implements Listener {
|
||||||
|
@ -33,6 +41,38 @@ public class PKListener implements Listener {
|
||||||
BendingPlayer.players.remove(e.getPlayer().getName());
|
BendingPlayer.players.remove(e.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
public void onEntityCombust(EntityCombustEvent event) {
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
Block block = entity.getLocation().getBlock();
|
||||||
|
if (FireStream.ignitedblocks.containsKey(block) && entity instanceof LivingEntity) {
|
||||||
|
new Enflamed(entity, FireStream.ignitedblocks.get(block));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
public void onEntityDamageEvent(EntityDamageEvent event) {
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (event.getCause() == DamageCause.FIRE && FireStream.ignitedblocks.containsKey(entity.getLocation().getBlock())) {
|
||||||
|
new Enflamed(entity, FireStream.ignitedblocks.get(entity.getLocation().getBlock()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Enflamed.isEnflamed(entity) && event.getCause() == DamageCause.FIRE_TICK) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
Enflamed.dealFlameDamage(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
public void onBlockMeltEvent(BlockFadeEvent event) {
|
||||||
|
Block block = event.getBlock();
|
||||||
|
if (block.getType() == Material.FIRE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (FireStream.ignitedblocks.containsKey(block)) {
|
||||||
|
FireStream.remove(block);
|
||||||
|
}
|
||||||
|
}
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDamageByPlayer(EntityDamageByEntityEvent e) {
|
public void onPlayerDamageByPlayer(EntityDamageByEntityEvent e) {
|
||||||
Entity en = e.getEntity();
|
Entity en = e.getEntity();
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package Utilities;
|
package com.projectkorra.ProjectKorra.Utilities;
|
||||||
|
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package Utilities;
|
package com.projectkorra.ProjectKorra.Utilities;
|
||||||
|
|
||||||
public class AbilityLoadable implements Cloneable {
|
public class AbilityLoadable implements Cloneable {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package Utilities;
|
package com.projectkorra.ProjectKorra.Utilities;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -17,8 +17,9 @@ import java.util.logging.Logger;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import Utilities.AbilityLoadable.LoadResult;
|
import com.projectkorra.ProjectKorra.Utilities.AbilityLoadable.LoadResult;
|
||||||
import Utilities.AbilityLoadable.LoadResult.Result;
|
import com.projectkorra.ProjectKorra.Utilities.AbilityLoadable.LoadResult.Result;
|
||||||
|
|
||||||
|
|
||||||
public class AbilityLoader <T extends AbilityLoadable> implements Listener {
|
public class AbilityLoader <T extends AbilityLoadable> implements Listener {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package Utilities;
|
package com.projectkorra.ProjectKorra.Utilities;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
|
@ -1,4 +1,4 @@
|
||||||
package com.projectkorra.ProjectKorra.airbending.chiblocking;
|
package com.projectkorra.ProjectKorra.chiblocking;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
67
src/com/projectkorra/ProjectKorra/firebending/Enflamed.java
Normal file
67
src/com/projectkorra/ProjectKorra/firebending/Enflamed.java
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
package com.projectkorra.ProjectKorra.firebending;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Enflamed {
|
||||||
|
|
||||||
|
private static ConcurrentHashMap<Entity, Player> instances = new ConcurrentHashMap<Entity, Player>();
|
||||||
|
private static ConcurrentHashMap<Entity, Long> times = new ConcurrentHashMap<Entity, Long>();
|
||||||
|
|
||||||
|
private static final int damage = 1;
|
||||||
|
private static final int max = 90;
|
||||||
|
private static final long buffer = 30;
|
||||||
|
|
||||||
|
public Enflamed(Entity entity, Player source) {
|
||||||
|
if (entity.getEntityId() == source.getEntityId())
|
||||||
|
return;
|
||||||
|
if (instances.containsKey(entity)) {
|
||||||
|
instances.replace(entity, source);
|
||||||
|
} else {
|
||||||
|
instances.put(entity, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isEnflamed(Entity entity) {
|
||||||
|
// return false;
|
||||||
|
if (instances.containsKey(entity)) {
|
||||||
|
if (times.containsKey(entity)) {
|
||||||
|
long time = times.get(entity);
|
||||||
|
if (System.currentTimeMillis() < time + buffer) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
times.put(entity, System.currentTimeMillis());
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void dealFlameDamage(Entity entity) {
|
||||||
|
if (instances.containsKey(entity) && entity instanceof LivingEntity) {
|
||||||
|
// if (entity instanceof Player) {
|
||||||
|
// if (!Extinguish.canBurn((Player) entity)) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
LivingEntity Lentity = (LivingEntity) entity;
|
||||||
|
Player source = instances.get(entity);
|
||||||
|
Lentity.damage(damage, source);
|
||||||
|
if (entity.getFireTicks() > max)
|
||||||
|
entity.setFireTicks(max);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void handleFlames() {
|
||||||
|
for (Entity entity : instances.keySet()) {
|
||||||
|
if (entity.getFireTicks() <= 0) {
|
||||||
|
instances.remove(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue