├── .gitignore ├── .gitmodules ├── DragonProxy ├── .gitignore ├── pom.xml └── src │ └── main │ ├── java │ ├── META-INF │ │ └── MANIFEST.MF │ ├── org │ │ ├── dragonet │ │ │ ├── configuration │ │ │ │ ├── Configuration.java │ │ │ │ ├── ConfigurationOptions.java │ │ │ │ ├── ConfigurationSection.java │ │ │ │ ├── InvalidConfigurationException.java │ │ │ │ ├── MemoryConfiguration.java │ │ │ │ ├── MemoryConfigurationOptions.java │ │ │ │ ├── MemorySection.java │ │ │ │ ├── file │ │ │ │ │ ├── FileConfiguration.java │ │ │ │ │ ├── FileConfigurationOptions.java │ │ │ │ │ ├── YamlConfiguration.java │ │ │ │ │ ├── YamlConfigurationOptions.java │ │ │ │ │ ├── YamlConstructor.java │ │ │ │ │ └── YamlRepresenter.java │ │ │ │ └── serialization │ │ │ │ │ ├── ConfigurationSerializable.java │ │ │ │ │ ├── ConfigurationSerialization.java │ │ │ │ │ ├── DelegateDeserialization.java │ │ │ │ │ └── SerializableAs.java │ │ │ ├── inventory │ │ │ │ └── PEInventorySlot.java │ │ │ └── proxy │ │ │ │ ├── DesktopServer.java │ │ │ │ ├── DragonProxy.java │ │ │ │ ├── NetworkConnectionManager.java │ │ │ │ ├── PocketServer.java │ │ │ │ ├── ServerMetrics.java │ │ │ │ ├── TickerThread.java │ │ │ │ ├── commands │ │ │ │ ├── Command.java │ │ │ │ ├── CommandRegister.java │ │ │ │ ├── ConsoleCommand.java │ │ │ │ ├── ConsoleCommandReader.java │ │ │ │ └── defaults │ │ │ │ │ ├── HelpCommand.java │ │ │ │ │ ├── KillCommand.java │ │ │ │ │ ├── StopCommand.java │ │ │ │ │ └── TestCommand.java │ │ │ │ ├── configuration │ │ │ │ ├── Lang.java │ │ │ │ ├── PropertiesConfig.java │ │ │ │ ├── RemoteServer.java │ │ │ │ └── ServerConfig.java │ │ │ │ ├── entity │ │ │ │ ├── EntityType.java │ │ │ │ └── meta │ │ │ │ │ ├── EntityMetaData.java │ │ │ │ │ ├── EntityMetaDataObject.java │ │ │ │ │ └── type │ │ │ │ │ ├── ByteArrayMeta.java │ │ │ │ │ ├── ByteMeta.java │ │ │ │ │ ├── CoordinateMeta.java │ │ │ │ │ ├── FloatMeta.java │ │ │ │ │ ├── IntegerMeta.java │ │ │ │ │ ├── LongMeta.java │ │ │ │ │ ├── ShortMeta.java │ │ │ │ │ └── SlotMeta.java │ │ │ │ ├── network │ │ │ │ ├── CacheKey.java │ │ │ │ ├── ClientConnection.java │ │ │ │ ├── ConnectionStatus.java │ │ │ │ ├── InventoryTranslatorRegister.java │ │ │ │ ├── PEPacketProcessor.java │ │ │ │ ├── PacketTranslatorRegister.java │ │ │ │ ├── SessionRegister.java │ │ │ │ ├── adapter │ │ │ │ │ ├── ClientProtocolAdapter.java │ │ │ │ │ ├── MCPCClientProtocolAdapter.java │ │ │ │ │ ├── MCPCServerProtocolAdapter.java │ │ │ │ │ ├── MCPEClientProtocolAdapter.java │ │ │ │ │ ├── MCPEServerProtocolAdapter.java │ │ │ │ │ ├── ProtocolAdapter.java │ │ │ │ │ └── ServerProtocolAdapter.java │ │ │ │ ├── cache │ │ │ │ │ ├── CachedEntity.java │ │ │ │ │ ├── CachedWindow.java │ │ │ │ │ ├── EntityCache.java │ │ │ │ │ └── WindowCache.java │ │ │ │ └── translator │ │ │ │ │ ├── EntityMetaTranslator.java │ │ │ │ │ ├── IgnorePacketTranslator.java │ │ │ │ │ ├── InventoryTranslator.java │ │ │ │ │ ├── ItemBlockTranslator.java │ │ │ │ │ ├── MessageTranslator.java │ │ │ │ │ ├── PCPacketTranslator.java │ │ │ │ │ ├── PEPacketTranslator.java │ │ │ │ │ ├── inv │ │ │ │ │ └── ChestWindowTranslator.java │ │ │ │ │ ├── pc │ │ │ │ │ ├── PCBlockChangePacketTranslator.java │ │ │ │ │ ├── PCChatPacketTranslator.java │ │ │ │ │ ├── PCChunkDataTranslator.java │ │ │ │ │ ├── PCDestroyEntitiesPacketTranslator.java │ │ │ │ │ ├── PCEntityEffectPacketTranslator.java │ │ │ │ │ ├── PCEntityHeadLookPacketTranslator.java │ │ │ │ │ ├── PCEntityMetadataPacketTranslator.java │ │ │ │ │ ├── PCEntityPositionPacketTranslator.java │ │ │ │ │ ├── PCEntityPositionRotationPacketTranslator.java │ │ │ │ │ ├── PCEntityRemoveEffectPacketTranslator.java │ │ │ │ │ ├── PCEntityVelocityPacketTranslator.java │ │ │ │ │ ├── PCJoinGamePacketTranslator.java │ │ │ │ │ ├── PCLoginSucessPacketTranslator.java │ │ │ │ │ ├── PCMultiBlockChangePacketTranslator.java │ │ │ │ │ ├── PCNotifyClientPacketTranslator.java │ │ │ │ │ ├── PCOpenWindowPacketTranslator.java │ │ │ │ │ ├── PCPlaySoundPacketTranslator.java │ │ │ │ │ ├── PCPlayerListItemPacketTranslator.java │ │ │ │ │ ├── PCPlayerPositionRotationPacketTranslator.java │ │ │ │ │ ├── PCSetSlotPacketTranslator.java │ │ │ │ │ ├── PCSpawnMobPacketTranslator.java │ │ │ │ │ ├── PCSpawnObjectPacketTranslator.java │ │ │ │ │ ├── PCSpawnPlayerPacketTranslator.java │ │ │ │ │ ├── PCSpawnPositionPacketTranslator.java │ │ │ │ │ ├── PCUpdateHealthPacketTranslator.java │ │ │ │ │ ├── PCUpdateSignPacketTranslator.java │ │ │ │ │ ├── PCUpdateTimePacketTranslator.java │ │ │ │ │ └── PCWindowItemsTranslator.java │ │ │ │ │ └── pe │ │ │ │ │ ├── PEChatPacketTranslator.java │ │ │ │ │ ├── PEInteractPacketTranslator.java │ │ │ │ │ ├── PEMovePlayerPacketTranslator.java │ │ │ │ │ ├── PEPlayerActionPacketTranslator.java │ │ │ │ │ ├── PEPlayerEquipmentPacketTranslator.java │ │ │ │ │ ├── PERequestChunkRadiusPacketTranslator.java │ │ │ │ │ ├── PERespawnPacketTranslator.java │ │ │ │ │ ├── PEUseItemPacketTranslator.java │ │ │ │ │ └── PEWindowClosePacketTranslator.java │ │ │ │ └── utilities │ │ │ │ ├── DefaultSkin.java │ │ │ │ ├── HTTP.java │ │ │ │ ├── Logger.java │ │ │ │ ├── LoginPacketPayload.java │ │ │ │ ├── MCColor.java │ │ │ │ ├── MCPESkin.java │ │ │ │ ├── NumberConversions.java │ │ │ │ ├── PatternChecker.java │ │ │ │ ├── Terminal.java │ │ │ │ ├── Versioning.java │ │ │ │ ├── Zlib.java │ │ │ │ └── io │ │ │ │ ├── ArraySplitter.java │ │ │ │ ├── ByteUtility.java │ │ │ │ ├── DataIOPair.java │ │ │ │ ├── PEBinaryReader.java │ │ │ │ ├── PEBinaryUtils.java │ │ │ │ ├── PEBinaryWriter.java │ │ │ │ └── SkinDownloader.java │ │ └── mcstats │ │ │ └── Metrics.java │ └── sul │ │ ├── attributes │ │ └── Pocket100.java │ │ ├── creative │ │ └── Pocket100.java │ │ ├── metadata │ │ └── Pocket100.java │ │ ├── protocol │ │ └── pocket100 │ │ │ ├── play │ │ │ ├── AddEntity.java │ │ │ ├── AddHangingEntity.java │ │ │ ├── AddItem.java │ │ │ ├── AddItemEntity.java │ │ │ ├── AddPainting.java │ │ │ ├── AddPlayer.java │ │ │ ├── AdventureSettings.java │ │ │ ├── Animate.java │ │ │ ├── AvailableCommands.java │ │ │ ├── Batch.java │ │ │ ├── BlockEntityData.java │ │ │ ├── BlockEvent.java │ │ │ ├── BossEvent.java │ │ │ ├── Camera.java │ │ │ ├── ChangeDimension.java │ │ │ ├── ChunkRadiusUpdated.java │ │ │ ├── ClientMagic.java │ │ │ ├── ClientboundMapItemData.java │ │ │ ├── CommandStep.java │ │ │ ├── ContainerClose.java │ │ │ ├── ContainerOpen.java │ │ │ ├── ContainerSetContent.java │ │ │ ├── ContainerSetData.java │ │ │ ├── ContainerSetSlot.java │ │ │ ├── CraftingData.java │ │ │ ├── CraftingEvent.java │ │ │ ├── Disconnect.java │ │ │ ├── DropItem.java │ │ │ ├── EntityEvent.java │ │ │ ├── Explode.java │ │ │ ├── FullChunkData.java │ │ │ ├── HurtArmor.java │ │ │ ├── Interact.java │ │ │ ├── InventoryAction.java │ │ │ ├── ItemFrameDropItem.java │ │ │ ├── LevelEvent.java │ │ │ ├── LevelSoundEvent.java │ │ │ ├── Login.java │ │ │ ├── MapInfoRequest.java │ │ │ ├── MobArmorEquipment.java │ │ │ ├── MobEffect.java │ │ │ ├── MobEquipment.java │ │ │ ├── MoveEntity.java │ │ │ ├── MovePlayer.java │ │ │ ├── PlayStatus.java │ │ │ ├── PlayerAction.java │ │ │ ├── PlayerFall.java │ │ │ ├── PlayerInput.java │ │ │ ├── PlayerList.java │ │ │ ├── RemoveBlock.java │ │ │ ├── RemoveEntity.java │ │ │ ├── ReplaceSelectedItem.java │ │ │ ├── RequestChunkRadius.java │ │ │ ├── ResourcePackClientResponse.java │ │ │ ├── ResourcePacksInfo.java │ │ │ ├── Respawn.java │ │ │ ├── RiderJump.java │ │ │ ├── ServerHandshake.java │ │ │ ├── SetCheatsEnabled.java │ │ │ ├── SetDifficulty.java │ │ │ ├── SetEntityData.java │ │ │ ├── SetEntityLink.java │ │ │ ├── SetEntityMotion.java │ │ │ ├── SetHealth.java │ │ │ ├── SetPlayerGametype.java │ │ │ ├── SetSpawnPosition.java │ │ │ ├── SetTime.java │ │ │ ├── ShowCredits.java │ │ │ ├── SpawnExperienceOrb.java │ │ │ ├── StartGame.java │ │ │ ├── TakeItemEntity.java │ │ │ ├── TelemetryEvent.java │ │ │ ├── Text.java │ │ │ ├── UpdateAttributes.java │ │ │ ├── UpdateBlock.java │ │ │ └── UseItem.java │ │ │ └── types │ │ │ ├── Attribute.java │ │ │ ├── BlockPosition.java │ │ │ ├── Pack.java │ │ │ ├── PlayerList.java │ │ │ ├── Recipe.java │ │ │ ├── Skin.java │ │ │ └── Slot.java │ │ └── utils │ │ ├── Buffer.java │ │ ├── Enchantment.java │ │ ├── Item.java │ │ ├── Packet.java │ │ └── Tuples.java │ └── resources │ ├── config.yml │ ├── defaults │ └── SKIN.BIN │ ├── en_US.properties │ └── permissions.yml ├── LICENSE ├── README.md ├── VERSION.txt ├── licenseheader.txt ├── pom.xml ├── screenshots ├── MCPE0.15.4_MCPC1.8.8.PNG ├── README.md ├── TheArchon.png ├── cls_mcpe.png ├── console_color.png └── online-login.png └── wiki ├── HowTo-CLS.md ├── HowTo-Online.md ├── NetworkExamples.md ├── Schema-CLS.md └── Usage.md /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | build 3 | out 4 | classes 5 | nbproject 6 | bin 7 | lib 8 | doc 9 | target/ 10 | !.gitignore 11 | !.gitmodules 12 | !.mailmap 13 | !.gitattributes 14 | worlds 15 | logs 16 | console.log 17 | dependency-reduced-pom.xml 18 | nb-configuration.xml 19 | *.iml 20 | 21 | run/ 22 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "JRakNet"] 2 | path = JRakNet 3 | url = https://github.com/marfgamer/JRakNet.git 4 | -------------------------------------------------------------------------------- /DragonProxy/.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | build 3 | out 4 | target/ 5 | !.gitignore 6 | dependency-reduced-pom.xml 7 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: org.dragonet.proxy.DragonProxy 3 | 4 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/InvalidConfigurationException.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration; 2 | 3 | /** 4 | * Exception thrown when attempting to load an invalid {@link Configuration} 5 | */ 6 | @SuppressWarnings("serial") 7 | public class InvalidConfigurationException extends Exception { 8 | 9 | /** 10 | * Creates a new instance of InvalidConfigurationException without a 11 | * message or cause. 12 | */ 13 | public InvalidConfigurationException() {} 14 | 15 | /** 16 | * Constructs an instance of InvalidConfigurationException with the 17 | * specified message. 18 | * 19 | * @param msg The details of the exception. 20 | */ 21 | public InvalidConfigurationException(String msg) { 22 | super(msg); 23 | } 24 | 25 | /** 26 | * Constructs an instance of InvalidConfigurationException with the 27 | * specified cause. 28 | * 29 | * @param cause The cause of the exception. 30 | */ 31 | public InvalidConfigurationException(Throwable cause) { 32 | super(cause); 33 | } 34 | 35 | /** 36 | * Constructs an instance of InvalidConfigurationException with the 37 | * specified message and cause. 38 | * 39 | * @param cause The cause of the exception. 40 | * @param msg The details of the exception. 41 | */ 42 | public InvalidConfigurationException(String msg, Throwable cause) { 43 | super(msg, cause); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/MemoryConfigurationOptions.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration; 2 | 3 | /** 4 | * Various settings for controlling the input and output of a {@link 5 | * MemoryConfiguration} 6 | */ 7 | public class MemoryConfigurationOptions extends ConfigurationOptions { 8 | protected MemoryConfigurationOptions(MemoryConfiguration configuration) { 9 | super(configuration); 10 | } 11 | 12 | @Override 13 | public MemoryConfiguration configuration() { 14 | return (MemoryConfiguration) super.configuration(); 15 | } 16 | 17 | @Override 18 | public MemoryConfigurationOptions copyDefaults(boolean value) { 19 | super.copyDefaults(value); 20 | return this; 21 | } 22 | 23 | @Override 24 | public MemoryConfigurationOptions pathSeparator(char value) { 25 | super.pathSeparator(value); 26 | return this; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/file/YamlConstructor.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration.file; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | 6 | import org.dragonet.configuration.serialization.ConfigurationSerialization; 7 | import org.yaml.snakeyaml.constructor.SafeConstructor; 8 | import org.yaml.snakeyaml.error.YAMLException; 9 | import org.yaml.snakeyaml.nodes.Node; 10 | import org.yaml.snakeyaml.nodes.Tag; 11 | 12 | public class YamlConstructor extends SafeConstructor { 13 | 14 | public YamlConstructor() { 15 | this.yamlConstructors.put(Tag.MAP, new ConstructCustomObject()); 16 | } 17 | 18 | private class ConstructCustomObject extends ConstructYamlMap { 19 | @Override 20 | public Object construct(Node node) { 21 | if (node.isTwoStepsConstruction()) { 22 | throw new YAMLException("Unexpected referential mapping structure. Node: " + node); 23 | } 24 | 25 | Map raw = (Map) super.construct(node); 26 | 27 | if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) { 28 | Map typed = new LinkedHashMap(raw.size()); 29 | for (Map.Entry entry : raw.entrySet()) { 30 | typed.put(entry.getKey().toString(), entry.getValue()); 31 | } 32 | 33 | try { 34 | return ConfigurationSerialization.deserializeObject(typed); 35 | } catch (IllegalArgumentException ex) { 36 | throw new YAMLException("Could not deserialize object", ex); 37 | } 38 | } 39 | 40 | return raw; 41 | } 42 | 43 | @Override 44 | public void construct2ndStep(Node node, Object object) { 45 | throw new YAMLException("Unexpected referential mapping structure. Node: " + node); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/file/YamlRepresenter.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration.file; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.Map; 5 | 6 | import org.dragonet.configuration.ConfigurationSection; 7 | import org.dragonet.configuration.serialization.ConfigurationSerializable; 8 | import org.dragonet.configuration.serialization.ConfigurationSerialization; 9 | import org.yaml.snakeyaml.nodes.Node; 10 | import org.yaml.snakeyaml.representer.Representer; 11 | 12 | public class YamlRepresenter extends Representer { 13 | 14 | public YamlRepresenter() { 15 | this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection()); 16 | this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable()); 17 | } 18 | 19 | private class RepresentConfigurationSection extends RepresentMap { 20 | @Override 21 | public Node representData(Object data) { 22 | return super.representData(((ConfigurationSection) data).getValues(false)); 23 | } 24 | } 25 | 26 | private class RepresentConfigurationSerializable extends RepresentMap { 27 | @Override 28 | public Node representData(Object data) { 29 | ConfigurationSerializable serializable = (ConfigurationSerializable) data; 30 | Map values = new LinkedHashMap(); 31 | values.put(ConfigurationSerialization.SERIALIZED_TYPE_KEY, ConfigurationSerialization.getAlias(serializable.getClass())); 32 | values.putAll(serializable.serialize()); 33 | 34 | return super.representData(values); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/serialization/ConfigurationSerializable.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration.serialization; 2 | 3 | import java.util.Map; 4 | 5 | /** 6 | * Represents an object that may be serialized. 7 | *

