Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a catch for if a player is caged and kicked. Resolves #1789 #2041

Merged
merged 4 commits into from
Jun 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerKickEvent;

public class Cager extends FreedomService
{
Expand Down Expand Up @@ -95,6 +96,18 @@ public void onPlayerQuit(PlayerQuitEvent event)
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerKick(PlayerKickEvent event)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignoreCancelled? If the event is cancelled, why do you need to remove the cage?

Copy link
Member

@JeromSar JeromSar May 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wild's implementation is correct. If the kick event is cancelled, the player isn't kicked, so the cage data shouldn't be removed. ignoreCancelled causes the event handler to skip processing if the event is cancelled.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, never mind then. I was thinking the other way around.

{
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
CageData cage = player.getCageData();

if (cage.isCaged())
{
cage.playerQuit();
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Command_gtfo extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{

if (args.length == 0)
{
return false;
Expand Down