This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
/
VentureChatHook.java
58 lines (51 loc) · 1.79 KB
/
VentureChatHook.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Copyright (C) 2015 cnaude
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.cnaude.purpleirc.Hooks;
import com.cnaude.purpleirc.PurpleIRC;
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
*
* @author cnaude
*/
public class VentureChatHook {
private final PurpleIRC plugin;
/**
*
* @param plugin the PurpleIRC plugin
*/
public VentureChatHook(PurpleIRC plugin) {
this.plugin = plugin;
}
public void sendMessage(String channel, String message) {
if (channel.isEmpty() || message.isEmpty()) {
return;
}
for (Player player : Bukkit.getOnlinePlayers()) {
MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(player);
if (mcp != null) {
for (String listen : mcp.getListening()) {
if (listen.equalsIgnoreCase(channel)) {
plugin.broadcastToPlayer(player, message, "irc.message.chat");
}
}
}
}
}
}