Merge branch 'master' into inventory

This commit is contained in:
RednedEpic 2020-03-10 18:46:27 -05:00
commit 6eac178305
9 changed files with 82 additions and 26 deletions

View File

@ -49,6 +49,10 @@
<pattern>io.netty</pattern>
<shadedPattern>org.geysermc.platform.bukkit.shaded.netty</shadedPattern>
</relocation>
<relocation>
<pattern>it.unimi.dsi.fastutil</pattern>
<shadedPattern>org.geysermc.platform.bukkit.shaded.fastutil</shadedPattern>
</relocation>
</relocations>
<minimizeJar>true</minimizeJar>
</configuration>

View File

@ -53,6 +53,10 @@
<pattern>io.netty</pattern>
<shadedPattern>org.geysermc.platform.sponge.shaded.netty</shadedPattern>
</relocation>
<relocation>
<pattern>it.unimi.dsi.fastutil</pattern>
<shadedPattern>org.geysermc.platform.sponge.shaded.fastutil</shadedPattern>
</relocation>
</relocations>
<minimizeJar>true</minimizeJar>
</configuration>
@ -71,7 +75,6 @@
<excludes>
<exclude>com.google.code.gson:*</exclude>
<exclude>org.yaml:*</exclude>
<exclude>com.nukkitx:fastutil-lite:*</exclude>
<exclude>org.slf4j:*</exclude>
<exclude>org.ow2.asm:*</exclude>
</excludes>

View File

@ -18,5 +18,11 @@
<version>2.8.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -3,6 +3,8 @@ package org.geysermc.floodgate.util;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.UUID;
@AllArgsConstructor
@Getter
public class BedrockData {
@ -11,15 +13,15 @@ public class BedrockData {
private String version;
private String username;
private String xuid;
private UUID bedrockId;
private int deviceId;
private String languageCode;
private int inputMode;
private String ip;
private int dataLength;
public BedrockData(String version, String username, String xuid, int deviceId, String languageCode, int inputMode, String ip) {
this(version, username, xuid, deviceId, languageCode, inputMode, ip, EXPECTED_LENGTH);
public BedrockData(String version, String username, UUID bedrockId, int deviceId, String languageCode, int inputMode, String ip) {
this(version, username, bedrockId, deviceId, languageCode, inputMode, ip, EXPECTED_LENGTH);
}
public static BedrockData fromString(String data) {
@ -27,7 +29,7 @@ public class BedrockData {
if (split.length != EXPECTED_LENGTH) return null;
return new BedrockData(
split[0], split[1], split[2], Integer.parseInt(split[3]),
split[0], split[1], UUID.fromString(split[2]), Integer.parseInt(split[3]),
split[4], Integer.parseInt(split[5]), split[6], split.length
);
}
@ -38,7 +40,7 @@ public class BedrockData {
@Override
public String toString() {
return version +'\0'+ username +'\0'+ xuid +'\0'+ deviceId +'\0'+ languageCode +'\0'+
return version +'\0'+ username +'\0'+ bedrockId +'\0'+ deviceId +'\0'+ languageCode +'\0'+
inputMode +'\0'+ ip;
}
}

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2019-2020 GeyserMC. http://geysermc.org
*
* 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.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.floodgate.util;
import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
public enum DeviceOS {
@JsonEnumDefaultValue
UNKNOWN,
ANDROID,
IOS,
OSX,
FIREOS,
GEARVR,
HOLOLENS,
WIN10,
WIN32,
DEDICATED,
ORBIS,
NX,
SWITCH;
private static final DeviceOS[] VALUES = values();
public static DeviceOS getById(int id) {
return id < VALUES.length ? VALUES[id] : VALUES[0];
}
}

View File

@ -39,6 +39,9 @@ public class CreeperEntity extends MonsterEntity {
@Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 15 && (int) entityMetadata.getValue() > 0) {
metadata.getFlags().setFlag(EntityFlag.IGNITED, true);
}
if (entityMetadata.getId() == 16) {
metadata.getFlags().setFlag(EntityFlag.POWERED, (boolean) entityMetadata.getValue());
}

View File

@ -235,7 +235,7 @@ public class GeyserSession implements CommandSender {
encrypted = EncryptionUtil.encryptBedrockData(publicKey, new BedrockData(
clientData.getGameVersion(),
authData.getName(),
authData.getXboxUUID(),
authData.getUUID(),
clientData.getDeviceOS().ordinal(),
clientData.getLanguageCode(),
clientData.getCurrentInputMode().ordinal(),

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import org.geysermc.floodgate.util.DeviceOS;
import java.util.UUID;
@ -65,23 +66,6 @@ public class BedrockClientData {
POCKET
}
public enum DeviceOS {
@JsonEnumDefaultValue
UNKOWN,
ANDROID,
IOS,
OSX,
FIREOS,
GEARVR,
HOLOLENS,
WIN10,
WIN32,
DEDICATED,
ORBIS,
NX,
SWITCH
}
public enum InputMode {
@JsonEnumDefaultValue
UNKNOWN,

View File

@ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket;
import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.command.GeyserCommandMap;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.translators.PacketTranslator;
@ -37,8 +38,9 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq
@Override
public void translate(CommandRequestPacket packet, GeyserSession session) {
String command = packet.getCommand().replace("/", "");
if (GeyserConnector.getInstance().getCommandMap().getCommands().containsKey(command)) {
GeyserConnector.getInstance().getCommandMap().runCommand(session, command);
GeyserCommandMap commandMap = GeyserConnector.getInstance().getCommandMap();
if (command.startsWith("geyser ") && commandMap.getCommands().containsKey(command.split(" ")[1])) {
commandMap.runCommand(session, command);
} else {
ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand());
session.getDownstream().getSession().send(chatPacket);