Inital Release

main v1.00
Nichole Mattera 14 years ago
commit 694fb28c21
  1. 58
      src/net/mcbat/LightningEvent/LightningEvent.java
  2. 36
      src/net/mcbat/LightningEvent/Listeners/LightningEventEntityListener.java
  3. 74
      src/net/mcbat/LightningEvent/Listeners/LightningEventPlayerListener.java
  4. 41
      src/net/mcbat/LightningEvent/Listeners/LightningEventServerListener.java
  5. 6
      src/plugin.yml

@ -0,0 +1,58 @@
package net.mcbat.LightningEvent;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import com.nijiko.permissions.PermissionHandler;
import com.nijikokun.bukkit.Permissions.Permissions;
import net.mcbat.LightningEvent.Listeners.LightningEventEntityListener;
import net.mcbat.LightningEvent.Listeners.LightningEventPlayerListener;
import net.mcbat.LightningEvent.Listeners.LightningEventServerListener;
public class LightningEvent extends JavaPlugin {
private final Logger _logger;
public PermissionHandler Permissions = null;
public LightningEvent() {
_logger = Logger.getLogger("Minecraft");
}
@Override
public void onEnable() {
_logger.info("[LightningEvent] v"+this.getDescription().getVersion()+" (Helium) loaded.");
_logger.info("[LightningEvent] Developed by: [Mattera, Steven (IchigoKyger)]");
if (Permissions == null) {
Plugin PermissionsPlugin = this.getServer().getPluginManager().getPlugin("Permissions");
if (PermissionsPlugin != null) {
if (PermissionsPlugin.isEnabled()) {
Permissions = ((Permissions) PermissionsPlugin).getHandler();
_logger.info("[LightningEvent] hooked into Permissions/GroupManager.");
}
}
}
(new LightningEventEntityListener(this)).registerEvents();
(new LightningEventPlayerListener(this)).registerEvents();
(new LightningEventServerListener(this)).registerEvents();
}
@Override
public void onDisable() {
_logger.info("[LightningEvent] Plugin disabled.");
}
public Logger getMinecraftLogger() {
return _logger;
}
public void castLightningAtLocation(Location location) {
location.getWorld().strikeLightningEffect(location);
}
}

@ -0,0 +1,36 @@
package net.mcbat.LightningEvent.Listeners;
import net.mcbat.LightningEvent.LightningEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.plugin.PluginManager;
public class LightningEventEntityListener extends EntityListener {
private final LightningEvent _plugin;
public LightningEventEntityListener(LightningEvent plugin) {
_plugin = plugin;
}
public void registerEvents() {
PluginManager pm = _plugin.getServer().getPluginManager();
pm.registerEvent(Event.Type.ENTITY_DEATH, this, Priority.Monitor, _plugin);
}
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player)event.getEntity();
if (_plugin.Permissions != null && _plugin.Permissions.has(player, "LightningEvent.onDeath"))
_plugin.castLightningAtLocation(player.getLocation());
_plugin.getMinecraftLogger().info("OnDeath: "+player.getLocation().toString());
}
}
}

@ -0,0 +1,74 @@
package net.mcbat.LightningEvent.Listeners;
import net.mcbat.LightningEvent.LightningEvent;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBedLeaveEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.PluginManager;
public class LightningEventPlayerListener extends PlayerListener {
private final LightningEvent _plugin;
public LightningEventPlayerListener(LightningEvent plugin) {
_plugin = plugin;
}
public void registerEvents() {
PluginManager pm = _plugin.getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_BED_ENTER, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_BED_LEAVE, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_JOIN, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_QUIT, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_MOVE, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_TELEPORT, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLAYER_RESPAWN, this, Priority.Monitor, _plugin);
}
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onBedEnter"))
_plugin.castLightningAtLocation(event.getPlayer().getLocation());
}
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onBedLeave"))
_plugin.castLightningAtLocation(event.getPlayer().getLocation());
}
public void onPlayerJoin(PlayerJoinEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onJoin"))
_plugin.castLightningAtLocation(event.getPlayer().getLocation());
}
public void onPlayerQuit(PlayerQuitEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onQuit"))
_plugin.castLightningAtLocation(event.getPlayer().getLocation());
}
public void onPlayerMove(PlayerMoveEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onMove"))
_plugin.castLightningAtLocation(event.getPlayer().getLocation());
}
public void onPlayerTeleport(PlayerTeleportEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onTeleport.from"))
_plugin.castLightningAtLocation(event.getFrom());
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onTeleport.to"))
_plugin.castLightningAtLocation(event.getTo());
}
public void onPlayerRespawn(PlayerRespawnEvent event) {
if (_plugin.Permissions != null && _plugin.Permissions.has(event.getPlayer(), "LightningEvent.onRespawn"))
_plugin.castLightningAtLocation(event.getRespawnLocation());
_plugin.getMinecraftLogger().info("OnRespawn: "+event.getRespawnLocation().toString());
}
}

@ -0,0 +1,41 @@
package net.mcbat.LightningEvent.Listeners;
import net.mcbat.LightningEvent.LightningEvent;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.PluginManager;
import com.nijikokun.bukkit.Permissions.Permissions;
public class LightningEventServerListener extends ServerListener {
private final LightningEvent _plugin;
public LightningEventServerListener(LightningEvent plugin) {
_plugin = plugin;
}
public void registerEvents() {
PluginManager pm = _plugin.getServer().getPluginManager();
pm.registerEvent(Event.Type.PLUGIN_ENABLE, this, Priority.Monitor, _plugin);
pm.registerEvent(Event.Type.PLUGIN_DISABLE, this, Priority.Monitor, _plugin);
}
public void onPluginEnable(PluginEnableEvent event) {
if (_plugin.Permissions == null && event.getPlugin().getDescription().getName().equals("Permissions")) {
_plugin.Permissions = ((Permissions)event.getPlugin()).getHandler();
_plugin.getMinecraftLogger().info("[LightningEvent] hooked into Permissions/GroupManager.");
}
}
public void onPluginDisable(PluginDisableEvent event) {
if (_plugin.Permissions != null && event.getPlugin().getDescription().getName().equals("Permissions")) {
_plugin.Permissions = null;
_plugin.getMinecraftLogger().info("[LightningEvent] un-hooked from Permissions/GroupManager");
}
}
}

@ -0,0 +1,6 @@
name: LightningEvent
main: net.mcbat.LightningEvent.LightningEvent
version: 1.00
website: http://mc-bat.net
author: Steven Mattera
description: Simple plugin that casts lightning on events.
Loading…
Cancel
Save