-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6313903
commit 7729e6b
Showing
23 changed files
with
686 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ include("plugin") | |
include("common") | ||
include("v1_15_R1") | ||
include("v1_19_R3") | ||
include("v1_20") |
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,10 @@ | ||
repositories { | ||
mavenLocal() | ||
} | ||
|
||
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
|
||
dependencies { | ||
compileOnly(project(":common")) | ||
compileOnly("org.spigotmc:spigot:1.20.2-R0.1-SNAPSHOT") | ||
} |
30 changes: 30 additions & 0 deletions
30
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/chat/ChatModifierImpl.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,30 @@ | ||
package net.azisaba.loreeditor.v1_20.chat; | ||
|
||
import net.azisaba.loreeditor.common.chat.ChatModifier; | ||
import net.azisaba.loreeditor.common.util.Reflected; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
public record ChatModifierImpl(net.minecraft.network.chat.ChatModifier handle) implements ChatModifier { | ||
public ChatModifierImpl { | ||
Objects.requireNonNull(handle, "handle"); | ||
} | ||
|
||
@Contract(value = "_ -> new", pure = true) | ||
@Reflected | ||
public static @NotNull ChatModifierImpl getInstance(@NotNull Object handle) { | ||
return new ChatModifierImpl((net.minecraft.network.chat.ChatModifier) handle); | ||
} | ||
|
||
@Override | ||
public @NotNull net.minecraft.network.chat.ChatModifier handle() { | ||
return handle; | ||
} | ||
|
||
@Override | ||
public @NotNull ChatModifier setItalic(boolean italic) { | ||
return getInstance(handle.b(italic)); // setItalic | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/chat/ComponentImpl.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,58 @@ | ||
package net.azisaba.loreeditor.v1_20.chat; | ||
|
||
import net.azisaba.loreeditor.common.chat.ChatModifier; | ||
import net.azisaba.loreeditor.common.chat.Component; | ||
import net.azisaba.loreeditor.common.util.Reflected; | ||
import net.minecraft.network.chat.IChatBaseComponent; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.function.UnaryOperator; | ||
|
||
@Reflected | ||
public record ComponentImpl(IChatBaseComponent handle) implements Component { | ||
public ComponentImpl(@Nullable IChatBaseComponent handle) { | ||
this.handle = handle; | ||
} | ||
|
||
@Contract(value = "_ -> new", pure = true) | ||
@Reflected | ||
public static @NotNull ComponentImpl getInstance(@Nullable Object component) { | ||
return new ComponentImpl((IChatBaseComponent) component); | ||
} | ||
|
||
@Override | ||
public @NotNull IChatBaseComponent handle() { | ||
return Objects.requireNonNull(handle, "cannot reference handle in static context"); | ||
} | ||
|
||
@Override | ||
public @Nullable Component deserialize(@NotNull String input) { | ||
return getInstance(IChatBaseComponent.ChatSerializer.a(input)); // deserialize | ||
} | ||
|
||
@Override | ||
public @NotNull String serialize(@NotNull Component component) { | ||
return IChatBaseComponent.ChatSerializer.a(((ComponentImpl) component).handle()); // serialize | ||
} | ||
|
||
@Override | ||
public @NotNull List<?> getSiblings() { | ||
return handle().c(); // getSiblings | ||
} | ||
|
||
@Override | ||
public void addSiblingText(@NotNull String text) { | ||
handle().a(IChatBaseComponent.ChatSerializer.a(text)); // addSibling | ||
} | ||
|
||
@Override | ||
public @NotNull Component modifyStyle(@NotNull UnaryOperator<ChatModifier> action) { | ||
ChatModifier cm = new ChatModifierImpl(handle().a()); // getChatModifier | ||
net.minecraft.network.chat.ChatModifier newChatModifier = ((ChatModifierImpl) action.apply(cm)).handle(); | ||
return getInstance(handle().a(newChatModifier)); // setChatModifier | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/entity/CraftPlayer.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,21 @@ | ||
package net.azisaba.loreeditor.v1_20.entity; | ||
|
||
import net.azisaba.loreeditor.api.util.ReflectionUtil; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import xyz.acrylicstyle.util.reflector.CastTo; | ||
import xyz.acrylicstyle.util.reflector.Reflector; | ||
import xyz.acrylicstyle.util.reflector.ReflectorHandler; | ||
|
||
import java.util.Objects; | ||
|
||
public interface CraftPlayer { | ||
static @NotNull CraftPlayer getInstance(@NotNull Player player) { | ||
return Reflector.newReflector(null, CraftPlayer.class, | ||
new ReflectorHandler(ReflectionUtil.getOBCClass("entity.CraftPlayer"), Objects.requireNonNull(player, "player"))); | ||
} | ||
|
||
@NotNull | ||
@CastTo(EntityPlayer.class) | ||
EntityPlayer getHandle(); | ||
} |
22 changes: 22 additions & 0 deletions
22
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/entity/EntityPlayer.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,22 @@ | ||
package net.azisaba.loreeditor.v1_20.entity; | ||
|
||
import net.azisaba.loreeditor.api.util.ReflectionUtil; | ||
import net.azisaba.loreeditor.v1_20.network.ServerCommonPacketListenerImpl; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
import xyz.acrylicstyle.util.reflector.CastTo; | ||
import xyz.acrylicstyle.util.reflector.FieldGetter; | ||
import xyz.acrylicstyle.util.reflector.Reflector; | ||
import xyz.acrylicstyle.util.reflector.ReflectorHandler; | ||
|
||
public interface EntityPlayer { | ||
static @NotNull EntityPlayer getInstance(@Nullable Object o) { | ||
return Reflector.newReflector(null, EntityPlayer.class, | ||
new ReflectorHandler(ReflectionUtil.getNMSClass("net.minecraft.server.level.EntityPlayer"), o)); | ||
} | ||
|
||
@NotNull | ||
@CastTo(value = ServerCommonPacketListenerImpl.class, createInstance = true) | ||
@FieldGetter("c") | ||
ServerCommonPacketListenerImpl getPlayerConnection(); | ||
} |
27 changes: 27 additions & 0 deletions
27
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/item/CraftItemStackImpl.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,27 @@ | ||
package net.azisaba.loreeditor.v1_20.item; | ||
|
||
import net.azisaba.loreeditor.api.item.CraftItemStack; | ||
import net.azisaba.loreeditor.api.item.ItemStack; | ||
import net.azisaba.loreeditor.common.util.Reflected; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CraftItemStackImpl implements CraftItemStack { | ||
@Contract(value = "_ -> new", pure = true) | ||
@Reflected | ||
public static @NotNull CraftItemStackImpl getInstance(@Nullable Object item) { | ||
return new CraftItemStackImpl(); | ||
} | ||
|
||
@Override | ||
public @Nullable ItemStack asNMSCopy(org.bukkit.inventory.@Nullable ItemStack item) { | ||
return new ItemStackImpl(org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack.asNMSCopy(item)); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public org.bukkit.inventory.ItemStack asCraftMirror(@NotNull ItemStack item) { | ||
return org.bukkit.craftbukkit.v1_20_R2.inventory.CraftItemStack.asCraftMirror(((ItemStackImpl) item).handle()); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/item/ItemStackImpl.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,51 @@ | ||
package net.azisaba.loreeditor.v1_20.item; | ||
|
||
import net.azisaba.loreeditor.api.item.ItemStack; | ||
import net.azisaba.loreeditor.api.item.tag.CompoundTag; | ||
import net.azisaba.loreeditor.common.util.Reflected; | ||
import net.azisaba.loreeditor.v1_20.item.tag.CompoundTagImpl; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Objects; | ||
|
||
public record ItemStackImpl(net.minecraft.world.item.ItemStack handle) implements ItemStack { | ||
public ItemStackImpl(net.minecraft.world.item.ItemStack handle) { | ||
this.handle = Objects.requireNonNull(handle, "handle"); | ||
} | ||
|
||
@Override | ||
public @NotNull net.minecraft.world.item.ItemStack handle() { | ||
return handle; | ||
} | ||
|
||
@Contract("_ -> new") | ||
@Reflected | ||
public static @NotNull ItemStackImpl getInstance(@NotNull Object item) { | ||
Objects.requireNonNull(item, "item"); | ||
return new ItemStackImpl((net.minecraft.world.item.ItemStack) item); | ||
} | ||
|
||
@Override | ||
public @NotNull CompoundTag getOrCreateTag() { | ||
return new CompoundTagImpl(handle.w()); // getOrCreateTag | ||
} | ||
|
||
@Override | ||
public @Nullable CompoundTag getTag() { | ||
NBTTagCompound handle = this.handle.v(); // getTag | ||
return handle == null ? null : new CompoundTagImpl(handle); | ||
} | ||
|
||
@Override | ||
public void setTag(@Nullable CompoundTag tag) { | ||
handle.c(tag == null ? null : ((CompoundTagImpl) tag).getHandle()); // setTag | ||
} | ||
|
||
@Override | ||
public int getCount() { | ||
return handle.K(); // getCount (probably) | ||
} | ||
} |
95 changes: 95 additions & 0 deletions
95
v1_20/src/main/java/net/azisaba/loreeditor/v1_20/item/tag/CompoundTagImpl.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,95 @@ | ||
package net.azisaba.loreeditor.v1_20.item.tag; | ||
|
||
import net.azisaba.loreeditor.api.item.tag.CompoundTag; | ||
import net.azisaba.loreeditor.api.item.tag.ListTag; | ||
import net.azisaba.loreeditor.api.item.tag.Tag; | ||
import net.azisaba.loreeditor.common.util.Reflected; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CompoundTagImpl extends TagImpl<NBTTagCompound> implements CompoundTag { | ||
public CompoundTagImpl(@NotNull NBTTagCompound handle) { | ||
super(handle); | ||
} | ||
|
||
@Contract("_ -> new") | ||
@Reflected | ||
public static @NotNull CompoundTagImpl getInstance(@Nullable Object tag) { | ||
if (tag == null) { | ||
return new CompoundTagImpl(new NBTTagCompound()); | ||
} | ||
return new CompoundTagImpl((NBTTagCompound) tag); | ||
} | ||
|
||
@Override | ||
public @NotNull CompoundTag constructor() { | ||
return new CompoundTagImpl(new NBTTagCompound()); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return getHandle().f(); // size | ||
} | ||
|
||
@Override | ||
public boolean hasKeyOfType(@NotNull String key, int type) { | ||
return getHandle().b(key, type); // hasKeyOfType | ||
} | ||
|
||
@Override | ||
public void remove(@NotNull String key) { | ||
getHandle().r(key); // remove | ||
} | ||
|
||
@Override | ||
public boolean getBoolean(@NotNull String key) { | ||
return getHandle().q(key); // getBoolean | ||
} | ||
|
||
@Override | ||
public int getInt(@NotNull String key) { | ||
return getHandle().h(key); // getInt | ||
} | ||
|
||
@Override | ||
public @NotNull String getString(@NotNull String key) { | ||
return getHandle().l(key); // getString | ||
} | ||
|
||
@Override | ||
public @NotNull CompoundTag getCompound(@NotNull String key) { | ||
return new CompoundTagImpl(getHandle().p(key)); // getCompound | ||
} | ||
|
||
@Override | ||
public @NotNull ListTag getList(@NotNull String key, int type) { | ||
return new ListTagImpl(getHandle().c(key, type)); // getList | ||
} | ||
|
||
@Override | ||
public void setString(@NotNull String key, @NotNull String value) { | ||
getHandle().a(key, value); // setString | ||
} | ||
|
||
@Override | ||
public void setBoolean(@NotNull String key, boolean value) { | ||
getHandle().a(key, value); // setBoolean | ||
} | ||
|
||
@Override | ||
public void setInt(@NotNull String key, int value) { | ||
getHandle().a(key, value); // setInt | ||
} | ||
|
||
@Override | ||
public void set(@NotNull String key, @NotNull Tag value) { | ||
getHandle().a(key, ((TagImpl<?>) value).getHandle()); // set | ||
} | ||
|
||
@Override | ||
public @Nullable Tag get(@NotNull String key) { | ||
return TagImpl.toTag(getHandle().c(key)); // get | ||
} | ||
} |
Oops, something went wrong.