mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2025-04-17 20:36:21 +02:00
Start writing descs to file
This commit is contained in:
parent
0f08ae35ad
commit
f26dec5adc
@ -12,6 +12,7 @@ import me.libraryaddict.disguise.commands.libsdisguises.LDDebugPlayer;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDHelp;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDJson;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDMetaInfo;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDMissingDescription;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDMods;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDPermTest;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDReload;
|
||||
@ -53,6 +54,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
||||
getCommands().add(new LDUpdatePacketEvents());
|
||||
getCommands().add(new LDDebugMineSkin());
|
||||
getCommands().add(new LDDebugDisguiseLoop());
|
||||
getCommands().add(new LDMissingDescription());
|
||||
}
|
||||
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
|
@ -0,0 +1,57 @@
|
||||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class LDMissingDescription implements LDCommand {
|
||||
@Override
|
||||
public List<String> getTabComplete() {
|
||||
return Collections.singletonList("missingdescriptions");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "libsdisguises.disguise";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return !LibsDisguises.getInstance().isJenkins();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
List<WatcherMethod> methods = new ArrayList<>(ParamInfoManager.getDisguiseMethods().getMethods());
|
||||
methods.removeIf(m -> m.isNoVisibleDifference() || m.getDescription() != null && m.getDescription().length() > 5);
|
||||
|
||||
for (int i = 0; i < methods.size(); i++) {
|
||||
if (i > 10) {
|
||||
sender.sendMessage(ChatColor.RED + "Skipping the remaining " + (methods.size() - (i - 1)) + " methods...");
|
||||
break;
|
||||
}
|
||||
|
||||
WatcherMethod m = methods.get(i);
|
||||
sender.sendMessage(
|
||||
ChatColor.DARK_AQUA + m.getWatcherClass().getSimpleName() + ChatColor.AQUA + " -> " + ChatColor.DARK_AQUA + m.getName() +
|
||||
ChatColor.AQUA + " = " + ChatColor.DARK_AQUA + "Missing");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibsMsg getHelp() {
|
||||
return LibsMsg.LD_COMMAND_RELOAD;
|
||||
}
|
||||
}
|
@ -379,7 +379,7 @@ public enum DisguiseType {
|
||||
if (getEntityType() == null) {
|
||||
try {
|
||||
setEntityType(ReflectionManager.fromEnum(EntityType.class, name()));
|
||||
} catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
if (LibsDisguises.getInstance() == null) {
|
||||
return;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ public class WatcherMethod {
|
||||
private final boolean hideFromTab;
|
||||
private final boolean[] unusableBy;
|
||||
private final boolean[] hiddenFor;
|
||||
private final String description;
|
||||
private final boolean noVisibleDifference;
|
||||
|
||||
public boolean isUsable(DisguiseType type) {
|
||||
return !unusableBy[type.ordinal()];
|
||||
|
@ -1,5 +1,6 @@
|
||||
package me.libraryaddict.disguise.utilities.reflection;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@ -11,17 +12,34 @@ import java.util.Objects;
|
||||
@Getter
|
||||
@Setter
|
||||
public class WatcherInfo {
|
||||
// Serialized names only lowers size by 10% compressed (1kb), but there's a bigger change when uncompressed! (17kb to 10kb)
|
||||
@SerializedName("a")
|
||||
private int added = -1;
|
||||
@SerializedName("b")
|
||||
private int removed = -1;
|
||||
@SerializedName("c")
|
||||
private boolean deprecated;
|
||||
@SerializedName("d")
|
||||
private String returnType;
|
||||
@SerializedName("e")
|
||||
private boolean randomDefault;
|
||||
@SerializedName("f")
|
||||
private String watcher;
|
||||
@SerializedName("g")
|
||||
private String method;
|
||||
@SerializedName("h")
|
||||
private String mappedAs;
|
||||
@SerializedName("i")
|
||||
private String param;
|
||||
@SerializedName("j")
|
||||
private String descriptor;
|
||||
@SerializedName("k")
|
||||
private String description;
|
||||
@SerializedName("l")
|
||||
private boolean noVisibleDifference;
|
||||
@SerializedName("m")
|
||||
private List<Integer> unusableBy = new ArrayList<>();
|
||||
@SerializedName("n")
|
||||
private List<Integer> hiddenFor = new ArrayList<>();
|
||||
|
||||
public void setHiddenFor(DisguiseType[] types) {
|
||||
|
@ -96,7 +96,7 @@ public class SoundManager {
|
||||
}
|
||||
|
||||
private void loadSounds() {
|
||||
try (InputStream stream = LibsDisguises.getInstance().getResource("SOUND_MAPPINGS")) {
|
||||
try (InputStream stream = LibsDisguises.getInstance().getResource("SOUND_MAPPINGS.txt")) {
|
||||
String[] lines = new String(ReflectionManager.readFuzzyFully(stream), StandardCharsets.UTF_8).split("\n");
|
||||
|
||||
for (String line : lines) {
|
||||
|
@ -7,6 +7,7 @@ import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
||||
import me.libraryaddict.disguise.utilities.reflection.WatcherInfo;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodDescription;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodHiddenFor;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodIgnoredBy;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodMappedAs;
|
||||
@ -48,7 +49,7 @@ public class CompileMethods {
|
||||
|
||||
public static String[] ignoredDirectories() {
|
||||
return new String[]{"META-INF/", "libsdisg/", "me/libraryaddict/disguise/utilities/reflection/v",
|
||||
"me/libraryaddict/disguise/utilities/reflection/ReflectionManagerAbstract.class", "fernflower_","net/kyori/adventure/"};
|
||||
"me/libraryaddict/disguise/utilities/reflection/ReflectionManagerAbstract.class", "fernflower_", "net/kyori/adventure/"};
|
||||
}
|
||||
|
||||
private static void doFileCount() {
|
||||
@ -87,7 +88,7 @@ public class CompileMethods {
|
||||
list.add(sound.toString());
|
||||
}
|
||||
|
||||
File soundsFile = new File("plugin/target/classes/SOUND_MAPPINGS");
|
||||
File soundsFile = new File("plugin/target/classes/SOUND_MAPPINGS.txt");
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(soundsFile)) {
|
||||
fos.write(String.join("\n", list).getBytes(StandardCharsets.UTF_8));
|
||||
@ -173,6 +174,8 @@ public class CompileMethods {
|
||||
DisguiseType[] unusableBy = new DisguiseType[0];
|
||||
DisguiseType[] hiddenFor = new DisguiseType[0];
|
||||
String mappedAs = method.getName();
|
||||
String description = null;
|
||||
boolean noVisibleDifference = false;
|
||||
|
||||
if (method.isAnnotationPresent(NmsAddedIn.class)) {
|
||||
added = method.getAnnotation(NmsAddedIn.class).value().ordinal();
|
||||
@ -216,6 +219,16 @@ public class CompileMethods {
|
||||
mappedAs = method.getAnnotation(MethodMappedAs.class).value();
|
||||
}
|
||||
|
||||
if (method.isAnnotationPresent(MethodDescription.class)) {
|
||||
description = method.getAnnotation(MethodDescription.class).value();
|
||||
|
||||
if (description.isEmpty()) {
|
||||
description = null;
|
||||
}
|
||||
|
||||
noVisibleDifference = method.getAnnotation(MethodDescription.class).noVisibleDifference();
|
||||
}
|
||||
|
||||
String param = method.getParameterCount() == 1 ? method.getParameterTypes()[0].getName() : null;
|
||||
|
||||
WatcherInfo info = new WatcherInfo();
|
||||
@ -228,6 +241,8 @@ public class CompileMethods {
|
||||
info.setDeprecated(method.isAnnotationPresent(Deprecated.class));
|
||||
info.setParam(param);
|
||||
info.setDescriptor(getMethodDescriptor(method));
|
||||
info.setDescription(description);
|
||||
info.setNoVisibleDifference(noVisibleDifference);
|
||||
info.setWatcher(method.getDeclaringClass().getSimpleName());
|
||||
info.setReturnType(method.getReturnType().getName());
|
||||
info.setRandomDefault(method.isAnnotationPresent(RandomDefaultValue.class));
|
||||
@ -252,7 +267,7 @@ public class CompileMethods {
|
||||
|
||||
String gson = new Gson().toJson(methods);
|
||||
|
||||
File methodsFile = new File("plugin/target/classes/METHOD_MAPPINGS");
|
||||
File methodsFile = new File("plugin/target/classes/METHOD_MAPPINGS.txt");
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(methodsFile)) {
|
||||
fos.write(gson.getBytes(StandardCharsets.UTF_8));
|
||||
|
@ -82,7 +82,7 @@ public class DisguiseMethods {
|
||||
private void loadMethods() {
|
||||
List<String> notedSkippedParamTypes = new ArrayList<>();
|
||||
|
||||
try (InputStream stream = LibsDisguises.getInstance().getResource("METHOD_MAPPINGS")) {
|
||||
try (InputStream stream = LibsDisguises.getInstance().getResource("METHOD_MAPPINGS.txt")) {
|
||||
|
||||
HashMap<String, Class<? extends FlagWatcher>> classes = new HashMap<>();
|
||||
classes.put(FlagWatcher.class.getSimpleName(), FlagWatcher.class);
|
||||
@ -158,7 +158,8 @@ public class DisguiseMethods {
|
||||
|
||||
WatcherMethod m =
|
||||
new WatcherMethod(watcher, method, info.getMappedAs(), info.getMethod(), returnType, param, info.isRandomDefault(),
|
||||
info.isDeprecated() && info.getAdded() == 0, unusableBy, hiddenFor);
|
||||
info.isDeprecated() && info.getAdded() == 0, unusableBy, hiddenFor, info.getDescription(),
|
||||
info.isNoVisibleDifference());
|
||||
|
||||
methods.add(m);
|
||||
|
||||
@ -224,7 +225,7 @@ public class DisguiseMethods {
|
||||
WatcherMethod method = new WatcherMethod(disguiseClass,
|
||||
MethodHandles.publicLookup().findVirtual(disguiseClass, methodName, MethodType.methodType(returnType, cl)),
|
||||
methodName, methodName, null, cl, randomDefault, false, new boolean[DisguiseType.values().length],
|
||||
new boolean[DisguiseType.values().length]);
|
||||
new boolean[DisguiseType.values().length], null, false);
|
||||
|
||||
methods.add(method);
|
||||
|
||||
@ -241,7 +242,7 @@ public class DisguiseMethods {
|
||||
|
||||
WatcherMethod getMethod = new WatcherMethod(disguiseClass,
|
||||
MethodHandles.publicLookup().findVirtual(disguiseClass, getName, MethodType.methodType(cl)), getName,
|
||||
getName, cl, null, randomDefault, false, new boolean[DisguiseType.values().length], hiddenFor);
|
||||
getName, cl, null, randomDefault, false, new boolean[DisguiseType.values().length], hiddenFor, null, false);
|
||||
|
||||
methods.add(getMethod);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user