Update to new Bukkit Event system
Also remove leftover TNT exploit prevention code which I missed earlier
This commit is contained in:
parent
1dc5a0f226
commit
fb92fb7c68
@ -11,7 +11,6 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@ -109,43 +108,14 @@ public class P extends MPlugin
|
|||||||
{
|
{
|
||||||
Worldguard.init(this);
|
Worldguard.init(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player Events
|
// Register Event Handlers
|
||||||
this.registerEvent(Event.Type.PLAYER_CHAT, this.playerListener, Event.Priority.Highest);
|
getServer().getPluginManager().registerEvents(playerListener, this);
|
||||||
this.registerEvent(Event.Type.PLAYER_CHAT, this.chatEarlyListener, Event.Priority.Lowest);
|
getServer().getPluginManager().registerEvents(chatEarlyListener, this);
|
||||||
this.registerEvent(Event.Type.PLAYER_INTERACT, this.playerListener, Event.Priority.Normal);
|
getServer().getPluginManager().registerEvents(entityListener, this);
|
||||||
this.registerEvent(Event.Type.PLAYER_MOVE, this.playerListener, Event.Priority.Normal);
|
getServer().getPluginManager().registerEvents(blockListener, this);
|
||||||
this.registerEvent(Event.Type.PLAYER_JOIN, this.playerListener, Event.Priority.Normal);
|
getServer().getPluginManager().registerEvents(serverListener, this);
|
||||||
this.registerEvent(Event.Type.PLAYER_QUIT, this.playerListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PLAYER_RESPAWN, this.playerListener, Event.Priority.High);
|
|
||||||
this.registerEvent(Event.Type.PLAYER_BUCKET_EMPTY, this.playerListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PLAYER_BUCKET_FILL, this.playerListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PLAYER_KICK, this.playerListener, Event.Priority.Normal);
|
|
||||||
|
|
||||||
// Entity Events
|
|
||||||
this.registerEvent(Event.Type.ENDERMAN_PICKUP, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.ENDERMAN_PLACE, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.ENTITY_DEATH, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.ENTITY_DAMAGE, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.ENTITY_EXPLODE, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.CREATURE_SPAWN, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.ENTITY_TARGET, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PAINTING_BREAK, this.entityListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.PAINTING_PLACE, this.entityListener, Event.Priority.Normal);
|
|
||||||
|
|
||||||
// Block Events
|
|
||||||
this.registerEvent(Event.Type.BLOCK_BREAK, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_DAMAGE, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_PLACE, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_PISTON_EXTEND, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_PISTON_RETRACT, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_SPREAD, this.blockListener, Event.Priority.Normal);
|
|
||||||
this.registerEvent(Event.Type.BLOCK_BURN, this.blockListener, Event.Priority.Normal);
|
|
||||||
|
|
||||||
// Server Events
|
|
||||||
this.registerEvent(Event.Type.PLUGIN_ENABLE, this.serverListener, Event.Priority.Monitor);
|
|
||||||
this.registerEvent(Event.Type.PLUGIN_DISABLE, this.serverListener, Event.Priority.Monitor);
|
|
||||||
|
|
||||||
postEnable();
|
postEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,12 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockDamageEvent;
|
import org.bukkit.event.block.BlockDamageEvent;
|
||||||
import org.bukkit.event.block.BlockListener;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
@ -24,7 +26,7 @@ import com.massivecraft.factions.struct.FFlag;
|
|||||||
import com.massivecraft.factions.struct.FPerm;
|
import com.massivecraft.factions.struct.FPerm;
|
||||||
|
|
||||||
|
|
||||||
public class FactionsBlockListener extends BlockListener
|
public class FactionsBlockListener implements Listener
|
||||||
{
|
{
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsBlockListener(P p)
|
public FactionsBlockListener(P p)
|
||||||
@ -32,7 +34,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockSpread(BlockSpreadEvent event)
|
public void onBlockSpread(BlockSpreadEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -44,7 +46,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockBurn(BlockBurnEvent event)
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -78,7 +80,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
return FPerm.BUILD.has(me, loc, true);
|
return FPerm.BUILD.has(me, loc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -94,17 +96,10 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "build", false))
|
if ( ! playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock(), "build", false))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
|
||||||
Material handItem = event.getPlayer().getItemInHand().getType();
|
|
||||||
if (handItem == Material.TNT || handItem == Material.REDSTONE_TORCH_ON)
|
|
||||||
{
|
|
||||||
Faction targetFaction = Board.getFactionAt(new FLocation(event.getBlock()));
|
|
||||||
FactionsEntityListener.trackPotentialExplosionExploit(event.getPlayer().getName(), targetFaction, handItem, event.getBlock().getLocation());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -115,7 +110,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockDamage(BlockDamageEvent event)
|
public void onBlockDamage(BlockDamageEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -127,7 +122,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -152,7 +147,7 @@ public class FactionsBlockListener extends BlockListener
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
||||||
{
|
{
|
||||||
// if not a sticky piston, retraction should be fine
|
// if not a sticky piston, retraction should be fine
|
||||||
|
@ -4,8 +4,10 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerChatEvent;
|
import org.bukkit.event.player.PlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.Conf;
|
import com.massivecraft.factions.Conf;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
@ -17,7 +19,7 @@ import com.massivecraft.factions.struct.Rel;
|
|||||||
|
|
||||||
|
|
||||||
// this is an addtional PlayerListener for handling slashless command usage and faction chat, to be set at low priority so Factions gets to them first
|
// this is an addtional PlayerListener for handling slashless command usage and faction chat, to be set at low priority so Factions gets to them first
|
||||||
public class FactionsChatEarlyListener extends PlayerListener
|
public class FactionsChatEarlyListener implements Listener
|
||||||
{
|
{
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsChatEarlyListener(P p)
|
public FactionsChatEarlyListener(P p)
|
||||||
@ -25,7 +27,7 @@ public class FactionsChatEarlyListener extends PlayerListener
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Projectile;
|
import org.bukkit.entity.Projectile;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EndermanPickupEvent;
|
import org.bukkit.event.entity.EndermanPickupEvent;
|
||||||
import org.bukkit.event.entity.EndermanPlaceEvent;
|
import org.bukkit.event.entity.EndermanPlaceEvent;
|
||||||
@ -18,9 +17,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.EntityListener;
|
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
|
||||||
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
|
||||||
import org.bukkit.event.painting.PaintingBreakEvent;
|
import org.bukkit.event.painting.PaintingBreakEvent;
|
||||||
import org.bukkit.event.painting.PaintingPlaceEvent;
|
import org.bukkit.event.painting.PaintingPlaceEvent;
|
||||||
@ -37,7 +34,7 @@ import com.massivecraft.factions.struct.Rel;
|
|||||||
import com.massivecraft.factions.util.MiscUtil;
|
import com.massivecraft.factions.util.MiscUtil;
|
||||||
|
|
||||||
|
|
||||||
public class FactionsEntityListener extends EntityListener
|
public class FactionsEntityListener implements Listener
|
||||||
{
|
{
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsEntityListener(P p)
|
public FactionsEntityListener(P p)
|
||||||
@ -45,9 +42,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ArrayList<PotentialExplosionExploit> exploitExplosions = new ArrayList<PotentialExplosionExploit>();
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEntityDeath(EntityDeathEvent event)
|
public void onEntityDeath(EntityDeathEvent event)
|
||||||
{
|
{
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
@ -73,7 +68,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
fplayer.msg("<i>Your power is now <h>"+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded());
|
fplayer.msg("<i>Your power is now <h>"+fplayer.getPowerRounded()+" / "+fplayer.getPowerMaxRounded());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
if ( event.isCancelled()) return;
|
if ( event.isCancelled()) return;
|
||||||
@ -94,7 +89,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityExplode(EntityExplodeEvent event)
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
{
|
{
|
||||||
if ( event.isCancelled()) return;
|
if ( event.isCancelled()) return;
|
||||||
@ -228,7 +223,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -243,7 +238,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEntityTarget(EntityTargetEvent event)
|
public void onEntityTarget(EntityTargetEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -263,7 +258,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPaintingBreak(PaintingBreakEvent event)
|
public void onPaintingBreak(PaintingBreakEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -285,7 +280,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPaintingPlace(PaintingPlaceEvent event)
|
public void onPaintingPlace(PaintingPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -296,7 +291,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEndermanPickup(EndermanPickupEvent event)
|
public void onEndermanPickup(EndermanPickupEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -309,7 +304,7 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onEndermanPlace(EndermanPlaceEvent event)
|
public void onEndermanPlace(EndermanPlaceEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -321,38 +316,4 @@ public class FactionsEntityListener extends EntityListener
|
|||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Since the Bukkit team still don't seem to be in any hurry to fix the problem after at least half a year,
|
|
||||||
* we'll track potential explosion exploits ourselves and try to prevent them
|
|
||||||
* For reference, canceled TNT placement next to redstone power is bugged and triggers a free explosion
|
|
||||||
* Same thing happens for canceled redstone torch placement next to existing TNT
|
|
||||||
* https://bukkit.atlassian.net/browse/BUKKIT-89
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static void trackPotentialExplosionExploit(String playerName, Faction faction, Material item, Location location)
|
|
||||||
{
|
|
||||||
exploitExplosions.add(new PotentialExplosionExploit(playerName, faction, item, location));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class PotentialExplosionExploit
|
|
||||||
{
|
|
||||||
public String playerName;
|
|
||||||
public Faction faction;
|
|
||||||
public Material item;
|
|
||||||
public long timeMillis;
|
|
||||||
public int X;
|
|
||||||
public int Z;
|
|
||||||
|
|
||||||
public PotentialExplosionExploit(String playerName, Faction faction, Material item, Location location)
|
|
||||||
{
|
|
||||||
this.playerName = playerName;
|
|
||||||
this.faction = faction;
|
|
||||||
this.item = item;
|
|
||||||
this.timeMillis = System.currentTimeMillis();
|
|
||||||
this.X = location.getBlockX();
|
|
||||||
this.Z = location.getBlockZ();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,9 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
@ -17,7 +20,6 @@ import org.bukkit.event.player.PlayerChatEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerListener;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
@ -37,7 +39,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class FactionsPlayerListener extends PlayerListener
|
public class FactionsPlayerListener implements Listener
|
||||||
{
|
{
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsPlayerListener(P p)
|
public FactionsPlayerListener(P p)
|
||||||
@ -45,7 +47,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerChat(PlayerChatEvent event)
|
public void onPlayerChat(PlayerChatEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -140,7 +142,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
// Make sure that all online players do have a fplayer.
|
// Make sure that all online players do have a fplayer.
|
||||||
@ -156,7 +158,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
SpoutFeatures.updateAppearancesShortly(event.getPlayer());
|
SpoutFeatures.updateAppearancesShortly(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
{
|
{
|
||||||
// Make sure player's power is up to date when they log off.
|
// Make sure player's power is up to date when they log off.
|
||||||
@ -165,7 +167,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
SpoutFeatures.playerDisconnect(me);
|
SpoutFeatures.playerDisconnect(me);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
// Did we change block?
|
// Did we change block?
|
||||||
@ -205,7 +207,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -279,7 +281,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
{
|
{
|
||||||
FPlayer me = FPlayers.i.get(event.getPlayer());
|
FPlayer me = FPlayers.i.get(event.getPlayer());
|
||||||
@ -305,7 +307,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
|
|
||||||
// For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected),
|
// For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected),
|
||||||
// but these separate bucket events below always fire without fail
|
// but these separate bucket events below always fire without fail
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -319,7 +321,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerBucketFill(PlayerBucketFillEvent event)
|
public void onPlayerBucketFill(PlayerBucketFillEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
@ -425,7 +427,7 @@ public class FactionsPlayerListener extends PlayerListener
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled()) return;
|
if (event.isCancelled()) return;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.listeners;
|
||||||
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.event.server.ServerListener;
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
import org.bukkit.event.server.PluginEnableEvent;
|
import org.bukkit.event.server.PluginEnableEvent;
|
||||||
|
|
||||||
@ -9,7 +11,7 @@ import com.massivecraft.factions.P;
|
|||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
|
|
||||||
|
|
||||||
public class FactionsServerListener extends ServerListener
|
public class FactionsServerListener implements Listener
|
||||||
{
|
{
|
||||||
public P p;
|
public P p;
|
||||||
public FactionsServerListener(P p)
|
public FactionsServerListener(P p)
|
||||||
@ -17,7 +19,7 @@ public class FactionsServerListener extends ServerListener
|
|||||||
this.p = p;
|
this.p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginDisable(PluginDisableEvent event)
|
public void onPluginDisable(PluginDisableEvent event)
|
||||||
{
|
{
|
||||||
String name = event.getPlugin().getDescription().getName();
|
String name = event.getPlugin().getDescription().getName();
|
||||||
@ -27,7 +29,7 @@ public class FactionsServerListener extends ServerListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPluginEnable(PluginEnableEvent event)
|
public void onPluginEnable(PluginEnableEvent event)
|
||||||
{
|
{
|
||||||
Plugin plug = event.getPlugin();
|
Plugin plug = event.getPlugin();
|
||||||
|
Loading…
Reference in New Issue
Block a user