Fixed some errors with wall damage.

This commit is contained in:
Brendan Wilson 2015-02-03 21:22:30 -05:00
parent bc135c6f12
commit 2ff4484394
3 changed files with 9 additions and 8 deletions

View file

@ -3,9 +3,9 @@ package com.projectkorra.ProjectKorra.Objects;
import com.projectkorra.ProjectKorra.Methods; import com.projectkorra.ProjectKorra.Methods;
import com.projectkorra.ProjectKorra.ProjectKorra; import com.projectkorra.ProjectKorra.ProjectKorra;
import com.projectkorra.ProjectKorra.Utilities.HorizontalVelocityChangeEvent; import com.projectkorra.ProjectKorra.Utilities.HorizontalVelocityChangeEvent;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -20,11 +20,11 @@ public class HorizontalVelocityTracker
private long delay; private long delay;
private long fireTime; private long fireTime;
private Entity entity; private Entity entity;
private Entity instigator; private Player instigator;
private Vector lastVelocity; private Vector lastVelocity;
private Vector thisVelocity; private Vector thisVelocity;
public HorizontalVelocityTracker(Entity e, Entity instigator, long delay) public HorizontalVelocityTracker(Entity e, Player instigator, long delay)
{ {
entity = e; entity = e;
this.instigator = instigator; this.instigator = instigator;
@ -56,7 +56,7 @@ public class HorizontalVelocityTracker
{ {
for(Block b : Methods.getBlocksAroundPoint(entity.getLocation(), 2)) for(Block b : Methods.getBlocksAroundPoint(entity.getLocation(), 2))
{ {
if(b.getType() != Material.AIR) if(!Methods.isTransparentToEarthbending(instigator, b))
{ {
ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff)); ProjectKorra.plugin.getServer().getPluginManager().callEvent(new HorizontalVelocityChangeEvent(entity, instigator, lastVelocity, thisVelocity, diff));
remove(); remove();

View file

@ -70,7 +70,7 @@ public class PKListener implements Listener {
if(e.getEntity() instanceof LivingEntity) if(e.getEntity() instanceof LivingEntity)
{ {
((LivingEntity) e.getEntity()).damage(e.getDifference().length() * 2, e.getInstigator()); Methods.damageEntity(e.getInstigator(), e.getEntity(), e.getDifference().length() * 2);
} }
} }

View file

@ -1,6 +1,7 @@
package com.projectkorra.ProjectKorra.Utilities; package com.projectkorra.ProjectKorra.Utilities;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -16,12 +17,12 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
private boolean isCancelled; private boolean isCancelled;
private Entity entity; private Entity entity;
private Entity instigator; private Player instigator;
private Vector from; private Vector from;
private Vector to; private Vector to;
private Vector difference; private Vector difference;
public HorizontalVelocityChangeEvent(Entity entity, Entity instigator, Vector from, Vector to, Vector difference) public HorizontalVelocityChangeEvent(Entity entity, Player instigator, Vector from, Vector to, Vector difference)
{ {
this.entity = entity; this.entity = entity;
this.instigator = instigator; this.instigator = instigator;
@ -35,7 +36,7 @@ public class HorizontalVelocityChangeEvent extends Event implements Cancellable
return entity; return entity;
} }
public Entity getInstigator() public Player getInstigator()
{ {
return instigator; return instigator;
} }