! Fix NPE in player listeners

This commit is contained in:
PikachuEXE 2015-04-16 07:08:53 +08:00
parent 7783144b68
commit 2fbea95b39

View File

@ -379,17 +379,21 @@ public class PlayerListener implements Listener, ColorUtil {
if (quester.currentQuests.isEmpty() == false) {
for (Quest quest : quester.currentQuests.keySet()) {
Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
continue;
}
if (quester.getCurrentStage(quest).chatEvents.isEmpty() == false) {
if (currentStage.chatEvents.isEmpty() == false) {
String chat = evt.getMessage();
for (String s : quester.getCurrentStage(quest).chatEvents.keySet()) {
for (String s : currentStage.chatEvents.keySet()) {
if (s.equalsIgnoreCase(chat)) {
if (quester.getQuestData(quest).eventFired.get(s) == null || quester.getQuestData(quest).eventFired.get(s) == false) {
quester.getCurrentStage(quest).chatEvents.get(s).fire(quester, quest);
currentStage.chatEvents.get(s).fire(quester, quest);
quester.getQuestData(quest).eventFired.put(s, true);
}
@ -873,13 +877,17 @@ public class PlayerListener implements Listener, ColorUtil {
Quester quester = plugin.getQuester(evt.getPlayer().getUniqueId());
for (Quest quest : quester.currentQuests.keySet()) {
Stage currentStage = quester.getCurrentStage(quest);
if (currentStage == null) {
continue;
}
if (quester.getCurrentStage(quest).delay > -1) {
if (currentStage.delay > -1) {
quester.stopStageTimer(quest);
}
if (quester.getCurrentStage(quest).disconnectEvent != null) {
quester.getCurrentStage(quest).disconnectEvent.fire(quester, quest);
if (currentStage.disconnectEvent != null) {
currentStage.disconnectEvent.fire(quester, quest);
}
}