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