World events
This commit is contained in:
parent
d5be0f5061
commit
b55902f853
@ -74,8 +74,6 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
public class GemHunters extends JavaPlugin
|
||||
{
|
||||
|
||||
private static final String WEB_CONFIG = "webServer";
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
|
@ -8,11 +8,13 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
@ReflectivelyCreateMiniPlugin
|
||||
public class WorldEventModule extends MiniPlugin
|
||||
{
|
||||
|
||||
|
@ -5,15 +5,21 @@ import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Giant;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.Managers;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -24,7 +30,8 @@ public class CustomGiant implements Listener
|
||||
{
|
||||
|
||||
private static final int GIANT_HEALTH = 100;
|
||||
private static final int DESTORY_BLOCK_RADIUS = 5;
|
||||
private static final int DESTORY_BLOCK_RADIUS = 7;
|
||||
private static final float DESTORY_FALLING_BLOCK_CHANCE = 0.05F;
|
||||
|
||||
private final Monster _giant;
|
||||
|
||||
@ -38,7 +45,8 @@ public class CustomGiant implements Listener
|
||||
_giant.setHealth(_giant.getMaxHealth());
|
||||
|
||||
UtilEnt.vegetate(_giant);
|
||||
|
||||
UtilEnt.setStepHeight(_giant, 2);
|
||||
|
||||
Managers.get(WorldEventModule.class).registerEvents(this);
|
||||
}
|
||||
|
||||
@ -52,10 +60,10 @@ public class CustomGiant implements Listener
|
||||
|
||||
if (_target == null)
|
||||
{
|
||||
_target = acquireTarget();
|
||||
_target = acquireTarget();
|
||||
}
|
||||
|
||||
UtilEnt.CreatureMoveFast(_giant, _target.getLocation(), 1.5F);
|
||||
UtilEnt.CreatureMove(_giant, _target.getLocation(), 0.5F);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -66,7 +74,19 @@ public class CustomGiant implements Listener
|
||||
return;
|
||||
}
|
||||
|
||||
_giant.getWorld().createExplosion(_giant.getLocation().add(0, 10, 0), DESTORY_BLOCK_RADIUS);
|
||||
for (Block block : UtilBlock.getInBoundingBox(_giant.getLocation().subtract(5, 0, 5), _giant.getLocation().add(5, 13, 5)))
|
||||
{
|
||||
if (Math.random() < DESTORY_FALLING_BLOCK_CHANCE)
|
||||
{
|
||||
FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
|
||||
|
||||
fallingBlock.setDropItem(false);
|
||||
fallingBlock.setHurtEntities(false);
|
||||
fallingBlock.setVelocity(new Vector(UtilMath.random(-1, 1), UtilMath.random(0.5, 1), UtilMath.random(-1, 1)));
|
||||
}
|
||||
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
Loading…
Reference in New Issue
Block a user