8 | * These objects MUST implement one of the following, in addition to the 9 | * methods as defined by this interface: 10 | *

    11 | *
  • A static method "deserialize" that accepts a single {@link Map}< 12 | * {@link String}, {@link Object}> and returns the class.
  • 13 | *
  • A static method "valueOf" that accepts a single {@link Map}<{@link 14 | * String}, {@link Object}> and returns the class.
  • 15 | *
  • A constructor that accepts a single {@link Map}<{@link String}, 16 | * {@link Object}>.
  • 17 | *
18 | * In addition to implementing this interface, you must register the class 19 | * with {@link ConfigurationSerialization#registerClass(Class)}. 20 | * 21 | * @see DelegateDeserialization 22 | * @see SerializableAs 23 | */ 24 | public interface ConfigurationSerializable { 25 | 26 | /** 27 | * Creates a Map representation of this class. 28 | *

29 | * This class must provide a method to restore this class, as defined in 30 | * the {@link ConfigurationSerializable} interface javadocs. 31 | * 32 | * @return Map containing the current state of this class 33 | */ 34 | public Map serialize(); 35 | } 36 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/serialization/DelegateDeserialization.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration.serialization; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Applies to a {@link ConfigurationSerializable} that will delegate all 10 | * deserialization to another {@link ConfigurationSerializable}. 11 | */ 12 | @Retention(RetentionPolicy.RUNTIME) 13 | @Target(ElementType.TYPE) 14 | public @interface DelegateDeserialization { 15 | /** 16 | * Which class should be used as a delegate for this classes 17 | * deserialization 18 | * 19 | * @return Delegate class 20 | */ 21 | public Class value(); 22 | } 23 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/configuration/serialization/SerializableAs.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.configuration.serialization; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /** 9 | * Represents an "alias" that a {@link ConfigurationSerializable} may be 10 | * stored as. 11 | * If this is not present on a {@link ConfigurationSerializable} class, it 12 | * will use the fully qualified name of the class. 13 | *

14 | * This value will be stored in the configuration so that the configuration 15 | * deserialization can determine what type it is. 16 | *

17 | * Using this annotation on any other class than a {@link 18 | * ConfigurationSerializable} will have no effect. 19 | * 20 | * @see ConfigurationSerialization#registerClass(Class, String) 21 | */ 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Target(ElementType.TYPE) 24 | public @interface SerializableAs { 25 | /** 26 | * This is the name your class will be stored and retrieved as. 27 | *

28 | * This name MUST be unique. We recommend using names such as 29 | * "MyPluginThing" instead of "Thing". 30 | * 31 | * @return Name to serialize the class as. 32 | */ 33 | public String value(); 34 | } 35 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/DesktopServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy; 14 | 15 | import java.util.Map; 16 | 17 | import org.dragonet.proxy.configuration.RemoteServer; 18 | import org.dragonet.proxy.network.ClientConnection; 19 | import org.dragonet.proxy.network.adapter.MCPCServerProtocolAdapter; 20 | import org.dragonet.proxy.network.adapter.ServerProtocolAdapter; 21 | 22 | public class DesktopServer extends RemoteServer { 23 | 24 | private MCPCServerProtocolAdapter protocol; 25 | 26 | public static DesktopServer deserialize(Map map) { 27 | return (DesktopServer) delicatedDeserialize(new DesktopServer(), map); 28 | } 29 | 30 | @Override 31 | public final ServerProtocolAdapter getProtocolAdapter(ClientConnection session) { 32 | if(protocol == null){ 33 | protocol = new MCPCServerProtocolAdapter(); 34 | protocol.setClient(session); 35 | } 36 | return protocol; 37 | } 38 | } 39 | 40 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/NetworkConnectionManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy; 14 | 15 | import lombok.Getter; 16 | import lombok.Setter; 17 | import org.dragonet.proxy.network.SessionRegister; 18 | import org.dragonet.proxy.network.adapter.ClientProtocolAdapter; 19 | 20 | /** 21 | * 22 | * @author robotman3000 23 | */ 24 | public class NetworkConnectionManager { 25 | 26 | @Getter 27 | private SessionRegister sessionRegister; 28 | 29 | @Getter 30 | @Setter 31 | private String motd = ""; 32 | 33 | private final DragonProxy proxy; 34 | private final ClientProtocolAdapter clientNetwork; 35 | 36 | public NetworkConnectionManager(DragonProxy proxy, ClientProtocolAdapter clientNetwork) { 37 | this.proxy = proxy; 38 | this.sessionRegister = new SessionRegister(proxy); 39 | this.clientNetwork = clientNetwork; 40 | } 41 | 42 | public void onTick() { 43 | clientNetwork.onTick(); 44 | sessionRegister.onTick(); 45 | //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/PocketServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy; 14 | 15 | import java.util.Map; 16 | 17 | import org.dragonet.proxy.configuration.RemoteServer; 18 | import org.dragonet.proxy.network.ClientConnection; 19 | import org.dragonet.proxy.network.adapter.MCPEServerProtocolAdapter; 20 | import org.dragonet.proxy.network.adapter.ServerProtocolAdapter; 21 | 22 | public class PocketServer extends RemoteServer { 23 | 24 | private MCPEServerProtocolAdapter protocol; 25 | 26 | public static PocketServer deserialize(Map map) { 27 | return (PocketServer) delicatedDeserialize(new PocketServer(), map); 28 | } 29 | 30 | @Override 31 | public final ServerProtocolAdapter getProtocolAdapter(ClientConnection session) { 32 | if(protocol == null){ 33 | protocol = new MCPEServerProtocolAdapter(); 34 | protocol.setClient(session); 35 | } 36 | return protocol; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/ServerMetrics.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy; 14 | 15 | import java.io.File; 16 | import java.io.IOException; 17 | 18 | import org.dragonet.proxy.utilities.Versioning; 19 | import org.mcstats.Metrics; 20 | 21 | public class ServerMetrics extends Metrics { 22 | 23 | private final DragonProxy proxy; 24 | 25 | public ServerMetrics(DragonProxy proxy) throws IOException { 26 | super("DragonProxy", Versioning.RELEASE_VERSION); 27 | this.proxy = proxy; 28 | 29 | Metrics.Graph g = createGraph("Extra Data"); 30 | g.addPlotter(new Plotter("OnlineMode") { 31 | @Override 32 | public int getValue() { 33 | if(proxy.getAuthMode().equals("cls")){ 34 | return 0; 35 | }else if(proxy.getAuthMode().equals("online")){ 36 | return 1; 37 | }else{ 38 | return 2; 39 | } 40 | } 41 | }); 42 | } 43 | 44 | @Override 45 | public String getFullServerVersion() { 46 | return Versioning.RELEASE_VERSION; 47 | } 48 | 49 | @Override 50 | public int getPlayersOnline() { 51 | return proxy 52 | .getNetwork() 53 | .getSessionRegister() 54 | .getOnlineCount(); 55 | } 56 | 57 | @Override 58 | public File getConfigFile() { 59 | return new File("statistic.properties"); 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/TickerThread.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy; 14 | 15 | public class TickerThread extends Thread { 16 | 17 | private final DragonProxy proxy; 18 | 19 | public TickerThread(DragonProxy proxy) { 20 | this.proxy = proxy; 21 | setDaemon(true); 22 | } 23 | 24 | @Override 25 | public void run() { 26 | long time; 27 | while (!proxy.isShuttingDown()) { 28 | time = System.currentTimeMillis(); 29 | proxy.onTick(); 30 | time = System.currentTimeMillis() - time; 31 | if (time >= 50) { 32 | continue; 33 | } else { 34 | try { 35 | Thread.sleep(50 - time); 36 | } catch (InterruptedException ex) { 37 | return; 38 | } 39 | } 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/Command.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.commands; 2 | 3 | import lombok.Getter; 4 | 5 | import org.dragonet.proxy.DragonProxy; 6 | 7 | public abstract class Command { 8 | 9 | @Getter 10 | private final String name; 11 | 12 | private CommandRegister commandMap = null; 13 | 14 | @Getter 15 | protected String description = ""; 16 | 17 | public Command(String name) { 18 | this(name, ""); 19 | } 20 | 21 | public Command(String name, String description) { 22 | this.name = name; 23 | this.description = description; 24 | } 25 | 26 | public abstract void execute(DragonProxy proxy, String[] args); 27 | } 28 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/ConsoleCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.commands; 14 | 15 | import org.dragonet.proxy.DragonProxy; 16 | 17 | public interface ConsoleCommand { 18 | 19 | public void execute(DragonProxy proxy, String[] args); 20 | } 21 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/ConsoleCommandReader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.commands; 14 | 15 | import java.io.IOException; 16 | 17 | import jline.console.ConsoleReader; 18 | 19 | import org.dragonet.proxy.DragonProxy; 20 | import org.dragonet.proxy.utilities.Logger; 21 | 22 | public class ConsoleCommandReader { 23 | 24 | private final Logger logger; 25 | 26 | private final DragonProxy proxy; 27 | 28 | private ConsoleReader reader; 29 | 30 | public ConsoleCommandReader(DragonProxy proxy) { 31 | this.proxy = proxy; 32 | this.logger = proxy.getLogger(); 33 | 34 | try { 35 | reader = new ConsoleReader(); 36 | } catch (IOException ex) { 37 | logger.severe("Exception initializing console reader: " + ex); 38 | } 39 | } 40 | 41 | public void startConsole() { 42 | Thread thread = new ConsoleCommandThread(); 43 | thread.setName("ConsoleCommandThread"); 44 | thread.setDaemon(true); 45 | thread.start(); 46 | } 47 | 48 | 49 | private class ConsoleCommandThread extends Thread { 50 | 51 | @Override 52 | public void run() { 53 | String command = ""; 54 | while (!proxy.isShuttingDown()) { 55 | try { 56 | command = reader.readLine(">", null); 57 | 58 | if (command == null || command.trim().length() == 0) { 59 | continue; 60 | } 61 | 62 | proxy.getCommandRegister().callCommand(command); 63 | } catch (Exception ex) { 64 | logger.severe("Error while reading command: " + ex); 65 | } 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/defaults/HelpCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.commands.defaults; 14 | 15 | import java.util.Map; 16 | import java.util.TreeMap; 17 | 18 | import org.dragonet.proxy.DragonProxy; 19 | import org.dragonet.proxy.commands.Command; 20 | import org.dragonet.proxy.utilities.MCColor; 21 | 22 | public class HelpCommand extends Command { 23 | 24 | public HelpCommand(String name) { 25 | super(name, "Displays commands for DragonProxy"); 26 | } 27 | 28 | @Override 29 | public void execute(DragonProxy proxy, String[] args) { 30 | proxy.getLogger().info(MCColor.GREEN + "----[ All commands for DragonProxy ]----"); 31 | 32 | Map commands = new TreeMap<>(); 33 | for (Command cmd : proxy.getCommandRegister().getCommands().values()) { 34 | commands.put(cmd.getName(), cmd); 35 | } 36 | 37 | for (Command command1 : commands.values()) { 38 | proxy.getLogger().info(MCColor.DARK_GREEN + command1.getName() + ": " + MCColor.WHITE + command1.getDescription()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/defaults/KillCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.commands.defaults; 14 | 15 | import org.dragonet.proxy.DragonProxy; 16 | import org.dragonet.proxy.commands.Command; 17 | 18 | // Only use if you have to. Clients will eventually timeout. 19 | public class KillCommand extends Command { 20 | 21 | public KillCommand(String name) { 22 | super(name, "Forcefully kill the proxy"); 23 | } 24 | 25 | @Override 26 | public void execute(DragonProxy proxy, String[] args) { 27 | proxy.getLogger().info("Forcefully killing proxy..."); 28 | System.exit(0); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/commands/defaults/StopCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.commands.defaults; 14 | 15 | import org.dragonet.proxy.DragonProxy; 16 | import org.dragonet.proxy.commands.Command; 17 | 18 | public class StopCommand extends Command { 19 | 20 | public StopCommand(String name) { 21 | super(name, "Stop the proxy"); 22 | } 23 | 24 | @Override 25 | public void execute(DragonProxy proxy, String[] args) { 26 | proxy.shutdown(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/configuration/PropertiesConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.configuration; 14 | 15 | import java.io.File; 16 | import java.io.FileInputStream; 17 | import java.io.FileOutputStream; 18 | import java.io.IOException; 19 | import java.io.InputStream; 20 | import java.util.Properties; 21 | 22 | import lombok.Getter; 23 | 24 | public class PropertiesConfig { 25 | 26 | @Getter 27 | private final Properties config; 28 | 29 | public PropertiesConfig(String defaultResourcePath, String fileName, boolean saveDefault) throws IOException { 30 | Properties defaultConfig = new Properties(); 31 | defaultConfig.load(PropertiesConfig.class.getResourceAsStream(defaultResourcePath)); 32 | config = new Properties(defaultConfig); 33 | File file = new File(fileName); 34 | if (file.exists()) { 35 | config.load(new FileInputStream(fileName)); 36 | } else if (saveDefault) { 37 | FileOutputStream fos = new FileOutputStream(fileName); 38 | InputStream ris = PropertiesConfig.class.getResourceAsStream(defaultResourcePath); 39 | int d = -1; 40 | while ((d = ris.read()) != -1) { 41 | fos.write(d); 42 | } 43 | fos.close(); 44 | ris.close(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/configuration/RemoteServer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.configuration; 14 | 15 | import java.util.LinkedHashMap; 16 | import java.util.Map; 17 | 18 | import lombok.Getter; 19 | import lombok.Setter; 20 | 21 | import org.dragonet.configuration.serialization.ConfigurationSerializable; 22 | import org.dragonet.proxy.network.ClientConnection; 23 | import org.dragonet.proxy.network.adapter.ServerProtocolAdapter; 24 | 25 | public abstract class RemoteServer implements ConfigurationSerializable { 26 | @Getter 27 | @Setter 28 | private String remoteAddr; 29 | 30 | @Getter 31 | @Setter 32 | private int remotePort; 33 | 34 | public void setRemote_addr(String remoteAddr) { 35 | setRemoteAddr(remoteAddr); 36 | } 37 | 38 | public void setRemote_port(int reportPort) { 39 | setRemotePort(reportPort); 40 | } 41 | 42 | @Override 43 | public Map serialize() { 44 | Map map = new LinkedHashMap<>(); 45 | map.put("remote_addr", remoteAddr); 46 | map.put("remote_port", remotePort); 47 | return map; 48 | } 49 | 50 | /** 51 | * Required for deserailization. 52 | * @param server 53 | * @param map 54 | * @return 55 | */ 56 | public static RemoteServer delicatedDeserialize(RemoteServer server, Map map) { 57 | server.remoteAddr = (String) map.get("remote_addr"); 58 | server.remotePort = ((Number) map.get("remote_port")).intValue(); 59 | return server; 60 | } 61 | 62 | public abstract ServerProtocolAdapter getProtocolAdapter(ClientConnection session); 63 | } 64 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/configuration/ServerConfig.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.configuration; 14 | 15 | import java.util.Map; 16 | 17 | import lombok.Getter; 18 | import lombok.Setter; 19 | 20 | public class ServerConfig { 21 | 22 | @Getter @Setter 23 | private String lang = "default"; 24 | 25 | @Getter @Setter 26 | private String udp_bind_ip = "0.0.0.0"; 27 | 28 | @Getter @Setter 29 | private int udp_bind_port = 19132; 30 | 31 | @Getter @Setter 32 | private String motd = "&aServer by DragonProxy"; 33 | 34 | @Getter @Setter 35 | private String default_server = "NONE"; 36 | 37 | @Getter @Setter 38 | private Map remote_servers; 39 | 40 | @Getter @Setter 41 | private String mode = "cls"; 42 | 43 | @Getter @Setter 44 | private String command_prefix = "/"; 45 | 46 | @Getter @Setter 47 | private int max_players = -1; 48 | 49 | @Getter @Setter 50 | private boolean log_console = true; 51 | 52 | @Getter @Setter 53 | private int thread_pool_size; 54 | 55 | @Getter @Setter 56 | private boolean acceptPCClients; 57 | 58 | } 59 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/EntityMetaDataObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta; 14 | 15 | public interface EntityMetaDataObject { 16 | 17 | public int type(); 18 | 19 | public byte[] encode(); 20 | } 21 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/ByteArrayMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | import java.nio.charset.StandardCharsets; 18 | 19 | import org.dragonet.proxy.entity.meta.EntityMetaData; 20 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 21 | 22 | public class ByteArrayMeta implements EntityMetaDataObject { 23 | 24 | public byte[] data; 25 | 26 | public ByteArrayMeta(byte[] data) { 27 | this.data = data; 28 | } 29 | 30 | public ByteArrayMeta(String data) { 31 | this(data.getBytes(StandardCharsets.UTF_8)); 32 | } 33 | 34 | @Override 35 | public int type() { 36 | return EntityMetaData.Constants.DATA_TYPE_STRING; 37 | } 38 | 39 | @Override 40 | public byte[] encode() { 41 | ByteBuffer buff = ByteBuffer.allocate(2 + this.data.length); 42 | buff.order(ByteOrder.LITTLE_ENDIAN); 43 | buff.putShort((short) (this.data.length & 0xFFFF)); 44 | buff.put(this.data); 45 | return buff.array(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/ByteMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import org.dragonet.proxy.entity.meta.EntityMetaData; 16 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 17 | 18 | public class ByteMeta implements EntityMetaDataObject { 19 | 20 | public byte data; 21 | 22 | public ByteMeta(byte data) { 23 | this.data = data; 24 | } 25 | 26 | @Override 27 | public int type() { 28 | return EntityMetaData.Constants.DATA_TYPE_BYTE; 29 | } 30 | 31 | @Override 32 | public byte[] encode() { 33 | return new byte[]{this.data}; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/CoordinateMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class CoordinateMeta implements EntityMetaDataObject { 22 | 23 | public int data1; 24 | public int data2; 25 | public int data3; 26 | 27 | public CoordinateMeta(int data1, int data2, int data3) { 28 | this.data1 = data1; 29 | this.data2 = data2; 30 | this.data3 = data3; 31 | } 32 | 33 | @Override 34 | public int type() { 35 | return EntityMetaData.Constants.DATA_TYPE_POS; 36 | } 37 | 38 | @Override 39 | public byte[] encode() { 40 | ByteBuffer buff = ByteBuffer.allocate(12); 41 | buff.order(ByteOrder.LITTLE_ENDIAN); 42 | buff.putInt(this.data1); 43 | buff.putInt(this.data2); 44 | buff.putInt(this.data3); 45 | return buff.array(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/FloatMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class FloatMeta implements EntityMetaDataObject { 22 | 23 | public float data; 24 | 25 | public FloatMeta(float data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public int type() { 31 | return EntityMetaData.Constants.DATA_TYPE_FLOAT; 32 | } 33 | 34 | @Override 35 | public byte[] encode() { 36 | ByteBuffer buff = ByteBuffer.allocate(4); 37 | buff.order(ByteOrder.LITTLE_ENDIAN); 38 | buff.putFloat(this.data); 39 | return buff.array(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/IntegerMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class IntegerMeta implements EntityMetaDataObject { 22 | 23 | public int data; 24 | 25 | public IntegerMeta(int data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public int type() { 31 | return EntityMetaData.Constants.DATA_TYPE_INT; 32 | } 33 | 34 | @Override 35 | public byte[] encode() { 36 | ByteBuffer buff = ByteBuffer.allocate(4); 37 | buff.order(ByteOrder.LITTLE_ENDIAN); 38 | buff.putInt(this.data); 39 | return buff.array(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/LongMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class LongMeta implements EntityMetaDataObject { 22 | 23 | public long data; 24 | 25 | public LongMeta(long data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public int type() { 31 | return EntityMetaData.Constants.DATA_TYPE_LONG; 32 | } 33 | 34 | @Override 35 | public byte[] encode() { 36 | ByteBuffer buff = ByteBuffer.allocate(8); 37 | buff.order(ByteOrder.LITTLE_ENDIAN); 38 | buff.putLong(this.data); 39 | return buff.array(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/ShortMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class ShortMeta implements EntityMetaDataObject { 22 | 23 | public short data; 24 | 25 | public ShortMeta(short data) { 26 | this.data = data; 27 | } 28 | 29 | @Override 30 | public int type() { 31 | return EntityMetaData.Constants.DATA_TYPE_SHORT; 32 | } 33 | 34 | @Override 35 | public byte[] encode() { 36 | ByteBuffer buff = ByteBuffer.allocate(2); 37 | buff.order(ByteOrder.LITTLE_ENDIAN); 38 | buff.putShort(this.data); 39 | return buff.array(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/entity/meta/type/SlotMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.entity.meta.type; 14 | 15 | import java.nio.ByteBuffer; 16 | import java.nio.ByteOrder; 17 | 18 | import org.dragonet.proxy.entity.meta.EntityMetaData; 19 | import org.dragonet.proxy.entity.meta.EntityMetaDataObject; 20 | 21 | public class SlotMeta implements EntityMetaDataObject { 22 | 23 | public short data1; 24 | public byte data2; 25 | public short data3; 26 | 27 | public SlotMeta(short data1, byte data2, short data3) { 28 | this.data1 = data1; 29 | this.data2 = data2; 30 | this.data3 = data3; 31 | } 32 | 33 | @Override 34 | public int type() { 35 | return EntityMetaData.Constants.DATA_TYPE_SLOT; 36 | } 37 | 38 | @Override 39 | public byte[] encode() { 40 | ByteBuffer buff = ByteBuffer.allocate(5); 41 | buff.order(ByteOrder.LITTLE_ENDIAN); 42 | buff.putShort(this.data1); 43 | buff.put(this.data2); 44 | buff.putShort(this.data3); 45 | return buff.array(); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/CacheKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network; 14 | 15 | public final class CacheKey { 16 | 17 | // PEPacket 18 | public final static String PACKET_JOIN_GAME_PACKET = "achedJoinGamePacket"; 19 | 20 | // int 21 | public final static String PLAYER_EID = "player_entity_id"; 22 | 23 | // int 24 | public final static String AUTHENTICATION_STATE = "auth_state"; 25 | 26 | // String 27 | public final static String AUTHENTICATION_EMAIL = "auth_mail"; 28 | 29 | // Position 30 | public final static String BLOCK_BREAKING_POSITION = "block_breaking_position"; 31 | 32 | 33 | // Position 34 | public final static String WINDOW_BLOCK_POSITION = "window_block_position"; 35 | 36 | // int 37 | public final static String WINDOW_OPENED_ID = "window_opened_id"; 38 | } 39 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/ConnectionStatus.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network; 2 | 3 | public enum ConnectionStatus { 4 | 5 | UNCONNECTED, 6 | AWAITING_CLIENT_AUTHENTICATION, 7 | CONNECTING_CLIENT, 8 | AWAITING_CLIENT_LOGIN, 9 | CONNECTING_SERVER, 10 | AWAITING_SERVER_LOGIN, 11 | CONNECTED; 12 | } 13 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/SessionRegister.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network; 14 | 15 | import java.util.Collections; 16 | import java.util.HashMap; 17 | import java.util.Iterator; 18 | import java.util.Map; 19 | import java.util.UUID; 20 | import lombok.Getter; 21 | import lombok.Setter; 22 | 23 | import org.dragonet.proxy.DragonProxy; 24 | 25 | public class SessionRegister { 26 | 27 | private final DragonProxy proxy; 28 | 29 | private final Map clients = Collections.synchronizedMap(new HashMap()); 30 | 31 | public SessionRegister(DragonProxy proxy) { 32 | this.proxy = proxy; 33 | } 34 | 35 | public void onTick() { 36 | Iterator> iterator = clients.entrySet().iterator(); 37 | while (iterator.hasNext()) { 38 | Map.Entry ent = iterator.next(); 39 | ent.getValue().onTick(); 40 | } 41 | } 42 | 43 | public void removeSession(ClientConnection session) { 44 | clients.remove(session.getSessionID()); 45 | } 46 | 47 | public ClientConnection getSession(UUID identifier) { 48 | return clients.get(identifier); 49 | } 50 | 51 | public Map getAll() { 52 | return Collections.unmodifiableMap(clients); 53 | } 54 | 55 | public int getOnlineCount() { 56 | return clients.size(); 57 | } 58 | 59 | public boolean acceptConnection(ClientConnection session){ 60 | if(clients.size() < proxy.getConfig().getMax_players()){ 61 | clients.put(session.getSessionID(), session); 62 | return true; 63 | } 64 | return false; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/adapter/ClientProtocolAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.adapter; 14 | 15 | import java.util.UUID; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | 18 | /** 19 | * @author robotman3000 20 | */ 21 | public interface ClientProtocolAdapter extends ProtocolAdapter { 22 | public void sendPacket(T packet, ClientConnection id); 23 | 24 | public void clientDisconectRequest(ClientConnection id, String reason); 25 | 26 | public void onTick(); 27 | } 28 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/adapter/ProtocolAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.adapter; 14 | 15 | import java.util.UUID; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | 18 | /** 19 | * Adapts a protocol to the common protocol used by the proxy 20 | * 21 | * @author robotman3000 22 | */ 23 | public interface ProtocolAdapter { 24 | 25 | public void handlePacket(T packet, ClientConnection identifier); 26 | 27 | public Class getSupportedPacketType(); 28 | } 29 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/adapter/ServerProtocolAdapter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.adapter; 14 | import org.dragonet.proxy.network.ClientConnection; 15 | 16 | /** 17 | * @author robotman3000 18 | */ 19 | public interface ServerProtocolAdapter extends ProtocolAdapter { 20 | 21 | public void connectToRemoteServer(String address, int port); 22 | 23 | public void disconnectFromRemoteServer(String reason); 24 | 25 | public void setClient(ClientConnection session); 26 | 27 | public void sendPacket(T packet); 28 | } 29 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/cache/CachedEntity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.cache; 14 | 15 | import java.util.Collections; 16 | import java.util.HashSet; 17 | import java.util.Set; 18 | import java.util.UUID; 19 | 20 | import lombok.Data; 21 | 22 | import org.dragonet.proxy.entity.EntityType; 23 | import org.spacehq.mc.protocol.data.game.entity.metadata.EntityMetadata; 24 | import org.spacehq.mc.protocol.data.game.entity.type.object.ObjectType; 25 | 26 | @Data 27 | public class CachedEntity { 28 | 29 | public final int eid; 30 | 31 | public final int pcType; 32 | public final EntityType peType; 33 | 34 | public final ObjectType objType; 35 | 36 | public final boolean player; 37 | public final UUID playerUniqueId; 38 | 39 | public double x; 40 | public double y; 41 | public double z; 42 | 43 | public double motionX; 44 | public double motionY; 45 | public double motionZ; 46 | 47 | public float yaw; 48 | public float pitch; 49 | 50 | public EntityMetadata[] pcMeta; 51 | 52 | public boolean spawned; 53 | 54 | public final Set effects = Collections.synchronizedSet(new HashSet()); 55 | 56 | public CachedEntity relativeMove(double rx, double ry, double rz, float yaw, float pitch) { 57 | x += rx; 58 | y += ry; 59 | z += rz; 60 | this.yaw = yaw; 61 | this.pitch = pitch; 62 | return this; 63 | } 64 | 65 | public CachedEntity relativeMove(double rx, double ry, double rz) { 66 | x += rx; 67 | y += ry; 68 | z += rz; 69 | return this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/cache/CachedWindow.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.cache; 14 | 15 | import java.util.Collections; 16 | import java.util.HashMap; 17 | import java.util.Map; 18 | 19 | import org.spacehq.mc.protocol.data.game.entity.metadata.ItemStack; 20 | import org.spacehq.mc.protocol.data.game.window.WindowType; 21 | 22 | public class CachedWindow { 23 | 24 | public final int windowId; 25 | 26 | /** 27 | * The type of this window on remote side, -1 for player inventory. 28 | */ 29 | public final WindowType pcType; 30 | 31 | public final int size; 32 | 33 | public String title = "Window"; 34 | 35 | public final Map properties = Collections.synchronizedMap(new HashMap()); 36 | 37 | public ItemStack[] slots; 38 | 39 | public CachedWindow(int windowId, WindowType pcType, int size) { 40 | this.windowId = windowId; 41 | this.pcType = pcType; 42 | this.size = size; 43 | slots = new ItemStack[this.size]; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/IgnorePacketTranslator.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network.translator; 2 | 3 | import org.dragonet.proxy.network.ClientConnection; 4 | import org.spacehq.packetlib.packet.Packet; 5 | 6 | import net.marfgamer.jraknet.RakNetPacket; 7 | 8 | public class IgnorePacketTranslator implements PEPacketTranslator, PCPacketTranslator { 9 | 10 | @Override 11 | public RakNetPacket[] translate(ClientConnection session, Packet packet) { 12 | System.err.println("[PC to PE] Ignoring packet: " + packet.getClass().getCanonicalName()); 13 | return new RakNetPacket[0]; 14 | } 15 | 16 | @Override 17 | public Packet[] translate(ClientConnection session, sul.utils.Packet packet) { 18 | System.err.println("[PE to PC] Ignoring packet: " + packet.getClass().getCanonicalName()); 19 | return new Packet[0]; 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/InventoryTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedWindow; 17 | 18 | 19 | public interface InventoryTranslator { 20 | /** 21 | * Opens a window on MCPE. 22 | * @param session 23 | * @param window 24 | * @return Can that window be opened on MCPE? 25 | */ 26 | public boolean open(ClientConnection session, CachedWindow window); 27 | 28 | /** 29 | * Update a window's content. 30 | * @param session 31 | * @param window 32 | */ 33 | public void updateContent(ClientConnection session, CachedWindow window); 34 | 35 | /** 36 | * Update a single slot in a window. 37 | * @param session 38 | * @param window 39 | * @param slotIndex 40 | */ 41 | public void updateSlot(ClientConnection session, CachedWindow window, int slotIndex); 42 | } 43 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/PCPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator; 14 | 15 | import net.marfgamer.jraknet.RakNetPacket; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.spacehq.packetlib.packet.Packet; 18 | 19 | public interface PCPacketTranslator

{ 20 | 21 | /** 22 | * Translate a packet from PC version to PE version. 23 | * 24 | * @param session 25 | * @param packet 26 | * @return 27 | */ 28 | public RakNetPacket[] translate(ClientConnection session, P packet); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/PEPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator; 14 | 15 | import net.marfgamer.jraknet.RakNetPacket; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.spacehq.packetlib.packet.Packet; 18 | 19 | public interface PEPacketTranslator

{ 20 | 21 | /** 22 | * Translate a packet from PE version to PC version. 23 | * 24 | * @param session 25 | * @param packet 26 | * @return 27 | */ 28 | public Packet[] translate(ClientConnection session, P packet); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCBlockChangePacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.ItemBlockTranslator; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.UpdateBlockPacket; 22 | 23 | public class PCBlockChangePacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerBlockChangePacket packet) { 27 | UpdateBlockPacket pk = new UpdateBlockPacket(); 28 | pk.flags = UpdateBlockPacket.FLAG_ALL; 29 | pk.blockId = (byte) (ItemBlockTranslator.translateToPE(packet.getRecord().getBlock().getId()) & 0xFF); 30 | pk.blockData = (byte) (packet.getRecord().getBlock().getData() & 0xFF); 31 | pk.x = packet.getRecord().getPosition().getX(); 32 | pk.y = (byte) (packet.getRecord().getPosition().getY() & 0xFF); 33 | pk.z = packet.getRecord().getPosition().getZ(); 34 | return new DataPacket[]{pk}; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCChatPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.MessageTranslator; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.TextPacket; 22 | 23 | public class PCChatPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerChatPacket packet) throws java.lang.IllegalStateException{ 27 | TextPacket ret = new TextPacket(); 28 | /* 29 | * Reset the chat message so we can parse the JSON again (if needed) 30 | */ 31 | ret.source = session.getUsername(); 32 | ret.message = MessageTranslator.translate(packet.getMessage()); 33 | //ret.message = packet.getMessage().getText(); 34 | /* switch (packet.getType()) { 35 | case CHAT: 36 | ret.type = TextPacket.TYPE_CHAT; 37 | break; 38 | case NOTIFICATION: 39 | ret.type = TextPacket.TYPE_CHAT; 40 | break; 41 | case SYSTEM: 42 | ret.type = TextPacket.TYPE_SYSTEM; 43 | break; 44 | default: 45 | ret.type = TextPacket.TYPE_SYSTEM; 46 | break; 47 | }*/ 48 | 49 | ret.type = TextPacket.TYPE_SYSTEM; 50 | return new DataPacket[]{ret}; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCDestroyEntitiesPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityDestroyPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.RemoveEntityPacket; 22 | 23 | public class PCDestroyEntitiesPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerEntityDestroyPacket packet) { 27 | DataPacket[] ret = new DataPacket[packet.getEntityIds().length]; 28 | for (int i = 0; i < ret.length; i++) { 29 | CachedEntity e = session.getEntityCache().remove(packet.getEntityIds()[i]); 30 | if (e == null) { 31 | continue; 32 | } 33 | ret[i] = new RemoveEntityPacket(); 34 | ((RemoveEntityPacket) ret[i]).eid = e.eid; 35 | } 36 | return ret; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCEntityHeadLookPacketTranslator.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network.translator.pc; 2 | 3 | import org.dragonet.proxy.network.ClientConnection; 4 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 5 | import org.spacehq.packetlib.packet.Packet; 6 | 7 | import cn.nukkit.network.protocol.DataPacket; 8 | 9 | public class PCEntityHeadLookPacketTranslator implements PCPacketTranslator { 10 | 11 | @Override 12 | public DataPacket[] translate(ClientConnection session, Packet packet) { 13 | // TODO Auto-generated method stub 14 | return null; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCEntityPositionPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.MoveEntityPacket; 22 | 23 | public class PCEntityPositionPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerEntityPositionPacket packet) { 27 | CachedEntity e = session.getEntityCache().get(packet.getEntityId()); 28 | if (e == null) { 29 | return null; 30 | } 31 | 32 | e.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ()); 33 | 34 | MoveEntityPacket pk = new MoveEntityPacket(); 35 | pk.eid = e.eid; 36 | pk.yaw = e.yaw; 37 | pk.headYaw = e.yaw; 38 | pk.pitch = e.pitch; 39 | pk.x = (float) e.x; 40 | pk.y = (float) e.y; 41 | if(e.player){ 42 | pk.y += 1.62f; 43 | } 44 | pk.z = (float) e.z; 45 | return new DataPacket[]{pk}; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCEntityPositionRotationPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.MoveEntityPacket; 22 | 23 | public class PCEntityPositionRotationPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerEntityPositionRotationPacket packet) { 27 | CachedEntity e = session.getEntityCache().get(packet.getEntityId()); 28 | if (e == null) { 29 | return null; 30 | } 31 | 32 | e.relativeMove(packet.getMovementX(), packet.getMovementY(), packet.getMovementZ(), packet.getYaw(), packet.getPitch()); 33 | 34 | MoveEntityPacket pk = new MoveEntityPacket(); 35 | pk.eid = e.eid; 36 | pk.yaw = e.yaw; 37 | pk.headYaw = e.yaw; 38 | pk.pitch = e.pitch; 39 | pk.x = (float) e.x; 40 | pk.y = (float) e.y; 41 | if(e.player){ 42 | pk.y += 1.62f; 43 | } 44 | pk.z = (float) e.z; 45 | return new DataPacket[]{pk}; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCEntityRemoveEffectPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.CacheKey; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.dragonet.proxy.network.cache.CachedEntity; 18 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 19 | import org.spacehq.mc.protocol.data.MagicValues; 20 | import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRemoveEffectPacket; 21 | 22 | import cn.nukkit.network.protocol.DataPacket; 23 | import cn.nukkit.network.protocol.MobEffectPacket; 24 | 25 | public class PCEntityRemoveEffectPacketTranslator implements PCPacketTranslator { 26 | 27 | @Override 28 | public DataPacket[] translate(ClientConnection session, ServerEntityRemoveEffectPacket packet) { 29 | CachedEntity entity = session.getEntityCache().get(packet.getEntityId()); 30 | if (entity == null) { 31 | return null; 32 | } 33 | int effectId = MagicValues.value(Integer.class, packet.getEffect()); 34 | if (!entity.effects.contains(effectId)) { 35 | return null; 36 | } 37 | MobEffectPacket eff = new MobEffectPacket(); 38 | eff.eid = packet.getEntityId() == (int) session.getDataCache().get(CacheKey.PLAYER_EID) ? 0 : packet.getEntityId(); 39 | eff.effectId = MobEffectPacket.EVENT_REMOVE; 40 | return new DataPacket[]{eff}; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCEntityVelocityPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.SetEntityMotionPacket; 22 | 23 | public class PCEntityVelocityPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerEntityVelocityPacket packet) { 27 | CachedEntity e = session.getEntityCache().get(packet.getEntityId()); 28 | if (e == null) { 29 | return null; 30 | } 31 | e.motionX = packet.getMotionX(); 32 | e.motionY = packet.getMotionY(); 33 | e.motionZ = packet.getMotionZ(); 34 | 35 | SetEntityMotionPacket pk = new SetEntityMotionPacket(); 36 | pk.eid = packet.getEntityId(); 37 | pk.motionX = (float) packet.getMotionX(); 38 | pk.motionY = (float) packet.getMotionY(); 39 | pk.motionZ = (float) packet.getMotionZ(); 40 | return new DataPacket[]{pk}; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCLoginSucessPacketTranslator.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network.translator.pc; 2 | 3 | import org.dragonet.proxy.DragonProxy; 4 | import org.dragonet.proxy.network.ClientConnection; 5 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 6 | import org.spacehq.mc.protocol.packet.login.server.LoginSuccessPacket; 7 | 8 | import cn.nukkit.network.protocol.DataPacket; 9 | import cn.nukkit.network.protocol.PlayStatusPacket; 10 | import cn.nukkit.network.protocol.ResourcePacksInfoPacket; 11 | 12 | public class PCLoginSucessPacketTranslator implements PCPacketTranslator { 13 | 14 | @Override 15 | public DataPacket[] translate(ClientConnection session, LoginSuccessPacket packet) { 16 | DragonProxy.getLogger().info("Recieved LoginSuccessPacket from remote server for player: " + packet.getProfile()); 17 | PlayStatusPacket pkPlayStatus = new PlayStatusPacket(); 18 | pkPlayStatus.status = PlayStatusPacket.LOGIN_SUCCESS; 19 | 20 | // ResourcePacksInfoPacket Required; Causes the client to switch to the "locating server" screen 21 | return new DataPacket[] {pkPlayStatus, new ResourcePacksInfoPacket()}; 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCMultiBlockChangePacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.ItemBlockTranslator; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.UpdateBlockPacket; 22 | 23 | public class PCMultiBlockChangePacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerMultiBlockChangePacket packet) { 27 | UpdateBlockPacket[] packets = new UpdateBlockPacket[packet.getRecords().length]; 28 | byte generalFlag = (byte) (packet.getRecords().length > 64 ? UpdateBlockPacket.FLAG_PRIORITY : UpdateBlockPacket.FLAG_ALL); 29 | for (int i = 0; i < packets.length; i++) { 30 | packets[i] = new UpdateBlockPacket(); 31 | packets[i].flags = generalFlag; 32 | packets[i].x = packet.getRecords()[i].getPosition().getX(); 33 | packets[i].y = (byte) (packet.getRecords()[i].getPosition().getY() & 0xFF); 34 | packets[i].z = packet.getRecords()[i].getPosition().getZ(); 35 | packets[i].blockId = (byte) (ItemBlockTranslator.translateToPE(packet.getRecords()[i].getBlock().getId()) & 0xFF); 36 | packets[i].blockData = (byte) (packet.getRecords()[i].getBlock().getData() & 0xFF); 37 | } 38 | return packets; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCOpenWindowPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.InventoryTranslatorRegister; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | 22 | public class PCOpenWindowPacketTranslator implements PCPacketTranslator { 23 | 24 | @Override 25 | public DataPacket[] translate(ClientConnection session, ServerOpenWindowPacket packet) { 26 | session.getProxy().getGeneralThreadPool().execute(() -> { 27 | InventoryTranslatorRegister.open(session, packet); 28 | }); 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCPlayerListItemPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 17 | import org.spacehq.mc.protocol.data.game.PlayerListEntry; 18 | import org.spacehq.mc.protocol.data.game.PlayerListEntryAction; 19 | import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket; 20 | 21 | import cn.nukkit.network.protocol.DataPacket; 22 | 23 | public class PCPlayerListItemPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerPlayerListEntryPacket packet) { 27 | if(packet.getAction() == PlayerListEntryAction.ADD_PLAYER){ 28 | PlayerListEntry[] entries = packet.getEntries(); 29 | for (PlayerListEntry entrie : entries) { 30 | session.getPlayerInfoCache().put(entrie.getProfile().getId(), entrie); 31 | } 32 | }else if(packet.getAction() == PlayerListEntryAction.REMOVE_PLAYER){ 33 | PlayerListEntry[] entries = packet.getEntries(); 34 | for (PlayerListEntry entrie : entries) { 35 | session.getPlayerInfoCache().remove(entrie.getProfile().getId()); 36 | } 37 | } 38 | return null; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCPlayerPositionRotationPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; 19 | 20 | import cn.nukkit.network.protocol.DataPacket; 21 | import cn.nukkit.network.protocol.MovePlayerPacket; 22 | 23 | public class PCPlayerPositionRotationPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerPlayerPositionRotationPacket packet) { 27 | MovePlayerPacket pkMovePlayer = new MovePlayerPacket(); 28 | pkMovePlayer.eid = 0; 29 | pkMovePlayer.x = (float) packet.getX(); 30 | pkMovePlayer.y = (float) packet.getY(); 31 | pkMovePlayer.z = (float) packet.getZ(); 32 | pkMovePlayer.headYaw = 0.0f; 33 | pkMovePlayer.yaw = 0.0f; 34 | pkMovePlayer.pitch = 0.0f; 35 | pkMovePlayer.onGround = false; 36 | pkMovePlayer.mode = MovePlayerPacket.MODE_RESET; 37 | 38 | CachedEntity cliEntity = session.getEntityCache().getClientEntity(); 39 | cliEntity.x = packet.getX(); 40 | cliEntity.y = packet.getY(); 41 | cliEntity.z= packet.getZ(); 42 | return new DataPacket[]{pkMovePlayer}; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCSetSlotPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.InventoryTranslatorRegister; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.dragonet.proxy.network.cache.CachedWindow; 18 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 19 | import org.spacehq.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket; 20 | 21 | import cn.nukkit.network.protocol.DataPacket; 22 | 23 | public class PCSetSlotPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerSetSlotPacket packet) { 27 | if (!session.getWindowCache().hasWindow(packet.getWindowId())) { 28 | //Cache this 29 | session.getWindowCache().newCachedPacket(packet.getWindowId(), packet); 30 | return null; 31 | } 32 | CachedWindow win = session.getWindowCache().get(packet.getWindowId()); 33 | if (win.pcType == null && packet.getWindowId() != 0) return null; 34 | if (packet.getWindowId() == 0) { 35 | if(packet.getSlot() >= win.slots.length) return null; 36 | win.slots[packet.getSlot()] = packet.getItem(); 37 | return InventoryTranslatorRegister.sendPlayerInventory(session); //Too lazy lol 38 | } 39 | InventoryTranslatorRegister.updateSlot(session, packet); 40 | return null; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCSpawnMobPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.EntityMetaTranslator; 18 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 19 | import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket; 20 | 21 | import cn.nukkit.network.protocol.AddEntityPacket; 22 | import cn.nukkit.network.protocol.DataPacket; 23 | 24 | public class PCSpawnMobPacketTranslator implements PCPacketTranslator { 25 | 26 | @Override 27 | public DataPacket[] translate(ClientConnection session, ServerSpawnMobPacket packet) { 28 | try { 29 | CachedEntity e = session.getEntityCache().newEntity(packet); 30 | if (e == null) { 31 | return null; 32 | } 33 | 34 | AddEntityPacket pk = new AddEntityPacket(); 35 | pk.entityRuntimeId = e.eid; 36 | pk.type = e.peType.getPeType(); 37 | pk.x = (float) e.x; 38 | pk.y = (float) e.y; 39 | pk.z = (float) e.z; 40 | pk.speedX = (float) e.motionX; 41 | pk.speedY = (float) e.motionY; 42 | pk.speedZ = (float) e.motionZ; 43 | //TODO: Hack for now. ;P 44 | pk.metadata = EntityMetaTranslator.translateToPE(e.pcMeta, e.peType); 45 | 46 | return new DataPacket[]{pk}; 47 | } catch (Exception e) { 48 | e.printStackTrace(); 49 | return null; 50 | } 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCSpawnObjectPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 18 | import org.spacehq.mc.protocol.data.game.entity.type.object.ObjectType; 19 | import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket; 20 | 21 | import cn.nukkit.network.protocol.DataPacket; 22 | 23 | public class PCSpawnObjectPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerSpawnObjectPacket packet) { 27 | if(packet.getType() == ObjectType.ITEM){ 28 | //Currently only handles item data 29 | CachedEntity futureEntity = session.getEntityCache().newObject(packet); 30 | //This crap needs entity meta to be completed so we have to wait. 31 | return null; 32 | } 33 | return null; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCUpdateHealthPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 17 | import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket; 18 | 19 | import cn.nukkit.network.protocol.DataPacket; 20 | import cn.nukkit.network.protocol.RespawnPacket; 21 | import cn.nukkit.network.protocol.SetHealthPacket; 22 | 23 | public class PCUpdateHealthPacketTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerPlayerHealthPacket packet) { 27 | // TODO: Support food and saturation 28 | SetHealthPacket h = new SetHealthPacket(); 29 | h.health = (int) packet.getHealth(); 30 | if (packet.getHealth() > 0 && h.health <= 0) { 31 | h.health = 1; 32 | } 33 | if (packet.getHealth() <= 0.0f) { 34 | RespawnPacket r = new RespawnPacket(); 35 | r.x = 0.0f; 36 | r.y = 0.0f; 37 | r.z = 0.0f; 38 | return new DataPacket[]{h, r}; 39 | } 40 | return new DataPacket[]{h}; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCUpdateTimePacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 17 | import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket; 18 | 19 | import cn.nukkit.network.protocol.DataPacket; 20 | import cn.nukkit.network.protocol.SetTimePacket; 21 | 22 | public class PCUpdateTimePacketTranslator implements PCPacketTranslator { 23 | 24 | @Override 25 | public DataPacket[] translate(ClientConnection session, ServerUpdateTimePacket packet) { 26 | SetTimePacket pk = new SetTimePacket(); 27 | pk.time = (int) packet.getTime(); 28 | pk.started = true; 29 | return new DataPacket[]{pk}; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc/PCWindowItemsTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pc; 14 | 15 | import org.dragonet.proxy.network.InventoryTranslatorRegister; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.dragonet.proxy.network.cache.CachedWindow; 18 | import org.dragonet.proxy.network.translator.PCPacketTranslator; 19 | import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket; 20 | 21 | import cn.nukkit.network.protocol.DataPacket; 22 | 23 | public class PCWindowItemsTranslator implements PCPacketTranslator { 24 | 25 | @Override 26 | public DataPacket[] translate(ClientConnection session, ServerWindowItemsPacket packet) { 27 | if (!session.getWindowCache().hasWindow(packet.getWindowId())) { 28 | //Cache this 29 | session.getWindowCache().newCachedPacket(packet.getWindowId(), packet); 30 | return null; 31 | } 32 | CachedWindow win = session.getWindowCache().get(packet.getWindowId()); 33 | if (win.pcType == null && packet.getWindowId() == 0) { 34 | if (packet.getItems().length < 45) { 35 | //Almost impossible to happen either. 36 | return null; 37 | } 38 | //Update items in window cache 39 | win.slots = packet.getItems(); 40 | return InventoryTranslatorRegister.sendPlayerInventory(session); 41 | } 42 | InventoryTranslatorRegister.updateContent(session, packet); 43 | return null; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PEChatPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pe; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 17 | import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket; 18 | import org.spacehq.packetlib.packet.Packet; 19 | import sul.protocol.pocket100.play.Text.Chat; 20 | 21 | public class PEChatPacketTranslator implements PEPacketTranslator { 22 | 23 | @Override 24 | public Packet[] translate(ClientConnection session, Chat packet) { 25 | // What is packet.parameters for? 26 | ClientChatPacket pk = new ClientChatPacket(packet.message); 27 | return new Packet[]{pk}; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PEInteractPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pe; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 17 | import org.spacehq.mc.protocol.data.game.entity.player.InteractAction; 18 | import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket; 19 | import org.spacehq.packetlib.packet.Packet; 20 | 21 | import cn.nukkit.network.protocol.InteractPacket; 22 | 23 | public class PEInteractPacketTranslator implements PEPacketTranslator { 24 | 25 | @Override 26 | public Packet[] translate(ClientConnection session, InteractPacket packet) { 27 | ClientPlayerInteractEntityPacket pk = new ClientPlayerInteractEntityPacket((int) (packet.target & 0xFFFFFFFF), InteractAction.ATTACK); 28 | return new Packet[]{pk}; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PEMovePlayerPacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pe; 14 | 15 | import org.dragonet.proxy.network.ClientConnection; 16 | import org.dragonet.proxy.network.cache.CachedEntity; 17 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 18 | import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket; 19 | import org.spacehq.packetlib.packet.Packet; 20 | 21 | import cn.nukkit.network.protocol.MovePlayerPacket; 22 | 23 | public class PEMovePlayerPacketTranslator implements PEPacketTranslator { 24 | 25 | @Override 26 | public Packet[] translate(ClientConnection session, MovePlayerPacket packet) { 27 | ClientPlayerPositionRotationPacket pk = new ClientPlayerPositionRotationPacket(!packet.onGround, packet.x, packet.y, packet.z, packet.yaw, packet.pitch); 28 | CachedEntity cliEntity = session.getEntityCache().getClientEntity(); 29 | cliEntity.x = packet.x; 30 | cliEntity.y = packet.y; 31 | cliEntity.z = packet.z; 32 | return new Packet[]{pk}; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PERequestChunkRadiusPacketTranslator.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network.translator.pe; 2 | 3 | import org.dragonet.proxy.network.ClientConnection; 4 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 5 | import org.spacehq.packetlib.packet.Packet; 6 | 7 | import cn.nukkit.network.protocol.ChunkRadiusUpdatedPacket; 8 | import cn.nukkit.network.protocol.RequestChunkRadiusPacket; 9 | 10 | public class PERequestChunkRadiusPacketTranslator implements PEPacketTranslator { 11 | 12 | @Override 13 | public Packet[] translate(ClientConnection session, RequestChunkRadiusPacket packet) { 14 | ChunkRadiusUpdatedPacket pk = new ChunkRadiusUpdatedPacket(); 15 | pk.radius = packet.radius; 16 | session.sendPacket(pk); 17 | return null; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PERespawnPacketTranslator.java: -------------------------------------------------------------------------------- 1 | package org.dragonet.proxy.network.translator.pe; 2 | 3 | import org.dragonet.proxy.network.ClientConnection; 4 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 5 | import org.spacehq.mc.protocol.data.game.ClientRequest; 6 | import org.spacehq.mc.protocol.packet.ingame.client.ClientRequestPacket; 7 | import org.spacehq.packetlib.packet.Packet; 8 | 9 | import cn.nukkit.network.protocol.RespawnPacket; 10 | 11 | public class PERespawnPacketTranslator implements PEPacketTranslator { 12 | 13 | @Override 14 | public Packet[] translate(ClientConnection session, RespawnPacket packet) { 15 | System.err.println("Respawning Client"); 16 | ClientRequestPacket pack = new ClientRequestPacket(ClientRequest.RESPAWN); 17 | return new Packet[]{pack}; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe/PEWindowClosePacketTranslator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.network.translator.pe; 14 | 15 | import org.dragonet.proxy.network.InventoryTranslatorRegister; 16 | import org.dragonet.proxy.network.ClientConnection; 17 | import org.dragonet.proxy.network.translator.PEPacketTranslator; 18 | import org.spacehq.packetlib.packet.Packet; 19 | 20 | import cn.nukkit.network.protocol.ContainerClosePacket; 21 | 22 | public class PEWindowClosePacketTranslator implements PEPacketTranslator { 23 | 24 | @Override 25 | public Packet[] translate(ClientConnection session, ContainerClosePacket packet) { 26 | session.getProxy().getGeneralThreadPool().execute(() -> { 27 | InventoryTranslatorRegister.closeOpened(session, false); 28 | }); 29 | return null; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/DefaultSkin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities; 14 | 15 | import java.io.ByteArrayOutputStream; 16 | import java.io.IOException; 17 | import java.io.InputStream; 18 | 19 | public class DefaultSkin { 20 | 21 | protected static String NAME; 22 | protected static String SKIN_BASE64_ENCODED; 23 | 24 | protected static MCPESkin SKIN; 25 | 26 | static { 27 | loadSkin(); 28 | } 29 | 30 | public static String getDefaultSkinName() { 31 | return NAME; 32 | } 33 | 34 | public static String getDefaultSkinBase64Encoded() { 35 | return SKIN_BASE64_ENCODED; 36 | } 37 | 38 | public static MCPESkin getDefaultSkin() { 39 | return SKIN; 40 | } 41 | 42 | private static void loadSkin() { 43 | try { 44 | ByteArrayOutputStream bos = new ByteArrayOutputStream(); 45 | InputStream ins = DefaultSkin.class.getResourceAsStream("/defaults/SKIN.BIN"); 46 | int d = -1; 47 | while((d = ins.read()) != -1){ 48 | if(d == ':') { 49 | NAME = new String(bos.toByteArray(), "UTF-8"); 50 | bos.reset(); 51 | } else { 52 | bos.write(d); 53 | } 54 | 55 | } 56 | ins.close(); 57 | SKIN_BASE64_ENCODED = new String(bos.toByteArray(), "UTF-8"); 58 | 59 | SKIN = new MCPESkin(SKIN_BASE64_ENCODED, NAME); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/PatternChecker.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities; 14 | 15 | import java.util.regex.Matcher; 16 | import java.util.regex.Pattern; 17 | 18 | public final class PatternChecker { 19 | 20 | public final static String REGEX_EMAIL = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; 21 | 22 | public final static Pattern PATTERN_EMAIL = Pattern.compile(REGEX_EMAIL); 23 | 24 | public static boolean matchEmail(String email) { 25 | Matcher matcher = PATTERN_EMAIL.matcher(email); 26 | return matcher.matches(); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/Terminal.java: -------------------------------------------------------------------------------- 1 | 2 | package org.dragonet.proxy.utilities; 3 | 4 | @Deprecated 5 | public class Terminal { 6 | public static final String ITALIC = "\u001B[3m"; 7 | public static final String UNDERLINE = "\u001B[4m"; 8 | 9 | public static final String BLACK = "\u001B[30m"; 10 | public static final String RED = "\u001B[31m"; 11 | public static final String GREEN = "\u001B[32m"; 12 | public static final String YELLOW = "\u001B[33m"; 13 | public static final String BLUE = "\u001B[34m"; 14 | public static final String MAGENTA = "\u001B[35m"; 15 | public static final String CYAN = "\u001B[36m"; 16 | public static final String WHITE = "\u001B[37m"; 17 | } -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/Versioning.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities; 14 | 15 | import org.spacehq.mc.protocol.MinecraftConstants; 16 | 17 | public class Versioning { 18 | 19 | public final static int VERSION_INT = 007; //History: 0.0.6.01 (You can't have preR1 in an int!) 20 | public final static String RELEASE_VERSION = "0.0.7"; 21 | 22 | public final static String MINECRAFT_PC_VERSION = MinecraftConstants.GAME_VERSION; 23 | public final static int MINECRAFT_PC_PROTOCOL = MinecraftConstants.PROTOCOL_VERSION; 24 | 25 | // This is STRICT to MCPE binary's definition, DO NOT CHANGE 26 | public final static String MINECRAFT_PE_VERSION = "1.0.2"; 27 | 28 | public final static int MINECRAFT_PE_PROTOCOL = 100; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/io/ArraySplitter.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities.io; 14 | 15 | import java.util.Arrays; 16 | 17 | public final class ArraySplitter { 18 | 19 | public static byte[][] splitArray(byte[] array, int singleSlice) { 20 | if (array.length <= singleSlice) { 21 | byte[][] singleRet = new byte[1][]; 22 | singleRet[0] = array; 23 | return singleRet; 24 | } 25 | byte[][] ret = new byte[(array.length / singleSlice + (array.length % singleSlice == 0 ? 0 : 1))][]; 26 | int pos = 0; 27 | int slice = 0; 28 | while (slice < ret.length) { 29 | if (pos + singleSlice < array.length) { 30 | ret[slice] = Arrays.copyOfRange(array, pos, pos + singleSlice); 31 | pos += singleSlice; 32 | slice++; 33 | } else { 34 | ret[slice] = Arrays.copyOfRange(array, pos, array.length); 35 | pos += array.length - pos; 36 | slice++; 37 | } 38 | } 39 | return ret; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/io/ByteUtility.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities.io; 14 | 15 | public class ByteUtility { 16 | 17 | public static String bytesToHexString(byte[] data) { 18 | StringBuilder sb = new StringBuilder(); 19 | String sTemp; 20 | for (int i = 0; i < data.length; i++) { 21 | sTemp = Integer.toHexString(0xFF & data[i]); 22 | if (sTemp.length() < 2) { 23 | sb.append(0); 24 | } 25 | sb.append(sTemp.toUpperCase()).append(", "); 26 | } 27 | return sb.toString(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/io/DataIOPair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities.io; 14 | 15 | import java.io.DataInputStream; 16 | import java.io.DataOutputStream; 17 | 18 | import lombok.Getter; 19 | 20 | public class DataIOPair { 21 | 22 | private @Getter 23 | DataInputStream input; 24 | 25 | private @Getter 26 | DataOutputStream output; 27 | 28 | public DataIOPair(DataInputStream input, DataOutputStream output) { 29 | this.input = input; 30 | this.output = output; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/io/PEBinaryUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ 13 | package org.dragonet.proxy.utilities.io; 14 | 15 | public abstract class PEBinaryUtils { 16 | 17 | public final static boolean BIG_ENDIAN = false; 18 | public final static boolean LITTLE_ENDIAN = true; 19 | 20 | public static byte[] write(long x, int length, boolean endianness) { 21 | byte[] result = new byte[length]; 22 | for (int i = 0; i < length; i++) { 23 | result[endianness == BIG_ENDIAN ? (length - 1 - i) : i] = (byte) (x & 0xFF); 24 | x >>= 8; 25 | } 26 | return result; 27 | } 28 | 29 | public static byte[] write(long x, int length) { 30 | return write(x, length, BIG_ENDIAN); 31 | } 32 | 33 | public static long read(byte[] buffer, int start, int length, boolean endianness) { 34 | long x = 0; 35 | for (int i = 0; i < length; i++) { 36 | x <<= 8; 37 | x |= buffer[endianness == BIG_ENDIAN ? (start + i) : (start + length - 1 - i)] & 0xFF; 38 | } 39 | return x; 40 | } 41 | 42 | public static long read(byte[] buffer, int start, int length) { 43 | return read(buffer, start, length, BIG_ENDIAN); 44 | } 45 | 46 | public static long read(byte[] buffer, boolean endianness) { 47 | return read(buffer, 0, buffer.length, endianness); 48 | } 49 | 50 | public static long read(byte[] buffer) { 51 | return read(buffer, 0, buffer.length, BIG_ENDIAN); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/org/dragonet/proxy/utilities/io/SkinDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package org.dragonet.proxy.utilities.io; 7 | 8 | import java.io.ByteArrayOutputStream; 9 | import java.io.DataInputStream; 10 | import java.net.HttpURLConnection; 11 | import java.net.URL; 12 | 13 | public class SkinDownloader { 14 | 15 | public static byte[] download(String username) { 16 | try { 17 | URL url = new URL(String.format("http://s3.amazonaws.com/MinecraftSkins/%s.png", username)); 18 | 19 | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); 20 | DataInputStream in = new DataInputStream(connection.getInputStream()); 21 | 22 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 23 | 24 | byte[] buffer = new byte[4096]; 25 | int count = 0; 26 | while ((count = in.read(buffer)) > 0) { 27 | out.write(buffer, 0, count); 28 | } 29 | out.close(); 30 | in.close(); 31 | connection.disconnect(); 32 | return out.toByteArray(); 33 | 34 | } catch (Exception e) { 35 | return null; 36 | } 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/attributes/Pocket100.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/attributes/pocket100.xml 8 | */ 9 | package sul.attributes; 10 | 11 | public enum Pocket100 { 12 | 13 | HEALTH("minecraft:health", 0f, 20f, 20f), 14 | 15 | ABSORPTION("minecraft:generic.absorption", 0f, 4f, 0f), 16 | 17 | HUNGER("minecraft:player.hunger", 0f, 20f, 20f), 18 | 19 | SATURATION("minecraft:player.saturation", 0f, 20f, 5f), 20 | 21 | EXPERIENCE("minecraft:player.experience", 0f, 1f, 0f), 22 | 23 | LEVEL("minecraft:player.level", 0f, 24791f, 0f), 24 | 25 | SPEED("minecraft:movement", 0f, 24791f, 0.1f), 26 | 27 | KNOCKBACK_RESISTANCE("minecraft:generic.knockback_resistance", 0f, 1f, 0f); 28 | 29 | public final String name; 30 | public final float min, max, def; 31 | 32 | Pocket100(String name, float min, float max, float def) { 33 | this.name = name; 34 | this.min = min; 35 | this.max = max; 36 | this.def = def; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/metadata/Pocket100.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/metadata/pocket100.xml 8 | */ 9 | package sul.metadata; 10 | 11 | import sul.utils.*; 12 | 13 | public class Pocket100 extends Packet { 14 | 15 | @Override 16 | public int length() { 17 | return 0; 18 | } 19 | 20 | @Override 21 | public byte[] encode() { 22 | return new byte[]{}; 23 | } 24 | 25 | @Override 26 | public void decode(byte[] buffer) { 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/AddItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import sul.utils.*; 12 | 13 | public class AddItem extends Packet { 14 | 15 | public static final byte ID = (byte)74; 16 | 17 | public static final boolean CLIENTBOUND = true; 18 | public static final boolean SERVERBOUND = false; 19 | 20 | public sul.protocol.pocket100.types.Slot item; 21 | 22 | public AddItem() {} 23 | 24 | public AddItem(sul.protocol.pocket100.types.Slot item) { 25 | this.item = item; 26 | } 27 | 28 | @Override 29 | public int length() { 30 | return item.length() + 1; 31 | } 32 | 33 | @Override 34 | public byte[] encode() { 35 | this._buffer = new byte[this.length()]; 36 | this.writeBigEndianByte(ID); 37 | this.writeBytes(item.encode()); 38 | return this._buffer; 39 | } 40 | 41 | @Override 42 | public void decode(byte[] buffer) { 43 | this._buffer = buffer; 44 | readBigEndianByte(); 45 | item=new sul.protocol.pocket100.types.Slot(); item._index=this._index; item.decode(this._buffer); this._index=item._index; 46 | } 47 | 48 | public static AddItem fromBuffer(byte[] buffer) { 49 | AddItem ret = new AddItem(); 50 | ret.decode(buffer); 51 | return ret; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/Animate.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import sul.utils.*; 12 | 13 | public class Animate extends Packet { 14 | 15 | public static final byte ID = (byte)44; 16 | 17 | public static final boolean CLIENTBOUND = true; 18 | public static final boolean SERVERBOUND = true; 19 | 20 | // action 21 | public static final int BREAKING = 1; 22 | public static final int WAKE_UP = 3; 23 | 24 | public int action; 25 | public long entityId; 26 | 27 | public Animate() {} 28 | 29 | public Animate(int action, long entityId) { 30 | this.action = action; 31 | this.entityId = entityId; 32 | } 33 | 34 | @Override 35 | public int length() { 36 | return Buffer.varintLength(action) + Buffer.varlongLength(entityId) + 1; 37 | } 38 | 39 | @Override 40 | public byte[] encode() { 41 | this._buffer = new byte[this.length()]; 42 | this.writeBigEndianByte(ID); 43 | this.writeVarint(action); 44 | this.writeVarlong(entityId); 45 | return this._buffer; 46 | } 47 | 48 | @Override 49 | public void decode(byte[] buffer) { 50 | this._buffer = buffer; 51 | readBigEndianByte(); 52 | action=this.readVarint(); 53 | entityId=this.readVarlong(); 54 | } 55 | 56 | public static Animate fromBuffer(byte[] buffer) { 57 | Animate ret = new Animate(); 58 | ret.decode(buffer); 59 | return ret; 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/AvailableCommands.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import java.nio.charset.StandardCharsets; 12 | 13 | import sul.utils.*; 14 | 15 | public class AvailableCommands extends Packet { 16 | 17 | public static final byte ID = (byte)77; 18 | 19 | public static final boolean CLIENTBOUND = true; 20 | public static final boolean SERVERBOUND = false; 21 | 22 | public String commands; 23 | 24 | public AvailableCommands() {} 25 | 26 | public AvailableCommands(String commands) { 27 | this.commands = commands; 28 | } 29 | 30 | @Override 31 | public int length() { 32 | return Buffer.varuintLength(commands.getBytes(StandardCharsets.UTF_8).length) + commands.getBytes(StandardCharsets.UTF_8).length + 1; 33 | } 34 | 35 | @Override 36 | public byte[] encode() { 37 | this._buffer = new byte[this.length()]; 38 | this.writeBigEndianByte(ID); 39 | byte[] y29tbwfuzhm=commands.getBytes(StandardCharsets.UTF_8); this.writeVaruint((int)y29tbwfuzhm.length); this.writeBytes(y29tbwfuzhm); 40 | return this._buffer; 41 | } 42 | 43 | @Override 44 | public void decode(byte[] buffer) { 45 | this._buffer = buffer; 46 | readBigEndianByte(); 47 | int bgvuy29tbwfuzhm=this.readVaruint(); commands=new String(this.readBytes(bgvuy29tbwfuzhm), StandardCharsets.UTF_8); 48 | } 49 | 50 | public static AvailableCommands fromBuffer(byte[] buffer) { 51 | AvailableCommands ret = new AvailableCommands(); 52 | ret.decode(buffer); 53 | return ret; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/Batch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import sul.utils.*; 12 | 13 | public class Batch extends Packet { 14 | 15 | public static final byte ID = (byte)6; 16 | 17 | public static final boolean CLIENTBOUND = true; 18 | public static final boolean SERVERBOUND = true; 19 | 20 | public byte[] data; 21 | 22 | public Batch() {} 23 | 24 | public Batch(byte[] data) { 25 | this.data = data; 26 | } 27 | 28 | @Override 29 | public int length() { 30 | return Buffer.varuintLength(data.length) + data.length + 1; 31 | } 32 | 33 | @Override 34 | public byte[] encode() { 35 | this._buffer = new byte[this.length()]; 36 | this.writeBigEndianByte(ID); 37 | this.writeVaruint((int)data.length); this.writeBytes(data); 38 | return this._buffer; 39 | } 40 | 41 | @Override 42 | public void decode(byte[] buffer) { 43 | this._buffer = buffer; 44 | readBigEndianByte(); 45 | int bgrhdge=this.readVaruint(); data=this.readBytes(bgrhdge); 46 | } 47 | 48 | public static Batch fromBuffer(byte[] buffer) { 49 | Batch ret = new Batch(); 50 | ret.decode(buffer); 51 | return ret; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/BlockEntityData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import sul.utils.*; 12 | 13 | public class BlockEntityData extends Packet { 14 | 15 | public static final byte ID = (byte)56; 16 | 17 | public static final boolean CLIENTBOUND = true; 18 | public static final boolean SERVERBOUND = false; 19 | 20 | public sul.protocol.pocket100.types.BlockPosition position; 21 | public byte[] nbt; 22 | 23 | public BlockEntityData() {} 24 | 25 | public BlockEntityData(sul.protocol.pocket100.types.BlockPosition position, byte[] nbt) { 26 | this.position = position; 27 | this.nbt = nbt; 28 | } 29 | 30 | @Override 31 | public int length() { 32 | return position.length() + nbt.length + 1; 33 | } 34 | 35 | @Override 36 | public byte[] encode() { 37 | this._buffer = new byte[this.length()]; 38 | this.writeBigEndianByte(ID); 39 | this.writeBytes(position.encode()); 40 | this.writeBytes(nbt); 41 | return this._buffer; 42 | } 43 | 44 | @Override 45 | public void decode(byte[] buffer) { 46 | this._buffer = buffer; 47 | readBigEndianByte(); 48 | position=new sul.protocol.pocket100.types.BlockPosition(); position._index=this._index; position.decode(this._buffer); this._index=position._index; 49 | nbt=this.readBytes(this._buffer.length-this._index); 50 | } 51 | 52 | public static BlockEntityData fromBuffer(byte[] buffer) { 53 | BlockEntityData ret = new BlockEntityData(); 54 | ret.decode(buffer); 55 | return ret; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/protocol/pocket100/play/BlockEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | * Generated from https://github.com/sel-project/sel-utils/blob/master/xml/protocol/pocket100.xml 8 | */ 9 | package sul.protocol.pocket100.play; 10 | 11 | import sul.utils.*; 12 | 13 | public class BlockEvent extends Packet { 14 | 15 | public static final byte ID = (byte)28; 16 | 17 | public static final boolean CLIENTBOUND = true; 18 | public static final boolean SERVERBOUND = false; 19 | 20 | public sul.protocol.pocket100.types.BlockPosition position; 21 | public int[] data = new int[2]; 22 | 23 | public BlockEvent() {} 24 | 25 | public BlockEvent(sul.protocol.pocket100.types.BlockPosition position, int[] data) { 26 | this.position = position; 27 | this.data = data; 28 | } 29 | 30 | @Override 31 | public int length() { 32 | int length=position.length() + 1; for(int zgf0yq:data){ length+=Buffer.varintLength(zgf0yq); } return length; 33 | } 34 | 35 | @Override 36 | public byte[] encode() { 37 | this._buffer = new byte[this.length()]; 38 | this.writeBigEndianByte(ID); 39 | this.writeBytes(position.encode()); 40 | for(int zgf0yq:data){ this.writeVarint(zgf0yq); } 41 | return this._buffer; 42 | } 43 | 44 | @Override 45 | public void decode(byte[] buffer) { 46 | this._buffer = buffer; 47 | readBigEndianByte(); 48 | position=new sul.protocol.pocket100.types.BlockPosition(); position._index=this._index; position.decode(this._buffer); this._index=position._index; 49 | final int bgrhdge=2; data=new int[bgrhdge]; for(int zgf0yq=0;zgf0yq0){ this.writeVarint(metaAndCount); } 37 | if(id>0){ this.writeLittleEndianShort((short)nbt.length); this.writeBytes(nbt); } 38 | return this._buffer; 39 | } 40 | 41 | @Override 42 | public void decode(byte[] buffer) { 43 | this._buffer = buffer; 44 | id=this.readVarint(); 45 | if(id>0){ metaAndCount=this.readVarint(); } 46 | if(id>0){ int bg5ida=readLittleEndianShort(); nbt=this.readBytes(bg5ida); } 47 | } 48 | 49 | 50 | } 51 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/utils/Enchantment.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | */ 8 | package sul.utils; 9 | 10 | public class Enchantment { 11 | 12 | public final byte id; 13 | public final short level; 14 | 15 | public Enchantment(byte id, short level) { 16 | this.id = id; 17 | this.level = level; 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/utils/Item.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | */ 8 | package sul.utils; 9 | 10 | public class Item { 11 | 12 | public final String name; 13 | public final int id, meta; 14 | public final Enchantment[] enchantments; 15 | 16 | public Item(String name, int id, int meta, Enchantment[] enchantments) { 17 | this.name = name; 18 | this.id = id; 19 | this.meta = meta; 20 | this.enchantments = enchantments; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /DragonProxy/src/main/java/sul/utils/Packet.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file was automatically generated by sel-utils and 3 | * released under the GNU General Public License version 3. 4 | * 5 | * License: https://github.com/sel-project/sel-utils/blob/master/LICENSE 6 | * Repository: https://github.com/sel-project/sel-utils 7 | */ 8 | package sul.utils; 9 | 10 | public abstract class Packet extends Buffer { 11 | 12 | public final void reset() { 13 | this._buffer = new byte[0]; 14 | this._index = 0; 15 | } 16 | 17 | public abstract int length(); 18 | 19 | public abstract byte[] encode(); 20 | 21 | public abstract void decode(byte[] buffer); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /DragonProxy/src/main/resources/permissions.yml: -------------------------------------------------------------------------------- 1 | # ================================= 2 | #| DragonProxy Configuration File | 3 | #| Sponsered by BytePowered | 4 | # ================================= 5 | 6 | # Permissions which player will have if they have no group assigned 7 | default_permission: 8 | - 'server' 9 | 10 | # Group definitions with their permissions. 11 | groups: 12 | - admin: 13 | - 'server' 14 | - 'stop' 15 | 16 | # Users 17 | # WARNING: You must change some_random_guy to your username if you are using offline mode! 18 | users: 19 | some_random_guy: 'admin' 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Logo](http://dragonet.org/assets/img/Dragonet.png) 2 | 3 | A proxy for **Minecraft - Pocket Edition** connecting to **Minecraft PC/Mac** servers. 4 | 5 | Video by **[@MrPowerGamerBR](https://github.com/MrPowerGamerBR)** (On an older version): https://www.youtube.com/watch?v=oRSKQMzZYDE 6 | 7 | ![Screenshot](https://raw.githubusercontent.com/DragonetMC/DragonProxy/master/screenshots/TheArchon.png) 8 | 9 | Wanna donate to help us? Go to http://dragonet.org/donate.php 10 | 11 | ## Installation 12 | [![Build Status](https://drone.io/github.com/DragonetMC/DragonProxy/status.png)](https://drone.io/github.com/DragonetMC/DragonProxy/files) [Download](https://drone.io/github.com/DragonetMC/DragonProxy/files) 13 | Once compiled, run `dragonproxy-*.jar` in `proxy/target` where '*' is the version number. 14 | 15 | ## Compiling 16 | See the tutorial in the [wiki](https://github.com/DragonetMC/DragonProxy/wiki). 17 | Note: Maven won't build the project because every class in DragonProxy/DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pe and DragonProxy/DragonProxy/src/main/java/org/dragonet/proxy/network/translator/pc has compile errors. Just move these folders out of the project to fix the problem until the translators are updated 18 | 19 | #### Supported Remote Server Types 20 | - For PC/Mac Servers: `Bukkit`/`Spigot`/`Glowstone`/`SpongeVanilla`/`BungeeCord` 21 | - For Pocket Edition Servers: `MiNET`, `Nukkit`, `PocketMine-MP (and all forks)` 22 | - Not listed is **NOT** mean unsupported, just **untested**. 23 | 24 | ## Community 25 | **Website:** [http://dragonet.org](http://dragonet.org) 26 | **Forums:** [http://forums.dragonet.org](http://forums.dragonet.org) 27 | 28 | ## Libraries Used 29 | * RakLib Port by the Nukkit project @ [Site](http://nukkit.io) 30 | * @Steveice10 's MCProtocolLib @ [Link](https://github.com/Steveice10/MCProtocolLib) 31 | -------------------------------------------------------------------------------- /VERSION.txt: -------------------------------------------------------------------------------- 1 | [version]00601[/version] 2 | -------------------------------------------------------------------------------- /licenseheader.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * GNU LESSER GENERAL PUBLIC LICENSE 3 | * Version 3, 29 June 2007 4 | * 5 | * Copyright (C) 2007 Free Software Foundation, Inc. 6 | * Everyone is permitted to copy and distribute verbatim copies 7 | * of this license document, but changing it is not allowed. 8 | * 9 | * You can view LICENCE file for details. 10 | * 11 | * @author The Dragonet Team 12 | */ -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.sonatype.oss 7 | oss-parent 8 | 9 9 | 10 | 11 | org.dragonet.proxy 12 | DragonProxy-parent 13 | 0.0.7 14 | pom 15 | 16 | 17 | UTF-8 18 | 1.8 19 | 1.8 20 | 21 | 22 | 23 | 24 | DragonProxy 25 | JRakNet 26 | 27 | 28 | clean install 29 | 30 | 31 | 32 | 33 | org.projectlombok 34 | lombok 35 | 1.14.8 36 | provided 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /screenshots/MCPE0.15.4_MCPC1.8.8.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotman3000/DragonProxy/83f96e8bebb1458a9fca5b3ab09913d858ba799d/screenshots/MCPE0.15.4_MCPC1.8.8.PNG -------------------------------------------------------------------------------- /screenshots/README.md: -------------------------------------------------------------------------------- 1 | Some of these screenshots may be old. 2 | -------------------------------------------------------------------------------- /screenshots/TheArchon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotman3000/DragonProxy/83f96e8bebb1458a9fca5b3ab09913d858ba799d/screenshots/TheArchon.png -------------------------------------------------------------------------------- /screenshots/cls_mcpe.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotman3000/DragonProxy/83f96e8bebb1458a9fca5b3ab09913d858ba799d/screenshots/cls_mcpe.png -------------------------------------------------------------------------------- /screenshots/console_color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotman3000/DragonProxy/83f96e8bebb1458a9fca5b3ab09913d858ba799d/screenshots/console_color.png -------------------------------------------------------------------------------- /screenshots/online-login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robotman3000/DragonProxy/83f96e8bebb1458a9fca5b3ab09913d858ba799d/screenshots/online-login.png -------------------------------------------------------------------------------- /wiki/HowTo-CLS.md: -------------------------------------------------------------------------------- 1 | ## How to Login vis CLS 2 | #### 1. Register/Login to CLS system 3 | Login or register to Dragonet CLS system at http://auth.dragonet.org . 4 | 5 | #### 2. Add your Minecraft account 6 | If your account is already listed, click `Login & View`. 7 | If your account isn't added before, click `add` and then go to **step 4**. 8 | 9 | #### 3. Authenticate your Minecraft account 10 | Type in your Minecraft account info and click `Register`. 11 | **WARNING: **Do NOT try to login to a same account too many times within one hour or Mojang will block you from loggin in via our service for 2-3 hours. 12 | 13 | #### 4. Get and set your special username for MCPE 14 | Your special username will be displayed as huge blue text in the center of the page. 15 | Follow the instructions on the page to set up your MCPE client. 16 | **Note: **If you leaked your special username in accident, you can generate a new one on the information page. 17 | 18 | #### 5. Join servers 19 | Enjoy your game without typing your password everytime. 20 | 21 | -------------------------------------------------------------------------------- /wiki/HowTo-Online.md: -------------------------------------------------------------------------------- 1 | #### You will be noticed to login only if you enabled online mode in the configuration file. 2 | ## Step 1. Connect to your proxy and you can see 3 | ![Screenshot](https://raw.githubusercontent.com/DragonetMC/DragonProxy/master/screenshots/online-login.png) 4 | 5 | ## Step 2. Enter your e-mail address in chat and send it. 6 | 7 | ## Step 3. Enter your password and send it. (Server will not display it) 8 | #### WARNING: We do NOT guarantee that hackers using edited DragonProxy to capture your password so be careful and only join to trusted servers. 9 | 10 | ## Step 4. Wait for joining. 11 | #### If you are noticed for login faliure, disconnect and re-connect then perform this process again. 12 | 13 | -------------------------------------------------------------------------------- /wiki/NetworkExamples.md: -------------------------------------------------------------------------------- 1 | Network Example 2 | =============== 3 | 4 | ## Example. Single->Multiple 5 | `DragonProxy` <=> `PC Server 1`,`PC Server 2`,`PE Server 3`,`PE Server 4` 6 | or 7 | `DragonProxy` <=> `Spigot Server`,`Spigot Server`,`PocketMine Server`,`Nukkit Server`,`MiNet Server` 8 | 9 | ## Example 2. Single->BungeeCord 10 | `DragonProxy` <=> `BungeeCord` <=> `Spigot Server`,`Spigot Server` 11 | 12 | ## Example 3. Multiple->Single->More 13 | `DragonProxy 1`,`DragonProxy 2` <=> `DragonProxy Main` <=> `...` 14 | or 15 | `DragonProxy 1`,`DragonProxy 2` <=> `BungeeCord` <=> `...` 16 | -------------------------------------------------------------------------------- /wiki/Schema-CLS.md: -------------------------------------------------------------------------------- 1 | ## CLS Login Schema 2 | #### Default endpoint: `http://api.dragonet.org/cls` 3 | Please note that queries are sent using GET method and returned with JSON data.
4 | 5 | #### Definitions 6 | Custom usernames are USER_ID and KeyCode with underscore(`_`) in the middle of it.
7 | As for `1234_d6a5f0`, `1234` is USER_ID and `d6a5f0` is the KeyCode.
8 | 9 | ### Endpoints 10 | #### `/query_token.php` 11 | **Query**: `/query_token.php?username=USER_ID&keycode=KeyCode`
12 | **Warning**: The confusing part in this query is that `username` field is the CLS USER_ID not player's IGN.
13 | **Result**:
14 | ```text 15 | { 16 | "status": "success", //Success or not 17 | //Following fields only appears if success 18 | "ign": "USERNAME", //The in-game name(username). 19 | "client": "CLIENT_TOKEN", //Client ID 20 | "token": "ACCESS_TOKEN", //The access token. 21 | } 22 | ``` 23 | **Note**: 24 | Once you get it, you have to refresh the access token(call to `/refresh` method on MojangAPI) and get a new access token that bind to your server's IP address and upload that token back using `/update_token.php` method on CLS or the player sometimes will expirience `bad login` error.
25 | 26 | #### `/update_token.php` 27 | **Query**: `/update_token.php?username=PLAYER_IGN&oldtoken=OLD_TOKEN&newtoken=NEW_TOKEN`
28 | **Warning**: This time `username` field IS the actual player's IGN.
29 | **Result**:
30 | ```text 31 | { 32 | "status": "success", //Success or not 33 | } 34 | ``` 35 | **Note**: 36 | Although it returns something but you can't do anything about it if it fails, it can be server's problem so you may wanna just leave the result alone. 37 | 38 | -------------------------------------------------------------------------------- /wiki/Usage.md: -------------------------------------------------------------------------------- 1 | . 2 | --------------------------------------------------------------------------------