Permalink
Browse files

Initial commit

  • Loading branch information...
minecrafter committed Jul 23, 2016
0 parents commit 369c8c3e93a3a87dbbf9e95a1d66e2fd5aa721f0
Showing with 2,302 additions and 0 deletions.
  1. +83 −0 .gitignore
  2. +20 −0 LICENSE
  3. +31 −0 NOTICE
  4. +14 −0 PERFORMANCE.md
  5. +28 −0 README.md
  6. +69 −0 pom.xml
  7. +45 −0 src/main/java/io/minimum/voxelwind/VoxelwindServer.java
  8. +14 −0 src/main/java/io/minimum/voxelwind/network/Native.java
  9. +87 −0 src/main/java/io/minimum/voxelwind/network/NettyVoxelwindNetworkListener.java
  10. +61 −0 src/main/java/io/minimum/voxelwind/network/PacketRegistry.java
  11. +5 −0 src/main/java/io/minimum/voxelwind/network/handler/NetworkPacketHandler.java
  12. +51 −0 src/main/java/io/minimum/voxelwind/network/handler/VoxelwindDatagramHandler.java
  13. +67 −0 src/main/java/io/minimum/voxelwind/network/handler/VoxelwindDirectPacketHandler.java
  14. +115 −0 src/main/java/io/minimum/voxelwind/network/mcpe/McpeBatch.java
  15. +15 −0 src/main/java/io/minimum/voxelwind/network/mcpe/annotations/BatchDisallowed.java
  16. +40 −0 src/main/java/io/minimum/voxelwind/network/raknet/DatagramRakNetPacketCodec.java
  17. +11 −0 src/main/java/io/minimum/voxelwind/network/raknet/RakNetConstants.java
  18. +18 −0 src/main/java/io/minimum/voxelwind/network/raknet/RakNetPackage.java
  19. +94 −0 src/main/java/io/minimum/voxelwind/network/raknet/RakNetUtil.java
  20. +63 −0 src/main/java/io/minimum/voxelwind/network/raknet/SimpleRakNetPacketCodec.java
  21. +192 −0 src/main/java/io/minimum/voxelwind/network/raknet/datagrams/EncapsulatedRakNetPacket.java
  22. +74 −0 src/main/java/io/minimum/voxelwind/network/raknet/datagrams/RakNetDatagram.java
  23. +35 −0 src/main/java/io/minimum/voxelwind/network/raknet/datagrams/RakNetDatagramFlags.java
  24. +12 −0 src/main/java/io/minimum/voxelwind/network/raknet/datagrams/RakNetReliability.java
  25. +16 −0 src/main/java/io/minimum/voxelwind/network/raknet/enveloped/AddressedRakNetDatagram.java
  26. +16 −0 src/main/java/io/minimum/voxelwind/network/raknet/enveloped/DirectAddressedRakNetPacket.java
  27. +4 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/AckPacket.java
  28. +79 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/BaseAckPacket.java
  29. +26 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/ConnectedPingPacket.java
  30. +39 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/ConnectedPongPacket.java
  31. +48 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/ConnectionRequestPacket.java
  32. +78 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/ConnectionResponsePacket.java
  33. +4 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/NakPacket.java
  34. +67 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/NewIncomingConnectionPacket.java
  35. +42 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/OpenConnectionRequest1Packet.java
  36. +55 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/OpenConnectionRequest2Packet.java
  37. +42 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/OpenConnectionResponse1Packet.java
  38. +66 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/OpenConnectionResponse2Packet.java
  39. +42 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/UnconnectedPingPacket.java
  40. +52 −0 src/main/java/io/minimum/voxelwind/network/raknet/packets/UnconnectedPongPacket.java
  41. +44 −0 src/main/java/io/minimum/voxelwind/network/session/SentDatagram.java
  42. +66 −0 src/main/java/io/minimum/voxelwind/network/session/SessionManager.java
  43. +7 −0 src/main/java/io/minimum/voxelwind/network/session/SessionState.java
  44. +265 −0 src/main/java/io/minimum/voxelwind/network/session/UserSession.java
