pandalib-chat API changes (+ some javadoc) and pandalib-reflect imports fixes
This commit is contained in:
parent
eea6d2b5b2
commit
5ff9a40f19
@ -90,8 +90,8 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
|
|||||||
public Chat then(BaseComponent subComponent) {
|
public Chat then(BaseComponent subComponent) {
|
||||||
return then(toAdventure(subComponent));
|
return then(toAdventure(subComponent));
|
||||||
}
|
}
|
||||||
public Chat then(Chat comp) {
|
public Chat then(ComponentLike comp) {
|
||||||
return then(comp.getAdv());
|
return then(comp.asComponent());
|
||||||
}
|
}
|
||||||
public Chat then(BaseComponent[] components) {
|
public Chat then(BaseComponent[] components) {
|
||||||
return then(toAdventure(components));
|
return then(toAdventure(components));
|
||||||
@ -112,20 +112,20 @@ public abstract sealed class Chat extends ChatStatic implements HoverEventSource
|
|||||||
public Chat thenKeyBind(String key) { return then(keybind(key)); }
|
public Chat thenKeyBind(String key) { return then(keybind(key)); }
|
||||||
public Chat thenScore(String name, String objective) { return then(score(name, objective)); }
|
public Chat thenScore(String name, String objective) { return then(score(name, objective)); }
|
||||||
|
|
||||||
public Chat thenURLLink(Chat inner, String url, Chat hover) { return then(ChatUtil.createURLLink(inner, url, hover)); }
|
public Chat thenURLLink(Chat inner, String url, Chat hover) { return then(clickableURL(inner, url, hover)); }
|
||||||
public Chat thenURLLink(Chat inner, String url) { return thenURLLink(inner, url, null); }
|
public Chat thenURLLink(Chat inner, String url) { return then(clickableURL(inner, url)); }
|
||||||
public Chat thenURLLink(String url, Chat hover) { return thenURLLink(text(url), url, hover); }
|
public Chat thenURLLink(String url, Chat hover) { return then(clickableURL(url, hover)); }
|
||||||
public Chat thenURLLink(String url) { return thenURLLink(text(url), url); }
|
public Chat thenURLLink(String url) { return then(clickableURL(url)); }
|
||||||
|
|
||||||
public Chat thenCommandLink(Chat inner, String cmdWithSlash, Chat hover) { return then(ChatUtil.createCommandLink(inner, cmdWithSlash, hover)); }
|
public Chat thenCommandLink(Chat inner, String cmdWithSlash, Chat hover) { return then(clickableCommand(inner, cmdWithSlash, hover)); }
|
||||||
public Chat thenCommandLink(Chat inner, String cmdWithSlash) { return thenCommandLink(inner, cmdWithSlash, null); }
|
public Chat thenCommandLink(Chat inner, String cmdWithSlash) { return then(clickableCommand(inner, cmdWithSlash)); }
|
||||||
public Chat thenCommandLink(String cmdWithSlash, Chat hover) { return thenCommandLink(text(cmdWithSlash), cmdWithSlash, hover); }
|
public Chat thenCommandLink(String cmdWithSlash, Chat hover) { return then(clickableCommand(cmdWithSlash, hover)); }
|
||||||
public Chat thenCommandLink(String cmdWithSlash) { return thenCommandLink(text(cmdWithSlash), cmdWithSlash); }
|
public Chat thenCommandLink(String cmdWithSlash) { return then(clickableCommand(cmdWithSlash)); }
|
||||||
|
|
||||||
public Chat thenCommandSuggest(Chat inner, String cmdWithSlash, Chat hover) { return then(ChatUtil.createCommandSuggest(inner, cmdWithSlash, hover)); }
|
public Chat thenCommandSuggest(Chat inner, String cmdWithSlash, Chat hover) { return then(clickableSuggest(inner, cmdWithSlash, hover)); }
|
||||||
public Chat thenCommandSuggest(Chat inner, String cmdWithSlash) { return thenCommandSuggest(inner, cmdWithSlash, null); }
|
public Chat thenCommandSuggest(Chat inner, String cmdWithSlash) { return then(clickableSuggest(inner, cmdWithSlash)); }
|
||||||
public Chat thenCommandSuggest(String cmdWithSlash, Chat hover) { return thenCommandSuggest(text(cmdWithSlash), cmdWithSlash, hover); }
|
public Chat thenCommandSuggest(String cmdWithSlash, Chat hover) { return then(clickableSuggest(cmdWithSlash, hover)); }
|
||||||
public Chat thenCommandSuggest(String cmdWithSlash) { return thenCommandSuggest(text(cmdWithSlash), cmdWithSlash); }
|
public Chat thenCommandSuggest(String cmdWithSlash) { return then(clickableSuggest(cmdWithSlash)); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,8 +40,7 @@ public abstract class ChatStatic {
|
|||||||
*
|
*
|
||||||
* @param plainText the text to use as he content of the new Chat instance.
|
* @param plainText the text to use as he content of the new Chat instance.
|
||||||
* @return a Chat instance with the provided text as its main text content.
|
* @return a Chat instance with the provided text as its main text content.
|
||||||
*
|
* @throws IllegalArgumentException if the {@code plainText} parameter is instance of {@link Chat} or
|
||||||
* @throws IllegalArgumentException If the {@code plainText} parameter is instance of {@link Chat} or
|
|
||||||
* {@link Component}. The caller should use {@link #chatComponent(ComponentLike)}
|
* {@link Component}. The caller should use {@link #chatComponent(ComponentLike)}
|
||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
@ -58,7 +57,6 @@ public abstract class ChatStatic {
|
|||||||
*
|
*
|
||||||
* @param legacyText the text to use as he content of the new Chat instance.
|
* @param legacyText the text to use as he content of the new Chat instance.
|
||||||
* @return a Chat instance with the provided text as its main text content.
|
* @return a Chat instance with the provided text as its main text content.
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException If the {@code plainText} parameter is instance of {@link Chat} or
|
* @throws IllegalArgumentException If the {@code plainText} parameter is instance of {@link Chat} or
|
||||||
* {@link Component}. The caller should use {@link #chatComponent(ComponentLike)}
|
* {@link Component}. The caller should use {@link #chatComponent(ComponentLike)}
|
||||||
* instead.
|
* instead.
|
||||||
@ -107,34 +105,90 @@ public abstract class ChatStatic {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FormatableChat translation(String key, Object... with) {
|
public static FormatableChat translation(String key, Object... with) {
|
||||||
return new FormatableChat(Component.translatable()
|
return new FormatableChat(Component.translatable().key(key).args(Chat.filterObjToComponentLike(with)));
|
||||||
.key(key)
|
|
||||||
.args(Chat.filterObjToComponentLike(with))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FormatableChat keybind(String key) {
|
public static FormatableChat keybind(String key) {
|
||||||
return new FormatableChat(Component.keybind()
|
return new FormatableChat(Component.keybind().keybind(key));
|
||||||
.keybind(key)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FormatableChat score(String name, String objective) {
|
public static FormatableChat score(String name, String objective) {
|
||||||
return new FormatableChat(Component.score()
|
return new FormatableChat(Component.score().name(name).objective(objective));
|
||||||
.name(name)
|
}
|
||||||
.objective(objective)
|
|
||||||
);
|
public static FormatableChat clickableURL(Chat inner, String url, Chat hover) {
|
||||||
|
Objects.requireNonNull(url, "url");
|
||||||
|
if (inner == null)
|
||||||
|
inner = text(url);
|
||||||
|
if (hover == null)
|
||||||
|
hover = text(ChatUtil.wrapInLimitedPixels(url, 240));
|
||||||
|
return (FormatableChat) chat().clickURL(url).urlColor().hover(hover).then(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableURL(Chat inner, String url) {
|
||||||
|
return clickableURL(inner, url, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableURL(String url, Chat hover) {
|
||||||
|
return clickableURL(null, url, hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableURL(String url) {
|
||||||
|
return clickableURL(null, url, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableCommand(Chat inner, String commandWithSlash, Chat hover) {
|
||||||
|
Objects.requireNonNull(commandWithSlash, "commandWithSlash");
|
||||||
|
if (!commandWithSlash.startsWith("/"))
|
||||||
|
throw new IllegalArgumentException("commandWithSlash must start with a '/' character.");
|
||||||
|
if (inner == null)
|
||||||
|
inner = text(commandWithSlash);
|
||||||
|
if (hover == null)
|
||||||
|
hover = text(ChatUtil.wrapInLimitedPixels(commandWithSlash, 240));
|
||||||
|
return (FormatableChat) chat().clickCommand(commandWithSlash).commandColor().hover(hover).then(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableCommand(Chat inner, String commandWithSlash) {
|
||||||
|
return clickableCommand(inner, commandWithSlash, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableCommand(String commandWithSlash, Chat hover) {
|
||||||
|
return clickableCommand(null, commandWithSlash, hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableCommand(String commandWithSlash) {
|
||||||
|
return clickableCommand(null, commandWithSlash, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableSuggest(Chat inner, String commandWithSlash, Chat hover) {
|
||||||
|
Objects.requireNonNull(commandWithSlash, "commandWithSlash");
|
||||||
|
if (!commandWithSlash.startsWith("/"))
|
||||||
|
throw new IllegalArgumentException("commandWithSlash must start with a '/' character.");
|
||||||
|
if (inner == null)
|
||||||
|
inner = text(commandWithSlash);
|
||||||
|
if (hover == null)
|
||||||
|
hover = text(ChatUtil.wrapInLimitedPixels(commandWithSlash, 240));
|
||||||
|
return (FormatableChat) chat().clickSuggest(commandWithSlash).commandColor().hover(hover).then(inner);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableSuggest(Chat inner, String commandWithSlash) {
|
||||||
|
return clickableSuggest(inner, commandWithSlash, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableSuggest(String commandWithSlash, Chat hover) {
|
||||||
|
return clickableSuggest(null, commandWithSlash, hover);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FormatableChat clickableSuggest(String commandWithSlash) {
|
||||||
|
return clickableSuggest(null, commandWithSlash, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Component prefixedAndColored(ComponentLike message) {
|
|
||||||
return prefixedAndColored(Chat.chatComponent(message)).getAdv();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Chat prefixedAndColored(Chat message) {
|
public static Chat prefixedAndColored(ComponentLike message) {
|
||||||
return Chat.chat()
|
return Chat.chat()
|
||||||
.broadcastColor()
|
.broadcastColor()
|
||||||
.then(Chat.getConfig().prefix.get())
|
.then(Chat.getConfig().prefix.get())
|
||||||
|
@ -2,6 +2,8 @@ package fr.pandacube.lib.chat;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -19,10 +21,16 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
|
|
||||||
import fr.pandacube.lib.chat.Chat.FormatableChat;
|
import fr.pandacube.lib.chat.Chat.FormatableChat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides various methods and properties to manipulate text displayed in chat an other parts of the game.
|
||||||
|
*/
|
||||||
public class ChatUtil {
|
public class ChatUtil {
|
||||||
|
|
||||||
public static final int DEFAULT_CHAR_SIZE = 6;
|
/*
|
||||||
public static final Map<Integer, String> CHARS_SIZE = Map.ofEntries(
|
* Note : this field is for easy listing of all characters with special sizes. It will all be reported to
|
||||||
|
* #CHAR_SIZES on class initialization for optimization.
|
||||||
|
*/
|
||||||
|
private static final Map<Integer, String> SIZE_CHARS_MAPPING = Map.ofEntries(
|
||||||
Map.entry(-6, "§"),
|
Map.entry(-6, "§"),
|
||||||
Map.entry(2, "!.,:;i|¡'"),
|
Map.entry(2, "!.,:;i|¡'"),
|
||||||
Map.entry(3, "`lìí’‘"),
|
Map.entry(3, "`lìí’‘"),
|
||||||
@ -31,88 +39,146 @@ public class ChatUtil {
|
|||||||
Map.entry(7, "@~®©«»"),
|
Map.entry(7, "@~®©«»"),
|
||||||
Map.entry(9, "├└")
|
Map.entry(9, "├└")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default text pixel width for a character in the default Minecraft font.
|
||||||
|
* If a character has another width, it should be found in {@link #CHAR_SIZES}.
|
||||||
|
*/
|
||||||
|
public static final int DEFAULT_CHAR_SIZE = 6;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapping indicating the text pixel with for specific characters in the default Minecraft font.
|
||||||
|
* If a character doesn’t have a mapping in this map, then its width is {@link #DEFAULT_CHAR_SIZE}.
|
||||||
|
*/
|
||||||
|
public static final Map<Character, Integer> CHAR_SIZES;
|
||||||
|
static {
|
||||||
|
Map<Character, Integer> charSizes = new HashMap<>();
|
||||||
|
for (var e : SIZE_CHARS_MAPPING.entrySet()) {
|
||||||
|
int size = e.getKey();
|
||||||
|
for (char c : e.getValue().toCharArray()) {
|
||||||
|
charSizes.put(c, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CHAR_SIZES = Collections.unmodifiableMap(charSizes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default width of the Minecraft Java Edition chat window, in text pixels.
|
||||||
|
*/
|
||||||
public static final int DEFAULT_CHAT_WIDTH = 320;
|
public static final int DEFAULT_CHAT_WIDTH = 320;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width of a Minecraft sign, in text pixels.
|
||||||
|
*/
|
||||||
public static final int SIGN_WIDTH = 90;
|
public static final int SIGN_WIDTH = 90;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width of a Minecraft book content, in text pixels.
|
||||||
|
*/
|
||||||
public static final int BOOK_WIDTH = 116;
|
public static final int BOOK_WIDTH = 116;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width of a Minecraft server MOTD message, in text pixels.
|
||||||
|
*/
|
||||||
public static final int MOTD_WIDTH = 270;
|
public static final int MOTD_WIDTH = 270;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width of a Minecraft Bedrock Edition form button, in text pixels.
|
||||||
|
*/
|
||||||
public static final int BEDROCK_FORM_WIDE_BUTTON = 178;
|
public static final int BEDROCK_FORM_WIDE_BUTTON = 178;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default number of character per lines for the console.
|
||||||
|
*/
|
||||||
public static final int CONSOLE_NB_CHAR_DEFAULT = 50;
|
public static final int CONSOLE_NB_CHAR_DEFAULT = 50;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link Chat} that is a cliquable URL link.
|
||||||
|
* It is equivalent to the HTML {@code <a>} tag pointing to another page.
|
||||||
|
* @param text the link text.
|
||||||
|
* @param url the destination url. must starts with {@code http} or {@code https}.
|
||||||
|
* @return a {@link Chat} that is a cliquable URL link.
|
||||||
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableURL(Chat, String)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
public static FormatableChat createURLLink(String text, String url) {
|
public static FormatableChat createURLLink(String text, String url) {
|
||||||
return createURLLink(ChatStatic.legacyText(text), url, null);
|
return Chat.clickableURL(text == null ? null : Chat.legacyText(text), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link Chat} that is a cliquable URL link.
|
||||||
|
* It is equivalent to the HTML {@code <a>} tag pointing to another page.
|
||||||
|
* @param text the link text.
|
||||||
|
* @param url the destination url. must starts with {@code http} or {@code https}.
|
||||||
|
* @param hoverText the text displayed when hovering the link.
|
||||||
|
* @return a {@link Chat} that is a cliquable URL link.
|
||||||
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableURL(Chat, String, Chat)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
public static FormatableChat createURLLink(String text, String url, String hoverText) {
|
public static FormatableChat createURLLink(String text, String url, String hoverText) {
|
||||||
return createURLLink(ChatStatic.legacyText(text), url, hoverText != null ? ChatStatic.legacyText(hoverText) : null);
|
return Chat.clickableURL(text == null ? null : Chat.legacyText(text), url, hoverText == null ? null : Chat.legacyText(hoverText));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ static FormatableChat createURLLink(Chat element, String url, Chat hover) {
|
|
||||||
String dispURL = (url.length() > 50) ? (url.substring(0, 48) + "...") : url;
|
|
||||||
return (FormatableChat) ChatStatic.chat()
|
|
||||||
.clickURL(url)
|
|
||||||
.urlColor()
|
|
||||||
.hover(
|
|
||||||
hover != null ? hover : Chat.text(dispURL)
|
|
||||||
)
|
|
||||||
.then(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link Chat} that is a cliquable command link.
|
||||||
|
* When the players clicks on it, they will execute the command.
|
||||||
|
* @param text the link text.
|
||||||
|
* @param commandWithSlash the command to execute when clicked.
|
||||||
|
* @param hoverText the text displayed when hovering the link.
|
||||||
|
* @return a {@link Chat} that is a cliquable command link.
|
||||||
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableCommand(Chat, String, Chat)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
public static FormatableChat createCommandLink(String text, String commandWithSlash, String hoverText) {
|
public static FormatableChat createCommandLink(String text, String commandWithSlash, String hoverText) {
|
||||||
return createCommandLink(text, commandWithSlash, hoverText == null ? null : ChatStatic.legacyText(hoverText));
|
return Chat.clickableCommand(text == null ? null : Chat.legacyText(text), commandWithSlash, hoverText == null ? null : Chat.legacyText(hoverText));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link Chat} that is a cliquable command link.
|
||||||
|
* When the players clicks on it, they will execute the command.
|
||||||
|
* @param text the link text.
|
||||||
|
* @param commandWithSlash the command to execute when clicked.
|
||||||
|
* @param hoverText the text displayed when hovering the link.
|
||||||
|
* @return a {@link Chat} that is a cliquable command link.
|
||||||
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableCommand(Chat, String, Chat)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
public static FormatableChat createCommandLink(String text, String commandWithSlash, Chat hoverText) {
|
public static FormatableChat createCommandLink(String text, String commandWithSlash, Chat hoverText) {
|
||||||
return createCommandLink(ChatStatic.legacyText(text), commandWithSlash, hoverText);
|
return Chat.clickableCommand(text == null ? null : Chat.legacyText(text), commandWithSlash, hoverText);
|
||||||
}
|
|
||||||
|
|
||||||
/* package */ static FormatableChat createCommandLink(Chat d, String commandWithSlash, Chat hoverText) {
|
|
||||||
FormatableChat c = ChatStatic.chat()
|
|
||||||
.clickCommand(commandWithSlash)
|
|
||||||
.commandColor();
|
|
||||||
if (hoverText != null)
|
|
||||||
c.hover(hoverText);
|
|
||||||
return (FormatableChat) c.then(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a {@link Chat} that is a cliquable command suggestion.
|
||||||
|
* When the players clicks on it, they will execute the command.
|
||||||
|
* @param inner the link text.
|
||||||
|
* @param commandWithSlash the command to put in the chat box when clicked.
|
||||||
|
* @param hover the text displayed when hovering the link.
|
||||||
|
* @return a {@link Chat} that is a cliquable command suggestion.
|
||||||
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableSuggest(Chat, String, Chat)} instead.
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
|
public static FormatableChat createCommandSuggest(String inner, String commandWithSlash, String hover) {
|
||||||
|
return Chat.clickableSuggest(inner == null ? null : Chat.legacyText(inner), commandWithSlash, hover == null ? null : Chat.legacyText(hover));
|
||||||
|
}
|
||||||
|
|
||||||
public static FormatableChat createCommandSuggest(String text, String commandWithSlash, String hoverText) {
|
/**
|
||||||
return createCommandSuggest(text, commandWithSlash, hoverText == null ? null : ChatStatic.legacyText(hoverText));
|
* Create a {@link Chat} that is a cliquable command suggestion.
|
||||||
}
|
* When the players clicks on it, they will execute the command.
|
||||||
public static FormatableChat createCommandSuggest(String text, String commandWithSlash, Chat hoverText) {
|
* @param inner the link text.
|
||||||
return createCommandSuggest(ChatStatic.legacyText(text), commandWithSlash, hoverText);
|
* @param commandWithSlash the command to put in the chat box when clicked.
|
||||||
}
|
* @param hover the text displayed when hovering the link.
|
||||||
|
* @return a {@link Chat} that is a cliquable command suggestion.
|
||||||
/* package */ static FormatableChat createCommandSuggest(Chat d, String commandWithSlash, Chat hoverText) {
|
* @deprecated it uses String for displayed text. Use {@link Chat#clickableSuggest(Chat, String, Chat)} instead.
|
||||||
FormatableChat c = ChatStatic.chat()
|
*/
|
||||||
.clickSuggest(commandWithSlash)
|
@Deprecated(forRemoval = true, since = "2022-07-27")
|
||||||
.commandColor();
|
public static FormatableChat createCommandSuggest(String inner, String commandWithSlash, Chat hover) {
|
||||||
if (hoverText != null)
|
return Chat.clickableSuggest(inner == null ? null : Chat.legacyText(inner), commandWithSlash, hover);
|
||||||
c.hover(hoverText);
|
|
||||||
return (FormatableChat) c.then(d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -123,7 +189,15 @@ public class ChatUtil {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Create a page navigator with clickable page numbers for the chat.
|
||||||
|
* @param prefix the text to put before the
|
||||||
* @param cmdFormat the command with %d inside to be replaced with the page number (must start with slash)
|
* @param cmdFormat the command with %d inside to be replaced with the page number (must start with slash)
|
||||||
|
* @param currentPage the current page number (it is highlighted, and the pages around are displayed, according to
|
||||||
|
* {@code nbPagesToDisplay}).
|
||||||
|
* @param nbPages the number of pages.
|
||||||
|
* @param nbPagesToDisplay the number of pages to display around the first page, the last page and the
|
||||||
|
* {@code currentPage}.
|
||||||
|
* @return a {@link Chat} containging the created page navigator.
|
||||||
*/
|
*/
|
||||||
public static Chat createPagination(String prefix, String cmdFormat, int currentPage, int nbPages, int nbPagesToDisplay) {
|
public static Chat createPagination(String prefix, String cmdFormat, int currentPage, int nbPages, int nbPagesToDisplay) {
|
||||||
Set<Integer> pagesToDisplay = new TreeSet<>();
|
Set<Integer> pagesToDisplay = new TreeSet<>();
|
||||||
@ -150,7 +224,7 @@ public class ChatUtil {
|
|||||||
else {
|
else {
|
||||||
if (cmdFormat.endsWith("%d")) {
|
if (cmdFormat.endsWith("%d")) {
|
||||||
d.thenText(" ");
|
d.thenText(" ");
|
||||||
d.then(createCommandSuggest("...", cmdFormat.substring(0, cmdFormat.length() - 2), "Choisir la page"));
|
d.then(Chat.clickableSuggest(Chat.text("..."), cmdFormat.substring(0, cmdFormat.length() - 2), Chat.text("Choisir la page")));
|
||||||
d.thenText(" ");
|
d.thenText(" ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -160,7 +234,7 @@ public class ChatUtil {
|
|||||||
else
|
else
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
FormatableChat pDisp = createCommandLink(Integer.toString(page), String.format(cmdFormat, page), "Aller à la page " + page);
|
FormatableChat pDisp = Chat.clickableCommand(Chat.text(page), String.format(cmdFormat, page), Chat.text("Aller à la page " + page));
|
||||||
if (page == currentPage) {
|
if (page == currentPage) {
|
||||||
pDisp.highlightedCommandColor();
|
pDisp.highlightedCommandColor();
|
||||||
}
|
}
|
||||||
@ -342,10 +416,9 @@ public class ChatUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int charW(char c, boolean console, boolean bold) {
|
public static int charW(char c, boolean console, boolean bold) {
|
||||||
if (console) return (c == '§') ? -1 : 1;
|
if (console)
|
||||||
for (int px : CHARS_SIZE.keySet())
|
return (c == '§') ? -1 : 1;
|
||||||
if (CHARS_SIZE.get(px).indexOf(c) >= 0) return px + (bold ? 1 : 0);
|
return CHAR_SIZES.getOrDefault(c, DEFAULT_CHAR_SIZE);
|
||||||
return 6 + (bold ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,10 +21,10 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
import fr.pandacube.lib.util.Log;
|
import fr.pandacube.lib.util.Log;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectClass;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectField;
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectMember;
|
import fr.pandacube.lib.reflect.ReflectMember;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import net.fabricmc.mappingio.MappingReader;
|
import net.fabricmc.mappingio.MappingReader;
|
||||||
import net.fabricmc.mappingio.format.MappingFormat;
|
import net.fabricmc.mappingio.format.MappingFormat;
|
||||||
import net.fabricmc.mappingio.tree.MappingTree;
|
import net.fabricmc.mappingio.tree.MappingTree;
|
||||||
|
@ -6,7 +6,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectClass;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
|
|
||||||
/* package */ class NMSTypeWrapper implements Comparable<NMSTypeWrapper> {
|
/* package */ class NMSTypeWrapper implements Comparable<NMSTypeWrapper> {
|
||||||
|
@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectClass;
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
|
||||||
public class OBCReflect {
|
public class OBCReflect {
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper;
|
package fr.pandacube.lib.paper.reflect.wrapper;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -60,7 +61,7 @@ public abstract class ReflectWrapper implements ReflectWrapperI {
|
|||||||
if (expectedWrapperClass != null && !expectedWrapperClass.isAssignableFrom(wrapperClass)) {
|
if (expectedWrapperClass != null && !expectedWrapperClass.isAssignableFrom(wrapperClass)) {
|
||||||
throw new ClassCastException("Wrapper class " + wrapperClass + " is not a sub-class or a sub-interface of expected wrapper class" + expectedWrapperClass);
|
throw new ClassCastException("Wrapper class " + wrapperClass + " is not a sub-class or a sub-interface of expected wrapper class" + expectedWrapperClass);
|
||||||
}
|
}
|
||||||
Reflect.ReflectConstructor<? extends ReflectWrapperI> constructor = WrapperRegistry.getWrapperConstructorOfWrapperClass(wrapperClass);
|
ReflectConstructor<? extends ReflectWrapperI> constructor = WrapperRegistry.getWrapperConstructorOfWrapperClass(wrapperClass);
|
||||||
if (constructor == null) {
|
if (constructor == null) {
|
||||||
throw new IllegalStateException("Unable to find a constructor to instanciate " + wrapperClass + " to wrap an instance of " + runtimeObj);
|
throw new IllegalStateException("Unable to find a constructor to instanciate " + wrapperClass + " to wrap an instance of " + runtimeObj);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package fr.pandacube.lib.paper.reflect.wrapper;
|
|||||||
|
|
||||||
import fr.pandacube.lib.util.Log;
|
import fr.pandacube.lib.util.Log;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectConstructor;
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode;
|
import fr.pandacube.lib.paper.reflect.wrapper.brigadier.CommandNode;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftMapView;
|
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftMapView;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey;
|
import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftNamespacedKey;
|
||||||
|
@ -2,13 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.brigadier;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CommandNode<S> extends ReflectWrapperTyped<com.mojang.brigadier.tree.CommandNode<S>> {
|
public class CommandNode<S> extends ReflectWrapperTyped<com.mojang.brigadier.tree.CommandNode<S>> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = Reflect.ofClass(com.mojang.brigadier.tree.CommandNode.class);
|
public static final ReflectClass<?> REFLECT = Reflect.ofClass(com.mojang.brigadier.tree.CommandNode.class);
|
||||||
private static final Reflect.ReflectMethod<?> removeCommand = wrapEx(() -> REFLECT.method("removeCommand", String.class));
|
private static final ReflectMethod<?> removeCommand = wrapEx(() -> REFLECT.method("removeCommand", String.class));
|
||||||
|
|
||||||
public void removeCommand(String cmd) {
|
public void removeCommand(String cmd) {
|
||||||
wrapReflectEx(() -> removeCommand.invoke(__getRuntimeInstance(), cmd));
|
wrapReflectEx(() -> removeCommand.invoke(__getRuntimeInstance(), cmd));
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.MapItemSavedData;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.map.MapView;
|
import org.bukkit.map.MapView;
|
||||||
|
|
||||||
@ -11,9 +14,9 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftMapView extends ReflectWrapperTyped<MapView> {
|
public class CraftMapView extends ReflectWrapperTyped<MapView> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.CraftMapView"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.CraftMapView"));
|
||||||
public static final Reflect.ReflectField<?> worldMap = wrapEx(() -> REFLECT.field("worldMap"));
|
public static final ReflectField<?> worldMap = wrapEx(() -> REFLECT.field("worldMap"));
|
||||||
public static final Reflect.ReflectMethod<?> render = wrapEx(() -> REFLECT.method("render", CraftPlayer.REFLECT.get()));
|
public static final ReflectMethod<?> render = wrapEx(() -> REFLECT.method("render", CraftPlayer.REFLECT.get()));
|
||||||
|
|
||||||
protected CraftMapView(Object obj) {
|
protected CraftMapView(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftNamespacedKey extends ReflectWrapper {
|
public class CraftNamespacedKey extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftNamespacedKey"));
|
||||||
public static final Reflect.ReflectMethod<?> toMinecraft = wrapEx(() -> REFLECT.method("toMinecraft", NamespacedKey.class));
|
public static final ReflectMethod<?> toMinecraft = wrapEx(() -> REFLECT.method("toMinecraft", NamespacedKey.class));
|
||||||
public static final Reflect.ReflectMethod<?> fromMinecraft = wrapEx(() -> REFLECT.method("fromMinecraft", ResourceLocation.MAPPING.runtimeClass()));
|
public static final ReflectMethod<?> fromMinecraft = wrapEx(() -> REFLECT.method("fromMinecraft", ResourceLocation.MAPPING.runtimeClass()));
|
||||||
|
|
||||||
public static ResourceLocation toMinecraft(NamespacedKey key) {
|
public static ResourceLocation toMinecraft(NamespacedKey key) {
|
||||||
return wrap(wrapReflectEx(() -> toMinecraft.invokeStatic(key)), ResourceLocation.class);
|
return wrap(wrapReflectEx(() -> toMinecraft.invokeStatic(key)), ResourceLocation.class);
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftPlayer extends ReflectWrapperTyped<Player> {
|
public class CraftPlayer extends ReflectWrapperTyped<Player> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("entity.CraftPlayer"));
|
||||||
public static final Reflect.ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
public static final ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
||||||
|
|
||||||
public ServerPlayer getHandle() {
|
public ServerPlayer getHandle() {
|
||||||
return wrap(wrapReflectEx(() -> getHandle.invoke(__getRuntimeInstance())), ServerPlayer.class);
|
return wrap(wrapReflectEx(() -> getHandle.invoke(__getRuntimeInstance())), ServerPlayer.class);
|
||||||
|
@ -1,19 +1,21 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedPlayerList;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.DedicatedServer;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftServer extends ReflectWrapperTyped<Server> {
|
public class CraftServer extends ReflectWrapperTyped<Server> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftServer"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftServer"));
|
||||||
public static final Reflect.ReflectMethod<?> getServer = wrapEx(() -> REFLECT.method("getServer"));
|
public static final ReflectMethod<?> getServer = wrapEx(() -> REFLECT.method("getServer"));
|
||||||
public static final Reflect.ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
public static final ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
||||||
|
|
||||||
public DedicatedServer getServer() {
|
public DedicatedServer getServer() {
|
||||||
return wrap(wrapReflectEx(() -> getServer.invoke(__getRuntimeInstance())), DedicatedServer.class);
|
return wrap(wrapReflectEx(() -> getServer.invoke(__getRuntimeInstance())), DedicatedServer.class);
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftVector extends ReflectWrapper {
|
public class CraftVector extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("util.CraftVector"));
|
||||||
public static final Reflect.ReflectMethod<?> toBukkit_Vec3 = wrapEx(() -> REFLECT.method("toBukkit", Vec3.MAPPING.runtimeClass()));
|
public static final ReflectMethod<?> toBukkit_Vec3 = wrapEx(() -> REFLECT.method("toBukkit", Vec3.MAPPING.runtimeClass()));
|
||||||
public static final Reflect.ReflectMethod<?> toBukkit_BlockPos = wrapEx(() -> REFLECT.method("toBukkit", BlockPos.MAPPING.runtimeClass()));
|
public static final ReflectMethod<?> toBukkit_BlockPos = wrapEx(() -> REFLECT.method("toBukkit", BlockPos.MAPPING.runtimeClass()));
|
||||||
public static final Reflect.ReflectMethod<?> toNMS = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
public static final ReflectMethod<?> toNMS = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
||||||
public static final Reflect.ReflectMethod<?> toBlockPos = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
public static final ReflectMethod<?> toBlockPos = wrapEx(() -> REFLECT.method("toNMS", Vector.class));
|
||||||
|
|
||||||
public static Vector toBukkit(Vec3 nms) {
|
public static Vector toBukkit(Vec3 nms) {
|
||||||
return (Vector) wrapReflectEx(() -> toBukkit_Vec3.invokeStatic(unwrap(nms)));
|
return (Vector) wrapReflectEx(() -> toBukkit_Vec3.invokeStatic(unwrap(nms)));
|
||||||
|
@ -1,17 +1,19 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerLevel;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class CraftWorld extends ReflectWrapperTyped<World> {
|
public class CraftWorld extends ReflectWrapperTyped<World> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftWorld"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("CraftWorld"));
|
||||||
public static final Reflect.ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
public static final ReflectMethod<?> getHandle = wrapEx(() -> REFLECT.method("getHandle"));
|
||||||
|
|
||||||
public ServerLevel getHandle() {
|
public ServerLevel getHandle() {
|
||||||
return wrap(wrapReflectEx(() -> getHandle.invoke(__getRuntimeInstance())), ServerLevel.class);
|
return wrap(wrapReflectEx(() -> getHandle.invoke(__getRuntimeInstance())), ServerLevel.class);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class RenderData extends ReflectWrapper {
|
public class RenderData extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.RenderData"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("map.RenderData"));
|
||||||
private static final Reflect.ReflectField<?> buffer = wrapEx(() -> REFLECT.field("buffer"));
|
private static final ReflectField<?> buffer = wrapEx(() -> REFLECT.field("buffer"));
|
||||||
|
|
||||||
protected RenderData(Object obj) {
|
protected RenderData(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -2,10 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.craftbukkit;
|
|||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
import com.mojang.brigadier.tree.CommandNode;
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
import fr.pandacube.lib.paper.reflect.OBCReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.defaults.BukkitCommand;
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
|
||||||
@ -13,10 +18,10 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
|
public class VanillaCommandWrapper extends ReflectWrapperTyped<BukkitCommand> {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> OBCReflect.ofClass("command.VanillaCommandWrapper"));
|
||||||
public static final Reflect.ReflectConstructor<?> CONSTRUTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class));
|
public static final ReflectConstructor<?> CONSTRUTOR = wrapEx(() -> REFLECT.constructor(Commands.MAPPING.runtimeClass(), CommandNode.class));
|
||||||
public static final Reflect.ReflectField<?> vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand"));
|
public static final ReflectField<?> vanillaCommand = wrapEx(() -> REFLECT.field("vanillaCommand"));
|
||||||
public static final Reflect.ReflectMethod<?> getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class));
|
public static final ReflectMethod<?> getListener = wrapEx(() -> REFLECT.method("getListener", CommandSender.class));
|
||||||
|
|
||||||
public VanillaCommandWrapper(Commands dispatcher, CommandNode<BukkitBrigadierCommandSource> vanillaCommand) {
|
public VanillaCommandWrapper(Commands dispatcher, CommandNode<BukkitBrigadierCommandSource> vanillaCommand) {
|
||||||
this(wrapReflectEx(() -> CONSTRUTOR.instanciate(unwrap(dispatcher), vanillaCommand)));
|
this(wrapReflectEx(() -> CONSTRUTOR.instanciate(unwrap(dispatcher), vanillaCommand)));
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class SharedConstants extends ReflectWrapper {
|
public class SharedConstants extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.SharedConstants"));
|
||||||
private static final Reflect.ReflectMethod<?> getCurrentVersion = wrapEx(() -> MAPPING.mojMethod("getCurrentVersion"));
|
private static final ReflectMethod<?> getCurrentVersion = wrapEx(() -> MAPPING.mojMethod("getCurrentVersion"));
|
||||||
private static final Reflect.ReflectMethod<?> getProtocolVersion = wrapEx(() -> MAPPING.mojMethod("getProtocolVersion"));
|
private static final ReflectMethod<?> getProtocolVersion = wrapEx(() -> MAPPING.mojMethod("getProtocolVersion"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class BlockPosArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class BlockPosArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.BlockPosArgument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.BlockPosArgument"));
|
||||||
private static final Reflect.ReflectMethod<?> blockPos = wrapEx(() -> MAPPING.mojMethod("blockPos"));
|
private static final ReflectMethod<?> blockPos = wrapEx(() -> MAPPING.mojMethod("blockPos"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> blockPos() {
|
public static ArgumentType<Object> blockPos() {
|
||||||
|
@ -2,16 +2,17 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
|||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
import com.mojang.brigadier.CommandDispatcher;
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Commands extends ReflectWrapper {
|
public class Commands extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.Commands"));
|
||||||
public static final Reflect.ReflectField<?> dispatcher = wrapEx(() -> MAPPING.mojField("dispatcher"));
|
public static final ReflectField<?> dispatcher = wrapEx(() -> MAPPING.mojField("dispatcher"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public CommandDispatcher<BukkitBrigadierCommandSource> dispatcher() {
|
public CommandDispatcher<BukkitBrigadierCommandSource> dispatcher() {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ComponentArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class ComponentArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ComponentArgument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ComponentArgument"));
|
||||||
private static final Reflect.ReflectMethod<?> textComponent = wrapEx(() -> MAPPING.mojMethod("textComponent"));
|
private static final ReflectMethod<?> textComponent = wrapEx(() -> MAPPING.mojMethod("textComponent"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> textComponent() {
|
public static ArgumentType<Object> textComponent() {
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperI;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.core.BlockPos;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Vec3;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
@ -16,8 +17,8 @@ import static fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper.wrap;
|
|||||||
@ConcreteWrapper(Coordinates.__concrete.class)
|
@ConcreteWrapper(Coordinates.__concrete.class)
|
||||||
public interface Coordinates extends ReflectWrapperI {
|
public interface Coordinates extends ReflectWrapperI {
|
||||||
NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Coordinates"));
|
NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Coordinates"));
|
||||||
Reflect.ReflectMethod<?> getPosition = wrapEx(() -> MAPPING.mojMethod("getPosition", CommandSourceStack.MAPPING));
|
ReflectMethod<?> getPosition = wrapEx(() -> MAPPING.mojMethod("getPosition", CommandSourceStack.MAPPING));
|
||||||
Reflect.ReflectMethod<?> getBlockPos = wrapEx(() -> MAPPING.mojMethod("getBlockPos", CommandSourceStack.MAPPING));
|
ReflectMethod<?> getBlockPos = wrapEx(() -> MAPPING.mojMethod("getBlockPos", CommandSourceStack.MAPPING));
|
||||||
|
|
||||||
default Vec3 getPosition(BukkitBrigadierCommandSource source) {
|
default Vec3 getPosition(BukkitBrigadierCommandSource source) {
|
||||||
return wrap(wrapReflectEx(() -> getPosition.invoke(__getRuntimeInstance(), source)), Vec3.class);
|
return wrap(wrapReflectEx(() -> getPosition.invoke(__getRuntimeInstance(), source)), Vec3.class);
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class EntityArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class EntityArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.EntityArgument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.EntityArgument"));
|
||||||
private static final Reflect.ReflectMethod<?> entity = wrapEx(() -> MAPPING.mojMethod("entity"));
|
private static final ReflectMethod<?> entity = wrapEx(() -> MAPPING.mojMethod("entity"));
|
||||||
private static final Reflect.ReflectMethod<?> entities = wrapEx(() -> MAPPING.mojMethod("entities"));
|
private static final ReflectMethod<?> entities = wrapEx(() -> MAPPING.mojMethod("entities"));
|
||||||
private static final Reflect.ReflectMethod<?> player = wrapEx(() -> MAPPING.mojMethod("player"));
|
private static final ReflectMethod<?> player = wrapEx(() -> MAPPING.mojMethod("player"));
|
||||||
private static final Reflect.ReflectMethod<?> players = wrapEx(() -> MAPPING.mojMethod("players"));
|
private static final ReflectMethod<?> players = wrapEx(() -> MAPPING.mojMethod("players"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> entity() {
|
public static ArgumentType<Object> entity() {
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectListWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectListWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.server.ServerPlayer;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -15,10 +16,10 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class EntitySelector extends ReflectWrapper {
|
public class EntitySelector extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.selector.EntitySelector"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.selector.EntitySelector"));
|
||||||
private static final Reflect.ReflectMethod<?> findEntities = wrapEx(() -> MAPPING.mojMethod("findEntities", CommandSourceStack.MAPPING));
|
private static final ReflectMethod<?> findEntities = wrapEx(() -> MAPPING.mojMethod("findEntities", CommandSourceStack.MAPPING));
|
||||||
private static final Reflect.ReflectMethod<?> findPlayers = wrapEx(() -> MAPPING.mojMethod("findPlayers", CommandSourceStack.MAPPING));
|
private static final ReflectMethod<?> findPlayers = wrapEx(() -> MAPPING.mojMethod("findPlayers", CommandSourceStack.MAPPING));
|
||||||
private static final Reflect.ReflectMethod<?> findSingleEntity = wrapEx(() -> MAPPING.mojMethod("findSingleEntity", CommandSourceStack.MAPPING));
|
private static final ReflectMethod<?> findSingleEntity = wrapEx(() -> MAPPING.mojMethod("findSingleEntity", CommandSourceStack.MAPPING));
|
||||||
private static final Reflect.ReflectMethod<?> findSinglePlayer = wrapEx(() -> MAPPING.mojMethod("findSinglePlayer", CommandSourceStack.MAPPING));
|
private static final ReflectMethod<?> findSinglePlayer = wrapEx(() -> MAPPING.mojMethod("findSinglePlayer", CommandSourceStack.MAPPING));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public ReflectListWrapper<Entity> findEntities(BukkitBrigadierCommandSource source) {
|
public ReflectListWrapper<Entity> findEntities(BukkitBrigadierCommandSource source) {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class GameProfileArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.GameProfileArgument"));
|
||||||
private static final Reflect.ReflectMethod<?> gameProfile = wrapEx(() -> MAPPING.mojMethod("gameProfile"));
|
private static final ReflectMethod<?> gameProfile = wrapEx(() -> MAPPING.mojMethod("gameProfile"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> gameProfile() {
|
public static ArgumentType<Object> gameProfile() {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class ResourceLocationArgument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.ResourceLocationArgument"));
|
||||||
private static final Reflect.ReflectMethod<?> id = wrapEx(() -> MAPPING.mojMethod("id"));
|
private static final ReflectMethod<?> id = wrapEx(() -> MAPPING.mojMethod("id"));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> id() {
|
public static ArgumentType<Object> id() {
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands;
|
||||||
|
|
||||||
import com.mojang.brigadier.arguments.ArgumentType;
|
import com.mojang.brigadier.arguments.ArgumentType;
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapperTyped;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> {
|
public class Vec3Argument extends ReflectWrapperTyped<ArgumentType<?>> {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.commands.arguments.coordinates.Vec3Argument"));
|
||||||
private static final Reflect.ReflectMethod<?> vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class));
|
private static final ReflectMethod<?> vec3 = wrapEx(() -> MAPPING.mojMethod("vec3", boolean.class));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static ArgumentType<Object> vec3(boolean centerIntegers) {
|
public static ArgumentType<Object> vec3(boolean centerIntegers) {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.core;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Vec3i extends ReflectWrapper {
|
public class Vec3i extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.core.Vec3i"));
|
||||||
public static final Reflect.ReflectMethod<?> getX = wrapEx(() -> MAPPING.mojMethod("getX"));
|
public static final ReflectMethod<?> getX = wrapEx(() -> MAPPING.mojMethod("getX"));
|
||||||
public static final Reflect.ReflectMethod<?> getY = wrapEx(() -> MAPPING.mojMethod("getY"));
|
public static final ReflectMethod<?> getY = wrapEx(() -> MAPPING.mojMethod("getY"));
|
||||||
public static final Reflect.ReflectMethod<?> getZ = wrapEx(() -> MAPPING.mojMethod("getZ"));
|
public static final ReflectMethod<?> getZ = wrapEx(() -> MAPPING.mojMethod("getZ"));
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return (int) wrapReflectEx(() -> getX.invoke(__getRuntimeInstance()));
|
return (int) wrapReflectEx(() -> getX.invoke(__getRuntimeInstance()));
|
||||||
|
@ -8,7 +8,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
@ -4,7 +4,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
@ -3,7 +3,7 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt;
|
|||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect.ReflectMethod;
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
import fr.pandacube.lib.paper.reflect.NMSReflect.ClassMapping;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ConcreteWrapper;
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.netty.ByteBuf;
|
import fr.pandacube.lib.paper.reflect.wrapper.netty.ByteBuf;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class FriendlyByteBuf extends ByteBuf {
|
public class FriendlyByteBuf extends ByteBuf {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.FriendlyByteBuf"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.FriendlyByteBuf"));
|
||||||
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ByteBuf.REFLECT.get()));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ByteBuf.REFLECT.get()));
|
||||||
private static final Reflect.ReflectMethod<?> writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class));
|
private static final ReflectMethod<?> writeUtf = wrapEx(() -> MAPPING.mojMethod("writeUtf", String.class));
|
||||||
|
|
||||||
public FriendlyByteBuf(ByteBuf parent) {
|
public FriendlyByteBuf(ByteBuf parent) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(parent))));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(parent))));
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.FriendlyByteBuf;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.resources.ResourceLocation;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Packet {
|
public class ClientboundCustomPayloadPacket extends ReflectWrapper implements Packet {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket"));
|
||||||
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ResourceLocation.MAPPING.runtimeClass(), FriendlyByteBuf.MAPPING.runtimeClass()));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(ResourceLocation.MAPPING.runtimeClass(), FriendlyByteBuf.MAPPING.runtimeClass()));
|
||||||
private static final Reflect.ReflectField<?> FIELD_BRAND = wrapEx(() -> MAPPING.mojField("BRAND"));
|
private static final ReflectField<?> FIELD_BRAND = wrapEx(() -> MAPPING.mojField("BRAND"));
|
||||||
|
|
||||||
public static ResourceLocation BRAND() {
|
public static ResourceLocation BRAND() {
|
||||||
return wrap(wrapReflectEx(FIELD_BRAND::getStaticValue), ResourceLocation.class);
|
return wrap(wrapReflectEx(FIELD_BRAND::getStaticValue), ResourceLocation.class);
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ClientboundGameEventPacket extends ReflectWrapper implements Packet {
|
public class ClientboundGameEventPacket extends ReflectWrapper implements Packet {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.network.protocol.game.ClientboundGameEventPacket"));
|
||||||
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(Type.MAPPING.runtimeClass(), float.class));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(Type.MAPPING.runtimeClass(), float.class));
|
||||||
private static final Reflect.ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE"));
|
private static final ReflectField<?> FIELD_RAIN_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("RAIN_LEVEL_CHANGE"));
|
||||||
private static final Reflect.ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE"));
|
private static final ReflectField<?> FIELD_THUNDER_LEVEL_CHANGE = wrapEx(() -> MAPPING.mojField("THUNDER_LEVEL_CHANGE"));
|
||||||
|
|
||||||
public static Type RAIN_LEVEL_CHANGE() {
|
public static Type RAIN_LEVEL_CHANGE() {
|
||||||
return wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class);
|
return wrap(wrapReflectEx(FIELD_RAIN_LEVEL_CHANGE::getStaticValue), Type.class);
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.ChunkStorage;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.paper.QueuedChangesMapLong2Object;
|
import fr.pandacube.lib.paper.reflect.wrapper.paper.QueuedChangesMapLong2Object;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
|
import it.unimi.dsi.fastutil.objects.ObjectRBTreeSet;
|
||||||
@ -13,11 +14,11 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class ChunkMap extends ChunkStorage {
|
public class ChunkMap extends ChunkStorage {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ChunkMap"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ChunkMap"));
|
||||||
private static final Reflect.ReflectField<?> FIELD_autoSaveQueue = wrapEx(() -> MAPPING.runtimeReflect().field("autoSaveQueue")); // spigot/paper field
|
private static final ReflectField<?> FIELD_autoSaveQueue = wrapEx(() -> MAPPING.runtimeReflect().field("autoSaveQueue")); // spigot/paper field
|
||||||
public static final Reflect.ReflectField<?> FIELD_level = wrapEx(() -> MAPPING.mojField("level"));
|
public static final ReflectField<?> FIELD_level = wrapEx(() -> MAPPING.mojField("level"));
|
||||||
public static final Reflect.ReflectField<?> FIELD_pendingUnloads = wrapEx(() -> MAPPING.mojField("pendingUnloads"));
|
public static final ReflectField<?> FIELD_pendingUnloads = wrapEx(() -> MAPPING.mojField("pendingUnloads"));
|
||||||
public static final Reflect.ReflectField<?> FIELD_toDrop = wrapEx(() -> MAPPING.mojField("toDrop"));
|
public static final ReflectField<?> FIELD_toDrop = wrapEx(() -> MAPPING.mojField("toDrop"));
|
||||||
public static final Reflect.ReflectField<?> FIELD_updatingChunks = wrapEx(() -> MAPPING.runtimeReflect().field("updatingChunks")); // spigot/paper field
|
public static final ReflectField<?> FIELD_updatingChunks = wrapEx(() -> MAPPING.runtimeReflect().field("updatingChunks")); // spigot/paper field
|
||||||
|
|
||||||
/** This field in unmapped */
|
/** This field in unmapped */
|
||||||
public final ObjectRBTreeSet<?> autoSaveQueue;
|
public final ObjectRBTreeSet<?> autoSaveQueue;
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class DedicatedServer extends MinecraftServer {
|
public class DedicatedServer extends MinecraftServer {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedServer"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.DedicatedServer"));
|
||||||
private static final Reflect.ReflectMethod<?> getLevelIdName = wrapEx(() -> MAPPING.mojMethod("getLevelIdName"));
|
private static final ReflectMethod<?> getLevelIdName = wrapEx(() -> MAPPING.mojMethod("getLevelIdName"));
|
||||||
private static final Reflect.ReflectMethod<?> getProperties = wrapEx(() -> MAPPING.mojMethod("getProperties"));
|
private static final ReflectMethod<?> getProperties = wrapEx(() -> MAPPING.mojMethod("getProperties"));
|
||||||
|
|
||||||
public String getLevelIdName() {
|
public String getLevelIdName() {
|
||||||
return (String) wrapReflectEx(() -> getLevelIdName.invoke(__getRuntimeInstance()));
|
return (String) wrapReflectEx(() -> getLevelIdName.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.commands.Commands;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class MinecraftServer extends ReflectWrapper {
|
public class MinecraftServer extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.MinecraftServer"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.MinecraftServer"));
|
||||||
private static final Reflect.ReflectField<?> vanillaCommandDispatcher = wrapEx(() -> MAPPING.runtimeReflect().field("vanillaCommandDispatcher"));
|
private static final ReflectField<?> vanillaCommandDispatcher = wrapEx(() -> MAPPING.runtimeReflect().field("vanillaCommandDispatcher"));
|
||||||
|
|
||||||
public Commands vanillaCommandDispatcher() {
|
public Commands vanillaCommandDispatcher() {
|
||||||
return wrap(wrapReflectEx(() -> vanillaCommandDispatcher.getValue(__getRuntimeInstance())), Commands.class);
|
return wrap(wrapReflectEx(() -> vanillaCommandDispatcher.getValue(__getRuntimeInstance())), Commands.class);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerChunkCache extends ReflectWrapper {
|
public class ServerChunkCache extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerChunkCache"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerChunkCache"));
|
||||||
private static final Reflect.ReflectField<?> FIELD_chunkMap = wrapEx(() -> MAPPING.mojField("chunkMap"));
|
private static final ReflectField<?> FIELD_chunkMap = wrapEx(() -> MAPPING.mojField("chunkMap"));
|
||||||
|
|
||||||
public final ChunkMap chunkMap;
|
public final ChunkMap chunkMap;
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.protocol.Packet;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerGamePacketListenerImpl extends ReflectWrapper {
|
public class ServerGamePacketListenerImpl extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.network.ServerGamePacketListenerImpl"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.network.ServerGamePacketListenerImpl"));
|
||||||
public static final Reflect.ReflectMethod<?> send = wrapEx(() -> MAPPING.mojMethod("send", Packet.MAPPING));
|
public static final ReflectMethod<?> send = wrapEx(() -> MAPPING.mojMethod("send", Packet.MAPPING));
|
||||||
|
|
||||||
public void send(Packet packet) {
|
public void send(Packet packet) {
|
||||||
wrapReflectEx(() -> send.invoke(__getRuntimeInstance(), unwrap(packet)));
|
wrapReflectEx(() -> send.invoke(__getRuntimeInstance(), unwrap(packet)));
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProgressListener;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.util.ProgressListener;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Level;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerLevel extends Level {
|
public class ServerLevel extends Level {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerLevel"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerLevel"));
|
||||||
public static final Reflect.ReflectMethod<?> save = wrapEx(() -> MAPPING.mojMethod("save", ProgressListener.MAPPING, boolean.class, boolean.class));
|
public static final ReflectMethod<?> save = wrapEx(() -> MAPPING.mojMethod("save", ProgressListener.MAPPING, boolean.class, boolean.class));
|
||||||
public static final Reflect.ReflectMethod<?> getChunkSource = wrapEx(() -> MAPPING.mojMethod("getChunkSource"));
|
public static final ReflectMethod<?> getChunkSource = wrapEx(() -> MAPPING.mojMethod("getChunkSource"));
|
||||||
|
|
||||||
|
|
||||||
public ServerChunkCache getChunkSource() {
|
public ServerChunkCache getChunkSource() {
|
||||||
|
@ -2,20 +2,21 @@ package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSource;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.DamageSource;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.Entity;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ServerPlayer extends Entity { // in NMS, ServerPlayer is not a direct subclass of Entity
|
public class ServerPlayer extends Entity { // in NMS, ServerPlayer is not a direct subclass of Entity
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerPlayer"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.level.ServerPlayer"));
|
||||||
public static final Reflect.ReflectField<?> connection = wrapEx(() -> MAPPING.mojField("connection"));
|
public static final ReflectField<?> connection = wrapEx(() -> MAPPING.mojField("connection"));
|
||||||
public static final Reflect.ReflectMethod<?> hurt = wrapEx(() -> MAPPING.mojMethod("hurt", DamageSource.MAPPING, float.class));
|
public static final ReflectMethod<?> hurt = wrapEx(() -> MAPPING.mojMethod("hurt", DamageSource.MAPPING, float.class));
|
||||||
public static final Reflect.ReflectMethod<?> isTextFilteringEnabled = wrapEx(() -> MAPPING.mojMethod("isTextFilteringEnabled"));
|
public static final ReflectMethod<?> isTextFilteringEnabled = wrapEx(() -> MAPPING.mojMethod("isTextFilteringEnabled"));
|
||||||
public static final Reflect.ReflectMethod<?> allowsListing = wrapEx(() -> MAPPING.mojMethod("allowsListing"));
|
public static final ReflectMethod<?> allowsListing = wrapEx(() -> MAPPING.mojMethod("allowsListing"));
|
||||||
|
|
||||||
public boolean hurt(DamageSource source, float amount) {
|
public boolean hurt(DamageSource source, float amount) {
|
||||||
return (boolean) wrapReflectEx(() -> hurt.invoke(__getRuntimeInstance(), unwrap(source), amount));
|
return (boolean) wrapReflectEx(() -> hurt.invoke(__getRuntimeInstance(), unwrap(source), amount));
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.server;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class Settings extends ReflectWrapper {
|
public class Settings extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.Settings"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.server.dedicated.Settings"));
|
||||||
public static final Reflect.ReflectField<?> properties = wrapEx(() -> MAPPING.mojField("properties"));
|
public static final ReflectField<?> properties = wrapEx(() -> MAPPING.mojField("properties"));
|
||||||
|
|
||||||
public Properties properties() {
|
public Properties properties() {
|
||||||
return (Properties) wrapReflectEx(() -> properties.getValue(__getRuntimeInstance()));
|
return (Properties) wrapReflectEx(() -> properties.getValue(__getRuntimeInstance()));
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class AABB extends ReflectWrapper {
|
public class AABB extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.AABB"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.phys.AABB"));
|
||||||
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(double.class, double.class, double.class, double.class, double.class, double.class));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(double.class, double.class, double.class, double.class, double.class, double.class));
|
||||||
|
|
||||||
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
public AABB(double x1, double y1, double z1, double x2, double y2, double z2) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x1, y1, z1, x2, y2, z2)));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x1, y1, z1, x2, y2, z2)));
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class ChunkPos extends ReflectWrapper {
|
public class ChunkPos extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.ChunkPos"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.ChunkPos"));
|
||||||
public static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class));
|
public static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> MAPPING.runtimeReflect().constructor(int.class, int.class));
|
||||||
|
|
||||||
public ChunkPos(int x, int z) {
|
public ChunkPos(int x, int z) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x, z)));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(x, z)));
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.nbt.CompoundTag;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -13,7 +13,7 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
|||||||
|
|
||||||
public class ChunkStorage extends ReflectWrapper {
|
public class ChunkStorage extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.chunk.storage.ChunkStorage"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.chunk.storage.ChunkStorage"));
|
||||||
private static final Reflect.ReflectMethod<?> readSync = wrapEx(() -> MAPPING.runtimeReflect().method("readSync", ChunkPos.MAPPING.runtimeReflect().get())); // spigot/paper method
|
private static final ReflectMethod<?> readSync = wrapEx(() -> MAPPING.runtimeReflect().method("readSync", ChunkPos.MAPPING.runtimeReflect().get())); // spigot/paper method
|
||||||
|
|
||||||
public CompoundTag readSync(ChunkPos pos) {
|
public CompoundTag readSync(ChunkPos pos) {
|
||||||
return wrap(wrapReflectEx(() -> readSync.invoke(__getRuntimeInstance(), unwrap(pos))), CompoundTag.class);
|
return wrap(wrapReflectEx(() -> readSync.invoke(__getRuntimeInstance(), unwrap(pos))), CompoundTag.class);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class DamageSource extends ReflectWrapper {
|
public class DamageSource extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.damagesource.DamageSource"));
|
||||||
private static final Reflect.ReflectField<?> FIELD_OUT_OF_WORLD = wrapEx(() -> MAPPING.mojField("OUT_OF_WORLD"));
|
private static final ReflectField<?> FIELD_OUT_OF_WORLD = wrapEx(() -> MAPPING.mojField("OUT_OF_WORLD"));
|
||||||
|
|
||||||
public static DamageSource OUT_OF_WORLD() {
|
public static DamageSource OUT_OF_WORLD() {
|
||||||
return wrap(wrapReflectEx(FIELD_OUT_OF_WORLD::getStaticValue), DamageSource.class);
|
return wrap(wrapReflectEx(FIELD_OUT_OF_WORLD::getStaticValue), DamageSource.class);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Entity extends ReflectWrapper {
|
public class Entity extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.entity.Entity"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.entity.Entity"));
|
||||||
public static final Reflect.ReflectMethod<?> getBukkitEntity = wrapEx(() -> MAPPING.runtimeReflect().method("getBukkitEntity")); // spigot field
|
public static final ReflectMethod<?> getBukkitEntity = wrapEx(() -> MAPPING.runtimeReflect().method("getBukkitEntity")); // spigot field
|
||||||
|
|
||||||
public org.bukkit.entity.Entity getBukkitEntity() {
|
public org.bukkit.entity.Entity getBukkitEntity() {
|
||||||
return (org.bukkit.entity.Entity) wrapReflectEx(() -> getBukkitEntity.invoke(__getRuntimeInstance()));
|
return (org.bukkit.entity.Entity) wrapReflectEx(() -> getBukkitEntity.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
|
import fr.pandacube.lib.paper.reflect.wrapper.paper.configuration.WorldConfiguration;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Level extends ReflectWrapper {
|
public class Level extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.Level"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.Level"));
|
||||||
public static final Reflect.ReflectMethod<?> getGameTime = wrapEx(() -> MAPPING.mojMethod("getGameTime"));
|
public static final ReflectMethod<?> getGameTime = wrapEx(() -> MAPPING.mojMethod("getGameTime"));
|
||||||
public static final Reflect.ReflectMethod<?> getFreeMapId = wrapEx(() -> MAPPING.mojMethod("getFreeMapId"));
|
public static final ReflectMethod<?> getFreeMapId = wrapEx(() -> MAPPING.mojMethod("getFreeMapId"));
|
||||||
public static final Reflect.ReflectMethod<?> paperConfig = wrapEx(() -> MAPPING.runtimeReflect().method("paperConfig")); // paper method
|
public static final ReflectMethod<?> paperConfig = wrapEx(() -> MAPPING.runtimeReflect().method("paperConfig")); // paper method
|
||||||
|
|
||||||
public long getGameTime() {
|
public long getGameTime() {
|
||||||
return (long) wrapReflectEx(() -> getGameTime.invoke(__getRuntimeInstance()));
|
return (long) wrapReflectEx(() -> getGameTime.invoke(__getRuntimeInstance()));
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class MapItemSavedData extends SavedData {
|
public class MapItemSavedData extends SavedData {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.maps.MapItemSavedData"));
|
||||||
public static final Reflect.ReflectField<?> colors = wrapEx(() -> MAPPING.mojField("colors"));
|
public static final ReflectField<?> colors = wrapEx(() -> MAPPING.mojField("colors"));
|
||||||
public static final Reflect.ReflectField<?> locked = wrapEx(() -> MAPPING.mojField("locked"));
|
public static final ReflectField<?> locked = wrapEx(() -> MAPPING.mojField("locked"));
|
||||||
|
|
||||||
protected MapItemSavedData(Object obj) {
|
protected MapItemSavedData(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class SavedData extends ReflectWrapper {
|
public class SavedData extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.SavedData"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.saveddata.SavedData"));
|
||||||
private static final Reflect.ReflectMethod<?> setDirty = wrapEx(() -> MAPPING.mojMethod("setDirty"));
|
private static final ReflectMethod<?> setDirty = wrapEx(() -> MAPPING.mojMethod("setDirty"));
|
||||||
|
|
||||||
protected SavedData(Object obj) {
|
protected SavedData(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block;
|
package fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.block;
|
||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
|
||||||
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
import fr.pandacube.lib.paper.reflect.NMSReflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class BambooBlock extends ReflectWrapper {
|
public class BambooBlock extends ReflectWrapper {
|
||||||
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.BambooBlock"));
|
public static final NMSReflect.ClassMapping MAPPING = wrapEx(() -> NMSReflect.mojClass("net.minecraft.world.level.block.BambooBlock"));
|
||||||
public static final Reflect.ReflectField<?> COLLISION_SHAPE = wrapEx(() -> MAPPING.mojField("COLLISION_SHAPE"));
|
public static final ReflectField<?> COLLISION_SHAPE = wrapEx(() -> MAPPING.mojField("COLLISION_SHAPE"));
|
||||||
|
|
||||||
public static VoxelShape COLLISION_SHAPE() {
|
public static VoxelShape COLLISION_SHAPE() {
|
||||||
return wrap(wrapReflectEx(COLLISION_SHAPE::getStaticValue), VoxelShape.class);
|
return wrap(wrapReflectEx(COLLISION_SHAPE::getStaticValue), VoxelShape.class);
|
||||||
|
@ -2,11 +2,12 @@ package fr.pandacube.lib.paper.reflect.wrapper.netty;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
|
|
||||||
public class ByteBuf extends ReflectWrapper {
|
public class ByteBuf extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.netty.buffer.ByteBuf"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.netty.buffer.ByteBuf"));
|
||||||
|
|
||||||
protected ByteBuf(Object obj) {
|
protected ByteBuf(Object obj) {
|
||||||
super(obj);
|
super(obj);
|
||||||
|
@ -2,13 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.netty;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class Unpooled extends ReflectWrapper {
|
public class Unpooled extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.netty.buffer.Unpooled"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.netty.buffer.Unpooled"));
|
||||||
private static final Reflect.ReflectMethod<?> buffer = wrapEx(() -> REFLECT.method("buffer"));
|
private static final ReflectMethod<?> buffer = wrapEx(() -> REFLECT.method("buffer"));
|
||||||
|
|
||||||
|
|
||||||
public static ByteBuf buffer() {
|
public static ByteBuf buffer() {
|
||||||
|
@ -3,13 +3,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.paper;
|
|||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.AABB;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.AABB;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.world.VoxelShape;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectConstructor;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class AABBVoxelShape extends VoxelShape {
|
public class AABBVoxelShape extends VoxelShape {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.voxel.AABBVoxelShape"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.voxel.AABBVoxelShape"));
|
||||||
private static final Reflect.ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(AABB.MAPPING.runtimeClass()));
|
private static final ReflectConstructor<?> CONSTRUCTOR = wrapEx(() -> REFLECT.constructor(AABB.MAPPING.runtimeClass()));
|
||||||
|
|
||||||
public AABBVoxelShape(AABB aabb) {
|
public AABBVoxelShape(AABB aabb) {
|
||||||
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(aabb))));
|
this(wrapReflectEx(() -> CONSTRUCTOR.instanciate(unwrap(aabb))));
|
||||||
|
@ -3,13 +3,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.paper;
|
|||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
|
import fr.pandacube.lib.paper.reflect.wrapper.minecraft.network.chat.Component;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class PaperAdventure extends ReflectWrapper {
|
public class PaperAdventure extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.adventure.PaperAdventure"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.adventure.PaperAdventure"));
|
||||||
private static final Reflect.ReflectMethod<?> asAdventure = wrapEx(() -> REFLECT.method("asAdventure", Component.MAPPING.runtimeClass()));
|
private static final ReflectMethod<?> asAdventure = wrapEx(() -> REFLECT.method("asAdventure", Component.MAPPING.runtimeClass()));
|
||||||
|
|
||||||
public static net.kyori.adventure.text.Component asAdventure(Component component) {
|
public static net.kyori.adventure.text.Component asAdventure(Component component) {
|
||||||
return (net.kyori.adventure.text.Component) wrapReflectEx(() -> asAdventure.invokeStatic(unwrap(component)));
|
return (net.kyori.adventure.text.Component) wrapReflectEx(() -> asAdventure.invokeStatic(unwrap(component)));
|
||||||
|
@ -2,14 +2,17 @@ package fr.pandacube.lib.paper.reflect.wrapper.paper;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class QueuedChangesMapLong2Object extends ReflectWrapper {
|
public class QueuedChangesMapLong2Object extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("com.destroystokyo.paper.util.map.QueuedChangesMapLong2Object"));
|
||||||
public static final Reflect.ReflectMethod<?> getVisibleMap = wrapEx(() -> REFLECT.method("getVisibleMap"));
|
public static final ReflectMethod<?> getVisibleMap = wrapEx(() -> REFLECT.method("getVisibleMap"));
|
||||||
|
|
||||||
/** The entries in the returned value are not mapped */
|
/** The entries in the returned value are not mapped */
|
||||||
public Long2ObjectLinkedOpenHashMap<?> getVisibleMap() {
|
public Long2ObjectLinkedOpenHashMap<?> getVisibleMap() {
|
||||||
|
@ -2,13 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectMethod;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class FallbackValue_Int extends ReflectWrapper {
|
public class FallbackValue_Int extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.type.fallback.FallbackValue$Int"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.type.fallback.FallbackValue$Int"));
|
||||||
public static final Reflect.ReflectMethod<?> value = wrapEx(() -> REFLECT.method("value"));
|
public static final ReflectMethod<?> value = wrapEx(() -> REFLECT.method("value"));
|
||||||
|
|
||||||
public int value() {
|
public int value() {
|
||||||
return (int) wrapReflectEx(() -> value.invoke(__getRuntimeInstance()));
|
return (int) wrapReflectEx(() -> value.invoke(__getRuntimeInstance()));
|
||||||
|
@ -2,13 +2,15 @@ package fr.pandacube.lib.paper.reflect.wrapper.paper.configuration;
|
|||||||
|
|
||||||
import fr.pandacube.lib.reflect.Reflect;
|
import fr.pandacube.lib.reflect.Reflect;
|
||||||
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
import fr.pandacube.lib.paper.reflect.wrapper.ReflectWrapper;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectClass;
|
||||||
|
import fr.pandacube.lib.reflect.ReflectField;
|
||||||
|
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapEx;
|
||||||
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
|
||||||
|
|
||||||
public class WorldConfiguration extends ReflectWrapper {
|
public class WorldConfiguration extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration"));
|
||||||
public static final Reflect.ReflectField<?> chunks = wrapEx(() -> REFLECT.field("chunks"));
|
public static final ReflectField<?> chunks = wrapEx(() -> REFLECT.field("chunks"));
|
||||||
|
|
||||||
public Chunks chunks() {
|
public Chunks chunks() {
|
||||||
return wrap(wrapReflectEx(() -> chunks.getValue(__getRuntimeInstance())), Chunks.class);
|
return wrap(wrapReflectEx(() -> chunks.getValue(__getRuntimeInstance())), Chunks.class);
|
||||||
@ -19,8 +21,8 @@ public class WorldConfiguration extends ReflectWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Chunks extends ReflectWrapper {
|
public static class Chunks extends ReflectWrapper {
|
||||||
public static final Reflect.ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration$Chunks"));
|
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("io.papermc.paper.configuration.WorldConfiguration$Chunks"));
|
||||||
public static final Reflect.ReflectField<?> autoSavePeriod = wrapEx(() -> REFLECT.field("autoSaveInterval"));
|
public static final ReflectField<?> autoSavePeriod = wrapEx(() -> REFLECT.field("autoSaveInterval"));
|
||||||
|
|
||||||
public FallbackValue_Int autoSavePeriod() {
|
public FallbackValue_Int autoSavePeriod() {
|
||||||
return wrap(wrapReflectEx(() -> autoSavePeriod.getValue(__getRuntimeInstance())), FallbackValue_Int.class);
|
return wrap(wrapReflectEx(() -> autoSavePeriod.getValue(__getRuntimeInstance())), FallbackValue_Int.class);
|
||||||
|
Loading…
Reference in New Issue
Block a user