/
CommandSender.java
50 lines (44 loc) · 1.47 KB
/
CommandSender.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
package net.ME1312.Galaxi.Plugin.Command;
import net.ME1312.Galaxi.Galaxi;
import net.ME1312.Galaxi.Library.ExtraDataHandler;
import net.ME1312.Galaxi.Library.Util;
import java.lang.reflect.InvocationTargetException;
/**
* Command Sender Layout Class
*/
public interface CommandSender extends ExtraDataHandler {
/**
* Get Sender Name
*
* @return Sender Name
*/
String getName();
/**
* Test if the Sender has a permission
*
* @param permission Permission to test
* @return Sender's Permission Status
*/
boolean hasPermission(String permission);
/**
* Send the Sender a message
*
* @param messages Messages to send
*/
void sendMessage(String... messages);
/**
* Send a command as the Sender
*
* @param command Command to send
*/
default void command(String command) {
try {
Class.forName("net.ME1312.Galaxi.Engine.Library.ConsoleReader").getMethod("runCommand", CommandSender.class, String.class).invoke(
Util.getDespiteException(() -> Class.forName("net.ME1312.Galaxi.Engine.GalaxiEngine").getMethod("getConsoleReader").invoke(Galaxi.getInstance()), null), this, command);
} catch (InvocationTargetException e) {
Galaxi.getInstance().getAppInfo().getLogger().error.println(e.getTargetException());
} catch (Exception e) {
Galaxi.getInstance().getAppInfo().getLogger().error.println(e);
}
}
}