You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
3.3 KiB
74 lines
3.3 KiB
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());
|
|
}
|
|
}
|
|
|