This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
/
IRCCommandSender.java
244 lines (205 loc) · 4.91 KB
/
IRCCommandSender.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
/*
* Copyright (C) 2014 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;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
/**
*
* @author Chris Naude We have to implement our own CommandSender so that we can
* receive output from the command dispatcher.
*/
public class IRCCommandSender implements CommandSender {
private final PurpleBot ircBot;
private final String target;
private final PurpleIRC plugin;
private final boolean ctcpResponse;
/**
*
* @param message
*/
@Override
public void sendMessage(String message) {
plugin.logDebug("sendMessage: " + message);
addMessageToQueue(message);
}
/**
*
* @param messages
*/
@Override
public void sendMessage(String[] messages) {
for (String message : messages) {
plugin.logDebug("sendMessage[]: " + message);
addMessageToQueue(message);
}
}
private void addMessageToQueue(String message) {
ircBot.messageQueue.add(new IRCMessage(target,
plugin.colorConverter.gameColorsToIrc(message), ctcpResponse));
}
/**
*
* @param ircBot
* @param target
* @param plugin
* @param ctcpResponse
*/
public IRCCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, boolean ctcpResponse) {
super();
this.target = target;
this.ircBot = ircBot;
this.plugin = plugin;
this.ctcpResponse = ctcpResponse;
}
/**
*
* @return
*/
@Override
public Server getServer() {
return Bukkit.getServer();
}
/**
*
* @return
*/
@Override
public String getName() {
return "CONSOLE";
}
/**
*
* @return
*/
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return null;
}
/**
*
* @param perm
* @return
*/
@Override
public boolean hasPermission(final String perm) {
System.out.println("Perm: " + perm);
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean hasPermission(final Permission arg0) {
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean isPermissionSet(final String arg0) {
return true;
}
/**
*
* @param arg0
* @return
*/
@Override
public boolean isPermissionSet(final Permission arg0) {
return true;
}
/**
*
*/
@Override
public void recalculatePermissions() {
}
/**
*
* @param arg0
*/
@Override
public void removeAttachment(final PermissionAttachment arg0) {
}
/**
*
* @return
*/
@Override
public boolean isOp() {
return true;
}
/**
*
* @param op
*/
@Override
public void setOp(final boolean op) {
}
/**
*
* @param arg0
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final int arg1) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @param arg2
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final String arg1, final boolean arg2) {
return null;
}
/**
*
* @param arg0
* @param arg1
* @param arg2
* @param arg3
* @return
*/
@Override
public PermissionAttachment addAttachment(final Plugin arg0, final String arg1, final boolean arg2, final int arg3) {
return null;
}
}