forked from GeyserMC/Geyser
Hybrid mode start + try fixing chunks (hashcodes, etc.)
This commit is contained in:
parent
6cb80dea28
commit
59e0aff289
14 changed files with 240 additions and 6 deletions
15
.idea/encodings.xml
Normal file
15
.idea/encodings.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/api" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/api" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/common" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/connector" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/connector" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugin" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/plugin" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
12
.idea/modules.xml
Normal file
12
.idea/modules.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/api/api.iml" filepath="$PROJECT_DIR$/api/api.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/common/common.iml" filepath="$PROJECT_DIR$/common/common.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/connector/connector.iml" filepath="$PROJECT_DIR$/connector/connector.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/geyser-parent.iml" filepath="$PROJECT_DIR$/geyser-parent.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/plugin/plugin.iml" filepath="$PROJECT_DIR$/plugin/plugin.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
69
connector/connector.iml
Normal file
69
connector/connector.iml
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/../target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/../target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="api" />
|
||||
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.2" level="project" />
|
||||
<orderEntry type="module" module-name="common" />
|
||||
<orderEntry type="library" name="Maven: com.auth0:java-jwt:3.3.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.11" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.sentry:sentry:1.7.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.minecrell:terminalconsoleappender:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.8.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jline:jline-reader:3.5.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jline:jline-terminal:3.5.1" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.jline:jline-terminal-jna:3.5.1" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.java.dev.jna:jna:4.2.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.slf4j:slf4j-simple:1.6.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.projectlombok:lombok:1.18.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.fusesource.jansi:jansi:1.18" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx.protocol:bedrock-v361:2.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx.protocol:bedrock-common:2.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx.protocol:common:2.1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx.network:common:1.6.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-epoll:linux-x86_64:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-unix-common:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport-native-kqueue:osx-x86_64:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: cn.nukkit:nukkit-natives:1.0.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx:nbt:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.flowpowered:flow-math:1.0.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sf.trove4j:trove:3.1.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.sf.trove4j:trove-generator:3.1.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx.network:raknet:1.6.7" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.36.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nimbusds:nimbus-jose-jwt:4.41.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.stephenc.jcip:jcip-annotations:1.0-1" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.nukkitx:fastutil-lite:8.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.steveice10:opennbt:1.3-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.steveice10:packetlib:1.4-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-all:4.1.25.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.steveice10:mcauthlib:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.steveice10:mcprotocollib:1.14.4-SNAPSHOT" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -91,6 +91,7 @@ public class GeyserConnector implements Connector {
|
|||
}
|
||||
|
||||
private GeyserConnector() {
|
||||
System.out.println(UUID.randomUUID().toString());
|
||||
//Metric
|
||||
if(!(System.console() == null) && System.getProperty("os.name", "Windows 10").toLowerCase().contains("windows")) {
|
||||
AnsiConsole.systemInstall();
|
||||
|
|
|
@ -37,6 +37,6 @@ public class RemoteConfiguration {
|
|||
private String motd1;
|
||||
private String motd2;
|
||||
|
||||
@JsonProperty("online-mode")
|
||||
private boolean onlineMode;
|
||||
@JsonProperty("auth-type")
|
||||
private String authType;
|
||||
}
|
|
@ -119,7 +119,7 @@ public class GeyserSession implements PlayerSession, Player {
|
|||
startGame();
|
||||
|
||||
this.remoteServer = remoteServer;
|
||||
if (!connector.getConfig().getRemote().isOnlineMode()) {
|
||||
if (!(connector.getConfig().getRemote().getAuthType().hashCode() == "online".hashCode())) {
|
||||
connector.getLogger().info("Attempting to login using offline mode... authentication is disabled.");
|
||||
authenticate(authenticationData.getName());
|
||||
}
|
||||
|
|
|
@ -37,4 +37,14 @@ public class BedrockItem {
|
|||
private String identifier;
|
||||
private int id;
|
||||
private int data;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id << 4 | data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return obj == this || (obj instanceof BedrockItem && ((BedrockItem) obj).id == this.id && ((BedrockItem) obj).identifier.equals(this.identifier) && ((BedrockItem) obj).data == this.data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ public class ItemTranslator {
|
|||
}
|
||||
|
||||
public BedrockItem getBedrockBlock(BlockState state) {
|
||||
BedrockItem bedrockItem = Remapper.BLOCK_REMAPPER.convertToBedrock(new ItemStack(state.getId()));
|
||||
BedrockItem bedrockItem = Remapper.BLOCK_REMAPPER.convertToBedrockB(new ItemStack(state.getId()));
|
||||
if (bedrockItem == null) {
|
||||
// GeyserLogger.DEFAULT.debug("Missing mapping for java block " + state.getId());
|
||||
return BedrockItem.AIR;
|
||||
|
|
|
@ -39,7 +39,7 @@ public class JavaItem {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id & identifier.hashCode();
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -107,6 +107,19 @@ public class Remapper {
|
|||
return null;
|
||||
}
|
||||
|
||||
public BedrockItem convertToBedrockB(ItemStack block) {
|
||||
for (Map.Entry<String, JavaItem> javaItem : Toolbox.JAVA_BLOCKS.entrySet()) {
|
||||
if (javaItem.getValue().getId() != block.getId())
|
||||
continue;
|
||||
|
||||
return javaToBedrock.get(javaItem.getValue());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static String getBedrockIdentifier(String javaIdentifier) {
|
||||
javaIdentifier = javaIdentifier.toLowerCase();
|
||||
javaIdentifier = javaIdentifier.replace("terracotta", "stained_hardened_clay");
|
||||
|
|
|
@ -19,7 +19,9 @@ remote:
|
|||
address: 127.0.0.1
|
||||
# The port of the remote (Java Edition) server
|
||||
port: 25565
|
||||
online-mode: false
|
||||
|
||||
# Authentication type. Can be offline, online, or hybrid (see the wiki).
|
||||
auth-type: offline
|
||||
|
||||
## the Xbox/MCPE username is the key for the Java server auth-info
|
||||
## this allows automatic configuration/login to the remote Java server
|
||||
|
|
35
plugin/plugin.iml
Normal file
35
plugin/plugin.iml
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="waterfall-294" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-api:1.14-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.14-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-config:1.14-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-event:1.14-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-protocol:1.14-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:brigadier:1.0.16-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-codec:4.1.34.Final" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:core:3.1.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:20.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.whirvis:jraknet:2.11.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-core:2.12.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-handler:4.1.38.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-common:4.1.38.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-buffer:4.1.38.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-transport:4.1.38.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.netty:netty-resolver:4.1.38.Final" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.dosse:upnp:1.1" level="project" />
|
||||
</component>
|
||||
</module>
|
|
@ -9,4 +9,25 @@
|
|||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>plugin</artifactId>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.14-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.whirvis</groupId>
|
||||
<artifactId>jraknet</artifactId>
|
||||
<version>2.11.8</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
56
plugin/src/main/java/org/geysermc/plugin/GeyserPlugin.java
Normal file
56
plugin/src/main/java/org/geysermc/plugin/GeyserPlugin.java
Normal file
|
@ -0,0 +1,56 @@
|
|||
package org.geysermc.plugin;
|
||||
|
||||
import com.whirvis.jraknet.RakNetPacket;
|
||||
import com.whirvis.jraknet.peer.RakNetClientPeer;
|
||||
import com.whirvis.jraknet.server.RakNetServer;
|
||||
import com.whirvis.jraknet.server.RakNetServerListener;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ConnectedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class GeyserPlugin extends Plugin {
|
||||
private List<ConnectedPlayer> players;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
Class<? extends ProxyServer> clazz = getProxy().getClass();
|
||||
|
||||
Field field = clazz.getDeclaredField("connections");
|
||||
|
||||
field.setAccessible(true);
|
||||
|
||||
players = (List<ConnectedPlayer>) field.get(getProxy());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
RakNetServer server = new RakNetServer(new InetSocketAddress("0.0.0.0", 65500), 1000000);
|
||||
|
||||
server.addListener(new RakNetServerListener() {
|
||||
@Override
|
||||
public void handleMessage(RakNetServer server, RakNetClientPeer peer, RakNetPacket packet, int channel) {
|
||||
if(packet.getId() == 0) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private UUID fromXUID(String XUID) {
|
||||
String one = XUID.substring(0, XUID.length()/2);
|
||||
String two = XUID.substring(XUID.length()/2, XUID.length());
|
||||
|
||||
long L1 = Long.parseLong(one);
|
||||
long L2 = Long.parseLong(two);
|
||||
|
||||
return new UUID(L1, L2);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue