changes to scepter, NPE fix
This commit is contained in:
parent
d79107eaaa
commit
e88736c1aa
@ -13,7 +13,10 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class UtilServer
|
||||
{
|
||||
@ -91,7 +94,12 @@ public class UtilServer
|
||||
|
||||
public static void registerEvents(Listener listener)
|
||||
{
|
||||
getPluginManager().registerEvents(listener, getPluginManager().getPlugins()[0]);
|
||||
getPluginManager().registerEvents(listener, getPlugin());
|
||||
}
|
||||
|
||||
public static Plugin getPlugin()
|
||||
{
|
||||
return getPluginManager().getPlugins()[0];
|
||||
}
|
||||
|
||||
public static PluginManager getPluginManager()
|
||||
@ -103,4 +111,9 @@ public class UtilServer
|
||||
{
|
||||
getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
public static void repeat(BukkitRunnable runnable, long time)
|
||||
{
|
||||
runnable.runTaskTimer(getPlugin(), time, time);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.clans.nether;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@ -77,6 +78,9 @@ public class Portal
|
||||
}
|
||||
}
|
||||
|
||||
_fromBlocks = new ArrayList<>();
|
||||
_toBlocks = new ArrayList<>();
|
||||
|
||||
_fromBlocks.addAll(_fromObsidianBlocks);
|
||||
_fromBlocks.addAll(_fromPortalBlocks);
|
||||
_toBlocks.addAll(_toObsidianBlocks);
|
||||
|
@ -61,21 +61,21 @@ public class ChitauriScepter extends LegendaryItem
|
||||
|
||||
private void fire(final Player player)
|
||||
{
|
||||
final Location missileLocation = player.getEyeLocation();
|
||||
final Location shotFrom = missileLocation.clone();
|
||||
final Vector direction = missileLocation.getDirection().normalize().multiply(0.3);
|
||||
final int maxRange = 40;
|
||||
final int maxDings = maxRange * 3;
|
||||
final Location projectile = player.getEyeLocation();
|
||||
final Location origin = player.getEyeLocation();
|
||||
final Vector direction = player.getEyeLocation().getDirection().normalize().multiply(0.25);
|
||||
final int maxRange = 50;
|
||||
final int maxDings = maxRange * 4;
|
||||
final int damage = 6;
|
||||
|
||||
new BukkitRunnable()
|
||||
|
||||
UtilServer.repeat(new BukkitRunnable()
|
||||
{
|
||||
private int dingsDone;
|
||||
private Location previousLocation = missileLocation;
|
||||
private Location previousLocation = projectile;
|
||||
|
||||
private void burst()
|
||||
{
|
||||
for (Entity cur : missileLocation.getWorld().getEntities())
|
||||
for (Entity cur : projectile.getWorld().getEntities())
|
||||
{
|
||||
if (cur == player || !(cur instanceof LivingEntity) || (cur instanceof Player && UtilPlayer.isSpectator(cur)))
|
||||
continue;
|
||||
@ -85,13 +85,13 @@ public class ChitauriScepter extends LegendaryItem
|
||||
Location eLoc = entity.getLocation();
|
||||
|
||||
// If they are less than 0.5 blocks away
|
||||
if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7)
|
||||
if (eLoc.clone().add(0, projectile.getY() - eLoc.getY(), 0).distance(projectile) <= 0.7)
|
||||
{
|
||||
// If it is in their body height
|
||||
if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - missileLocation.getY()) <= entity
|
||||
if (Math.abs((eLoc.getY() + (entity.getEyeHeight() / 1.5)) - projectile.getY()) <= entity
|
||||
.getEyeHeight() / 2)
|
||||
{
|
||||
if (entity != player && (!(entity instanceof Player)))
|
||||
if (entity != player)
|
||||
{
|
||||
ClansManager.getInstance().getDamageManager().NewDamageEvent(entity, player, null, DamageCause.CUSTOM, damage, true,
|
||||
true, false, getDisplayName(), getDisplayName());
|
||||
@ -103,9 +103,9 @@ public class ChitauriScepter extends LegendaryItem
|
||||
}
|
||||
}
|
||||
|
||||
playParticle(missileLocation, previousLocation);
|
||||
playParticle(projectile, previousLocation);
|
||||
|
||||
missileLocation.getWorld().playSound(missileLocation, Sound.BAT_TAKEOFF, 1.2F, 1);
|
||||
projectile.getWorld().playSound(projectile, Sound.BAT_TAKEOFF, 1.2F, 1);
|
||||
cancel();
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ public class ChitauriScepter extends LegendaryItem
|
||||
|
||||
for (Player closest : UtilServer.getPlayers())
|
||||
{
|
||||
if (!closest.getWorld().equals(missileLocation.getWorld()))
|
||||
if (!closest.getWorld().equals(projectile.getWorld()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -133,13 +133,13 @@ public class ChitauriScepter extends LegendaryItem
|
||||
|
||||
if (closest != player)
|
||||
{
|
||||
double dist1 = loc.distance(shotFrom);
|
||||
double dist1 = loc.distance(origin);
|
||||
if (dist1 < maxRange + 10)
|
||||
{
|
||||
double dist2 = missileLocation.distance(loc);
|
||||
double dist2 = projectile.distance(loc);
|
||||
if (closestPlayer == null || dist2 < dist)
|
||||
{
|
||||
double dist3 = missileLocation.clone().add(direction).distance(loc);
|
||||
double dist3 = projectile.clone().add(direction).distance(loc);
|
||||
|
||||
if (dist3 < dist2)
|
||||
{
|
||||
@ -150,20 +150,19 @@ public class ChitauriScepter extends LegendaryItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (closestPlayer != null)
|
||||
{
|
||||
Vector newDirection = closestPlayer.getLocation().add(0, 1, 0).toVector()
|
||||
.subtract(missileLocation.toVector());
|
||||
.subtract(projectile.toVector());
|
||||
|
||||
direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.3);
|
||||
direction.add(newDirection.normalize().multiply(0.01)).normalize().multiply(0.25);
|
||||
}
|
||||
|
||||
missileLocation.add(direction);
|
||||
projectile.add(direction);
|
||||
|
||||
for (Entity cur : missileLocation.getWorld().getEntities())
|
||||
for (Entity cur : projectile.getWorld().getEntities())
|
||||
{
|
||||
|
||||
if (cur == player || !(cur instanceof LivingEntity)
|
||||
|| (cur instanceof Player && UtilPlayer.isSpectator(cur)))
|
||||
continue;
|
||||
@ -173,11 +172,10 @@ public class ChitauriScepter extends LegendaryItem
|
||||
Location eLoc = ent.getLocation();
|
||||
|
||||
// If they are less than 0.5 blocks away
|
||||
if (eLoc.clone().add(0, missileLocation.getY() - eLoc.getY(), 0).distance(missileLocation) <= 0.7)
|
||||
if (eLoc.clone().add(0, projectile.getY() - eLoc.getY(), 0).distance(projectile) <= 0.7)
|
||||
{
|
||||
// If it is in their body height
|
||||
if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - missileLocation.getY()) <= ent
|
||||
.getEyeHeight() / 2)
|
||||
if (Math.abs((eLoc.getY() + (ent.getEyeHeight() / 1.5)) - projectile.getY()) <= ent.getEyeHeight() / 2)
|
||||
{
|
||||
burst();
|
||||
return;
|
||||
@ -185,22 +183,22 @@ public class ChitauriScepter extends LegendaryItem
|
||||
}
|
||||
}
|
||||
|
||||
if (UtilBlock.solid(missileLocation.getBlock()))
|
||||
if (UtilBlock.solid(projectile.getBlock()))
|
||||
{
|
||||
burst();
|
||||
return;
|
||||
}
|
||||
|
||||
playParticle(missileLocation, previousLocation);
|
||||
previousLocation = missileLocation.clone();
|
||||
playParticle(projectile, previousLocation);
|
||||
previousLocation = projectile.clone();
|
||||
|
||||
dingsDone++;
|
||||
}
|
||||
|
||||
missileLocation.getWorld().playSound(missileLocation, Sound.ORB_PICKUP, 0.7F, 0);
|
||||
projectile.getWorld().playSound(projectile, Sound.ORB_PICKUP, 0.7F, 0);
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(ClansManager.getInstance().getPlugin(), 0, 0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private void playParticle(Location start, Location end)
|
||||
|
Loading…
Reference in New Issue
Block a user