mirror of
https://github.com/TotalFreedomMC/TotalFreedomMod.git
synced 2024-06-25 23:40:35 +00:00
![Lemon](/assets/img/avatar_default.png)
1. Remove marco from dev 2. Add namehistory 3. Fix grammar issues 4. Actually use CoreProtect bridge to rollback players 5. Improve automatic wiper
222 lines
5.9 KiB
Java
222 lines
5.9 KiB
Java
package me.totalfreedom.totalfreedommod.blocking;
|
|
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
import org.bukkit.entity.Entity;
|
|
import org.bukkit.entity.EntityType;
|
|
import org.bukkit.entity.Projectile;
|
|
import org.bukkit.entity.Tameable;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.EventPriority;
|
|
import org.bukkit.event.block.BlockBurnEvent;
|
|
import org.bukkit.event.block.BlockFromToEvent;
|
|
import org.bukkit.event.block.BlockIgniteEvent;
|
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
import org.bukkit.event.block.LeavesDecayEvent;
|
|
import org.bukkit.event.entity.EntityCombustEvent;
|
|
import org.bukkit.event.entity.EntityDamageEvent;
|
|
import org.bukkit.event.entity.EntityDeathEvent;
|
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
import org.bukkit.event.entity.FireworkExplodeEvent;
|
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
|
|
|
public class EventBlocker extends FreedomService
|
|
{
|
|
|
|
public EventBlocker(TotalFreedomMod plugin)
|
|
{
|
|
super(plugin);
|
|
}
|
|
|
|
@Override
|
|
protected void onStart()
|
|
{
|
|
}
|
|
|
|
@Override
|
|
protected void onStop()
|
|
{
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onBlockBurn(BlockBurnEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onBlockIgnite(BlockIgniteEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onBlockFromTo(BlockFromToEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onEntityExplode(EntityExplodeEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
{
|
|
event.blockList().clear();
|
|
return;
|
|
}
|
|
|
|
event.setYield(0.0F);
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onExplosionPrime(ExplosionPrimeEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
return;
|
|
}
|
|
|
|
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onEntityCombust(EntityCombustEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onEntityDeath(EntityDeathEvent event)
|
|
{
|
|
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
|
{
|
|
event.setDroppedExp(0);
|
|
}
|
|
}
|
|
|
|
//deprecated (buggy)
|
|
|
|
/* @EventHandler(priority = EventPriority.HIGH)
|
|
public void onProjectileHit(ProjectileHitEvent event)
|
|
{
|
|
if (ConfigEntry.MAKE_ARROW_EXPLOSIVE.getBoolean())
|
|
{
|
|
Projectile entity = event.getEntity();
|
|
if (entity instanceof Projectile)
|
|
{
|
|
if (event.getEntityType() == EntityType.ARROW)
|
|
{
|
|
entity.getWorld().createExplosion(entity.getLocation(), 2F);
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void onEntityDamage(EntityDamageEvent event
|
|
)
|
|
{
|
|
switch (event.getCause())
|
|
{
|
|
case LAVA:
|
|
{
|
|
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
|
{
|
|
Entity entity = event.getEntity();
|
|
if (entity instanceof Tameable)
|
|
{
|
|
if (((Tameable) entity).isTamed())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.NORMAL)
|
|
public void onPlayerDropItem(PlayerDropItemEvent event
|
|
)
|
|
{
|
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.NORMAL)
|
|
public void onLeavesDecay(LeavesDecayEvent event
|
|
)
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void FireworkExplodeEvent(final FireworkExplodeEvent event
|
|
)
|
|
{
|
|
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void BlockPistonRetractEvent(final BlockPistonRetractEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void BlockPistonExtendEvent(final BlockPistonExtendEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
|
{
|
|
event.setCancelled(true);
|
|
}
|
|
}
|
|
|
|
@EventHandler(priority = EventPriority.HIGH)
|
|
public void BlockRedstoneEvent(final BlockRedstoneEvent event)
|
|
{
|
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
|
{
|
|
event.setNewCurrent(0);
|
|
}
|
|
}
|
|
|
|
}
|