/src/com/dthielke/nocreep/NoCreep.java
https://bitbucket.org/DThielke/nocreep · Java · 43 lines · 36 code · 7 blank · 0 comment · 4 complexity · 9ba308690de628e4461fee7a1e334116 MD5 · raw file
- package com.dthielke.nocreep;
-
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.Creeper;
- import org.bukkit.entity.Entity;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.entity.EntityExplodeEvent;
- import org.bukkit.plugin.java.JavaPlugin;
-
- public class NoCreep extends JavaPlugin
- {
- private static final Logger logger = Logger.getLogger("Minecraft");
-
- public void onDisable() {
- logger.info("NoCreep disabled");
- }
-
- public void onEnable() {
- logger.info("NoCreep enabled");
-
- Bukkit.getServer().getPluginManager().registerEvents(new Listener() {
- @EventHandler(ignoreCancelled = true)
- public void onEntityExplode(EntityExplodeEvent event) {
- Entity entity = event.getEntity();
- if (entity == null) {
- return;
- }
-
- Location location = entity.getLocation();
- World world = entity.getWorld();
-
- if (((entity instanceof Creeper)) && (location.getY() >= world.getSeaLevel() - 5)) {
- event.setCancelled(true);
- world.createExplosion(location, 0.0F, false);
- }
- }
- }, this);
- }
- }