Fix spleef breaking blocks in the lobby
This commit is contained in:
parent
6731b5f3ab
commit
5985d5ef99
@ -1,26 +1,22 @@
|
|||||||
package nautilus.game.arcade.game.games.spleef;
|
package nautilus.game.arcade.game.games.spleef;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
|
|
||||||
import nautilus.game.arcade.game.games.spleef.kits.*;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftArrow;
|
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Snowball;
|
import org.bukkit.entity.Snowball;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
|
|
||||||
import mineplex.core.common.util.F;
|
import mineplex.core.common.util.F;
|
||||||
import mineplex.core.common.util.UtilBlock;
|
import mineplex.core.common.util.UtilBlock;
|
||||||
|
import mineplex.core.common.util.UtilEnt;
|
||||||
import mineplex.core.common.util.UtilInv;
|
import mineplex.core.common.util.UtilInv;
|
||||||
import mineplex.core.common.util.UtilMath;
|
import mineplex.core.common.util.UtilMath;
|
||||||
import mineplex.core.common.util.UtilPlayer;
|
import mineplex.core.common.util.UtilPlayer;
|
||||||
@ -28,16 +24,18 @@ import mineplex.core.itemstack.ItemStackFactory;
|
|||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.core.updater.UpdateType;
|
import mineplex.core.updater.UpdateType;
|
||||||
import mineplex.core.updater.event.UpdateEvent;
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
import nautilus.game.arcade.ArcadeManager;
|
import nautilus.game.arcade.ArcadeManager;
|
||||||
import nautilus.game.arcade.GameType;
|
import nautilus.game.arcade.GameType;
|
||||||
import nautilus.game.arcade.game.SoloGame;
|
import nautilus.game.arcade.game.SoloGame;
|
||||||
|
import nautilus.game.arcade.game.games.spleef.kits.KitArcher;
|
||||||
|
import nautilus.game.arcade.game.games.spleef.kits.KitBrawler;
|
||||||
|
import nautilus.game.arcade.game.games.spleef.kits.KitSnowballer;
|
||||||
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
import nautilus.game.arcade.game.modules.compass.CompassModule;
|
||||||
import nautilus.game.arcade.kit.Kit;
|
import nautilus.game.arcade.kit.Kit;
|
||||||
import nautilus.game.arcade.managers.chat.ChatStatData;
|
import nautilus.game.arcade.managers.chat.ChatStatData;
|
||||||
import nautilus.game.arcade.stats.SpleefBlockDestroyStatTracker;
|
import nautilus.game.arcade.stats.SpleefBlockDestroyStatTracker;
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.EntityArrow;
|
|
||||||
|
|
||||||
public class Spleef extends SoloGame
|
public class Spleef extends SoloGame
|
||||||
{
|
{
|
||||||
public Spleef(ArcadeManager manager)
|
public Spleef(ArcadeManager manager)
|
||||||
@ -84,11 +82,10 @@ public class Spleef extends SoloGame
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void SnowballDamage(ProjectileHitEvent event)
|
public void SnowballDamage(ProjectileHitEvent event)
|
||||||
{
|
{
|
||||||
if (!IsLive())
|
if (!IsLive() || !(event.getEntity() instanceof Snowball))
|
||||||
return;
|
{
|
||||||
|
|
||||||
if (!(event.getEntity() instanceof Snowball))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Snowball ball = (Snowball) event.getEntity();
|
Snowball ball = (Snowball) event.getEntity();
|
||||||
|
|
||||||
@ -129,8 +126,10 @@ public class Spleef extends SoloGame
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void ArrowDamage(ProjectileHitEvent event)
|
public void ArrowDamage(ProjectileHitEvent event)
|
||||||
{
|
{
|
||||||
if (!(event.getEntity() instanceof Arrow))
|
if (!IsLive() || !(event.getEntity() instanceof Arrow))
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final Arrow arrow = (Arrow) event.getEntity();
|
final Arrow arrow = (Arrow) event.getEntity();
|
||||||
final double velocity = arrow.getVelocity().length();
|
final double velocity = arrow.getVelocity().length();
|
||||||
@ -140,27 +139,9 @@ public class Spleef extends SoloGame
|
|||||||
|
|
||||||
final Player player = (Player) arrow.getShooter();
|
final Player player = (Player) arrow.getShooter();
|
||||||
|
|
||||||
Manager.getPlugin().getServer().getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable()
|
Manager.runSyncLater(() ->
|
||||||
{
|
{
|
||||||
public void run()
|
Block block = UtilEnt.getHitBlock(arrow);
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
EntityArrow entityArrow = ((CraftArrow)arrow).getHandle();
|
|
||||||
|
|
||||||
Field fieldX = EntityArrow.class.getDeclaredField("d");
|
|
||||||
Field fieldY = EntityArrow.class.getDeclaredField("e");
|
|
||||||
Field fieldZ = EntityArrow.class.getDeclaredField("f");
|
|
||||||
|
|
||||||
fieldX.setAccessible(true);
|
|
||||||
fieldY.setAccessible(true);
|
|
||||||
fieldZ.setAccessible(true);
|
|
||||||
|
|
||||||
int x = fieldX.getInt(entityArrow);
|
|
||||||
int y = fieldY.getInt(entityArrow);
|
|
||||||
int z = fieldZ.getInt(entityArrow);
|
|
||||||
|
|
||||||
Block block = arrow.getWorld().getBlockAt(x, y, z);
|
|
||||||
|
|
||||||
double radius = 0.5 + velocity / 1.6d;
|
double radius = 0.5 + velocity / 1.6d;
|
||||||
|
|
||||||
@ -172,12 +153,6 @@ public class Spleef extends SoloGame
|
|||||||
}
|
}
|
||||||
|
|
||||||
arrow.remove();
|
arrow.remove();
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user