├── .gitignore
├── LICENSE
├── README.md
├── betterprotocol-api
├── pom.xml
└── src
│ └── main
│ └── java
│ └── de
│ └── mcmdev
│ └── betterprotocol
│ ├── BetterProtocol.java
│ └── api
│ ├── BetterProtocolAPI.java
│ ├── EventBus.java
│ ├── PacketEvent.java
│ ├── PacketHandler.java
│ ├── PacketListener.java
│ └── PacketListenerFunction.java
├── betterprotocol-bukkit
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── de
│ │ └── mcmdev
│ │ └── betterprotocol
│ │ └── bukkit
│ │ ├── BetterProtocolBukkitPlugin.java
│ │ └── inject
│ │ ├── BukkitInjector.java
│ │ ├── EncodingInjector.java
│ │ ├── IncomingInjector.java
│ │ └── OutgoingInjector.java
│ └── resources
│ └── plugin.yml
├── betterprotocol-bungee
├── pom.xml
└── src
│ └── main
│ ├── java
│ └── de
│ │ └── mcmdev
│ │ └── betterprotocol
│ │ └── bungee
│ │ ├── BetterProtocolBungeePlugin.java
│ │ └── TestListener.java
│ └── resources
│ └── bungee.yml
├── betterprotocol-common
├── pom.xml
└── src
│ └── main
│ └── java
│ └── de
│ └── mcmdev
│ └── betterprotocol
│ └── common
│ ├── BetterProtocolPlatform.java
│ ├── BetterProtocolPlugin.java
│ ├── handler
│ ├── EncodingChannelHandler.java
│ ├── RewritingReadChannelHandler.java
│ └── RewritingWriteChannelHandler.java
│ ├── inject
│ └── Injector.java
│ ├── listener
│ └── CommonEventBus.java
│ └── protocol
│ ├── AbstractProtocolRegistry.java
│ └── ProtocolRegistry_1_16_5.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 |
3 | ### Java template
4 | # Compiled class file
5 | *.class
6 |
7 | # Log file
8 | *.log
9 |
10 | # BlueJ files
11 | *.ctxt
12 |
13 | # Mobile Tools for Java (J2ME)
14 | .mtj.tmp/
15 |
16 | # Package Files #
17 | *.jar
18 | *.war
19 | *.nar
20 | *.ear
21 | *.zip
22 | *.tar.gz
23 | *.rar
24 |
25 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
26 | hs_err_pid*
27 |
28 | ### Maven template
29 | target/
30 | pom.xml.tag
31 | pom.xml.releaseBackup
32 | pom.xml.versionsBackup
33 | pom.xml.next
34 | release.properties
35 | dependency-reduced-pom.xml
36 | .flattened-pom.xml
37 | buildNumber.properties
38 | .mvn/timing.properties
39 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
40 | .mvn/wrapper/maven-wrapper.jar
41 |
42 | ### Java template
43 | # Compiled class file
44 | *.class
45 |
46 | # Log file
47 | *.log
48 |
49 | # BlueJ files
50 | *.ctxt
51 |
52 | # Mobile Tools for Java (J2ME)
53 | .mtj.tmp/
54 |
55 | # Package Files #
56 | *.jar
57 | *.war
58 | *.nar
59 | *.ear
60 | *.zip
61 | *.tar.gz
62 | *.rar
63 |
64 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
65 | hs_err_pid*
66 |
67 | ### Maven template
68 | target/
69 | pom.xml.tag
70 | pom.xml.releaseBackup
71 | pom.xml.versionsBackup
72 | pom.xml.next
73 | release.properties
74 | dependency-reduced-pom.xml
75 | buildNumber.properties
76 | .mvn/timing.properties
77 | # https://github.com/takari/maven-wrapper#usage-without-binary-jar
78 | .mvn/wrapper/maven-wrapper.jar
79 |
80 | ### JetBrains template
81 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
82 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
83 |
84 | # User-specific stuff
85 | .idea/**/workspace.xml
86 | .idea/**/tasks.xml
87 | .idea/**/usage.statistics.xml
88 | .idea/**/dictionaries
89 | .idea/**/shelf
90 |
91 | # Generated files
92 | .idea/**/contentModel.xml
93 |
94 | # Sensitive or high-churn files
95 | .idea/**/dataSources/
96 | .idea/**/dataSources.ids
97 | .idea/**/dataSources.local.xml
98 | .idea/**/sqlDataSources.xml
99 | .idea/**/dynamic.xml
100 | .idea/**/uiDesigner.xml
101 | .idea/**/dbnavigator.xml
102 |
103 | # Gradle
104 | .idea/**/gradle.xml
105 | .idea/**/libraries
106 |
107 | # Gradle and Maven with auto-import
108 | # When using Gradle or Maven with auto-import, you should exclude module files,
109 | # since they will be recreated, and may cause churn. Uncomment if using
110 | # auto-import.
111 | .idea/artifacts
112 | .idea/compiler.xml
113 | .idea/jarRepositories.xml
114 | .idea/modules.xml
115 | .idea/*.iml
116 | .idea/modules
117 | *.iml
118 | *.ipr
119 |
120 | # CMake
121 | cmake-build-*/
122 |
123 | # Mongo Explorer plugin
124 | .idea/**/mongoSettings.xml
125 |
126 | # File-based project format
127 | *.iws
128 |
129 | # IntelliJ
130 | out/
131 |
132 | # mpeltonen/sbt-idea plugin
133 | .idea_modules/
134 |
135 | # JIRA plugin
136 | atlassian-ide-plugin.xml
137 |
138 | # Cursive Clojure plugin
139 | .idea/replstate.xml
140 |
141 | # Crashlytics plugin (for Android Studio and IntelliJ)
142 | com_crashlytics_export_strings.xml
143 | crashlytics.properties
144 | crashlytics-build.properties
145 | fabric.properties
146 |
147 | # Editor-based Rest Client
148 | .idea/httpRequests
149 |
150 | # Android studio 3.1+ serialized cache file
151 | .idea/caches/build_file_checksums.ser
152 |
153 | ### Java template
154 | # Compiled class file
155 | *.class
156 |
157 | # Log file
158 | *.log
159 |
160 | # BlueJ files
161 | *.ctxt
162 |
163 | # Mobile Tools for Java (J2ME)
164 | .mtj.tmp/
165 |
166 | # Package Files #
167 | *.jar
168 | *.war
169 | *.nar
170 | *.ear
171 | *.zip
172 | *.tar.gz
173 | *.rar
174 |
175 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
176 | hs_err_pid*
177 |
178 | ### JetBrains template
179 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
180 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
181 |
182 | # User-specific stuff
183 | .idea/**/workspace.xml
184 | .idea/**/tasks.xml
185 | .idea/**/usage.statistics.xml
186 | .idea/**/dictionaries
187 | .idea/**/shelf
188 |
189 | # Generated files
190 | .idea/**/contentModel.xml
191 |
192 | # Sensitive or high-churn files
193 | .idea/**/dataSources/
194 | .idea/**/dataSources.ids
195 | .idea/**/dataSources.local.xml
196 | .idea/**/sqlDataSources.xml
197 | .idea/**/dynamic.xml
198 | .idea/**/uiDesigner.xml
199 | .idea/**/dbnavigator.xml
200 |
201 | # Gradle
202 | .idea/**/gradle.xml
203 | .idea/**/libraries
204 |
205 | # Gradle and Maven with auto-import
206 | # When using Gradle or Maven with auto-import, you should exclude module files,
207 | # since they will be recreated, and may cause churn. Uncomment if using
208 | # auto-import.
209 | # .idea/artifacts
210 | # .idea/compiler.xml
211 | # .idea/jarRepositories.xml
212 | # .idea/modules.xml
213 | # .idea/*.iml
214 | # .idea/modules
215 | # *.iml
216 | # *.ipr
217 |
218 | # CMake
219 | cmake-build-*/
220 |
221 | # Mongo Explorer plugin
222 | .idea/**/mongoSettings.xml
223 |
224 | # File-based project format
225 | *.iws
226 |
227 | # IntelliJ
228 | out/
229 |
230 | # mpeltonen/sbt-idea plugin
231 | .idea_modules/
232 |
233 | # JIRA plugin
234 | atlassian-ide-plugin.xml
235 |
236 | # Cursive Clojure plugin
237 | .idea/replstate.xml
238 |
239 | # Crashlytics plugin (for Android Studio and IntelliJ)
240 | com_crashlytics_export_strings.xml
241 | crashlytics.properties
242 | crashlytics-build.properties
243 | fabric.properties
244 |
245 | # Editor-based Rest Client
246 | .idea/httpRequests
247 |
248 | # Android studio 3.1+ serialized cache file
249 | .idea/caches/build_file_checksums.ser
250 |
251 | ### JetBrains template
252 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
253 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
254 |
255 | # User-specific stuff
256 | .idea/**/workspace.xml
257 | .idea/**/tasks.xml
258 | .idea/**/usage.statistics.xml
259 | .idea/**/dictionaries
260 | .idea/**/shelf
261 |
262 | # Generated files
263 | .idea/**/contentModel.xml
264 |
265 | # Sensitive or high-churn files
266 | .idea/**/dataSources/
267 | .idea/**/dataSources.ids
268 | .idea/**/dataSources.local.xml
269 | .idea/**/sqlDataSources.xml
270 | .idea/**/dynamic.xml
271 | .idea/**/uiDesigner.xml
272 | .idea/**/dbnavigator.xml
273 |
274 | # Gradle
275 | .idea/**/gradle.xml
276 | .idea/**/libraries
277 |
278 | # Gradle and Maven with auto-import
279 | # When using Gradle or Maven with auto-import, you should exclude module files,
280 | # since they will be recreated, and may cause churn. Uncomment if using
281 | # auto-import.
282 | # .idea/artifacts
283 | # .idea/compiler.xml
284 | # .idea/jarRepositories.xml
285 | # .idea/modules.xml
286 | # .idea/*.iml
287 | # .idea/modules
288 | # *.iml
289 | # *.ipr
290 |
291 | # CMake
292 | cmake-build-*/
293 |
294 | # Mongo Explorer plugin
295 | .idea/**/mongoSettings.xml
296 |
297 | # File-based project format
298 | *.iws
299 |
300 | # IntelliJ
301 | out/
302 |
303 | # mpeltonen/sbt-idea plugin
304 | .idea_modules/
305 |
306 | # JIRA plugin
307 | atlassian-ide-plugin.xml
308 |
309 | # Cursive Clojure plugin
310 | .idea/replstate.xml
311 |
312 | # Crashlytics plugin (for Android Studio and IntelliJ)
313 | com_crashlytics_export_strings.xml
314 | crashlytics.properties
315 | crashlytics-build.properties
316 | fabric.properties
317 |
318 | # Editor-based Rest Client
319 | .idea/httpRequests
320 |
321 | # Android studio 3.1+ serialized cache file
322 | .idea/caches/build_file_checksums.ser
323 |
324 | ### JetBrains template
325 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
326 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
327 |
328 | # User-specific stuff
329 | .idea/**/workspace.xml
330 | .idea/**/tasks.xml
331 | .idea/**/usage.statistics.xml
332 | .idea/**/dictionaries
333 | .idea/**/shelf
334 |
335 | # Generated files
336 | .idea/**/contentModel.xml
337 |
338 | # Sensitive or high-churn files
339 | .idea/**/dataSources/
340 | .idea/**/dataSources.ids
341 | .idea/**/dataSources.local.xml
342 | .idea/**/sqlDataSources.xml
343 | .idea/**/dynamic.xml
344 | .idea/**/uiDesigner.xml
345 | .idea/**/dbnavigator.xml
346 |
347 | # Gradle
348 | .idea/**/gradle.xml
349 | .idea/**/libraries
350 |
351 | # Gradle and Maven with auto-import
352 | # When using Gradle or Maven with auto-import, you should exclude module files,
353 | # since they will be recreated, and may cause churn. Uncomment if using
354 | # auto-import.
355 | # .idea/artifacts
356 | # .idea/compiler.xml
357 | # .idea/jarRepositories.xml
358 | # .idea/modules.xml
359 | # .idea/*.iml
360 | # .idea/modules
361 | # *.iml
362 | # *.ipr
363 |
364 | # CMake
365 | cmake-build-*/
366 |
367 | # Mongo Explorer plugin
368 | .idea/**/mongoSettings.xml
369 |
370 | # File-based project format
371 | *.iws
372 |
373 | # IntelliJ
374 | out/
375 |
376 | # mpeltonen/sbt-idea plugin
377 | .idea_modules/
378 |
379 | # JIRA plugin
380 | atlassian-ide-plugin.xml
381 |
382 | # Cursive Clojure plugin
383 | .idea/replstate.xml
384 |
385 | # Crashlytics plugin (for Android Studio and IntelliJ)
386 | com_crashlytics_export_strings.xml
387 | crashlytics.properties
388 | crashlytics-build.properties
389 | fabric.properties
390 |
391 | # Editor-based Rest Client
392 | .idea/httpRequests
393 |
394 | # Android studio 3.1+ serialized cache file
395 | .idea/caches/build_file_checksums.ser
396 |
397 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 MCMDEV
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # BetterProtocol
2 | A Minecraft library for working with minecraft packets on various platforms, using MCProtocolLib
3 |
4 | **This library is still based on the proof of concept code and not refactored or optimized at all.**
5 | Use the betterprotocol-api module if you just want to access the API.
6 |
--------------------------------------------------------------------------------
/betterprotocol-api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | betterprotocol
7 | de.mcmdev
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | betterprotocol-api
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
20 |
21 | com.github.Steveice10
22 | MCProtocolLib
23 | 1.16.5-2
24 | compile
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/BetterProtocol.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol;
2 |
3 | import de.mcmdev.betterprotocol.api.BetterProtocolAPI;
4 |
5 | public class BetterProtocol {
6 |
7 | private static BetterProtocolAPI INSTANCE;
8 |
9 | public static void provide(BetterProtocolAPI INSTANCE) {
10 | if (BetterProtocol.INSTANCE != null) {
11 | throw new IllegalStateException("An instance has already been provided.");
12 | }
13 | BetterProtocol.INSTANCE = INSTANCE;
14 | }
15 |
16 | /**
17 | * Retrieves the API, which is provided by the platform you are running.
18 | *
19 | * @param
The platform's player type
20 | * @return The API interface
21 | */
22 | public static
BetterProtocolAPI
get() {
23 | if (INSTANCE == null) {
24 | throw new IllegalStateException(
25 | "No BetterProtocol instance provided. Please check if your platform is supported.");
26 | }
27 | return INSTANCE;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/BetterProtocolAPI.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | public interface BetterProtocolAPI
{
6 |
7 | /**
8 | * Sends a packet to the player
9 | *
10 | * @param player The target receiver
11 | * @param packet The packet you want to send
12 | */
13 | void send(P player, Packet packet);
14 |
15 | /**
16 | * Returns the EventBus used to register a {@link PacketListenerFunction}
17 | *
18 | * @return The EventBus
19 | */
20 | EventBus
getEventBus();
21 | }
22 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/EventBus.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | public interface EventBus
{
6 |
7 | /**
8 | * Registers a {@link PacketListenerFunction} for all incoming and outgoing packets of one class
9 | *
10 | * @param packetClass The packet type you want to listen to
11 | * @param packetListenerFunction Your packet listener
12 | */
13 | void listen(
14 | Class packetClass, PacketListenerFunction packetListenerFunction);
15 |
16 | /**
17 | * Registers all functions on the listener that are annotated with {@link PacketHandler} as
18 | * packet handlers.
19 | *
20 | * @param listener The listener whose handlers to register
21 | */
22 | void listen(PacketListener listener);
23 | }
24 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/PacketEvent.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | public class PacketEvent {
6 |
7 | private final P player;
8 | private final Class packetType;
9 | private T packet;
10 | private boolean cancelled = false;
11 |
12 | public PacketEvent(P player, Class packetType, T packet) {
13 | this.player = player;
14 | this.packetType = packetType;
15 | this.packet = packet;
16 | }
17 |
18 | /**
19 | * Returns the receiver/sender of the packet
20 | *
21 | * @return The receiver/sender of the packet
22 | */
23 | public P getPlayer() {
24 | return player;
25 | }
26 |
27 | /**
28 | * Returns the class of the packet
29 | *
30 | * @return The class of the packet
31 | */
32 | public Class getPacketType() {
33 | return packetType;
34 | }
35 |
36 | /**
37 | * Returns the involved packet itself
38 | *
39 | * @return The involved packet
40 | */
41 | public T getPacket() {
42 | return packet;
43 | }
44 |
45 | /**
46 | * Replaces the packet involved in the event
47 | *
48 | * @param packet The new packet
49 | */
50 | public void setPacket(T packet) {
51 | this.packet = packet;
52 | }
53 |
54 | /**
55 | * If true, prevents further processing/sending of the packet
56 | *
57 | * @param cancelled The cancel state
58 | */
59 | public void setCancelled(boolean cancelled) {
60 | this.cancelled = cancelled;
61 | }
62 |
63 | /**
64 | * If true, prevents further processing/sending of the packet
65 | *
66 | * @return The cancel state
67 | */
68 | public boolean isCancelled() {
69 | return cancelled;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/PacketHandler.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Functions marked with this annotation are registered as packet listeners when an instance of the
10 | * containing class is passed to {@link EventBus#listen(PacketListener)}.
11 | */
12 | @Target(ElementType.METHOD)
13 | @Retention(RetentionPolicy.RUNTIME)
14 | public @interface PacketHandler {
15 | // TODO: priority
16 | }
17 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/PacketListener.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | /**
4 | * Classes implementing this interface can be passed to {@link EventBus#listen(PacketListener)} to
5 | * register all of its methods annotated with {@link PacketHandler} as packet handlers.
6 | */
7 | public interface PacketListener {}
8 |
--------------------------------------------------------------------------------
/betterprotocol-api/src/main/java/de/mcmdev/betterprotocol/api/PacketListenerFunction.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.api;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | @FunctionalInterface
6 | public interface PacketListenerFunction {
7 |
8 | void handle(PacketEvent event);
9 | }
10 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | betterprotocol
7 | de.mcmdev
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | betterprotocol-bukkit
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
20 |
21 | de.mcmdev
22 | betterprotocol-common
23 | ${revision}
24 | compile
25 |
26 |
27 | org.spigotmc
28 | spigot
29 | 1.16.5-R0.1-SNAPSHOT
30 | provided
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/java/de/mcmdev/betterprotocol/bukkit/BetterProtocolBukkitPlugin.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bukkit;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | import de.mcmdev.betterprotocol.BetterProtocol;
6 | import de.mcmdev.betterprotocol.bukkit.inject.EncodingInjector;
7 | import de.mcmdev.betterprotocol.bukkit.inject.IncomingInjector;
8 | import de.mcmdev.betterprotocol.bukkit.inject.OutgoingInjector;
9 | import de.mcmdev.betterprotocol.common.BetterProtocolPlatform;
10 | import de.mcmdev.betterprotocol.common.BetterProtocolPlugin;
11 | import de.mcmdev.betterprotocol.common.inject.Injector;
12 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
13 |
14 | import org.bukkit.Bukkit;
15 | import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
16 | import org.bukkit.entity.Player;
17 | import org.bukkit.event.EventHandler;
18 | import org.bukkit.event.Listener;
19 | import org.bukkit.event.player.PlayerJoinEvent;
20 | import org.bukkit.event.player.PlayerQuitEvent;
21 | import org.bukkit.plugin.java.JavaPlugin;
22 |
23 | import java.util.Set;
24 |
25 | public class BetterProtocolBukkitPlugin extends JavaPlugin implements BetterProtocolPlugin {
26 |
27 | private BetterProtocolPlatform bukkitPlatform;
28 |
29 | @Override
30 | public void onEnable() {
31 | // create platform
32 | this.bukkitPlatform = new BetterProtocolPlatform<>(this, new CommonEventBus<>());
33 | this.bukkitPlatform.initialize();
34 |
35 | // provide the platform to the api singleton
36 | BetterProtocol.provide(this.bukkitPlatform);
37 | }
38 |
39 | @Override
40 | public void registerInjectors() {
41 | // register the three default injectors
42 | bukkitPlatform.registerInjector(
43 | new IncomingInjector(
44 | bukkitPlatform.getProtocolRegistry(), bukkitPlatform.getEventBus()));
45 | bukkitPlatform.registerInjector(
46 | new OutgoingInjector(
47 | bukkitPlatform.getProtocolRegistry(), bukkitPlatform.getEventBus()));
48 | bukkitPlatform.registerInjector(
49 | new EncodingInjector(
50 | bukkitPlatform.getProtocolRegistry(), bukkitPlatform.getEventBus()));
51 | }
52 |
53 | @Override
54 | public void registerListeners(Set> injectors) {
55 | getServer()
56 | .getPluginManager()
57 | .registerEvents(
58 | new Listener() {
59 |
60 | @EventHandler
61 | public void onJoin(PlayerJoinEvent event) {
62 | // inject all injectors in join
63 | injectors.forEach(injector -> injector.inject(event.getPlayer()));
64 | }
65 |
66 | @EventHandler
67 | public void onQuit(PlayerQuitEvent event) {
68 | // uninject all injectors on quit
69 | injectors.forEach(injector -> injector.uninject(event.getPlayer()));
70 | }
71 | },
72 | this);
73 | }
74 |
75 | @Override
76 | public String getVersion() {
77 | return Bukkit.getVersion();
78 | }
79 |
80 | @Override
81 | public void send(Player player, Packet packet) {
82 | ((CraftPlayer) player)
83 | .getHandle()
84 | .playerConnection
85 | .networkManager
86 | .channel
87 | .writeAndFlush(packet);
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/java/de/mcmdev/betterprotocol/bukkit/inject/BukkitInjector.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bukkit.inject;
2 |
3 | import de.mcmdev.betterprotocol.common.inject.Injector;
4 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
5 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
6 | import io.netty.channel.Channel;
7 | import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
8 | import org.bukkit.entity.Player;
9 |
10 | public abstract class BukkitInjector extends Injector {
11 |
12 | public BukkitInjector(
13 | String stage,
14 | String name,
15 | AbstractProtocolRegistry protocolRegistry,
16 | CommonEventBus bukkitEventBus) {
17 | super(stage, name, protocolRegistry, bukkitEventBus);
18 | }
19 |
20 | public void inject(Player player) {
21 | Channel channel =
22 | ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel;
23 | // don't inject if the Injector is already there
24 | if (channel.pipeline().get(name) != null) return;
25 | // add the injector before the stage
26 | channel.pipeline().addBefore(stage, name, getHandler(player));
27 | }
28 |
29 | public void uninject(Player player) {
30 | Channel channel =
31 | ((CraftPlayer) player).getHandle().playerConnection.networkManager.channel;
32 | // don't uninject the Injector if it isn't there
33 | if (channel.pipeline().get(name) == null) return;
34 | channel.pipeline().remove(name);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/java/de/mcmdev/betterprotocol/bukkit/inject/EncodingInjector.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bukkit.inject;
2 |
3 | import de.mcmdev.betterprotocol.common.handler.EncodingChannelHandler;
4 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
5 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
6 |
7 | import io.netty.channel.ChannelHandler;
8 |
9 | import org.bukkit.entity.Player;
10 |
11 | public class EncodingInjector extends BukkitInjector {
12 |
13 | public EncodingInjector(
14 | AbstractProtocolRegistry protocolRegistry, CommonEventBus eventBus) {
15 | super(
16 | "better_protocol_outgoing_listener",
17 | "better_protocol_encoder",
18 | protocolRegistry,
19 | eventBus);
20 | }
21 |
22 | @Override
23 | public ChannelHandler getHandler(Player player) {
24 | return new EncodingChannelHandler(protocolRegistry);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/java/de/mcmdev/betterprotocol/bukkit/inject/IncomingInjector.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bukkit.inject;
2 |
3 | import de.mcmdev.betterprotocol.common.handler.RewritingReadChannelHandler;
4 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
5 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
6 |
7 | import io.netty.channel.ChannelHandler;
8 |
9 | import org.bukkit.entity.Player;
10 |
11 | public class IncomingInjector extends BukkitInjector {
12 |
13 | public IncomingInjector(
14 | AbstractProtocolRegistry protocolRegistry, CommonEventBus eventBus) {
15 | super("decoder", "better_protocol_incoming_listener", protocolRegistry, eventBus);
16 | }
17 |
18 | @Override
19 | public ChannelHandler getHandler(Player player) {
20 | return new RewritingReadChannelHandler<>(player, protocolRegistry, eventBus);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/java/de/mcmdev/betterprotocol/bukkit/inject/OutgoingInjector.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bukkit.inject;
2 |
3 | import de.mcmdev.betterprotocol.common.handler.RewritingWriteChannelHandler;
4 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
5 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
6 |
7 | import io.netty.channel.ChannelHandler;
8 |
9 | import org.bukkit.entity.Player;
10 |
11 | public class OutgoingInjector extends BukkitInjector {
12 |
13 | public OutgoingInjector(
14 | AbstractProtocolRegistry protocolRegistry, CommonEventBus eventBus) {
15 | super("encoder", "better_protocol_outgoing_listener", protocolRegistry, eventBus);
16 | }
17 |
18 | @Override
19 | public ChannelHandler getHandler(Player player) {
20 | return new RewritingWriteChannelHandler<>(player, protocolRegistry, eventBus);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/betterprotocol-bukkit/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: BetterProtocol
2 | version: 1.0
3 | author: MCMDEV
4 | api-version: 1.16
5 | main: de.mcmdev.betterprotocol.bukkit.BetterProtocolBukkitPlugin
6 | load: STARTUP
7 |
--------------------------------------------------------------------------------
/betterprotocol-bungee/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | betterprotocol
7 | de.mcmdev
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | betterprotocol-bungee
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
20 |
21 | de.mcmdev
22 | betterprotocol-common
23 | ${revision}
24 |
25 |
26 | net.md-5
27 | bungeecord-api
28 | 1.17-R0.1-SNAPSHOT
29 | jar
30 | provided
31 |
32 |
33 | net.md-5
34 | bungeecord-api
35 | 1.17-R0.1-SNAPSHOT
36 | javadoc
37 | provided
38 |
39 |
40 | net.md-5
41 | bungeecord-proxy
42 | 1.17-R0.1-SNAPSHOT
43 | jar
44 | provided
45 |
46 |
47 | org.jooq
48 | joor-java-8
49 | 0.9.13
50 |
51 |
52 |
--------------------------------------------------------------------------------
/betterprotocol-bungee/src/main/java/de/mcmdev/betterprotocol/bungee/BetterProtocolBungeePlugin.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bungee;
2 |
3 | import net.md_5.bungee.api.plugin.Plugin;
4 |
5 | public class BetterProtocolBungeePlugin extends Plugin {
6 |
7 | @Override
8 | public void onEnable() {
9 | getProxy().getPluginManager().registerListener(this, new TestListener());
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/betterprotocol-bungee/src/main/java/de/mcmdev/betterprotocol/bungee/TestListener.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.bungee;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetInput;
5 |
6 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
7 | import de.mcmdev.betterprotocol.common.protocol.ProtocolRegistry_1_16_5;
8 |
9 | import io.netty.buffer.ByteBuf;
10 | import io.netty.channel.Channel;
11 | import io.netty.channel.ChannelDuplexHandler;
12 | import io.netty.channel.ChannelHandlerContext;
13 |
14 | import net.md_5.bungee.UserConnection;
15 | import net.md_5.bungee.api.event.PostLoginEvent;
16 | import net.md_5.bungee.api.plugin.Listener;
17 | import net.md_5.bungee.event.EventHandler;
18 | import net.md_5.bungee.netty.ChannelWrapper;
19 |
20 | import org.joor.Reflect;
21 |
22 | public class TestListener implements Listener {
23 |
24 | private final AbstractProtocolRegistry abstractProtocolRegistry = new ProtocolRegistry_1_16_5();
25 |
26 | @EventHandler
27 | public void onJoin(PostLoginEvent event) {
28 | Channel channel = getChannelWrapper((UserConnection) event.getPlayer()).getHandle();
29 | System.out.println(channel.pipeline().toMap());
30 | channel.pipeline()
31 | .addBefore(
32 | "packet-decoder",
33 | "better_protocol_decoder",
34 | new ChannelDuplexHandler() {
35 | @Override
36 | public void channelRead(ChannelHandlerContext ctx, Object msg)
37 | throws Exception {
38 | ByteBuf byteBuf = (ByteBuf) msg;
39 | int readerIndex = byteBuf.readerIndex();
40 | ByteBufNetInput netInput = new ByteBufNetInput(byteBuf);
41 | int i =
42 | abstractProtocolRegistry
43 | .getPacketHeader()
44 | .readPacketId(netInput);
45 | Packet packet = abstractProtocolRegistry.createIncomingPacket(i);
46 | packet.read(netInput);
47 |
48 | System.out.println(packet);
49 |
50 | byteBuf.readerIndex(readerIndex);
51 | super.channelRead(ctx, byteBuf);
52 | }
53 | });
54 | }
55 |
56 | private ChannelWrapper getChannelWrapper(UserConnection userConnection) {
57 | return Reflect.on(userConnection).get("ch");
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/betterprotocol-bungee/src/main/resources/bungee.yml:
--------------------------------------------------------------------------------
1 | name: BetterProtocol
2 | main: de.mcmdev.betterprotocol.bungee.BetterProtocolBungeePlugin
3 | version: v0.1
4 | author: MCMDEV
--------------------------------------------------------------------------------
/betterprotocol-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | betterprotocol
7 | de.mcmdev
8 | ${revision}
9 |
10 | 4.0.0
11 |
12 | betterprotocol-common
13 |
14 |
15 | 8
16 | 8
17 |
18 |
19 |
20 |
21 | de.mcmdev
22 | betterprotocol-api
23 | ${revision}
24 | compile
25 |
26 |
27 | com.google.guava
28 | guava
29 | 30.1.1-jre
30 | provided
31 |
32 |
33 | com.github.Nesaak
34 | NoReflection
35 | 28e3db8
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/BetterProtocolPlatform.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 | import de.mcmdev.betterprotocol.api.BetterProtocolAPI;
5 | import de.mcmdev.betterprotocol.common.inject.Injector;
6 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
7 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
8 | import de.mcmdev.betterprotocol.common.protocol.ProtocolRegistry_1_16_5;
9 |
10 | import java.util.HashSet;
11 | import java.util.Set;
12 |
13 | /**
14 | * The common core of BetterProtocol, which implements the API
15 | *
16 | * @param The player type
17 | */
18 | public class BetterProtocolPlatform
implements BetterProtocolAPI
{
19 |
20 | private final BetterProtocolPlugin
plugin;
21 | private AbstractProtocolRegistry protocolRegistry;
22 | private final CommonEventBus
eventBus;
23 | private final Set> injectors = new HashSet<>();
24 |
25 | public BetterProtocolPlatform(BetterProtocolPlugin plugin, CommonEventBus
eventBus) {
26 | this.plugin = plugin;
27 | this.eventBus = eventBus;
28 | }
29 |
30 | public void initialize() {
31 | // use a protocol registry for the current version
32 | this.protocolRegistry = findProtocolRegistry();
33 |
34 | // register all the plugin injectors
35 | plugin.registerInjectors();
36 |
37 | // register listeners to inject these injectors
38 | plugin.registerListeners(injectors);
39 | }
40 |
41 | @Override
42 | public void send(P player, Packet packet) {
43 | plugin.send(player, packet);
44 | }
45 |
46 | public void registerInjector(Injector
injector) {
47 | this.injectors.add(injector);
48 | }
49 |
50 | public AbstractProtocolRegistry getProtocolRegistry() {
51 | return protocolRegistry;
52 | }
53 |
54 | @Override
55 | public CommonEventBus
getEventBus() {
56 | return eventBus;
57 | }
58 |
59 | private AbstractProtocolRegistry findProtocolRegistry() {
60 | if (plugin.getVersion().contains("1.16.5")) {
61 | return new ProtocolRegistry_1_16_5();
62 | }
63 |
64 | throw new IllegalStateException("Unsupported version " + plugin.getVersion());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/BetterProtocolPlugin.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 |
5 | import de.mcmdev.betterprotocol.common.inject.Injector;
6 |
7 | import java.util.Set;
8 |
9 | /**
10 | * Provides access to required platform-dependent methods
11 | *
12 | * @param
13 | */
14 | public interface BetterProtocolPlugin
{
15 |
16 | void send(P player, Packet packet);
17 |
18 | void registerInjectors();
19 |
20 | void registerListeners(Set> injectors);
21 |
22 | String getVersion();
23 | }
24 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/handler/EncodingChannelHandler.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.handler;
2 |
3 | import com.github.steveice10.packetlib.io.NetOutput;
4 | import com.github.steveice10.packetlib.packet.Packet;
5 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetOutput;
6 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
7 | import io.netty.buffer.ByteBuf;
8 | import io.netty.channel.ChannelHandlerContext;
9 | import io.netty.handler.codec.MessageToByteEncoder;
10 |
11 | /**
12 | * A ChannelHandler that encodes {@link Packet}s so they can be send to a player using {@link
13 | * de.mcmdev.betterprotocol.api.BetterProtocolAPI#send(Object, Packet)}
14 | */
15 | public class EncodingChannelHandler extends MessageToByteEncoder {
16 |
17 | private final AbstractProtocolRegistry protocolRegistry;
18 |
19 | public EncodingChannelHandler(AbstractProtocolRegistry protocolRegistry) {
20 | this.protocolRegistry = protocolRegistry;
21 | }
22 |
23 | @Override
24 | protected void encode(ChannelHandlerContext ctx, Packet packet, ByteBuf byteBuf) {
25 | // safe the writerIndex before the encoding
26 | int before = byteBuf.writerIndex();
27 | try {
28 | // create a NetOutput, which Packet data can be written to, write the packet id, and
29 | // then the packet data.
30 | NetOutput out = new ByteBufNetOutput(byteBuf);
31 | protocolRegistry
32 | .getPacketHeader()
33 | .writePacketId(out, protocolRegistry.getOutgoingId(packet));
34 | packet.write(out);
35 | } catch (Throwable t) {
36 | // in case of error, set writerIndex from before
37 | byteBuf.writerIndex(before);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/handler/RewritingReadChannelHandler.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.handler;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetInput;
5 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetOutput;
6 | import de.mcmdev.betterprotocol.api.PacketEvent;
7 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
8 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
9 | import io.netty.buffer.ByteBuf;
10 | import io.netty.buffer.Unpooled;
11 | import io.netty.channel.ChannelHandlerContext;
12 | import io.netty.channel.ChannelInboundHandlerAdapter;
13 |
14 | /**
15 | * Reads all incoming packets, fires a {@link PacketEvent} and rewrites or cancels the packet when
16 | * necessary
17 | *
18 | * @param The player type
19 | */
20 | public class RewritingReadChannelHandler
extends ChannelInboundHandlerAdapter {
21 |
22 | private final P player;
23 | private final AbstractProtocolRegistry protocolRegistry;
24 | private final CommonEventBus
eventBus;
25 |
26 | public RewritingReadChannelHandler(
27 | P player, AbstractProtocolRegistry protocolRegistry, CommonEventBus
eventBus) {
28 | this.player = player;
29 | this.protocolRegistry = protocolRegistry;
30 | this.eventBus = eventBus;
31 | }
32 |
33 | @Override
34 | public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
35 | // read the packet id from the data, create an incoming packet from the id, and write the
36 | // data to the packet
37 | ByteBuf byteBuf = (ByteBuf) msg;
38 | ByteBufNetInput netInput = new ByteBufNetInput(byteBuf);
39 | int i = protocolRegistry.getPacketHeader().readPacketId(netInput);
40 | Packet packet = protocolRegistry.createIncomingPacket(i);
41 | packet.read(netInput);
42 |
43 | // fire a packet event
44 | PacketEvent packetEvent = new PacketEvent(player, packet.getClass(), packet);
45 | eventBus.post(packetEvent);
46 |
47 | // don't handle the packet further if the event was cancelled
48 | if (packetEvent.isCancelled()) return;
49 |
50 | // create a new buffer, write the packet id and packet data
51 | ByteBuf buffer = Unpooled.buffer();
52 | ByteBufNetOutput netOutput = new ByteBufNetOutput(buffer);
53 | protocolRegistry
54 | .getPacketHeader()
55 | .writePacketId(netOutput, protocolRegistry.getIncomingId(packetEvent.getPacket()));
56 | packetEvent.getPacket().write(netOutput);
57 |
58 | byteBuf.resetReaderIndex();
59 |
60 | // pass the new packet
61 | super.channelRead(ctx, buffer);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/handler/RewritingWriteChannelHandler.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.handler;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetInput;
5 | import com.github.steveice10.packetlib.tcp.io.ByteBufNetOutput;
6 | import de.mcmdev.betterprotocol.api.PacketEvent;
7 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
8 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
9 | import io.netty.buffer.ByteBuf;
10 | import io.netty.buffer.Unpooled;
11 | import io.netty.channel.ChannelHandlerContext;
12 | import io.netty.channel.ChannelOutboundHandlerAdapter;
13 | import io.netty.channel.ChannelPromise;
14 |
15 | /**
16 | * Reads all outgoing packets, fires a {@link PacketEvent} and rewrites or cancels the packet when
17 | * necessary. Can also listen to {@link Packet}'s sent using the API
18 | *
19 | * @param
The player type
20 | */
21 | public class RewritingWriteChannelHandler
extends ChannelOutboundHandlerAdapter {
22 |
23 | private final P player;
24 | private final AbstractProtocolRegistry protocolRegistry;
25 | private final CommonEventBus
eventBus;
26 |
27 | public RewritingWriteChannelHandler(
28 | P player, AbstractProtocolRegistry protocolRegistry, CommonEventBus
eventBus) {
29 | this.player = player;
30 | this.protocolRegistry = protocolRegistry;
31 | this.eventBus = eventBus;
32 | }
33 |
34 | @Override
35 | public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
36 | throws Exception {
37 |
38 | // if the passing data already is a packet (from send method), just fire the event, cancel
39 | // if needed, and pass
40 | if (msg instanceof Packet) {
41 | Packet packet = (Packet) msg;
42 | PacketEvent packetEvent = new PacketEvent(player, packet.getClass(), packet);
43 | eventBus.post(packetEvent);
44 | if (packetEvent.isCancelled()) return;
45 |
46 | super.write(ctx, packetEvent.getPacket(), promise);
47 | return;
48 | }
49 |
50 | // read the packet id from data, create an outgoing packet from the id, and write the data
51 | // to the packet
52 | ByteBuf byteBuf = (ByteBuf) msg;
53 | ByteBufNetInput netInput = new ByteBufNetInput(byteBuf);
54 | int i = protocolRegistry.getPacketHeader().readPacketId(netInput);
55 | Packet packet = protocolRegistry.createOutgoingPacket(i);
56 | packet.read(netInput);
57 |
58 | // fire a packet event
59 | PacketEvent packetEvent = new PacketEvent(player, packet.getClass(), packet);
60 | eventBus.post(packetEvent);
61 |
62 | // don't handle the packet further if the event was cancelled
63 | if (packetEvent.isCancelled()) return;
64 |
65 | // create a new buffer, write the packet id and packet data
66 | ByteBuf buffer = Unpooled.buffer();
67 | ByteBufNetOutput netOutput = new ByteBufNetOutput(buffer);
68 | protocolRegistry
69 | .getPacketHeader()
70 | .writePacketId(netOutput, protocolRegistry.getOutgoingId(packetEvent.getPacket()));
71 | packetEvent.getPacket().write(netOutput);
72 |
73 | byteBuf.resetReaderIndex();
74 |
75 | // pass the new packet
76 | super.write(ctx, buffer, promise);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/inject/Injector.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.inject;
2 |
3 | import de.mcmdev.betterprotocol.common.listener.CommonEventBus;
4 | import de.mcmdev.betterprotocol.common.protocol.AbstractProtocolRegistry;
5 |
6 | import io.netty.channel.ChannelHandler;
7 |
8 | /**
9 | * A netty pipeline injector
10 | *
11 | * @param
12 | */
13 | public abstract class Injector
{
14 |
15 | /** The name of the reference handler. The injector will inject before this handler. */
16 | protected final String stage;
17 |
18 | protected final String name;
19 | protected final AbstractProtocolRegistry protocolRegistry;
20 | protected final CommonEventBus
eventBus;
21 |
22 | public Injector(
23 | String stage,
24 | String name,
25 | AbstractProtocolRegistry protocolRegistry,
26 | CommonEventBus
eventBus) {
27 | this.stage = stage;
28 | this.name = name;
29 | this.protocolRegistry = protocolRegistry;
30 | this.eventBus = eventBus;
31 | }
32 |
33 | /**
34 | * The {@link ChannelHandler} you want to inject
35 | *
36 | * @param player The player type, used by some ChannelHandlers
37 | * @return The channel handler
38 | */
39 | public abstract ChannelHandler getHandler(P player);
40 |
41 | /**
42 | * Injects the ChannelHandler into the player's netty pipeline
43 | *
44 | * @param player The target player
45 | */
46 | public abstract void inject(P player);
47 |
48 | /**
49 | * Removes the ChannelHandler from the player's netty pipeline
50 | *
51 | * @param player The target player
52 | */
53 | public abstract void uninject(P player);
54 | }
55 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/listener/CommonEventBus.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.listener;
2 |
3 | import com.github.steveice10.packetlib.packet.Packet;
4 | import com.nesaak.noreflection.NoReflection;
5 | import com.nesaak.noreflection.access.DynamicCaller;
6 |
7 | import de.mcmdev.betterprotocol.api.EventBus;
8 | import de.mcmdev.betterprotocol.api.PacketEvent;
9 | import de.mcmdev.betterprotocol.api.PacketHandler;
10 | import de.mcmdev.betterprotocol.api.PacketListener;
11 | import de.mcmdev.betterprotocol.api.PacketListenerFunction;
12 |
13 | import java.lang.reflect.Method;
14 | import java.lang.reflect.ParameterizedType;
15 | import java.lang.reflect.Type;
16 | import java.util.ArrayList;
17 | import java.util.HashMap;
18 | import java.util.List;
19 | import java.util.Map;
20 |
21 | /**
22 | * Holds all registered {@link PacketListenerFunction}'s and fires them
23 | *
24 | * @param
The player type
25 | */
26 | public class CommonEventBus
implements EventBus
{
27 |
28 | private final Map, List> listenerMap =
29 | new HashMap<>();
30 |
31 | public void listen(
32 | Class packetClass, PacketListenerFunction packetListenerFunction) {
33 | // register the listener for the packet, create a list and put it, if it doesn't already
34 | // exist
35 | listenerMap.putIfAbsent(packetClass, new ArrayList<>());
36 | listenerMap.get(packetClass).add(packetListenerFunction);
37 | }
38 |
39 | @Override
40 | public void listen(PacketListener listener) {
41 | // traverse the class hierarchy upwards
42 | // to find annotated methods across all superclasses
43 | Class> clazz = listener.getClass();
44 | while (!clazz.equals(Object.class)) {
45 | for (Method method : clazz.getDeclaredMethods()) {
46 | // check the presence of the annotation
47 | PacketHandler packetHandlerAnnotation = method.getAnnotation(PacketHandler.class);
48 | if (packetHandlerAnnotation == null) {
49 | continue;
50 | }
51 |
52 | // check the method signature
53 | if (method.getReturnType() != void.class) {
54 | throw new IllegalArgumentException(
55 | "Methods annotated with @PacketHandler must return void");
56 | }
57 |
58 | if (method.getParameterCount() != 1
59 | || !PacketEvent.class.isAssignableFrom(method.getParameterTypes()[0])) {
60 | throw new IllegalArgumentException(
61 | "Methods annotated with @PacketHandler must have a PacketEvent as the only argument");
62 | }
63 |
64 | // determine the packet event's packet type (first generic type argument)
65 | if (!(method.getGenericParameterTypes()[0] instanceof ParameterizedType)) {
66 | throw new IllegalArgumentException(
67 | "Could not determine the PacketEvent's Packet generic parameter - is it defined?");
68 | }
69 |
70 | Type packetType =
71 | ((ParameterizedType) method.getGenericParameterTypes()[0])
72 | .getActualTypeArguments()[0];
73 | if (!(packetType instanceof Class)) {
74 | throw new IllegalArgumentException(
75 | "Could not determine the PacketEvent's Packet generic parameter's class");
76 | }
77 |
78 | Class extends Packet> packetClass = (Class extends Packet>) packetType;
79 |
80 | // the annotation is present and the signature is correct -
81 | // register the method as a listener using a lambda
82 | // instead of reflection for invocation to increase performance
83 | DynamicCaller noReflectionMethod = NoReflection.shared().get(method);
84 |
85 | listen(
86 | packetClass,
87 | event -> {
88 | noReflectionMethod.call(listener, event);
89 | });
90 | }
91 |
92 | clazz = clazz.getSuperclass();
93 | }
94 | }
95 |
96 | public void post(PacketEvent, P> event) {
97 | List packetListenerFunctions =
98 | listenerMap.get(event.getPacketType());
99 | if (packetListenerFunctions == null) {
100 | return;
101 | }
102 | packetListenerFunctions.forEach(
103 | packetListenerFunction -> packetListenerFunction.handle(event));
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/protocol/AbstractProtocolRegistry.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.protocol;
2 |
3 | import com.github.steveice10.packetlib.packet.BufferedPacket;
4 | import com.github.steveice10.packetlib.packet.DefaultPacketHeader;
5 | import com.github.steveice10.packetlib.packet.Packet;
6 | import com.github.steveice10.packetlib.packet.PacketHeader;
7 | import com.google.common.collect.BiMap;
8 | import com.google.common.collect.HashBiMap;
9 |
10 | import java.lang.reflect.Constructor;
11 |
12 | /**
13 | * A registry that maps packet id's to their respective {@link Packet} classes Implementations are
14 | * dependent on a version of MCProtocolLib
15 | *
16 | * Implementations for all versions are in common to support multi-version platforms like
17 | * BungeeCord
18 | */
19 | public abstract class AbstractProtocolRegistry {
20 |
21 | private final BiMap> incoming = HashBiMap.create();
22 | private final BiMap> outgoing = HashBiMap.create();
23 |
24 | private final PacketHeader packetHeader = new DefaultPacketHeader();
25 |
26 | public PacketHeader getPacketHeader() {
27 | return packetHeader;
28 | }
29 |
30 | public final void registerIncoming(int id, Class extends Packet> packet) {
31 | this.incoming.put(id, packet);
32 | }
33 |
34 | public final void registerOutgoing(int id, Class extends Packet> packet) {
35 | this.outgoing.put(id, packet);
36 | }
37 |
38 | public final Packet createIncomingPacket(int id) {
39 | Class extends Packet> packet = this.incoming.get(id);
40 | if (packet == null) {
41 | throw new IllegalArgumentException("Invalid packet id: " + id);
42 | } else {
43 | try {
44 | Constructor extends Packet> constructor = packet.getDeclaredConstructor();
45 | if (!constructor.isAccessible()) {
46 | constructor.setAccessible(true);
47 | }
48 |
49 | return constructor.newInstance();
50 | } catch (NoSuchMethodError var4) {
51 | throw new IllegalStateException(
52 | "Packet \""
53 | + id
54 | + ", "
55 | + packet.getName()
56 | + "\" does not have a no-params constructor for instantiation.");
57 | } catch (Exception var5) {
58 | throw new IllegalStateException(
59 | "Failed to instantiate packet \"" + id + ", " + packet.getName() + "\".",
60 | var5);
61 | }
62 | }
63 | }
64 |
65 | public final int getIncomingId(Class extends Packet> packetClass) {
66 | Integer packetId = this.incoming.inverse().get(packetClass);
67 | if (packetId == null) {
68 | throw new IllegalArgumentException(
69 | "Unregistered outgoing packet class: " + packetClass.getName());
70 | } else {
71 | return packetId;
72 | }
73 | }
74 |
75 | public final int getIncomingId(Packet packet) {
76 | return packet instanceof BufferedPacket
77 | ? this.getIncomingId(((BufferedPacket) packet).getPacketClass())
78 | : this.getIncomingId(packet.getClass());
79 | }
80 |
81 | public final int getOutgoingId(Class extends Packet> packetClass) {
82 | Integer packetId = this.outgoing.inverse().get(packetClass);
83 | if (packetId == null) {
84 | throw new IllegalArgumentException(
85 | "Unregistered outgoing packet class: " + packetClass.getName());
86 | } else {
87 | return packetId;
88 | }
89 | }
90 |
91 | public final int getOutgoingId(Packet packet) {
92 | return packet instanceof BufferedPacket
93 | ? this.getIncomingId(((BufferedPacket) packet).getPacketClass())
94 | : this.getOutgoingId(packet.getClass());
95 | }
96 |
97 | public final Packet createOutgoingPacket(int id) {
98 | Class extends Packet> packet = this.outgoing.get(id);
99 | if (packet == null) {
100 | throw new IllegalArgumentException("Invalid packet id: " + id);
101 | } else {
102 | try {
103 | Constructor extends Packet> constructor = packet.getDeclaredConstructor();
104 | if (!constructor.isAccessible()) {
105 | constructor.setAccessible(true);
106 | }
107 |
108 | return constructor.newInstance();
109 | } catch (NoSuchMethodError var4) {
110 | throw new IllegalStateException(
111 | "Packet \""
112 | + id
113 | + ", "
114 | + packet.getName()
115 | + "\" does not have a no-params constructor for instantiation.");
116 | } catch (Exception var5) {
117 | throw new IllegalStateException(
118 | "Failed to instantiate packet \"" + id + ", " + packet.getName() + "\".",
119 | var5);
120 | }
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/betterprotocol-common/src/main/java/de/mcmdev/betterprotocol/common/protocol/ProtocolRegistry_1_16_5.java:
--------------------------------------------------------------------------------
1 | package de.mcmdev.betterprotocol.common.protocol;
2 |
3 | import com.github.steveice10.mc.protocol.packet.ingame.client.*;
4 | import com.github.steveice10.mc.protocol.packet.ingame.client.player.*;
5 | import com.github.steveice10.mc.protocol.packet.ingame.client.window.*;
6 | import com.github.steveice10.mc.protocol.packet.ingame.client.world.*;
7 | import com.github.steveice10.mc.protocol.packet.ingame.server.*;
8 | import com.github.steveice10.mc.protocol.packet.ingame.server.entity.*;
9 | import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.*;
10 | import com.github.steveice10.mc.protocol.packet.ingame.server.entity.spawn.*;
11 | import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
12 | import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
13 | import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
14 | import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
15 | import com.github.steveice10.mc.protocol.packet.ingame.server.window.*;
16 | import com.github.steveice10.mc.protocol.packet.ingame.server.world.*;
17 |
18 | public class ProtocolRegistry_1_16_5 extends AbstractProtocolRegistry {
19 |
20 | public ProtocolRegistry_1_16_5() {
21 | this.registerIncoming(0x00, ClientTeleportConfirmPacket.class);
22 | this.registerIncoming(0x01, ClientBlockNBTRequestPacket.class);
23 | this.registerIncoming(0x02, ClientSetDifficultyPacket.class);
24 | this.registerIncoming(0x03, ClientChatPacket.class);
25 | this.registerIncoming(0x04, ClientRequestPacket.class);
26 | this.registerIncoming(0x05, ClientSettingsPacket.class);
27 | this.registerIncoming(0x06, ClientTabCompletePacket.class);
28 | this.registerIncoming(0x07, ClientConfirmTransactionPacket.class);
29 | this.registerIncoming(0x08, ClientClickWindowButtonPacket.class);
30 | this.registerIncoming(0x09, ClientWindowActionPacket.class);
31 | this.registerIncoming(0x0A, ClientCloseWindowPacket.class);
32 | this.registerIncoming(0x0B, ClientPluginMessagePacket.class);
33 | this.registerIncoming(0x0C, ClientEditBookPacket.class);
34 | this.registerIncoming(0x0D, ClientEntityNBTRequestPacket.class);
35 | this.registerIncoming(0x0E, ClientPlayerInteractEntityPacket.class);
36 | this.registerIncoming(0x0F, ClientGenerateStructuresPacket.class);
37 | this.registerIncoming(0x10, ClientKeepAlivePacket.class);
38 | this.registerIncoming(0x11, ClientLockDifficultyPacket.class);
39 | this.registerIncoming(0x12, ClientPlayerPositionPacket.class);
40 | this.registerIncoming(0x13, ClientPlayerPositionRotationPacket.class);
41 | this.registerIncoming(0x14, ClientPlayerRotationPacket.class);
42 | this.registerIncoming(0x15, ClientPlayerMovementPacket.class);
43 | this.registerIncoming(0x16, ClientVehicleMovePacket.class);
44 | this.registerIncoming(0x17, ClientSteerBoatPacket.class);
45 | this.registerIncoming(0x18, ClientMoveItemToHotbarPacket.class);
46 | this.registerIncoming(0x19, ClientPrepareCraftingGridPacket.class);
47 | this.registerIncoming(0x1A, ClientPlayerAbilitiesPacket.class);
48 | this.registerIncoming(0x1B, ClientPlayerActionPacket.class);
49 | this.registerIncoming(0x1C, ClientPlayerStatePacket.class);
50 | this.registerIncoming(0x1D, ClientSteerVehiclePacket.class);
51 | this.registerIncoming(0x1E, ClientCraftingBookStatePacket.class);
52 | this.registerIncoming(0x1F, ClientDisplayedRecipePacket.class);
53 | this.registerIncoming(0x20, ClientRenameItemPacket.class);
54 | this.registerIncoming(0x21, ClientResourcePackStatusPacket.class);
55 | this.registerIncoming(0x22, ClientAdvancementTabPacket.class);
56 | this.registerIncoming(0x23, ClientSelectTradePacket.class);
57 | this.registerIncoming(0x24, ClientSetBeaconEffectPacket.class);
58 | this.registerIncoming(0x25, ClientPlayerChangeHeldItemPacket.class);
59 | this.registerIncoming(0x26, ClientUpdateCommandBlockPacket.class);
60 | this.registerIncoming(0x27, ClientUpdateCommandBlockMinecartPacket.class);
61 | this.registerIncoming(0x28, ClientCreativeInventoryActionPacket.class);
62 | this.registerIncoming(0x29, ClientUpdateJigsawBlockPacket.class);
63 | this.registerIncoming(0x2A, ClientUpdateStructureBlockPacket.class);
64 | this.registerIncoming(0x2B, ClientUpdateSignPacket.class);
65 | this.registerIncoming(0x2C, ClientPlayerSwingArmPacket.class);
66 | this.registerIncoming(0x2D, ClientSpectatePacket.class);
67 | this.registerIncoming(0x2E, ClientPlayerPlaceBlockPacket.class);
68 | this.registerIncoming(0x2F, ClientPlayerUseItemPacket.class);
69 |
70 | this.registerOutgoing(0x00, ServerSpawnEntityPacket.class);
71 | this.registerOutgoing(0x01, ServerSpawnExpOrbPacket.class);
72 | this.registerOutgoing(0x02, ServerSpawnLivingEntityPacket.class);
73 | this.registerOutgoing(0x03, ServerSpawnPaintingPacket.class);
74 | this.registerOutgoing(0x04, ServerSpawnPlayerPacket.class);
75 | this.registerOutgoing(0x05, ServerEntityAnimationPacket.class);
76 | this.registerOutgoing(0x06, ServerStatisticsPacket.class);
77 | this.registerOutgoing(0x07, ServerPlayerActionAckPacket.class);
78 | this.registerOutgoing(0x08, ServerBlockBreakAnimPacket.class);
79 | this.registerOutgoing(0x09, ServerUpdateTileEntityPacket.class);
80 | this.registerOutgoing(0x0A, ServerBlockValuePacket.class);
81 | this.registerOutgoing(0x0B, ServerBlockChangePacket.class);
82 | this.registerOutgoing(0x0C, ServerBossBarPacket.class);
83 | this.registerOutgoing(0x0D, ServerDifficultyPacket.class);
84 | this.registerOutgoing(0x0E, ServerChatPacket.class);
85 | this.registerOutgoing(0x0F, ServerTabCompletePacket.class);
86 | this.registerOutgoing(0x10, ServerDeclareCommandsPacket.class);
87 | this.registerOutgoing(0x11, ServerConfirmTransactionPacket.class);
88 | this.registerOutgoing(0x12, ServerCloseWindowPacket.class);
89 | this.registerOutgoing(0x13, ServerWindowItemsPacket.class);
90 | this.registerOutgoing(0x14, ServerWindowPropertyPacket.class);
91 | this.registerOutgoing(0x15, ServerSetSlotPacket.class);
92 | this.registerOutgoing(0x16, ServerSetCooldownPacket.class);
93 | this.registerOutgoing(0x17, ServerPluginMessagePacket.class);
94 | this.registerOutgoing(0x18, ServerPlaySoundPacket.class);
95 | this.registerOutgoing(0x19, ServerDisconnectPacket.class);
96 | this.registerOutgoing(0x1A, ServerEntityStatusPacket.class);
97 | this.registerOutgoing(0x1B, ServerExplosionPacket.class);
98 | this.registerOutgoing(0x1C, ServerUnloadChunkPacket.class);
99 | this.registerOutgoing(0x1D, ServerNotifyClientPacket.class);
100 | this.registerOutgoing(0x1E, ServerOpenHorseWindowPacket.class);
101 | this.registerOutgoing(0x1F, ServerKeepAlivePacket.class);
102 | this.registerOutgoing(0x20, ServerChunkDataPacket.class);
103 | this.registerOutgoing(0x21, ServerPlayEffectPacket.class);
104 | this.registerOutgoing(0x22, ServerSpawnParticlePacket.class);
105 | this.registerOutgoing(0x23, ServerUpdateLightPacket.class);
106 | this.registerOutgoing(0x24, ServerJoinGamePacket.class);
107 | this.registerOutgoing(0x25, ServerMapDataPacket.class);
108 | this.registerOutgoing(0x26, ServerTradeListPacket.class);
109 | this.registerOutgoing(0x27, ServerEntityPositionPacket.class);
110 | this.registerOutgoing(0x28, ServerEntityPositionRotationPacket.class);
111 | this.registerOutgoing(0x29, ServerEntityRotationPacket.class);
112 | this.registerOutgoing(0x2A, ServerEntityMovementPacket.class);
113 | this.registerOutgoing(0x2B, ServerVehicleMovePacket.class);
114 | this.registerOutgoing(0x2C, ServerOpenBookPacket.class);
115 | this.registerOutgoing(0x2D, ServerOpenWindowPacket.class);
116 | this.registerOutgoing(0x2E, ServerOpenTileEntityEditorPacket.class);
117 | this.registerOutgoing(0x2F, ServerPreparedCraftingGridPacket.class);
118 | this.registerOutgoing(0x30, ServerPlayerAbilitiesPacket.class);
119 | this.registerOutgoing(0x31, ServerCombatPacket.class);
120 | this.registerOutgoing(0x32, ServerPlayerListEntryPacket.class);
121 | this.registerOutgoing(0x33, ServerPlayerFacingPacket.class);
122 | this.registerOutgoing(0x34, ServerPlayerPositionRotationPacket.class);
123 | this.registerOutgoing(0x35, ServerUnlockRecipesPacket.class);
124 | this.registerOutgoing(0x36, ServerEntityDestroyPacket.class);
125 | this.registerOutgoing(0x37, ServerEntityRemoveEffectPacket.class);
126 | this.registerOutgoing(0x38, ServerResourcePackSendPacket.class);
127 | this.registerOutgoing(0x39, ServerRespawnPacket.class);
128 | this.registerOutgoing(0x3A, ServerEntityHeadLookPacket.class);
129 | this.registerOutgoing(0x3B, ServerMultiBlockChangePacket.class);
130 | this.registerOutgoing(0x3C, ServerAdvancementTabPacket.class);
131 | this.registerOutgoing(0x3D, ServerWorldBorderPacket.class);
132 | this.registerOutgoing(0x3E, ServerSwitchCameraPacket.class);
133 | this.registerOutgoing(0x3F, ServerPlayerChangeHeldItemPacket.class);
134 | this.registerOutgoing(0x40, ServerUpdateViewPositionPacket.class);
135 | this.registerOutgoing(0x41, ServerUpdateViewDistancePacket.class);
136 | this.registerOutgoing(0x42, ServerSpawnPositionPacket.class);
137 | this.registerOutgoing(0x43, ServerDisplayScoreboardPacket.class);
138 | this.registerOutgoing(0x44, ServerEntityMetadataPacket.class);
139 | this.registerOutgoing(0x45, ServerEntityAttachPacket.class);
140 | this.registerOutgoing(0x46, ServerEntityVelocityPacket.class);
141 | this.registerOutgoing(0x47, ServerEntityEquipmentPacket.class);
142 | this.registerOutgoing(0x48, ServerPlayerSetExperiencePacket.class);
143 | this.registerOutgoing(0x49, ServerPlayerHealthPacket.class);
144 | this.registerOutgoing(0x4A, ServerScoreboardObjectivePacket.class);
145 | this.registerOutgoing(0x4B, ServerEntitySetPassengersPacket.class);
146 | this.registerOutgoing(0x4C, ServerTeamPacket.class);
147 | this.registerOutgoing(0x4D, ServerUpdateScorePacket.class);
148 | this.registerOutgoing(0x4E, ServerUpdateTimePacket.class);
149 | this.registerOutgoing(0x4F, ServerTitlePacket.class);
150 | this.registerOutgoing(0x50, ServerEntitySoundEffectPacket.class);
151 | this.registerOutgoing(0x51, ServerPlayBuiltinSoundPacket.class);
152 | this.registerOutgoing(0x52, ServerStopSoundPacket.class);
153 | this.registerOutgoing(0x53, ServerPlayerListDataPacket.class);
154 | this.registerOutgoing(0x54, ServerNBTResponsePacket.class);
155 | this.registerOutgoing(0x55, ServerEntityCollectItemPacket.class);
156 | this.registerOutgoing(0x56, ServerEntityTeleportPacket.class);
157 | this.registerOutgoing(0x57, ServerAdvancementsPacket.class);
158 | this.registerOutgoing(0x58, ServerEntityPropertiesPacket.class);
159 | this.registerOutgoing(0x59, ServerEntityEffectPacket.class);
160 | this.registerOutgoing(0x5A, ServerDeclareRecipesPacket.class);
161 | this.registerOutgoing(0x5B, ServerDeclareTagsPacket.class);
162 | }
163 | }
164 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | de.mcmdev
8 | betterprotocol
9 | pom
10 | ${revision}
11 |
12 | betterprotocol-api
13 | betterprotocol-common
14 | betterprotocol-bukkit
15 | betterprotocol-bungee
16 |
17 |
18 |
19 | 1.8
20 | 1.8
21 | 0.3
22 |
23 |
24 |
25 |
26 | jitpack.io
27 | https://jitpack.io
28 |
29 |
30 | bungeecord-repo
31 | https://oss.sonatype.org/content/repositories/snapshots
32 |
33 |
34 |
35 |
36 |
37 |
38 | com.coveo
39 | fmt-maven-plugin
40 | 2.11
41 |
42 |
43 |
44 | format
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | org.apache.maven.plugins
54 | maven-shade-plugin
55 | 3.2.4
56 |
57 |
58 | package
59 |
60 | shade
61 |
62 |
63 |
64 |
65 |
66 | org.codehaus.mojo
67 | flatten-maven-plugin
68 | 1.2.7
69 |
70 | true
71 |
72 |
73 |
74 | flatten
75 | package
76 |
77 | flatten
78 |
79 |
80 |
81 | flatten.clean
82 | clean
83 |
84 | clean
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------