From 8fc570706102bb6230e4f036df5cbe4ae05542e2 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 22 Oct 2014 07:53:56 +0200 Subject: [PATCH] Clean up player references even on exception. --- .../massivecore/cmd/MassiveCommand.java | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/massivecraft/massivecore/cmd/MassiveCommand.java b/src/main/java/com/massivecraft/massivecore/cmd/MassiveCommand.java index 5d2f4699..3dc9c8a1 100644 --- a/src/main/java/com/massivecraft/massivecore/cmd/MassiveCommand.java +++ b/src/main/java/com/massivecraft/massivecore/cmd/MassiveCommand.java @@ -247,24 +247,29 @@ public class MassiveCommand } } - // Set Sender Variables - this.sender = sender; - this.senderIsConsole = true; - this.me = null; - if (sender instanceof Player) + try { - this.me = (Player) sender; - this.senderIsConsole = false; + // Set Sender Variables + this.sender = sender; + this.senderIsConsole = true; + this.me = null; + if (sender instanceof Player) + { + this.me = (Player) sender; + this.senderIsConsole = false; + } + this.fixSenderVars(); + + if ( ! isValidCall(this.sender, this.getArgs())) return; + perform(); + } + finally + { + // Unset Sender Variables + this.sender = null; + this.me = null; + this.unsetSenderVars(); } - this.fixSenderVars(); - - if ( ! isValidCall(this.sender, this.getArgs())) return; - perform(); - - // Unset Sender Variables - this.sender = null; - this.me = null; - this.unsetSenderVars(); } public void fixSenderVars()