Add deadmau5 ears ability, it'll default to black tho. Also obfuscate 2 files
This commit is contained in:
parent
fd9c4cdad7
commit
e6cf577db0
@ -4,6 +4,7 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
@ -31,6 +32,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
private boolean explicitNameVisible = false;
|
private boolean explicitNameVisible = false;
|
||||||
private final UUID uuid = UUID.randomUUID();
|
private final UUID uuid = UUID.randomUUID();
|
||||||
private transient DisguiseUtilities.DScoreTeam scoreboardName;
|
private transient DisguiseUtilities.DScoreTeam scoreboardName;
|
||||||
|
@Getter
|
||||||
|
private boolean deadmau5Ears;
|
||||||
|
|
||||||
private PlayerDisguise() {
|
private PlayerDisguise() {
|
||||||
super(DisguiseType.PLAYER);
|
super(DisguiseType.PLAYER);
|
||||||
@ -110,7 +113,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (scoreboardName == null) {
|
if (scoreboardName == null) {
|
||||||
if (isUpsideDown()) {
|
if (isUpsideDown() || isDeadmau5Ears()) {
|
||||||
scoreboardName = new DisguiseUtilities.DScoreTeam(this, new String[]{"", getProfileName(), ""});
|
scoreboardName = new DisguiseUtilities.DScoreTeam(this, new String[]{"", getProfileName(), ""});
|
||||||
} else {
|
} else {
|
||||||
scoreboardName = DisguiseUtilities.createExtendedName(this);
|
scoreboardName = DisguiseUtilities.createExtendedName(this);
|
||||||
@ -121,7 +124,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setScoreboardName(String[] split) {
|
private void setScoreboardName(String[] split) {
|
||||||
if (isUpsideDown()) {
|
if (isUpsideDown() || isDeadmau5Ears()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +144,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return isUpsideDown() ? "Dinnerbone" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
|
return isUpsideDown() ? "Dinnerbone" :
|
||||||
|
isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUUID() {
|
public UUID getUUID() {
|
||||||
@ -216,6 +220,22 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlayerDisguise setDeadmau5Ears(boolean deadmau5Ears) {
|
||||||
|
if (deadmau5Ears == isDeadmau5Ears()) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.deadmau5Ears = deadmau5Ears;
|
||||||
|
|
||||||
|
if (isDisguiseInUse()) {
|
||||||
|
resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "deadmau5", true);
|
||||||
|
} else {
|
||||||
|
scoreboardName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlayerDisguise clone() {
|
public PlayerDisguise clone() {
|
||||||
PlayerDisguise disguise = new PlayerDisguise();
|
PlayerDisguise disguise = new PlayerDisguise();
|
||||||
@ -236,6 +256,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
disguise.nameVisible = isNameVisible();
|
disguise.nameVisible = isNameVisible();
|
||||||
disguise.explicitNameVisible = explicitNameVisible;
|
disguise.explicitNameVisible = explicitNameVisible;
|
||||||
disguise.setUpsideDown(isUpsideDown());
|
disguise.setUpsideDown(isUpsideDown());
|
||||||
|
disguise.setDeadmau5Ears(isDeadmau5Ears());
|
||||||
|
|
||||||
clone(disguise);
|
clone(disguise);
|
||||||
|
|
||||||
|
@ -5,8 +5,10 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
|
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
|
||||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoSoundGroup;
|
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoSoundGroup;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
@ -80,8 +82,9 @@ public class ParamInfoManager {
|
|||||||
|
|
||||||
public static ParamInfo getParamInfo(DisguiseType disguiseType, String methodName) {
|
public static ParamInfo getParamInfo(DisguiseType disguiseType, String methodName) {
|
||||||
for (Method method : getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
for (Method method : getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||||
if (!method.getName().toLowerCase(Locale.ENGLISH).equals(methodName.toLowerCase(Locale.ENGLISH)))
|
if (!method.getName().toLowerCase(Locale.ENGLISH).equals(methodName.toLowerCase(Locale.ENGLISH))) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return getParamInfo(method);
|
return getParamInfo(method);
|
||||||
}
|
}
|
||||||
@ -93,14 +96,17 @@ public class ParamInfoManager {
|
|||||||
ParamInfoTypes infoTypes = new ParamInfoTypes();
|
ParamInfoTypes infoTypes = new ParamInfoTypes();
|
||||||
paramList = infoTypes.getParamInfos();
|
paramList = infoTypes.getParamInfos();
|
||||||
paramInfoItemBlock = infoTypes.getParamInfoBlock();
|
paramInfoItemBlock = infoTypes.getParamInfoBlock();
|
||||||
paramInfoSoundGroup = (ParamInfoSoundGroup) paramList.stream().filter(p -> p instanceof ParamInfoSoundGroup)
|
paramInfoSoundGroup =
|
||||||
.findAny().orElse(null);
|
(ParamInfoSoundGroup) paramList.stream().filter(p -> p instanceof ParamInfoSoundGroup).findAny()
|
||||||
|
.orElse(null);
|
||||||
disguiseMethods = new DisguiseMethods();
|
disguiseMethods = new DisguiseMethods();
|
||||||
|
|
||||||
//paramList.sort((o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()));
|
//paramList.sort((o1, o2) -> String.CASE_INSENSITIVE_ORDER.compare(o1.getName(), o2.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method[] getDisguiseWatcherMethods(@Nullable Class<? extends FlagWatcher> watcherClass) {
|
public static Method[] getDisguiseWatcherMethods(
|
||||||
|
@Nullable
|
||||||
|
Class<? extends FlagWatcher> watcherClass) {
|
||||||
if (watcherClass == null) {
|
if (watcherClass == null) {
|
||||||
return new Method[0];
|
return new Method[0];
|
||||||
}
|
}
|
||||||
@ -124,9 +130,10 @@ public class ParamInfoManager {
|
|||||||
for (String methodName : new String[]{"setSelfDisguiseVisible", "setHideHeldItemFromSelf",
|
for (String methodName : new String[]{"setSelfDisguiseVisible", "setHideHeldItemFromSelf",
|
||||||
"setHideArmorFromSelf", "setHearSelfDisguise", "setHidePlayer", "setExpires", "setNotifyBar",
|
"setHideArmorFromSelf", "setHearSelfDisguise", "setHidePlayer", "setExpires", "setNotifyBar",
|
||||||
"setBossBarColor", "setBossBarStyle", "setTallDisguisesVisible", "setDynamicName", "setSoundGroup",
|
"setBossBarColor", "setBossBarStyle", "setTallDisguisesVisible", "setDynamicName", "setSoundGroup",
|
||||||
"setDisguiseName"}) {
|
"setDisguiseName", "setDeadmau5Ears"}) {
|
||||||
try {
|
try {
|
||||||
Class cl = boolean.class;
|
Class cl = boolean.class;
|
||||||
|
Class disguiseClass = Disguise.class;
|
||||||
|
|
||||||
switch (methodName) {
|
switch (methodName) {
|
||||||
case "setExpires":
|
case "setExpires":
|
||||||
@ -145,13 +152,19 @@ public class ParamInfoManager {
|
|||||||
case "setDisguiseName":
|
case "setDisguiseName":
|
||||||
cl = String.class;
|
cl = String.class;
|
||||||
break;
|
break;
|
||||||
|
case "setDeadmau5Ears":
|
||||||
|
if (watcherClass != PlayerWatcher.class) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
disguiseClass = PlayerDisguise.class;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
methods.add(Disguise.class.getMethod(methodName, cl));
|
methods.add(disguiseClass.getMethod(methodName, cl));
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,7 @@ import org.bukkit.plugin.SimplePluginManager;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.*;
|
||||||
import java.io.File;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -1717,6 +1714,24 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] readFully(InputStream input) throws IOException {
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int bytesRead;
|
||||||
|
ByteArrayOutputStream output = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
while ((bytesRead = input.read(buffer)) != -1) {
|
||||||
|
output.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] array = output.toByteArray();
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
array[i] = (byte) (Byte.MAX_VALUE - array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
private static void createNMSValues(DisguiseType disguiseType) {
|
private static void createNMSValues(DisguiseType disguiseType) {
|
||||||
String nmsEntityName = toReadable(disguiseType.name());
|
String nmsEntityName = toReadable(disguiseType.name());
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities.reflection.asm;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
|
|
||||||
@ -13,8 +14,10 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 17/02/2020.
|
* Created by libraryaddict on 17/02/2020.
|
||||||
@ -72,8 +75,7 @@ public class WatcherSanitizer {
|
|||||||
public static void init() {
|
public static void init() {
|
||||||
try {
|
try {
|
||||||
checkPreLoaded();
|
checkPreLoaded();
|
||||||
}
|
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||||
catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,8 +94,7 @@ public class WatcherSanitizer {
|
|||||||
asm = new Asm13();
|
asm = new Asm13();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> lines = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines()
|
String[] lines = new String(ReflectionManager.readFully(stream), StandardCharsets.UTF_8).split("\n");
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
LinkedHashMap<String, ArrayList<Map.Entry<String, String>>> toRemove = new LinkedHashMap<>();
|
LinkedHashMap<String, ArrayList<Map.Entry<String, String>>> toRemove = new LinkedHashMap<>();
|
||||||
|
|
||||||
@ -118,8 +119,7 @@ public class WatcherSanitizer {
|
|||||||
Class result = asm.createClassWithoutMethods(entry.getKey(), entry.getValue());
|
Class result = asm.createClassWithoutMethods(entry.getKey(), entry.getValue());
|
||||||
mapped.add(entry.getKey());
|
mapped.add(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | NoSuchFieldException | LinkageError e) {
|
||||||
catch (IOException | IllegalAccessException | InvocationTargetException | NoSuchMethodException | NoSuchFieldException | LinkageError e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LibsDisguises.getInstance().getLogger().severe("Registered: " + new Gson().toJson(mapped));
|
LibsDisguises.getInstance().getLogger().severe("Registered: " + new Gson().toJson(mapped));
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,17 @@ package me.libraryaddict.disguise.utilities.sounds;
|
|||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 23/05/2020.
|
* Created by libraryaddict on 23/05/2020.
|
||||||
@ -53,8 +55,8 @@ public class SoundManager {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> list = section
|
List<String> list = section.getStringList(
|
||||||
.getStringList(type.name().charAt(0) + type.name().substring(1).toLowerCase(Locale.ENGLISH));
|
type.name().charAt(0) + type.name().substring(1).toLowerCase(Locale.ENGLISH));
|
||||||
|
|
||||||
if (list == null || list.isEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
@ -96,8 +98,7 @@ public class SoundManager {
|
|||||||
|
|
||||||
private void loadSounds() {
|
private void loadSounds() {
|
||||||
try (InputStream stream = LibsDisguises.getInstance().getResource("ANTI_PIRACY_ENCODED_WITH_SOUNDS")) {
|
try (InputStream stream = LibsDisguises.getInstance().getResource("ANTI_PIRACY_ENCODED_WITH_SOUNDS")) {
|
||||||
List<String> lines = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines()
|
String[] lines = new String(ReflectionManager.readFully(stream), StandardCharsets.UTF_8).split("\n");
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
String[] groups = line.split("/", -1);
|
String[] groups = line.split("/", -1);
|
||||||
@ -119,14 +120,12 @@ public class SoundManager {
|
|||||||
Sound actualSound = Sound.valueOf(sound);
|
Sound actualSound = Sound.valueOf(sound);
|
||||||
|
|
||||||
group.addSound(actualSound, type);
|
group.addSound(actualSound, type);
|
||||||
}
|
} catch (Exception ignored) {
|
||||||
catch (Exception ignored) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (IOException | NoClassDefFoundError e) {
|
||||||
catch (IOException | NoClassDefFoundError e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,17 @@ import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
|||||||
import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums;
|
import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums;
|
||||||
import me.libraryaddict.disguise.utilities.sounds.SoundGroup;
|
import me.libraryaddict.disguise.utilities.sounds.SoundGroup;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 13/02/2020.
|
* Created by libraryaddict on 13/02/2020.
|
||||||
@ -63,11 +64,16 @@ public class CompileMethods {
|
|||||||
|
|
||||||
File soundsFile = new File("target/classes/ANTI_PIRACY_ENCODED_WITH_SOUNDS");
|
File soundsFile = new File("target/classes/ANTI_PIRACY_ENCODED_WITH_SOUNDS");
|
||||||
|
|
||||||
try (PrintWriter writer = new PrintWriter(soundsFile, "UTF-8")) {
|
try (FileOutputStream fos = new FileOutputStream(soundsFile)) {
|
||||||
writer.write(StringUtils.join(list, "\n"));
|
byte[] array = StringUtils.join(list, "\n").getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
array[i] = (byte) (Byte.MAX_VALUE - array[i]);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
fos.write(array);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,8 +90,8 @@ public class CompileMethods {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void doMethods() {
|
private static void doMethods() {
|
||||||
ArrayList<Class<?>> classes = ClassGetter
|
ArrayList<Class<?>> classes =
|
||||||
.getClassesForPackage(FlagWatcher.class, "me.libraryaddict.disguise.disguisetypes.watchers");
|
ClassGetter.getClassesForPackage(FlagWatcher.class, "me.libraryaddict.disguise.disguisetypes.watchers");
|
||||||
|
|
||||||
ArrayList<Class> sorted = new ArrayList<>();
|
ArrayList<Class> sorted = new ArrayList<>();
|
||||||
|
|
||||||
@ -147,40 +153,55 @@ public class CompileMethods {
|
|||||||
|
|
||||||
File methodsFile = new File("target/classes/ANTI_PIRACY_ENCRYPTION");
|
File methodsFile = new File("target/classes/ANTI_PIRACY_ENCRYPTION");
|
||||||
|
|
||||||
try (PrintWriter writer = new PrintWriter(methodsFile, "UTF-8")) {
|
try (FileOutputStream fos = new FileOutputStream(methodsFile)) {
|
||||||
writer.write(StringUtils.join(methods, "\n"));
|
byte[] array = StringUtils.join(methods, "\n").getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
for (int i = 0; i < array.length; i++) {
|
||||||
|
array[i] = (byte) (Byte.MAX_VALUE - array[i]);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
fos.write(array);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getDescriptorForClass(final Class c) {
|
static String getDescriptorForClass(final Class c) {
|
||||||
if (c.isPrimitive()) {
|
if (c.isPrimitive()) {
|
||||||
if (c == byte.class)
|
if (c == byte.class) {
|
||||||
return "B";
|
return "B";
|
||||||
if (c == char.class)
|
}
|
||||||
|
if (c == char.class) {
|
||||||
return "C";
|
return "C";
|
||||||
if (c == double.class)
|
}
|
||||||
|
if (c == double.class) {
|
||||||
return "D";
|
return "D";
|
||||||
if (c == float.class)
|
}
|
||||||
|
if (c == float.class) {
|
||||||
return "F";
|
return "F";
|
||||||
if (c == int.class)
|
}
|
||||||
|
if (c == int.class) {
|
||||||
return "I";
|
return "I";
|
||||||
if (c == long.class)
|
}
|
||||||
|
if (c == long.class) {
|
||||||
return "J";
|
return "J";
|
||||||
if (c == short.class)
|
}
|
||||||
|
if (c == short.class) {
|
||||||
return "S";
|
return "S";
|
||||||
if (c == boolean.class)
|
}
|
||||||
|
if (c == boolean.class) {
|
||||||
return "Z";
|
return "Z";
|
||||||
if (c == void.class)
|
}
|
||||||
|
if (c == void.class) {
|
||||||
return "V";
|
return "V";
|
||||||
|
}
|
||||||
|
|
||||||
throw new RuntimeException("Unrecognized primitive " + c);
|
throw new RuntimeException("Unrecognized primitive " + c);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c.isArray())
|
if (c.isArray()) {
|
||||||
return c.getName().replace('.', '/');
|
return c.getName().replace('.', '/');
|
||||||
|
}
|
||||||
|
|
||||||
return ('L' + c.getName() + ';').replace('.', '/');
|
return ('L' + c.getName() + ';').replace('.', '/');
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -53,8 +54,7 @@ public class DisguiseMethods {
|
|||||||
|
|
||||||
private void loadMethods() {
|
private void loadMethods() {
|
||||||
try (InputStream stream = LibsDisguises.getInstance().getResource("ANTI_PIRACY_ENCRYPTION")) {
|
try (InputStream stream = LibsDisguises.getInstance().getResource("ANTI_PIRACY_ENCRYPTION")) {
|
||||||
List<String> lines = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8)).lines()
|
String[] lines = new String(ReflectionManager.readFully(stream), StandardCharsets.UTF_8).split("\n");
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
HashMap<String, Class<? extends FlagWatcher>> classes = new HashMap<>();
|
HashMap<String, Class<? extends FlagWatcher>> classes = new HashMap<>();
|
||||||
classes.put(FlagWatcher.class.getSimpleName(), FlagWatcher.class);
|
classes.put(FlagWatcher.class.getSimpleName(), FlagWatcher.class);
|
||||||
@ -68,6 +68,11 @@ public class DisguiseMethods {
|
|||||||
|
|
||||||
while (!classes.containsKey(c.getSimpleName())) {
|
while (!classes.containsKey(c.getSimpleName())) {
|
||||||
classes.put(c.getSimpleName(), c);
|
classes.put(c.getSimpleName(), c);
|
||||||
|
|
||||||
|
if (c == FlagWatcher.class) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
c = ReflectionManager.getSuperClass(c);
|
c = ReflectionManager.getSuperClass(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user