diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..7d62d0bcf --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 000000000..60a7754d3 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/connector/connector.iml b/connector/connector.iml new file mode 100644 index 000000000..3525f9e25 --- /dev/null +++ b/connector/connector.iml @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java index cbd444d81..63bdc8bf7 100644 --- a/connector/src/main/java/org/geysermc/connector/GeyserConnector.java +++ b/connector/src/main/java/org/geysermc/connector/GeyserConnector.java @@ -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(); diff --git a/connector/src/main/java/org/geysermc/connector/configuration/RemoteConfiguration.java b/connector/src/main/java/org/geysermc/connector/configuration/RemoteConfiguration.java index 82f4ec096..7fcf8a2bb 100644 --- a/connector/src/main/java/org/geysermc/connector/configuration/RemoteConfiguration.java +++ b/connector/src/main/java/org/geysermc/connector/configuration/RemoteConfiguration.java @@ -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; } \ No newline at end of file diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 4eff93447..1a21edea7 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -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()); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/BedrockItem.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/BedrockItem.java index dbfa86720..69afbff92 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/BedrockItem.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/BedrockItem.java @@ -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); + } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java index a4e07f44f..5d223ba03 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/ItemTranslator.java @@ -97,9 +97,9 @@ 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 item " + state.getId()); + // GeyserLogger.DEFAULT.debug("Missing mapping for java block " + state.getId()); return BedrockItem.AIR; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/item/JavaItem.java b/connector/src/main/java/org/geysermc/connector/network/translators/item/JavaItem.java index 288420b40..06798b274 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/item/JavaItem.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/item/JavaItem.java @@ -39,7 +39,7 @@ public class JavaItem { @Override public int hashCode() { - return id & identifier.hashCode(); + return id; } @Override diff --git a/connector/src/main/java/org/geysermc/connector/utils/Remapper.java b/connector/src/main/java/org/geysermc/connector/utils/Remapper.java index 4676dec24..ab733321f 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Remapper.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Remapper.java @@ -107,6 +107,19 @@ public class Remapper { return null; } + public BedrockItem convertToBedrockB(ItemStack block) { + for (Map.Entry 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"); diff --git a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java index 1447c5726..83c9d1a59 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java +++ b/connector/src/main/java/org/geysermc/connector/utils/Toolbox.java @@ -31,15 +31,13 @@ public class Toolbox { Map bedrockBlocks = new HashMap<>(); Map bedrockItems = new HashMap<>(); - for (Map e : entries) { - BedrockItem bedrockItem = new BedrockItem((String) e.get("name"), (int) e.get("id"), (int) e.get("data")); - bedrockBlocks.put(bedrockItem.getIdentifier(), bedrockItem); - bedrockItems.put(bedrockItem.getIdentifier() + ":" + bedrockItem.getData(), bedrockItem); - } - ByteBuf b = Unpooled.buffer(); VarInts.writeUnsignedInt(b, entries.size()); for (Map e : entries) { + BedrockItem bedrockItem = new BedrockItem((String) e.get("name"), (int) e.get("id"), (int) e.get("data")); + bedrockItems.put(bedrockItem.getIdentifier() + ":" + bedrockItem.getData(), bedrockItem); + bedrockBlocks.put(bedrockItem.getIdentifier() + ":" + bedrockItem.getData(), bedrockItem); + GlobalBlockPalette.registerMapping((int) e.get("id") << 4 | (int) e.get("data")); BedrockUtils.writeString(b, (String) e.get("name")); b.writeShortLE((int) e.get("data")); diff --git a/connector/src/main/resources/config.yml b/connector/src/main/resources/config.yml index 5b14707c2..ff0214889 100644 --- a/connector/src/main/resources/config.yml +++ b/connector/src/main/resources/config.yml @@ -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 diff --git a/plugin/plugin.iml b/plugin/plugin.iml new file mode 100644 index 000000000..4358747eb --- /dev/null +++ b/plugin/plugin.iml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/plugin/src/main/java/org/geysermc/plugin/GeyserPlugin.java b/plugin/src/main/java/org/geysermc/plugin/GeyserPlugin.java new file mode 100644 index 000000000..34df2c2db --- /dev/null +++ b/plugin/src/main/java/org/geysermc/plugin/GeyserPlugin.java @@ -0,0 +1,42 @@ +package org.geysermc.plugin; + + +public class GeyserPlugin { + /*private List players; + + @SuppressWarnings("unchecked") + @Override + public void onEnable() { + try { + Class clazz = getProxy().getClass(); + + Field field = clazz.getDeclaredField("connections"); + + field.setAccessible(true); + + players = (List) 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); + }*/ +}