@@ -0,0 +1,83 @@
# Created by https://www.gitignore.io/api/intellij,maven,java
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
### Maven ###
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
### Java ###
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
20 LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2016 Panem LLC
Copyright (c) 2016 Voxelwind contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 NOTICE
@@ -0,0 +1,31 @@
This software may include components from BungeeCord, with the following copyright notice:
Copyright (c) 2012, md_5. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
The name of the author may not be used to endorse or promote products derived
from this software without specific prior written permission.
You may not use the software for commercial software hosting services without
written permission from the author.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,14 @@
# Performance
Voxelwind is meant to be high-performance, but has unique constraints that are discussed in this document.
## UDP socket listening
Voxelwind uses Netty as the I/O library. Although Netty has high performance and can efficiently use multiple threads
using TCP, MCPE uses UDP, which requires special care for proper usage.
On recent versions of Linux, Mac OS X, FreeBSD and Solaris, `SO_REUSEPORT` is available to allow multiple threads to
bind to the same port. However, in Netty, this support is currently only available for Linux users.
Therefore, Voxelwind does not do much processing in its event loop except for decoding and encoding packets and queuing
them to be executed by other threads.
@@ -0,0 +1,28 @@
# Voxelwind
**Current version**: version 0.0.1 (_Layer of Fog_)
Voxelwind is an upcoming _Minecraft: Pocket Edition_ server project written in Java. It aims to provide a Java-first API,
provide high performance, high scalability and flexibility while being easy to use for causal users.
Voxelwind at the present moment aims to have a basic server implementation that drops players into a flatworld and can
run basic commands. In the future, Voxelwind will eventually have proper world loading support, a plugin API, and entity
support.
Voxelwind is licensed under the permissive **MIT** license. However, we would love if you submit improvements you make to
Voxelwind upstream so that the larger community can benefit from them.
## Special Thanks
* [MiNET](https://github.com/NiclasOlofsson/MiNET) was invaluable in helping me figure out some of the more difficult stuff.
## Requirements
To run Voxelwind, Java 8 is required. Additionally, it is strongly recommended you run Voxelwind on a recent 64-bit x86
Debian-based Linux distribution (Debian 8 or Ubuntu 16.04) for two reasons:
* Voxelwind can use multiple threads to listen to the same port on Linux (`SO_REUSEPORT`). **JDK 9 includes more native
support for SO_REUSPORT, so it will work on any modern Unix-like OS.**
* Voxelwind can take advantage of native cryptography and compression support.
Voxelwind will work on other configurations outside 64-bit Debian/Ubuntu, but scalability and throughput will be affected.
69 pom.xml
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.minimum</groupId>
<artifactId>voxelwind</artifactId>
<version>1.0-SNAPSHOT</version>
<repositories>
<repository>
<id>sonatype-oss-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.39.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport-native-epoll</artifactId>
<version>4.0.39.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>19.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-native</artifactId>
<version>1.10-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,45 @@
package io.minimum.voxelwind;
import io.minimum.voxelwind.network.Native;
import io.minimum.voxelwind.network.NettyVoxelwindNetworkListener;
import io.minimum.voxelwind.network.session.SessionManager;
import io.netty.channel.epoll.Epoll;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
public class VoxelwindServer {
private static final Logger LOGGER = LogManager.getLogger(VoxelwindServer.class);
private final SessionManager sessionManager = new SessionManager();
private NettyVoxelwindNetworkListener listener;
public SessionManager getSessionManager() {
return sessionManager;
}
public void boot() throws Exception {
listener = new NettyVoxelwindNetworkListener(this, "0.0.0.0", 19132);
listener.bind();
Thread.sleep(10000000);
}
public static void main(String... args) throws Exception {
// RakNet doesn't really like IPv6
System.setProperty("java.net.preferIPv4Stack", "true");
if (!Epoll.isAvailable()) {
LOGGER.error("Your platform does not support epoll. The server will still work, but server throughput and performance may suffer.");
LOGGER.error("To resolve this issue, run your server on Linux.");
}
if (!Native.zlib.load()) {
LOGGER.error("Your platform does not support native compression. To resolve this issue, make sure you're using 64-bit Linux.");
}
VoxelwindServer server = new VoxelwindServer();
server.boot();
}
}
@@ -0,0 +1,14 @@
package io.minimum.voxelwind.network;
import net.md_5.bungee.jni.NativeCode;
import net.md_5.bungee.jni.zlib.BungeeZlib;
import net.md_5.bungee.jni.zlib.JavaZlib;
import net.md_5.bungee.jni.zlib.NativeZlib;
public class Native {
private Native() {
}
public static final NativeCode<BungeeZlib> zlib = new NativeCode("native-compress", JavaZlib.class, NativeZlib.class);
}
Oops, something went wrong.

0 comments on commit 369c8c3

Please sign in to comment.