Use lombok, add new config options for disabling pvp, pve, action bar when disguised, permission to hide name above head
This commit is contained in:
@@ -9,6 +9,7 @@ import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.DisguiseConfig.DisguisePushing;
|
||||
@@ -90,29 +91,33 @@ public class DisguiseUtilities {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static final Random random = new Random();
|
||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
|
||||
/**
|
||||
* A hashmap of the uuid's of entitys, alive and dead. And their disguises in use
|
||||
*/
|
||||
private static Map<UUID, Set<TargetedDisguise>> disguisesInUse = new ConcurrentHashMap<>();
|
||||
@Getter
|
||||
private static Map<UUID, Set<TargetedDisguise>> disguises = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only
|
||||
* stay in for
|
||||
* a max of a second.
|
||||
*/
|
||||
@Getter
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
||||
private static HashSet<UUID> savedDisguiseList = new HashSet<>();
|
||||
private static HashSet<String> cachedNames = new HashSet<>();
|
||||
private static final HashMap<String, ArrayList<Object>> runnables = new HashMap<>();
|
||||
@Getter
|
||||
private static HashSet<UUID> selfDisguised = new HashSet<>();
|
||||
private static Thread mainThread;
|
||||
private static PacketContainer spawnChunk;
|
||||
private static HashMap<UUID, String> preDisguiseTeam = new HashMap<>();
|
||||
private static HashMap<UUID, String> disguiseTeam = new HashMap<>();
|
||||
private static File profileCache = new File("plugins/LibsDisguises/GameProfiles"), savedDisguises = new File(
|
||||
"plugins/LibsDisguises/SavedDisguises");
|
||||
private static Gson gson;
|
||||
@Getter
|
||||
private static boolean pluginsUsed, commandsUsed, copyDisguiseCommandUsed, grabSkinCommandUsed,
|
||||
saveDisguiseCommandUsed;
|
||||
private static long libsDisguisesCalled;
|
||||
@@ -123,13 +128,10 @@ public class DisguiseUtilities {
|
||||
private static int velocityID;
|
||||
private static HashMap<UUID, ArrayList<Integer>> disguiseLoading = new HashMap<>();
|
||||
private static boolean runningPaper;
|
||||
@Getter
|
||||
private static MineSkinAPI mineSkinAPI = new MineSkinAPI();
|
||||
private static HashMap<String, ExtendedName> extendedNames = new HashMap<>();
|
||||
|
||||
public static MineSkinAPI getMineSkinAPI() {
|
||||
return mineSkinAPI;
|
||||
}
|
||||
|
||||
public static void setPlayerVelocity(Player player) {
|
||||
if (player == null) {
|
||||
velocityID = 0;
|
||||
@@ -190,13 +192,6 @@ public class DisguiseUtilities {
|
||||
commandsUsed = true;
|
||||
}
|
||||
|
||||
public static boolean isPluginsUsed() {
|
||||
return pluginsUsed;
|
||||
}
|
||||
|
||||
public static boolean isCommandsUsed() {
|
||||
return commandsUsed;
|
||||
}
|
||||
|
||||
public static void saveDisguises() {
|
||||
if (!LibsPremium.isPremium())
|
||||
@@ -634,9 +629,6 @@ public class DisguiseUtilities {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Map<UUID, Set<TargetedDisguise>> getDisguises() {
|
||||
return disguisesInUse;
|
||||
}
|
||||
|
||||
public static TargetedDisguise[] getDisguises(UUID entityId) {
|
||||
if (getDisguises().containsKey(entityId)) {
|
||||
@@ -648,9 +640,6 @@ public class DisguiseUtilities {
|
||||
return new TargetedDisguise[0];
|
||||
}
|
||||
|
||||
public static HashMap<Integer, HashSet<TargetedDisguise>> getFutureDisguises() {
|
||||
return futureDisguises;
|
||||
}
|
||||
|
||||
public static WrappedGameProfile getGameProfile(String playerName) {
|
||||
if (!hasGameProfile(playerName))
|
||||
@@ -885,13 +874,7 @@ public class DisguiseUtilities {
|
||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
|
||||
}
|
||||
|
||||
public static HashSet<UUID> getSelfDisguised() {
|
||||
return selfDisguised;
|
||||
}
|
||||
|
||||
public static Gson getGson() {
|
||||
return gson;
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
try {
|
||||
@@ -1986,7 +1969,7 @@ public class DisguiseUtilities {
|
||||
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
||||
|
||||
try {
|
||||
List<WrappedWatchableObject> list = DisguiseConfig.isMetadataPacketsEnabled() ?
|
||||
List<WrappedWatchableObject> list = DisguiseConfig.isMetaPacketsEnabled() ?
|
||||
disguiseWatcher.convert(entityWatcher.getWatchableObjects()) :
|
||||
disguiseWatcher.getWatchableObjects();
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -13,7 +14,9 @@ import java.util.Map;
|
||||
|
||||
public class UpdateChecker {
|
||||
private final String resourceID;
|
||||
@Getter
|
||||
private String latestVersion;
|
||||
@Getter
|
||||
private int latestSnapshot;
|
||||
|
||||
public UpdateChecker(String resourceID) {
|
||||
@@ -58,13 +61,6 @@ public class UpdateChecker {
|
||||
latestVersion = version;
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
public int getLatestSnapshot() {
|
||||
return latestSnapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks spigot for the version
|
||||
|
@@ -1,5 +1,11 @@
|
||||
package me.libraryaddict.disguise.utilities.reflection;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.security.CodeSource;
|
||||
@@ -8,26 +14,30 @@ import java.util.Enumeration;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
/**
|
||||
* User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester
|
||||
*/
|
||||
// Code for this taken and slightly modified from
|
||||
// https://github.com/ddopson/java-class-enumerator
|
||||
public class ClassGetter
|
||||
{
|
||||
public class ClassGetter {
|
||||
private class TestPrem {
|
||||
String user = "%%__USER__%%";
|
||||
}
|
||||
|
||||
public static ArrayList<Class<?>> getClassesForPackage(String pkgname)
|
||||
{
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.METHOD)
|
||||
private @interface PremInfo {
|
||||
String user();
|
||||
}
|
||||
|
||||
public static ArrayList<Class<?>> getClassesForPackage(String pkgname) {
|
||||
ArrayList<Class<?>> classes = new ArrayList<>();
|
||||
// String relPath = pkgname.replace('.', '/');
|
||||
|
||||
// Get a File object for the package
|
||||
CodeSource src = Entity.class.getProtectionDomain().getCodeSource();
|
||||
|
||||
if (src != null)
|
||||
{
|
||||
if (src != null) {
|
||||
URL resource = src.getLocation();
|
||||
resource.getPath();
|
||||
processJarfile(resource, pkgname, classes);
|
||||
@@ -36,26 +46,21 @@ public class ClassGetter
|
||||
return classes;
|
||||
}
|
||||
|
||||
private static Class<?> loadClass(String className)
|
||||
{
|
||||
try
|
||||
{
|
||||
private static Class<?> loadClass(String className) {
|
||||
try {
|
||||
return Class.forName(className);
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("Unexpected ClassNotFoundException loading class '" + className + "'");
|
||||
}
|
||||
catch (NoClassDefFoundError e)
|
||||
{
|
||||
catch (NoClassDefFoundError e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void processJarfile(URL resource, String pkgname, ArrayList<Class<?>> classes)
|
||||
{
|
||||
try
|
||||
{
|
||||
@PremInfo(user = "%%__USER__%%")
|
||||
private static void processJarfile(URL resource, String pkgname, ArrayList<Class<?>> classes) {
|
||||
try {
|
||||
String relPath = pkgname.replace('.', '/');
|
||||
String resPath = URLDecoder.decode(resource.getPath(), "UTF-8");
|
||||
String jarPath = resPath.replaceFirst("[.]jar[!].*", ".jar").replaceFirst("file:", "");
|
||||
@@ -64,22 +69,18 @@ public class ClassGetter
|
||||
|
||||
Enumeration<JarEntry> entries = jarFile.entries();
|
||||
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
while (entries.hasMoreElements()) {
|
||||
JarEntry entry = entries.nextElement();
|
||||
String entryName = entry.getName();
|
||||
String className = null;
|
||||
if (entryName.endsWith(".class") && entryName.startsWith(relPath)
|
||||
&& entryName.length() > (relPath.length() + "/".length()))
|
||||
{
|
||||
if (entryName.endsWith(".class") && entryName.startsWith(relPath) &&
|
||||
entryName.length() > (relPath.length() + "/".length())) {
|
||||
className = entryName.replace('/', '.').replace('\\', '.').replace(".class", "");
|
||||
}
|
||||
if (className != null)
|
||||
{
|
||||
if (className != null) {
|
||||
Class<?> c = loadClass(className);
|
||||
|
||||
if (c != null)
|
||||
{
|
||||
if (c != null) {
|
||||
classes.add(c);
|
||||
}
|
||||
}
|
||||
@@ -87,8 +88,7 @@ public class ClassGetter
|
||||
|
||||
jarFile.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@@ -244,7 +244,11 @@ public enum LibsMsg {
|
||||
LIBS_PERM_CHECK_SUCCESS(
|
||||
ChatColor.GOLD + "Lib's Disguises permission check, success. Pig disguise should be usable!"),
|
||||
LIBS_PERM_CHECK_FAIL(
|
||||
ChatColor.GOLD + "Lib's Disguises permission check, fail. Your permission plugin isn't compliant!");
|
||||
ChatColor.GOLD + "Lib's Disguises permission check, fail. Your permission plugin isn't compliant!"),
|
||||
CANT_ATTACK_DISGUISED(ChatColor.RED + "No PvP while disguised!"),
|
||||
CANT_ATTACK_DISGUISED_RECENTLY(ChatColor.RED + "You were disguised recently! Can't attack yet!"),
|
||||
SWITCH_WORLD_DISGUISE_REMOVED(ChatColor.RED + "Disguise removed as you've switched worlds!"),
|
||||
ACTION_BAR_MESSAGE(ChatColor.GOLD + "Currently disguised as %s");
|
||||
|
||||
private String string;
|
||||
|
||||
|
Reference in New Issue
Block a user