forked from GeyserMC/Geyser
		
	Merge branch 'master' into inventory
This commit is contained in:
		
						commit
						6eac178305
					
				
					 9 changed files with 82 additions and 26 deletions
				
			
		|  | @ -49,6 +49,10 @@ | ||||||
|                                     <pattern>io.netty</pattern> |                                     <pattern>io.netty</pattern> | ||||||
|                                     <shadedPattern>org.geysermc.platform.bukkit.shaded.netty</shadedPattern> |                                     <shadedPattern>org.geysermc.platform.bukkit.shaded.netty</shadedPattern> | ||||||
|                                 </relocation> |                                 </relocation> | ||||||
|  |                                 <relocation> | ||||||
|  |                                     <pattern>it.unimi.dsi.fastutil</pattern> | ||||||
|  |                                     <shadedPattern>org.geysermc.platform.bukkit.shaded.fastutil</shadedPattern> | ||||||
|  |                                 </relocation> | ||||||
|                             </relocations> |                             </relocations> | ||||||
|                             <minimizeJar>true</minimizeJar> |                             <minimizeJar>true</minimizeJar> | ||||||
|                         </configuration> |                         </configuration> | ||||||
|  |  | ||||||
|  | @ -53,6 +53,10 @@ | ||||||
|                                     <pattern>io.netty</pattern> |                                     <pattern>io.netty</pattern> | ||||||
|                                     <shadedPattern>org.geysermc.platform.sponge.shaded.netty</shadedPattern> |                                     <shadedPattern>org.geysermc.platform.sponge.shaded.netty</shadedPattern> | ||||||
|                                 </relocation> |                                 </relocation> | ||||||
|  |                                 <relocation> | ||||||
|  |                                     <pattern>it.unimi.dsi.fastutil</pattern> | ||||||
|  |                                     <shadedPattern>org.geysermc.platform.sponge.shaded.fastutil</shadedPattern> | ||||||
|  |                                 </relocation> | ||||||
|                             </relocations> |                             </relocations> | ||||||
|                             <minimizeJar>true</minimizeJar> |                             <minimizeJar>true</minimizeJar> | ||||||
|                         </configuration> |                         </configuration> | ||||||
|  | @ -71,7 +75,6 @@ | ||||||
|                         <excludes> |                         <excludes> | ||||||
|                             <exclude>com.google.code.gson:*</exclude> |                             <exclude>com.google.code.gson:*</exclude> | ||||||
|                             <exclude>org.yaml:*</exclude> |                             <exclude>org.yaml:*</exclude> | ||||||
|                             <exclude>com.nukkitx:fastutil-lite:*</exclude> |  | ||||||
|                             <exclude>org.slf4j:*</exclude> |                             <exclude>org.slf4j:*</exclude> | ||||||
|                             <exclude>org.ow2.asm:*</exclude> |                             <exclude>org.ow2.asm:*</exclude> | ||||||
|                         </excludes> |                         </excludes> | ||||||
|  |  | ||||||
|  | @ -18,5 +18,11 @@ | ||||||
|             <version>2.8.2</version> |             <version>2.8.2</version> | ||||||
|             <scope>compile</scope> |             <scope>compile</scope> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>com.fasterxml.jackson.datatype</groupId> | ||||||
|  |             <artifactId>jackson-datatype-jsr310</artifactId> | ||||||
|  |             <version>2.9.8</version> | ||||||
|  |             <scope>compile</scope> | ||||||
|  |         </dependency> | ||||||
|     </dependencies> |     </dependencies> | ||||||
| </project> | </project> | ||||||
|  | @ -3,6 +3,8 @@ package org.geysermc.floodgate.util; | ||||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
| 
 | 
 | ||||||
|  | import java.util.UUID; | ||||||
|  | 
 | ||||||
