diff --git a/src/main/java/com/massivecraft/factions/engine/EngineMain.java b/src/main/java/com/massivecraft/factions/engine/EngineMain.java index c8651780..78f353a6 100644 --- a/src/main/java/com/massivecraft/factions/engine/EngineMain.java +++ b/src/main/java/com/massivecraft/factions/engine/EngineMain.java @@ -471,6 +471,20 @@ public class EngineMain extends EngineAbstract @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onChunksChange(EventFactionsChunksChange event) + { + // For security reasons we block the chunk change on any error since an error might block security checks from happening. + try + { + onChunksChangeInner(event); + } + catch (Throwable throwable) + { + event.setCancelled(true); + throwable.printStackTrace(); + } + } + + public void onChunksChangeInner(EventFactionsChunksChange event) { // Args final MPlayer msender = event.getMSender(); diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index 38b559ae..7fb905d0 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -7,6 +7,7 @@ import java.util.Map.Entry; import java.util.Set; import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.massivecraft.factions.EconomyParticipator; @@ -830,7 +831,16 @@ public class MPlayer extends SenderEntity implements EconomyParticipato // Event // NOTE: We listen to this event ourselves at LOW. // NOTE: That is where we apply the standard checks. - EventFactionsChunksChange event = new EventFactionsChunksChange(this.getSender(), chunks, newFaction); + CommandSender sender = this.getSender(); + if (sender == null) + { + msg("ERROR: Your \"CommandSender Link\" has been severed. This shouldn't happen."); + msg("Help the Factions developers by reporting this at: https://github.com/MassiveCraft/Factions/issues"); + msg("Describe what you were doing, what client you are using, if this is your first time on the server etc. The more the better."); + msg("Relogging to the server should fix the issue."); + return false; + } + EventFactionsChunksChange event = new EventFactionsChunksChange(sender, chunks, newFaction); event.run(); if (event.isCancelled()) return false;