/
BukkitMiscEvents.java
158 lines (125 loc) · 3.43 KB
/
BukkitMiscEvents.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
package com.laytonsmith.abstraction.bukkit.events;
import com.laytonsmith.abstraction.MCCommand;
import com.laytonsmith.abstraction.MCCommandSender;
import com.laytonsmith.abstraction.MCPlayer;
import com.laytonsmith.abstraction.bukkit.BukkitMCCommand;
import com.laytonsmith.abstraction.bukkit.BukkitMCConsoleCommandSender;
import com.laytonsmith.abstraction.bukkit.BukkitMCPlayer;
import com.laytonsmith.abstraction.events.MCConsoleCommandEvent;
import com.laytonsmith.abstraction.events.MCPluginIncomingMessageEvent;
import com.laytonsmith.abstraction.events.MCServerPingEvent;
import com.laytonsmith.abstraction.events.MCCommandTabCompleteEvent;
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.event.server.ServerListPingEvent;
/**
*
* @author Layton
*/
public class BukkitMiscEvents {
public static class BukkitMCConsoleCommandEvent implements MCConsoleCommandEvent {
ServerCommandEvent sce;
public BukkitMCConsoleCommandEvent(ServerCommandEvent sce){
this.sce = sce;
}
public Object _GetObject() {
return sce;
}
public String getCommand() {
return sce.getCommand();
}
public void setCommand(String command) {
sce.setCommand(command);
}
}
/*
* Not an actual event, but making it one.
*/
public static class BukkitMCPluginIncomingMessageEvent implements MCPluginIncomingMessageEvent {
Player player;
String channel;
byte[] bytes;
public BukkitMCPluginIncomingMessageEvent(Player player, String channel, byte[] bytes) {
this.player = player;
this.channel = channel;
this.bytes = bytes;
}
public String getChannel() {
return channel;
}
public byte[] getBytes() {
return bytes;
}
public MCPlayer getPlayer() {
return new BukkitMCPlayer(player);
}
public Object _GetObject() {
return null;
}
}
public static class BukkitMCServerPingEvent implements MCServerPingEvent {
ServerListPingEvent slp;
public BukkitMCServerPingEvent(ServerListPingEvent event) {
slp = event;
}
public Object _GetObject() {
return slp;
}
public InetAddress getAddress() {
return slp.getAddress();
}
public int getMaxPlayers() {
return slp.getMaxPlayers();
}
public String getMOTD() {
return slp.getMotd();
}
public int getNumPlayers() {
return slp.getNumPlayers();
}
public void setMaxPlayers(int max) {
slp.setMaxPlayers(max);
}
public void setMOTD(String motd) {
slp.setMotd(motd);
}
}
public static class BukkitMCCommandTabCompleteEvent implements MCCommandTabCompleteEvent {
List<String> comp;
MCCommandSender sender;
Command cmd;
String alias;
String[] args;
public BukkitMCCommandTabCompleteEvent(MCCommandSender sender, Command cmd, String alias, String[] args) {
this.comp = new ArrayList<String>();
this.sender = sender;
this.cmd = cmd;
this.alias = alias;
this.args = args;
}
public Object _GetObject() {
return comp;
}
public MCCommandSender getCommandSender() {
return sender;
}
public MCCommand getCommand() {
return new BukkitMCCommand(cmd);
}
public String getAlias() {
return alias;
}
public String[] getArguments() {
return args;
}
public List<String> getCompletions() {
return comp;
}
}
}