| @AllArgsConstructor | @AllArgsConstructor | ||||||
| @Getter | @Getter | ||||||
| public class BedrockData { | public class BedrockData { | ||||||
|  | @ -11,15 +13,15 @@ public class BedrockData { | ||||||
| 
 | 
 | ||||||
|     private String version; |     private String version; | ||||||
|     private String username; |     private String username; | ||||||
|     private String xuid; |     private UUID bedrockId; | ||||||
|     private int deviceId; |     private int deviceId; | ||||||
|     private String languageCode; |     private String languageCode; | ||||||
|     private int inputMode; |     private int inputMode; | ||||||
|     private String ip; |     private String ip; | ||||||
|     private int dataLength; |     private int dataLength; | ||||||
| 
 | 
 | ||||||
|     public BedrockData(String version, String username, String xuid, int deviceId, String languageCode, int inputMode, String ip) { |     public BedrockData(String version, String username, UUID bedrockId, int deviceId, String languageCode, int inputMode, String ip) { | ||||||
|         this(version, username, xuid, deviceId, languageCode, inputMode, ip, EXPECTED_LENGTH); |         this(version, username, bedrockId, deviceId, languageCode, inputMode, ip, EXPECTED_LENGTH); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public static BedrockData fromString(String data) { |     public static BedrockData fromString(String data) { | ||||||
|  | @ -27,7 +29,7 @@ public class BedrockData { | ||||||
|         if (split.length != EXPECTED_LENGTH) return null; |         if (split.length != EXPECTED_LENGTH) return null; | ||||||
| 
 | 
 | ||||||
|         return new BedrockData( |         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 |                 split[4], Integer.parseInt(split[5]), split[6], split.length | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
|  | @ -38,7 +40,7 @@ public class BedrockData { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public String toString() { |     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; |                 inputMode +'\0'+ ip; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -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]; | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -39,6 +39,9 @@ public class CreeperEntity extends MonsterEntity { | ||||||
| 
 | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { |     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) { |         if (entityMetadata.getId() == 16) { | ||||||
|             metadata.getFlags().setFlag(EntityFlag.POWERED, (boolean) entityMetadata.getValue()); |             metadata.getFlags().setFlag(EntityFlag.POWERED, (boolean) entityMetadata.getValue()); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | @ -235,7 +235,7 @@ public class GeyserSession implements CommandSender { | ||||||
|                                 encrypted = EncryptionUtil.encryptBedrockData(publicKey, new BedrockData( |                                 encrypted = EncryptionUtil.encryptBedrockData(publicKey, new BedrockData( | ||||||
|                                         clientData.getGameVersion(), |                                         clientData.getGameVersion(), | ||||||
|                                         authData.getName(), |                                         authData.getName(), | ||||||
|                                         authData.getXboxUUID(), |                                         authData.getUUID(), | ||||||
|                                         clientData.getDeviceOS().ordinal(), |                                         clientData.getDeviceOS().ordinal(), | ||||||
|                                         clientData.getLanguageCode(), |                                         clientData.getLanguageCode(), | ||||||
|                                         clientData.getCurrentInputMode().ordinal(), |                                         clientData.getCurrentInputMode().ordinal(), | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonEnumDefaultValue; | ||||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||||||
| import com.fasterxml.jackson.annotation.JsonProperty; | import com.fasterxml.jackson.annotation.JsonProperty; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
|  | import org.geysermc.floodgate.util.DeviceOS; | ||||||
| 
 | 
 | ||||||
| import java.util.UUID; | import java.util.UUID; | ||||||
| 
 | 
 | ||||||
|  | @ -65,23 +66,6 @@ public class BedrockClientData { | ||||||
|         POCKET |         POCKET | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public enum DeviceOS { |  | ||||||
|         @JsonEnumDefaultValue |  | ||||||
|         UNKOWN, |  | ||||||
|         ANDROID, |  | ||||||
|         IOS, |  | ||||||
|         OSX, |  | ||||||
|         FIREOS, |  | ||||||
|         GEARVR, |  | ||||||
|         HOLOLENS, |  | ||||||
|         WIN10, |  | ||||||
|         WIN32, |  | ||||||
|         DEDICATED, |  | ||||||
|         ORBIS, |  | ||||||
|         NX, |  | ||||||
|         SWITCH |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public enum InputMode { |     public enum InputMode { | ||||||
|         @JsonEnumDefaultValue |         @JsonEnumDefaultValue | ||||||
|         UNKNOWN, |         UNKNOWN, | ||||||
|  |  | ||||||
|  | @ -29,6 +29,7 @@ import com.github.steveice10.mc.protocol.packet.ingame.client.ClientChatPacket; | ||||||
| import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket; | import com.nukkitx.protocol.bedrock.packet.CommandRequestPacket; | ||||||
| 
 | 
 | ||||||
| import org.geysermc.connector.GeyserConnector; | import org.geysermc.connector.GeyserConnector; | ||||||
|  | import org.geysermc.connector.command.GeyserCommandMap; | ||||||
| import org.geysermc.connector.network.session.GeyserSession; | import org.geysermc.connector.network.session.GeyserSession; | ||||||
| import org.geysermc.connector.network.translators.PacketTranslator; | import org.geysermc.connector.network.translators.PacketTranslator; | ||||||
| 
 | 
 | ||||||
|  | @ -37,8 +38,9 @@ public class BedrockCommandRequestTranslator extends PacketTranslator<CommandReq | ||||||
|     @Override |     @Override | ||||||
|     public void translate(CommandRequestPacket packet, GeyserSession session) { |     public void translate(CommandRequestPacket packet, GeyserSession session) { | ||||||
|         String command = packet.getCommand().replace("/", ""); |         String command = packet.getCommand().replace("/", ""); | ||||||
|         if (GeyserConnector.getInstance().getCommandMap().getCommands().containsKey(command)) { |         GeyserCommandMap commandMap = GeyserConnector.getInstance().getCommandMap(); | ||||||
|             GeyserConnector.getInstance().getCommandMap().runCommand(session, command); |         if (command.startsWith("geyser ") && commandMap.getCommands().containsKey(command.split(" ")[1])) { | ||||||
|  |             commandMap.runCommand(session, command); | ||||||
|         } else { |         } else { | ||||||
|             ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand()); |             ClientChatPacket chatPacket = new ClientChatPacket(packet.getCommand()); | ||||||
|             session.getDownstream().getSession().send(chatPacket); |             session.getDownstream().getSession().send(chatPacket); | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue