-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
790 changed files
with
119,241 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
67 changes: 67 additions & 0 deletions
67
...as/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutAbilitiesPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package cc.funkemunky.api.tinyprotocol.packet.out; | ||
|
||
import cc.funkemunky.api.reflections.Reflections; | ||
import cc.funkemunky.api.reflections.types.WrappedClass; | ||
import cc.funkemunky.api.reflections.types.WrappedField; | ||
import cc.funkemunky.api.tinyprotocol.api.NMSObject; | ||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.tinyprotocol.reflection.FieldAccessor; | ||
import lombok.Getter; | ||
import org.bukkit.entity.Player; | ||
|
||
public class WrappedOutAbilitiesPacket extends NMSObject { | ||
private static final String packet = Server.ABILITIES; | ||
|
||
private static FieldAccessor<Boolean> | ||
invulnerableField = fetchField(packet, boolean.class, 0), | ||
flyingField = fetchField(packet, boolean.class, 1), | ||
allowedFlightField = fetchField(packet, boolean.class, 2), | ||
creativeModeField = fetchField(packet, boolean.class, 3); | ||
private static FieldAccessor<Float> | ||
flySpeedField = fetchField(packet, float.class, 0), | ||
walkSpeedField = fetchField(packet, float.class, 1); | ||
|
||
private static WrappedClass abilitiesClass = Reflections.getNMSClass("PlayerAbilities"); | ||
private static WrappedField invulnerableAcc = abilitiesClass.getFieldByType(boolean.class, 0); | ||
private static WrappedField flyingAcc = abilitiesClass.getFieldByType(boolean.class, 1); | ||
private static WrappedField allowedFlightAcc = abilitiesClass.getFieldByType(boolean.class, 2); | ||
private static WrappedField creativeModeAcc = abilitiesClass.getFieldByType(boolean.class, 3); | ||
private static WrappedField flySpeedAcc = abilitiesClass.getFieldByType(float.class, 0); | ||
private static WrappedField walkSpeedAcc = abilitiesClass.getFieldByType(float.class, 1); | ||
@Getter | ||
private boolean invulnerable, flying, allowedFlight, creativeMode; | ||
@Getter | ||
private float flySpeed, walkSpeed; | ||
|
||
|
||
public WrappedOutAbilitiesPacket(Object object, Player player) { | ||
super(object, player); | ||
} | ||
|
||
public WrappedOutAbilitiesPacket(boolean invulernable, boolean flying, boolean allowedFlight, boolean creativeMode, float flySpeed, float walkSpeed) { | ||
Object abilities = abilitiesClass.getConstructorAtIndex(0).newInstance(); | ||
invulnerableAcc.set(abilities, invulernable); | ||
flyingAcc.set(abilities, flying); | ||
allowedFlightAcc.set(abilities, allowedFlight); | ||
creativeModeAcc.set(abilities, creativeMode); | ||
flySpeedAcc.set(abilities, flySpeed); | ||
walkSpeedAcc.set(abilities, walkSpeed); | ||
|
||
setObject(Reflections.getNMSClass(packet).getConstructor(abilitiesClass.getParent()).newInstance(abilities)); | ||
} | ||
|
||
@Override | ||
public void process(Player player, ProtocolVersion version) { | ||
invulnerable = fetch(invulnerableField); | ||
flying = fetch(flyingField); | ||
allowedFlight = fetch(allowedFlightField); | ||
creativeMode = fetch(creativeModeField); | ||
flySpeed = fetch(flySpeedField); | ||
walkSpeed = fetch(walkSpeedField); | ||
} | ||
|
||
@Override | ||
public void updateObject() { | ||
|
||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
.../Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutBlockChange.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package cc.funkemunky.api.tinyprotocol.packet.out; | ||
|
||
import cc.funkemunky.api.reflections.Reflections; | ||
import cc.funkemunky.api.reflections.types.WrappedClass; | ||
import cc.funkemunky.api.reflections.types.WrappedField; | ||
import cc.funkemunky.api.reflections.types.WrappedMethod; | ||
import cc.funkemunky.api.tinyprotocol.api.NMSObject; | ||
import cc.funkemunky.api.tinyprotocol.api.Packet; | ||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.tinyprotocol.packet.types.BaseBlockPosition; | ||
import cc.funkemunky.api.tinyprotocol.reflection.FieldAccessor; | ||
import cc.funkemunky.api.utils.ReflectionsUtil; | ||
import lombok.Getter; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.entity.Player; | ||
|
||
@Getter | ||
public class WrappedOutBlockChange extends NMSObject { | ||
private static final String packet = Packet.Server.BLOCK_CHANGE; | ||
|
||
//1.7.10 and below | ||
private static FieldAccessor<Integer> legacyX; | ||
private static FieldAccessor<Integer> legacyY; | ||
private static FieldAccessor<Integer> legacyZ; | ||
private static WrappedField blockChangeBlockField; | ||
private static WrappedField blockDataIntField; | ||
private static WrappedMethod getDataMethod; | ||
|
||
//1.8 and newer | ||
private static FieldAccessor<Object> blockPosAccessor; | ||
private static WrappedField iBlockDataField; | ||
|
||
|
||
private static WrappedClass blockChangeClass = Reflections.getNMSClass(packet); | ||
private static WrappedClass nmsBlockClass = Reflections.getNMSClass("Block"); | ||
private static WrappedClass craftBlockClass = Reflections.getCBClass("CraftBlock"); | ||
|
||
private BaseBlockPosition position; | ||
|
||
public WrappedOutBlockChange(Object packet) { | ||
super(packet); | ||
} | ||
|
||
public WrappedOutBlockChange(Block block) { | ||
if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10)) { | ||
setPacket(packet, block.getX(), block.getY(), block.getZ(), ReflectionsUtil.getWorldHandle(block.getWorld())); | ||
} else { | ||
setPacket(packet, ReflectionsUtil.getWorldHandle(block.getWorld()), new BaseBlockPosition(block.getX(), block.getY(), block.getZ()).getAsBlockPosition()); | ||
} | ||
} | ||
|
||
@Override | ||
public void process(Player player, ProtocolVersion version) { | ||
if (ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) { | ||
position = new BaseBlockPosition(fetch(legacyX), fetch(legacyY), fetch(legacyZ)); | ||
} else { | ||
position = new BaseBlockPosition(fetch(blockPosAccessor)); | ||
} | ||
} | ||
|
||
@Override | ||
public void updateObject() { | ||
|
||
} | ||
|
||
static { | ||
if(ProtocolVersion.getGameVersion().isBelow(ProtocolVersion.V1_8)) { | ||
legacyX = fetchField(packet, int.class, 0); | ||
legacyY = fetchField(packet, int.class, 1); | ||
legacyZ = fetchField(packet, int.class, 2); | ||
|
||
|
||
blockChangeBlockField = blockChangeClass.getFirstFieldByType(nmsBlockClass.getParent()); | ||
blockDataIntField = blockChangeClass.getFieldByName("data"); | ||
getDataMethod = Reflections.getNMSClass("World").getMethod("getData", int.class, int.class, int.class); | ||
} else { | ||
blockPosAccessor = fetchField(packet, Object.class, 0); | ||
iBlockDataField = blockChangeClass.getFieldByType(ReflectionsUtil.iBlockData, 0); | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
...t/Atlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutChatPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package cc.funkemunky.api.tinyprotocol.packet.out; | ||
|
||
import cc.funkemunky.api.reflections.Reflections; | ||
import cc.funkemunky.api.reflections.types.WrappedClass; | ||
import cc.funkemunky.api.reflections.types.WrappedConstructor; | ||
import cc.funkemunky.api.reflections.types.WrappedField; | ||
import cc.funkemunky.api.reflections.types.WrappedMethod; | ||
import cc.funkemunky.api.tinyprotocol.api.NMSObject; | ||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.tinyprotocol.packet.types.WrappedChatMessageType; | ||
import cc.funkemunky.api.utils.MiscUtils; | ||
import lombok.Getter; | ||
import net.md_5.bungee.api.chat.BaseComponent; | ||
import net.md_5.bungee.api.chat.TextComponent; | ||
import net.md_5.bungee.chat.ComponentSerializer; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.UUID; | ||
|
||
@Getter | ||
public class WrappedOutChatPacket extends NMSObject { | ||
private final static String packet = Server.CHAT; | ||
public static UUID b = new UUID(0L, 0L); | ||
|
||
public WrappedOutChatPacket(Object packetObj, Player player) { | ||
super(packetObj, player); | ||
} | ||
|
||
//Constructor (ichatbase, chattype); | ||
public WrappedOutChatPacket(TextComponent message, WrappedChatMessageType type) { | ||
setObject(constructor.newInstance()); | ||
this.message = message; | ||
this.chatType = type; | ||
updateObject(); | ||
} | ||
|
||
//1.16+ only | ||
public WrappedOutChatPacket(TextComponent message, WrappedChatMessageType chatType, UUID uuid) { | ||
setObject(constructor.newInstance()); | ||
this.message = message; | ||
this.chatType = chatType; | ||
this.uuid = uuid; | ||
updateObject(); | ||
} | ||
|
||
//Saving your fingers from the most common use for using this wrapper. | ||
public WrappedOutChatPacket(TextComponent message) { | ||
this(message, WrappedChatMessageType.CHAT); | ||
} | ||
|
||
private static WrappedClass chatBaseComp = Reflections.getNMSClass("IChatBaseComponent"); | ||
private static WrappedClass outChatClass = Reflections.getNMSClass(packet); | ||
private static WrappedConstructor constructor = outChatClass.getConstructor(); | ||
private static WrappedClass chatSerialClass = Reflections.getNMSClass("IChatBaseComponent$ChatSerializer"); | ||
private static WrappedMethod stcToComponent = chatSerialClass.getMethod("a", String.class); | ||
private static WrappedMethod getTextMethod = chatBaseComp.getMethod("getText"); | ||
private static WrappedField chatTypeField, chatCompField, fieldUUID, fieldComponents; | ||
|
||
private TextComponent message; | ||
private WrappedChatMessageType chatType; | ||
private UUID uuid = b; | ||
|
||
@Override | ||
public void process(Player player, ProtocolVersion version) { | ||
//Getting the message | ||
message = new TextComponent(ComponentSerializer.parse(getTextMethod.invoke(getObject()))); | ||
|
||
//Getting the chat type. | ||
chatType = WrappedChatMessageType.fromNMS(chatTypeField.get(getObject())); | ||
|
||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.v1_16)) { | ||
uuid = fetch(fieldUUID); | ||
} | ||
} | ||
|
||
@Override | ||
public void updateObject() { | ||
set(fieldComponents, MiscUtils.toComponentArray(message)); | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_12)) { | ||
set(chatTypeField, chatType.toNMS()); | ||
} else if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { | ||
set(chatTypeField, chatType.getTypeAsByte()); | ||
} else set(chatTypeField, chatType.getType()); | ||
|
||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.v1_16)) | ||
set(fieldUUID, b); | ||
} | ||
|
||
static { | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_12)) { | ||
chatTypeField = outChatClass.getFieldByType(Reflections.getNMSClass("ChatMessageType").getParent(), 0); | ||
} else if(ProtocolVersion.getGameVersion().isAbove(ProtocolVersion.V1_7_10)) { | ||
chatTypeField = outChatClass.getFieldByType(byte.class, 0); | ||
} else { | ||
chatTypeField = outChatClass.getFieldByType(int.class, 0); | ||
} | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.v1_16)) { | ||
fieldUUID = fetchField(outChatClass, UUID.class, 0); | ||
} | ||
chatCompField = outChatClass.getFieldByType(chatBaseComp.getParent(), 0); | ||
fieldComponents = fetchField(outChatClass, BaseComponent[].class, 0); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
.../src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutCloseWindowPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package cc.funkemunky.api.tinyprotocol.packet.out; | ||
|
||
import cc.funkemunky.api.reflections.Reflections; | ||
import cc.funkemunky.api.reflections.types.WrappedClass; | ||
import cc.funkemunky.api.reflections.types.WrappedField; | ||
import cc.funkemunky.api.tinyprotocol.api.NMSObject; | ||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import org.bukkit.entity.Player; | ||
|
||
public class WrappedOutCloseWindowPacket extends NMSObject { | ||
|
||
private static final WrappedClass packet = Reflections.getNMSClass(Server.CLOSE_WINDOW); | ||
private static final WrappedField idField = packet.getFieldByType(int.class, 0); | ||
|
||
public WrappedOutCloseWindowPacket(Object object, Player player) { | ||
super(object, player); | ||
} | ||
|
||
public WrappedOutCloseWindowPacket(int id) { | ||
this.id = id; | ||
updateObject(); | ||
} | ||
|
||
public int id; | ||
|
||
@Override | ||
public void updateObject() { | ||
setObject(NMSObject.construct(getObject(), Server.CLOSE_WINDOW, id)); | ||
} | ||
|
||
@Override | ||
public void process(Player player, ProtocolVersion version) { | ||
id = fetch(idField); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
...tlas/src/main/java/cc/funkemunky/api/tinyprotocol/packet/out/WrappedOutCustomPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package cc.funkemunky.api.tinyprotocol.packet.out; | ||
|
||
import cc.funkemunky.api.reflections.Reflections; | ||
import cc.funkemunky.api.reflections.types.WrappedClass; | ||
import cc.funkemunky.api.reflections.types.WrappedField; | ||
import cc.funkemunky.api.tinyprotocol.api.NMSObject; | ||
import cc.funkemunky.api.tinyprotocol.api.ProtocolVersion; | ||
import cc.funkemunky.api.tinyprotocol.packet.types.WrappedPacketDataSerializer; | ||
import lombok.Getter; | ||
import org.bukkit.entity.Player; | ||
|
||
//TODO Make this compatible with 1.13 and newer. | ||
@Getter | ||
public class WrappedOutCustomPayload extends NMSObject { | ||
|
||
public WrappedOutCustomPayload(Object object, Player player) { | ||
super(object, player); | ||
} | ||
|
||
public WrappedOutCustomPayload(String tag, byte[] data) { | ||
setObject(payloadClass.getConstructor().newInstance()); | ||
|
||
this.tag = tag; | ||
this.data = data; | ||
|
||
updateObject(); | ||
} | ||
|
||
private static WrappedClass payloadClass = Reflections.getNMSClass(Server.CUSTOM_PAYLOAD); | ||
private static WrappedField tagField, dataField; | ||
|
||
private String tag; | ||
private byte[] data; | ||
|
||
//1.13+ | ||
private static WrappedClass minecraftKeyWrapper; | ||
private static WrappedField keyOne, keyTwo; | ||
|
||
@Override | ||
public void process(Player player, ProtocolVersion version) { | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_13)) { | ||
Object mk = tagField.get(getObject()); | ||
tag = keyOne.get(mk) + ":" + keyTwo.get(mk); | ||
} else tag = tagField.get(getObject()); | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { | ||
data = new WrappedPacketDataSerializer(dataField.get(getObject())).getData(); | ||
|
||
} else data = dataField.get(getObject()); | ||
} | ||
|
||
@Override | ||
public void updateObject() { | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) { | ||
dataField.set(getObject(), new WrappedPacketDataSerializer(data).getObject()); | ||
} else dataField.set(getObject(), data); | ||
|
||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_13)) { | ||
if(tag.contains(":")) { | ||
Object mk = tagField.get(getObject()); | ||
String[] split = tag.split(":"); | ||
keyOne.set(mk, split[0]); | ||
keyTwo.set(mk, split[1]); | ||
} else { | ||
System.out.println("Tag (" + tag + ") must contain a ':' to be valid."); | ||
} | ||
} else tagField.set(getObject(), tag); | ||
} | ||
|
||
static { | ||
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_13)) { | ||
minecraftKeyWrapper = Reflections.getNMSClass("MinecraftKey"); | ||
keyOne = minecraftKeyWrapper.getFieldByType(String.class, 0); | ||
keyTwo = minecraftKeyWrapper.getFieldByType(String.class, 1); | ||
tagField = payloadClass.getFieldByType(minecraftKeyWrapper.getParent(), 0); | ||
} else tagField = payloadClass.getFieldByType(String.class, 0); | ||
if(ProtocolVersion.getGameVersion().isOrBelow(ProtocolVersion.V1_7_10)) { | ||
dataField = payloadClass.getFieldByType(byte[].class, 0); | ||
} else dataField = payloadClass.getFieldByType(WrappedPacketDataSerializer.vanillaClass.getParent(), 0); | ||
} | ||
} |
Oops, something went wrong.