merege fix

This commit is contained in:
Olof Larsson 2012-01-28 17:03:47 +01:00
commit 7575cfcafc
10 changed files with 114 additions and 176 deletions

View File

@ -2,7 +2,7 @@ name: Factions
version: 1.7_dev version: 1.7_dev
main: com.massivecraft.factions.P main: com.massivecraft.factions.P
authors: [Olof Larsson, Brett Flannigan] authors: [Olof Larsson, Brett Flannigan]
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard] softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag]
commands: commands:
factions: factions:
description: Reference command for Factions. description: Reference command for Factions.

View File

@ -385,6 +385,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
long millisPassed = now - this.lastPowerUpdateTime; long millisPassed = now - this.lastPowerUpdateTime;
this.lastPowerUpdateTime = now; this.lastPowerUpdateTime = now;
Player thisPlayer = this.getPlayer();
if (thisPlayer != null && thisPlayer.isDead()) return; // don't let dead players regain power until they respawn
int millisPerMinute = 60*1000; int millisPerMinute = 60*1000;
double powerPerMinute = Conf.powerPerMinute; double powerPerMinute = Conf.powerPerMinute;
if(Conf.scaleNegativePower && this.power < 0) if(Conf.scaleNegativePower && this.power < 0)

View File

@ -67,7 +67,11 @@ public class FPlayers extends PlayerEntityCollection<FPlayer>
// if player is faction leader, sort out the faction since he's going away // if player is faction leader, sort out the faction since he's going away
if (fplayer.getRole() == Rel.LEADER) if (fplayer.getRole() == Rel.LEADER)
{
Faction faction = fplayer.getFaction();
if (faction != null)
fplayer.getFaction().promoteNewLeader(); fplayer.getFaction().promoteNewLeader();
}
fplayer.leave(false); fplayer.leave(false);
fplayer.detach(); fplayer.detach();

View File

@ -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;
@ -100,8 +99,7 @@ public class P extends MPlugin
//setupPermissions(); //setupPermissions();
integrateEssentialsChat(); integrateEssentialsChat();
setupSpout(this); setupSpout(this);
Econ.doSetup(); Econ.initialSetup(this);
Econ.oldMoneyDoTransfer();
CapiFeatures.setup(); CapiFeatures.setup();
setupLWC(); setupLWC();
@ -110,42 +108,12 @@ 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);
this.registerEvent(Event.Type.EXPLOSION_PRIME, 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();
} }

View File

@ -33,6 +33,25 @@ public class Econ
return econ != null; return econ != null;
} }
public static void initialSetup(P p)
{
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null)
{
P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" is not installed.");
return;
}
p.getServer().getScheduler().scheduleSyncDelayedTask(p, new Runnable()
{
@Override
public void run()
{
doSetup();
oldMoneyDoTransfer();
}
}, 1);
}
public static void doSetup() public static void doSetup()
{ {
if (isSetup()) return; if (isSetup()) return;
@ -40,6 +59,11 @@ public class Econ
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null)
{ {
RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class); RegisteredServiceProvider<Economy> rsp = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (rsp == null)
{
P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled" : "disabled")+", but the plugin \"Vault\" is not hooked into an economy plugin.");
return;
}
econ = rsp.getProvider(); econ = rsp.getProvider();
P.p.log("Economy integration through Vault plugin successful."); P.p.log("Economy integration through Vault plugin successful.");
@ -47,10 +71,6 @@ public class Econ
if ( ! Conf.econEnabled) if ( ! Conf.econEnabled)
P.p.log("NOTE: Economy is disabled. Enable with command: f config econEnabled true"); P.p.log("NOTE: Economy is disabled. Enable with command: f config econEnabled true");
} }
else
{
P.p.log("Economy integration is "+(Conf.econEnabled ? "enabled, but" : "disabled, and")+" the plugin \"Vault\" is not installed.");
}
P.p.cmdBase.cmdHelp.updateHelp(); P.p.cmdBase.cmdHelp.updateHelp();
} }

View File

@ -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

View File

@ -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;

View File

@ -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,48 +89,7 @@ public class FactionsEntityListener extends EntityListener
}*/ }*/
} }
@Override @EventHandler(priority = EventPriority.NORMAL)
public void onExplosionPrime(ExplosionPrimeEvent event)
{
if (event.isCancelled()) return;
if (! (event.getEntity() instanceof TNTPrimed)) return;
if (exploitExplosions.isEmpty()) return;
// make sure this isn't a TNT explosion exploit attempt
int locX = event.getEntity().getLocation().getBlockX();
int locZ = event.getEntity().getLocation().getBlockZ();
for (int i = exploitExplosions.size() - 1; i >= 0; i--)
{
PotentialExplosionExploit ex = exploitExplosions.get(i);
// remove anything from the list older than 10 seconds (TNT takes 4 seconds to trigger; provide some leeway)
if (ex.timeMillis + 10000 < System.currentTimeMillis())
{
exploitExplosions.remove(i);
continue;
}
int absX = Math.abs(ex.X - locX);
int absZ = Math.abs(ex.Z - locZ);
if (absX < 5 && absZ < 5)
{ // it sure looks like an exploit attempt
// let's tattle on him to everyone
String msg = "NOTICE: Player \""+ex.playerName+"\" attempted to exploit a TNT bug in the territory of \""+ex.faction.getTag()+"\" at "+ex.X+","+ex.Z+" (X,Z) using "+ex.item.name();
P.p.log(Level.WARNING, msg);
for (FPlayer fplayer : FPlayers.i.getOnline())
{
fplayer.sendMessage(msg);
}
event.setCancelled(true);
exploitExplosions.remove(i);
return;
}
}
}
@Override
public void onEntityExplode(EntityExplodeEvent event) public void onEntityExplode(EntityExplodeEvent event)
{ {
if ( event.isCancelled()) return; if ( event.isCancelled()) return;
@ -269,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;
@ -284,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;
@ -304,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;
@ -326,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;
@ -337,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;
@ -350,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;
@ -362,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();
}
}
} }

View File

@ -8,16 +8,18 @@ import org.bukkit.ChatColor;
import org.bukkit.Location; 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.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;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
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;
@ -229,6 +231,25 @@ public class FactionsPlayerListener extends PlayerListener
return; // only interested on right-clicks for below return; // only interested on right-clicks for below
} }
// workaround fix for new CraftBukkit 1.1-R1 bug where half-step on half-step placement doesn't trigger BlockPlaceEvent
if (
event.hasItem()
&&
event.getItem().getType() == Material.STEP
&&
block.getType() == Material.STEP
&&
event.getBlockFace() == BlockFace.UP
&&
event.getItem().getData().getData() == block.getData()
&&
! FactionsBlockListener.playerCanBuildDestroyBlock(player, block, "build", false)
)
{
event.setCancelled(true);
return;
}
if ( ! playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false)) if ( ! playerCanUseItemHere(player, block.getLocation(), event.getMaterial(), false))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -260,10 +281,13 @@ 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());
me.getPower(); // update power, so they won't have gained any while dead
Location home = me.getFaction().getHome(); // TODO: WARNING FOR NPE HERE THE ORIO FOR RESPAWN SHOULD BE ASSIGNABLE FROM CONFIG. Location home = me.getFaction().getHome(); // TODO: WARNING FOR NPE HERE THE ORIO FOR RESPAWN SHOULD BE ASSIGNABLE FROM CONFIG.
if if
( (
@ -286,7 +310,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;
@ -300,7 +324,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;
@ -406,7 +430,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;

View File

@ -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();