Skip to content
This repository has been archived by the owner on Aug 31, 2019. It is now read-only.

Commit

Permalink
Fix NPE when player chats without a channel
Browse files Browse the repository at this point in the history
  • Loading branch information
jedediah committed Dec 10, 2014
1 parent 025922e commit 7bd5112
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.rmsy.channels.listener;

import com.github.rmsy.channels.Channel;
import com.github.rmsy.channels.ChannelsPlugin;
import com.google.common.base.Preconditions;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -30,8 +31,11 @@ public ChatListener(final ChannelsPlugin plugin) {
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerChat(final PlayerChatEvent event) {
Preconditions.checkNotNull(event, "event").setCancelled(true);
Player sender = event.getPlayer();
this.plugin.getPlayerManager().getMembershipChannel(sender).sendMessage(event.getMessage(), sender);
Channel channel = this.plugin.getPlayerManager().getMembershipChannel(sender);
if(channel != null) {
event.setCancelled(true);
channel.sendMessage(event.getMessage(), sender);
}
}
}

0 comments on commit 7bd5112

Please sign in to comment.