Move out and clean even more listener content.
This commit is contained in:
parent
7c2dacce7c
commit
ede66bac6b
@ -36,6 +36,8 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
|
|||||||
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
import org.bukkit.event.hanging.HangingBreakEvent.RemoveCause;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.server.PluginDisableEvent;
|
import org.bukkit.event.server.PluginDisableEvent;
|
||||||
@ -52,7 +54,9 @@ import com.massivecraft.factions.Faction;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
|
import com.massivecraft.factions.util.VisualizeUtil;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
import com.massivecraft.mcore.util.Txt;
|
import com.massivecraft.mcore.util.Txt;
|
||||||
|
|
||||||
public class FactionsListenerMain implements Listener
|
public class FactionsListenerMain implements Listener
|
||||||
@ -74,6 +78,45 @@ public class FactionsListenerMain implements Listener
|
|||||||
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// REMOVE PLAYER DATA WHEN BANNED
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
// If a player was kicked from the server ...
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer fplayer = FPlayerColl.get().get(player);
|
||||||
|
|
||||||
|
// ... and if the if player was banned (not just kicked) ...
|
||||||
|
if (!event.getReason().equals("Banned by admin.")) return;
|
||||||
|
|
||||||
|
// ... and we remove player data when banned ...
|
||||||
|
if (!ConfServer.removePlayerDataWhenBanned) return;
|
||||||
|
|
||||||
|
// ... get rid of their stored info.
|
||||||
|
if (fplayer.getRole() == Rel.LEADER)
|
||||||
|
{
|
||||||
|
fplayer.getFaction().promoteNewLeader();
|
||||||
|
}
|
||||||
|
fplayer.leave(false);
|
||||||
|
fplayer.detach();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// VISUALIZE UTIL
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerMoveClearVisualizations(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
if (MUtil.isSameBlock(event)) return;
|
||||||
|
|
||||||
|
VisualizeUtil.clear(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// DENY COMMANDS
|
// DENY COMMANDS
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -12,7 +12,6 @@ import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
|||||||
import org.bukkit.event.player.PlayerBucketFillEvent;
|
import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||||
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.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
import com.massivecraft.factions.BoardColl;
|
import com.massivecraft.factions.BoardColl;
|
||||||
@ -21,10 +20,8 @@ import com.massivecraft.factions.Const;
|
|||||||
import com.massivecraft.factions.FPerm;
|
import com.massivecraft.factions.FPerm;
|
||||||
import com.massivecraft.factions.FPlayer;
|
import com.massivecraft.factions.FPlayer;
|
||||||
import com.massivecraft.factions.FPlayerColl;
|
import com.massivecraft.factions.FPlayerColl;
|
||||||
import com.massivecraft.factions.Rel;
|
|
||||||
import com.massivecraft.factions.TerritoryAccess;
|
import com.massivecraft.factions.TerritoryAccess;
|
||||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||||
import com.massivecraft.factions.util.VisualizeUtil;
|
|
||||||
import com.massivecraft.mcore.event.MCorePlayerLeaveEvent;
|
import com.massivecraft.mcore.event.MCorePlayerLeaveEvent;
|
||||||
import com.massivecraft.mcore.ps.PS;
|
import com.massivecraft.mcore.ps.PS;
|
||||||
import com.massivecraft.mcore.util.MUtil;
|
import com.massivecraft.mcore.util.MUtil;
|
||||||
@ -200,36 +197,4 @@ public class TodoFactionsPlayerListener implements Listener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
|
||||||
public void onPlayerKick(PlayerKickEvent event)
|
|
||||||
{
|
|
||||||
FPlayer badGuy = FPlayerColl.get().get(event.getPlayer());
|
|
||||||
if (badGuy == null) return;
|
|
||||||
|
|
||||||
SpoutFeatures.playerDisconnect(badGuy);
|
|
||||||
|
|
||||||
// if player was banned (not just kicked), get rid of their stored info
|
|
||||||
if (ConfServer.removePlayerDataWhenBanned && event.getReason().equals("Banned by admin."))
|
|
||||||
{
|
|
||||||
if (badGuy.getRole() == Rel.LEADER)
|
|
||||||
badGuy.getFaction().promoteNewLeader();
|
|
||||||
badGuy.leave(false);
|
|
||||||
badGuy.detach();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// VisualizeUtil
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerMoveClearVisualizations(PlayerMoveEvent event)
|
|
||||||
{
|
|
||||||
Block blockFrom = event.getFrom().getBlock();
|
|
||||||
Block blockTo = event.getTo().getBlock();
|
|
||||||
if (blockFrom.equals(blockTo)) return;
|
|
||||||
|
|
||||||
VisualizeUtil.clear(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user