mirror of
https://github.com/TotalFreedomMC/TF-LibsDisguises.git
synced 2024-06-09 21:14:57 +00:00
This commit is contained in:
commit
aba1e9d304
|
@ -3,8 +3,14 @@ package me.libraryaddict.disguise;
|
|||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import java.util.ArrayList;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
@ -25,6 +31,7 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
|
@ -29,9 +29,17 @@ import org.bukkit.permissions.Permission;
|
|||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DisguiseConfig {
|
||||
|
@ -316,7 +324,7 @@ public class DisguiseConfig {
|
|||
|
||||
private static void doUpdaterTask() {
|
||||
boolean startTask = isAutoUpdate() || isNotifyUpdate() ||
|
||||
"1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID());
|
||||
"1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID());
|
||||
|
||||
// Don't ever run the auto updater on a custom build..
|
||||
if (!LibsDisguises.getInstance().isNumberedBuild()) {
|
||||
|
@ -408,7 +416,7 @@ public class DisguiseConfig {
|
|||
|
||||
// Bisect hosted, server ip, release builds
|
||||
for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild(), getLastUpdateRequest(), isHittingRateLimit(),
|
||||
getLastGithubUpdateETag(), getLastPluginUpdateVersion(), getData()}) {
|
||||
getLastGithubUpdateETag(), getLastPluginUpdateVersion(), getData()}) {
|
||||
internalConfig = internalConfig.replaceFirst("%data%", "" + s);
|
||||
}
|
||||
|
||||
|
@ -661,7 +669,7 @@ public class DisguiseConfig {
|
|||
|
||||
if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) {
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR");
|
||||
.warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR");
|
||||
|
||||
setNotifyBar(NotifyBar.ACTION_BAR);
|
||||
}
|
||||
|
@ -688,11 +696,11 @@ public class DisguiseConfig {
|
|||
}
|
||||
|
||||
String seeCommands = config.getString("Permissions.SeeCommands");
|
||||
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);
|
||||
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);
|
||||
|
||||
if (commandVisibility == null) {
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!");
|
||||
.warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!");
|
||||
} else {
|
||||
setCommandVisibility(commandVisibility);
|
||||
}
|
||||
|
@ -731,8 +739,9 @@ public class DisguiseConfig {
|
|||
ArrayList<String> returns = doOutput(config, changed, verbose);
|
||||
|
||||
if (!returns.isEmpty()) {
|
||||
DisguiseUtilities.getLogger().info("This is not an error! Now outputting " + (verbose ? "missing " : "") +
|
||||
(changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values");
|
||||
DisguiseUtilities.getLogger().info(
|
||||
"This is not an error! Now outputting " + (verbose ? "missing " : "") + (changed ? (verbose ? "and " : "") + "changed/invalid " : "") +
|
||||
"config values");
|
||||
|
||||
for (String v : returns) {
|
||||
DisguiseUtilities.getLogger().info(v);
|
||||
|
@ -822,8 +831,8 @@ public class DisguiseConfig {
|
|||
continue;
|
||||
}
|
||||
|
||||
ModdedManager
|
||||
.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity, register);
|
||||
ModdedManager.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity,
|
||||
register);
|
||||
|
||||
DisguiseUtilities.getLogger().info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
|
||||
} catch (Exception ex) {
|
||||
|
@ -911,7 +920,7 @@ public class DisguiseConfig {
|
|||
|
||||
if (!NmsVersion.v1_13.isSupported() && key.equals("libraryaddict")) {
|
||||
toParse =
|
||||
toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
||||
toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -953,7 +962,7 @@ public class DisguiseConfig {
|
|||
String[] disguiseArgs = DisguiseUtilities.split(toParse);
|
||||
|
||||
Disguise disguise = DisguiseParser.parseTestDisguise(Bukkit.getConsoleSender(), "disguise", disguiseArgs,
|
||||
DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise"));
|
||||
DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise"));
|
||||
|
||||
DisguisePerm perm = new DisguisePerm(disguise.getType(), disguiseName);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package me.libraryaddict.disguise;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||
|
@ -11,7 +10,14 @@ import me.libraryaddict.disguise.commands.undisguise.UndisguiseCommand;
|
|||
import me.libraryaddict.disguise.commands.undisguise.UndisguiseEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguisePlayerCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguiseRadiusCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.*;
|
||||
import me.libraryaddict.disguise.commands.utils.CopyDisguiseCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseCloneCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseHelpCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseViewBarCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseViewSelfCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.GrabHeadCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.GrabSkinCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.SaveDisguiseCommand;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.config.DisguiseCommandConfig;
|
||||
|
@ -28,7 +34,11 @@ import me.libraryaddict.disguise.utilities.sounds.SoundManager;
|
|||
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
@ -81,8 +91,8 @@ public class LibsDisguises extends JavaPlugin {
|
|||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe(
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
|
||||
" can " + "join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + " can " +
|
||||
"join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -92,7 +102,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
}
|
||||
|
||||
commandConfig = new DisguiseCommandConfig();
|
||||
|
@ -128,7 +138,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
}
|
||||
|
||||
File disguiseFile = new File(getDataFolder(), "configs/disguises.yml");
|
||||
|
@ -162,12 +172,12 @@ public class LibsDisguises extends JavaPlugin {
|
|||
|
||||
if (!LibsPremium.isPremium()) {
|
||||
getLogger().info(
|
||||
"You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
|
||||
"You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
|
||||
}
|
||||
|
||||
if (ReflectionManager.getVersion() == null) {
|
||||
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " + "intended for " +
|
||||
StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!");
|
||||
StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!");
|
||||
getPluginLoader().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
@ -183,8 +193,8 @@ public class LibsDisguises extends JavaPlugin {
|
|||
public void run() {
|
||||
getLogger().severe("!! May I have your attention please !!");
|
||||
getLogger().severe(
|
||||
"Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
|
||||
"!");
|
||||
"Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
|
||||
"!");
|
||||
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
||||
getLogger().severe("Or! Use /ld protocollib - To update to the latest development build");
|
||||
|
||||
|
|
|
@ -27,7 +27,16 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
|
@ -71,9 +80,9 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and " +
|
||||
"Operators only! Purchase the plugin for non-admin usage!");
|
||||
"Operators only! Purchase the plugin for non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -157,12 +166,15 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
List<String> tabs = new ArrayList<>();
|
||||
|
||||
ParamInfo info = null;
|
||||
String methodName = null;
|
||||
|
||||
if (allArgs.length == startsAt) {
|
||||
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||
info = ParamInfoManager.getParamInfoItemBlock();
|
||||
methodName = "setBlock";
|
||||
} else if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
||||
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
||||
methodName = "setItemstack";
|
||||
}
|
||||
} else if (allArgs.length > startsAt) {
|
||||
// Check what argument was used before the current argument to see what we're displaying
|
||||
|
@ -170,6 +182,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
String prevArg = allArgs[allArgs.length - 1];
|
||||
|
||||
info = ParamInfoManager.getParamInfo(disguisePerm, prevArg);
|
||||
methodName = prevArg;
|
||||
|
||||
if (info != null && !info.isParam(boolean.class)) {
|
||||
addMethods = false;
|
||||
|
@ -183,17 +196,36 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
|
||||
// If the previous argument is a method
|
||||
if (info != null) {
|
||||
Collection<String> wantToUse = null;
|
||||
|
||||
// If there is a list of default values
|
||||
if (info.hasValues()) {
|
||||
tabs.addAll(info.getEnums(currentArg));
|
||||
wantToUse = info.getEnums(currentArg);
|
||||
} else if (info.isParam(String.class)) {
|
||||
wantToUse = new ArrayList<>();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// If command user cannot see player online, don't tab-complete name
|
||||
if (commandSender instanceof Player && !((Player) commandSender).canSee(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(player.getName());
|
||||
wantToUse.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (wantToUse != null) {
|
||||
HashMap<String, HashMap<String, Boolean>> allowedOptions = DisguisePermissions.getDisguiseOptions(commandSender, getPermNode(), disguisePerm);
|
||||
HashMap<String, Boolean> methodValues = allowedOptions.get(methodName.toLowerCase(Locale.ENGLISH));
|
||||
|
||||
if (methodValues != null) {
|
||||
for (String value : wantToUse) {
|
||||
if (!DisguisePermissions.hasMethodOption(methodValues, value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,22 @@ package me.libraryaddict.disguise.commands;
|
|||
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.*;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDChangelog;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCommand;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDConfig;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCount;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugMineSkin;
|
||||
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.LDMods;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDPermTest;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDReload;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDScoreboard;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdate;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdateProtocolLib;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUploadLogs;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -39,8 +54,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
if (origArgs.length == 0)
|
||||
if (origArgs.length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Iterator<String> itel = list.iterator();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
|
||||
|
@ -48,8 +64,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
@ -63,8 +80,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
if (s.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newArgs.add(s);
|
||||
}
|
||||
|
@ -90,12 +108,11 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + "v" + version +
|
||||
" by libraryaddict, formerly maintained by Byteflux and NavidK0.");
|
||||
" by libraryaddict, formerly maintained by Byteflux and NavidK0.");
|
||||
|
||||
if (sender.hasPermission("libsdisguises.reload")) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" +
|
||||
ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" +
|
||||
".");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN +
|
||||
" to reload the config. All disguises will be blown by doing this" + ".");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use /libsdisguises help to see more help");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
package me.libraryaddict.disguise.commands.disguise;
|
||||
|
||||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
@Override
|
||||
|
@ -46,8 +47,8 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
Disguise disguise;
|
||||
|
||||
try {
|
||||
disguise = DisguiseParser
|
||||
.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender));
|
||||
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")),
|
||||
getPermissions(sender));
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
|
||||
|
@ -67,22 +68,12 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
}
|
||||
}
|
||||
|
||||
if (!BlockedDisguises.disabled) {
|
||||
|
||||
if (BlockedDisguises.isAllowed(disguise)) {
|
||||
disguise.setEntity((Player) sender);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "That disguise is forbidden.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Disguises are disabled.");
|
||||
return true;
|
||||
}
|
||||
disguise.setEntity((Player) sender);
|
||||
|
||||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +82,10 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
if (!sender.isOp() && LibsPremium.isBisectHosted() && !Bukkit.getIp().matches("((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}")) {
|
||||
disguise.setExpires(DisguiseConfig.isDynamicExpiry() ? 20 * 60 * 10 : System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10));
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package me.libraryaddict.disguise.commands.disguise;
|
||||
|
||||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
|
@ -12,7 +11,6 @@ import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
|||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
@ -61,26 +59,10 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom
|
|||
return true;
|
||||
}
|
||||
|
||||
if (!BlockedDisguises.disabled)
|
||||
{
|
||||
if (BlockedDisguises.isAllowed(testDisguise))
|
||||
{
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseEntityInteraction(disguiseArgs), DisguiseConfig.getDisguiseEntityExpire());
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseEntityInteraction(disguiseArgs), DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
LibsMsg.DISG_ENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getDisguiseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That disguise is forbidden.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Disguises are disabled.");
|
||||
return true;
|
||||
}
|
||||
LibsMsg.DISG_ENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getDisguiseName());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,7 +107,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
@ -120,11 +121,10 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
LibsMsg.DISG_PLAYER_AS_DISG.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(),
|
||||
disguise.getDisguiseName());
|
||||
disguise.getDisguiseName());
|
||||
} else {
|
||||
LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
||||
.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(),
|
||||
disguise.getDisguiseName());
|
||||
LibsMsg.DISG_PLAYER_AS_DISG_FAIL.send(sender,
|
||||
entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -179,6 +179,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
||||
|
||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||
disguise.getWatcher().setCustomNameVisible(true);
|
||||
}
|
||||
|
@ -189,7 +190,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,13 +26,11 @@ public class CopyDisguiseInteraction implements LibsEntityInteract {
|
|||
Disguise disguise = DisguiseAPI.getDisguise(player, entity);
|
||||
String disguiseString = DisguiseParser.parseToString(disguise, false);
|
||||
|
||||
getCopyDisguiseCommand()
|
||||
.sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
|
||||
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
|
||||
|
||||
if (disguise instanceof PlayerDisguise) {
|
||||
getCopyDisguiseCommand()
|
||||
.sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
|
||||
DisguiseParser.parseToString(disguise), true);
|
||||
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
|
||||
DisguiseParser.parseToString(disguise), true);
|
||||
}
|
||||
} else {
|
||||
LibsMsg.TARGET_NOT_DISGUISED.send(player);
|
||||
|
|
|
@ -24,15 +24,17 @@ public class UndisguiseEntityInteraction implements LibsEntityInteract {
|
|||
if (DisguiseAPI.isDisguised(entity)) {
|
||||
DisguiseAPI.undisguiseToAll(p, entity);
|
||||
|
||||
if (entity instanceof Player)
|
||||
if (entity instanceof Player) {
|
||||
LibsMsg.LISTEN_UNDISG_PLAYER.send(p, entityName);
|
||||
else
|
||||
} else {
|
||||
LibsMsg.LISTEN_UNDISG_ENT.send(p, entityName);
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player)
|
||||
if (entity instanceof Player) {
|
||||
LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.send(p, entityName);
|
||||
else
|
||||
} else {
|
||||
LibsMsg.LISTEN_UNDISG_ENT_FAIL.send(p, entityName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,8 +44,7 @@ public class LDChangelog implements LDCommand {
|
|||
|
||||
if (!checker.getUpdate().isReleaseBuild()) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") +
|
||||
LibsDisguises.getInstance().getBuildNo());
|
||||
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + LibsDisguises.getInstance().getBuildNo());
|
||||
}
|
||||
|
||||
for (String msg : checker.getUpdate().getChangelog()) {
|
||||
|
|
|
@ -8,7 +8,11 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
|||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/04/2020.
|
||||
|
@ -37,18 +41,16 @@ public class LDCount implements LDCommand {
|
|||
if (counts.isEmpty()) {
|
||||
LibsMsg.NO_DISGUISES_IN_USE.send(sender);
|
||||
} else {
|
||||
LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender,
|
||||
counts.values().stream().reduce(Integer::sum).get());
|
||||
LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender, counts.values().stream().reduce(Integer::sum).get());
|
||||
|
||||
ArrayList<DisguiseType> types = new ArrayList<>(counts.keySet());
|
||||
types.sort((d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()),
|
||||
TranslateType.DISGUISES.get(d2.toReadable())));
|
||||
types.sort(
|
||||
(d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()), TranslateType.DISGUISES.get(d2.toReadable())));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE
|
||||
.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
|
||||
|
||||
if (i + 1 < types.size()) {
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_SEPERATOR.get());
|
||||
|
|
|
@ -50,18 +50,14 @@ public class LDDebugPlayer implements LDCommand {
|
|||
DisguiseUtilities.DScoreTeam name = disg.getScoreboardName();
|
||||
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'",
|
||||
name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
|
||||
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'", name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'), name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
|
||||
|
||||
if (DisguiseConfig.isArmorstandsName()) {
|
||||
player.sendMessage(
|
||||
ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
|
||||
player.sendMessage(ChatColor.RED + String.format("Names: %s, Length: %s, Custom Name: '%s'",
|
||||
new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
|
||||
disg.getMultiNameLength(),
|
||||
disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
|
||||
player.sendMessage(ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Names: %s, Length: %s, Custom Name: '%s'", new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
|
||||
disg.getMultiNameLength(), disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
|
||||
}
|
||||
|
||||
Team team = player.getScoreboard().getTeam(name.getTeamName());
|
||||
|
@ -76,9 +72,8 @@ public class LDDebugPlayer implements LDCommand {
|
|||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s",
|
||||
team.getPrefix().equals(name.getPrefix()), team.getSuffix().equals(name.getSuffix()),
|
||||
team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
|
||||
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s", team.getPrefix().equals(name.getPrefix()),
|
||||
team.getSuffix().equals(name.getSuffix()), team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -115,8 +115,7 @@ public class LDJson implements LDCommand {
|
|||
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg))
|
||||
.create()));
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg)).create()));
|
||||
msg += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,24 +47,24 @@ public class LDMetaInfo implements LDCommand {
|
|||
|
||||
names.sort(String::compareToIgnoreCase);
|
||||
|
||||
// if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.META_VALUES.getBase());
|
||||
// if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.META_VALUES.getBase());
|
||||
|
||||
Iterator<String> itel = names.iterator();
|
||||
Iterator<String> itel = names.iterator();
|
||||
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
builder.append(TextComponent.fromLegacyText(name));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.META_CLICK_SHOW.getBase(name)));
|
||||
builder.append(TextComponent.fromLegacyText(name));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.META_CLICK_SHOW.getBase(name)));
|
||||
|
||||
if (itel.hasNext()) {
|
||||
builder.append(LibsMsg.META_VALUE_SEPERATOR.getBase());
|
||||
}
|
||||
if (itel.hasNext()) {
|
||||
builder.append(LibsMsg.META_VALUE_SEPERATOR.getBase());
|
||||
}
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
/*} else {
|
||||
LibsMsg.META_VALUES_NO_CLICK.send(sender,
|
||||
StringUtils.join(names, LibsMsg.META_VALUE_SEPERATOR.get()));
|
||||
|
|
|
@ -52,8 +52,7 @@ public class LDMods implements LDCommand {
|
|||
return;
|
||||
}
|
||||
|
||||
LibsMsg.MODS_LIST.send(sender, player.getName(),
|
||||
StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "));
|
||||
LibsMsg.MODS_LIST.send(sender, player.getName(), StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -66,8 +66,7 @@ public class LDPermTest implements LDCommand {
|
|||
LibsMsg.NORMAL_PERM_CHECK_FAIL.send(sender);
|
||||
}
|
||||
|
||||
if (player.hasPermission("libsdisguises.disguise.zombie") ||
|
||||
permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) {
|
||||
if (player.hasPermission("libsdisguises.disguise.zombie") || permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) {
|
||||
LibsMsg.LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS.send(sender);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class LDScoreboard implements LDCommand {
|
|||
if (!((PlayerDisguise) disguise).hasScoreboardName()) {
|
||||
if (unexpected++ < 3) {
|
||||
sender.sendMessage(
|
||||
"The player disguise " + ((PlayerDisguise) disguise).getName() + " isn't using a scoreboard name? This is unexpected");
|
||||
"The player disguise " + ((PlayerDisguise) disguise).getName() + " isn't using a scoreboard name? This is unexpected");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -79,28 +79,27 @@ public class LDScoreboard implements LDCommand {
|
|||
|
||||
checked.add(board);
|
||||
|
||||
|
||||
Team team = board.getTeam(scoreboardName.getTeamName());
|
||||
|
||||
if (team == null) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" and possibly more players!");
|
||||
" is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" and possibly more players!");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!team.getPrefix().equals("Colorize") &&
|
||||
(!team.getPrefix().equals(scoreboardName.getPrefix()) || !team.getSuffix().equals(scoreboardName.getSuffix()))) {
|
||||
(!team.getPrefix().equals(scoreboardName.getPrefix()) || !team.getSuffix().equals(scoreboardName.getSuffix()))) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" has an unexpected prefix/suffix of '" + team.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
team.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'! Expected '" +
|
||||
scoreboardName.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
scoreboardName.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" has an unexpected prefix/suffix of '" + team.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
team.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'! Expected '" +
|
||||
scoreboardName.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
scoreboardName.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -108,9 +107,9 @@ public class LDScoreboard implements LDCommand {
|
|||
if (!team.hasEntry(scoreboardName.getPlayer())) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" does not have the player entry expected! Instead has '" +
|
||||
StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" does not have the player entry expected! Instead has '" +
|
||||
StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -126,9 +125,9 @@ public class LDScoreboard implements LDCommand {
|
|||
LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender);
|
||||
}
|
||||
|
||||
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream()
|
||||
.filter(listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
|
||||
listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList());
|
||||
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter(
|
||||
listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
|
||||
listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList());
|
||||
|
||||
if (!listeners.isEmpty()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
|
@ -150,15 +149,15 @@ public class LDScoreboard implements LDCommand {
|
|||
builder.append(listener.getPlugin().getName());
|
||||
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
|
||||
|
||||
String plugin = ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" +
|
||||
listener.getPlugin().getDescription().getVersion();
|
||||
String plugin =
|
||||
ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" + listener.getPlugin().getDescription().getVersion();
|
||||
String listenerClass = ChatColor.GOLD + "Listener: " + ChatColor.YELLOW + listener.getClass().toString();
|
||||
String packets = ChatColor.GOLD + "Packets: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getTypes(), ", ");
|
||||
String priority = ChatColor.GOLD + "Priority: " + ChatColor.YELLOW + listener.getSendingWhitelist().getPriority();
|
||||
String options = ChatColor.GOLD + "Options: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getOptions(), ", ");
|
||||
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options)));
|
||||
TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options)));
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
|
@ -166,8 +165,8 @@ public class LDScoreboard implements LDCommand {
|
|||
|
||||
LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender);
|
||||
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players");
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players");
|
||||
|
||||
Player player;
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ public class LDUpdateProtocolLib implements LDCommand {
|
|||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
|
||||
" can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
|
||||
" can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
sender.sendMessage(ChatColor.RED + "Update failed, " + ex.getMessage());
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import lombok.Data;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
|
@ -12,8 +13,11 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
|
@ -130,7 +134,7 @@ public class LDUploadLogs implements LDCommand {
|
|||
File disguises = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
List<File> configs =
|
||||
new ConfigLoader().getConfigs().stream().map(f -> new File(LibsDisguises.getInstance().getDataFolder(), f)).collect(Collectors.toList());
|
||||
new ConfigLoader().getConfigs().stream().map(f -> new File(LibsDisguises.getInstance().getDataFolder(), f)).collect(Collectors.toList());
|
||||
|
||||
StringBuilder configText = new StringBuilder();
|
||||
|
||||
|
@ -151,13 +155,13 @@ public class LDUploadLogs implements LDCommand {
|
|||
|
||||
if (isTooBig(latest)) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Your latest.log file is too big! It should be less than 512kb! Please restart and run this " + "command again!");
|
||||
ChatColor.RED + "Your latest.log file is too big! It should be less than 512kb! Please restart and run this " + "command again!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTooBig(disguises)) {
|
||||
sender.sendMessage(ChatColor.RED + "Your disguises.yml is too big! You'll need to trim that file down before using this command! It " +
|
||||
"should be less than 512kb!");
|
||||
"should be less than 512kb!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -227,8 +231,8 @@ public class LDUploadLogs implements LDCommand {
|
|||
sender.sendMessage(ChatColor.GOLD + "Click on the below message to have it appear in your chat input");
|
||||
}
|
||||
|
||||
String text = "My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " +
|
||||
disguisesPaste;
|
||||
String text =
|
||||
"My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " + disguisesPaste;
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
builder.append(text);
|
||||
|
|
|
@ -58,15 +58,12 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
options = DisguiseParser.parsePlaceholders(options, sender, sender);
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||
"DisguiseModify");
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModify");
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
@ -78,13 +75,15 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
if (!(sender instanceof Player))
|
||||
if (!(sender instanceof Player)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String[] args = getPreviousArgs(origArgs);
|
||||
|
||||
|
@ -106,7 +105,6 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
LibsMsg.DMODIFY_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP2.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender,
|
||||
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
|||
|
||||
// TODO Validate if any disguises have this arg
|
||||
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(),
|
||||
new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
|
||||
DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
LibsMsg.DMODIFYENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
@ -79,7 +79,6 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
|||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
LibsMsg.DMODENT_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender,
|
||||
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +63,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Disguise disguise = null;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget);
|
||||
}
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
disguise = DisguiseAPI.getDisguise(entityTarget);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
LibsMsg.DMODPLAYER_NODISGUISE.send(sender, entityTarget.getName());
|
||||
|
@ -87,15 +88,11 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
options = DisguiseParser.parsePlaceholders(options, sender, entityTarget);
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||
"DisguiseModifyPlayer");
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModifyPlayer");
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (Throwable ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
@ -134,11 +131,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Disguise disguise = null;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
disguise = DisguiseAPI.getDisguise((Player) sender, player);
|
||||
}
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
disguise = DisguiseAPI.getDisguise(player);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
return tabs;
|
||||
|
@ -160,7 +159,6 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
LibsMsg.DMODPLAYER_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender,
|
||||
StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,11 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||
import me.libraryaddict.disguise.utilities.parser.*;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -20,7 +24,11 @@ import org.bukkit.command.TabCompleter;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) {
|
||||
|
@ -55,7 +63,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType")) ||
|
||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
||||
ArrayList<String> classes = new ArrayList<>();
|
||||
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
|
|
|
@ -15,8 +15,10 @@ public class UndisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,10 @@ public class UndisguiseEntityCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -30,8 +32,7 @@ public class UndisguiseEntityCommand implements CommandExecutor {
|
|||
return true;
|
||||
}
|
||||
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(),
|
||||
DisguiseConfig.getDisguiseEntityExpire());
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(), DisguiseConfig.getDisguiseEntityExpire());
|
||||
LibsMsg.UND_ENTITY.send(sender);
|
||||
|
||||
return true;
|
||||
|
|
|
@ -13,12 +13,17 @@ import org.bukkit.command.TabCompleter;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
if (origArgs.length == 0)
|
||||
if (origArgs.length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Iterator<String> itel = list.iterator();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
|
||||
|
@ -26,8 +31,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label))
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
@ -41,8 +47,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
if (s.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newArgs.add(s);
|
||||
}
|
||||
|
@ -53,8 +60,10 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -74,8 +83,7 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,13 +95,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
|
||||
if (DisguiseAPI.isDisguised(entityTarget)) {
|
||||
DisguiseAPI.undisguiseToAll(sender, entityTarget);
|
||||
LibsMsg.UNDISG_PLAYER.send(sender,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable());
|
||||
LibsMsg.UNDISG_PLAYER.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
|
||||
} else {
|
||||
LibsMsg.UNDISG_PLAYER_FAIL.send(sender,
|
||||
entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable());
|
||||
LibsMsg.UNDISG_PLAYER_FAIL.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -104,8 +108,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
ArrayList<String> tabs = new ArrayList<>();
|
||||
String[] args = getArgs(origArgs);
|
||||
|
||||
if (args.length != 0)
|
||||
if (args.length != 0) {
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// If command user cannot see player online, don't tab-complete name
|
||||
|
|
|
@ -18,8 +18,7 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -27,8 +26,10 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
|
||||
if (disguise == null) {
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new CopyDisguiseInteraction(this), DisguiseConfig.getDisguiseEntityExpire());
|
||||
.addInteraction(sender.getName(), new CopyDisguiseInteraction(this), DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
LibsMsg.DISGUISECOPY_INTERACT.send(sender, DisguiseConfig.getDisguiseEntityExpire());
|
||||
return true;
|
||||
|
@ -137,7 +137,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
builder.append(LibsMsg.CLICK_COPY.getBase(sections));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, current.toString()));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create()));
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create()));
|
||||
|
||||
current = new StringBuilder();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
doEquipment = false;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_ADDEDANIMATIONS.get())) {
|
||||
doAdded = true;
|
||||
} else {
|
||||
} else {
|
||||
LibsMsg.INVALID_CLONE.send(sender, option);
|
||||
return true;
|
||||
}
|
||||
|
@ -58,8 +58,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||
} else {
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options),
|
||||
DisguiseConfig.getDisguiseCloneExpire());
|
||||
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options), DisguiseConfig.getDisguiseCloneExpire());
|
||||
|
||||
LibsMsg.CLICK_TIMER.send(sender, DisguiseConfig.getDisguiseCloneExpire());
|
||||
}
|
||||
|
|
|
@ -48,12 +48,10 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
|
||||
if (help != null) {
|
||||
if (help.hasValues() && help.canTranslateValues()) {
|
||||
LibsMsg.DHELP_HELP4.send(sender, help.getName(),
|
||||
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
|
||||
LibsMsg.DHELP_HELP4.send(sender, help.getName(), StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
|
||||
} else {
|
||||
if (!help.getName().equals(help.getDescriptiveName())) {
|
||||
LibsMsg.DHELP_HELP6
|
||||
.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription());
|
||||
LibsMsg.DHELP_HELP6.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription());
|
||||
} else {
|
||||
LibsMsg.DHELP_HELP5.send(sender, help.getName(), help.getDescription());
|
||||
}
|
||||
|
@ -81,8 +79,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
try {
|
||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(
|
||||
Locale.ENGLISH)))) {
|
||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(Locale.ENGLISH)))) {
|
||||
ignored++;
|
||||
continue;
|
||||
}
|
||||
|
@ -99,13 +96,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
methodColor = ChatColor.GRAY;
|
||||
}
|
||||
|
||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
|
||||
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() +
|
||||
ChatColor.DARK_RED + ")";
|
||||
|
||||
methods.add(methodColor + str);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -113,8 +109,7 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||
}
|
||||
|
||||
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(),
|
||||
StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(), StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
|
||||
if (ignored > 0) {
|
||||
LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored);
|
||||
|
@ -138,8 +133,9 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
|
||||
if (args.length == 0) {
|
||||
for (DisguisePerm type : perms.getAllowed()) {
|
||||
if (type.isUnknown())
|
||||
if (type.isUnknown()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
||||
}
|
||||
|
@ -164,9 +160,8 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
LibsMsg.DHELP_HELP2.send(sender);
|
||||
|
||||
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
||||
LibsMsg.DHELP_HELP3.send(sender, s.getName().replaceAll(" ", "") +
|
||||
(!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""),
|
||||
s.getDescription());
|
||||
LibsMsg.DHELP_HELP3.send(sender,
|
||||
s.getName().replaceAll(" ", "") + (!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""), s.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ public class GrabHeadCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin usage!");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -94,8 +96,7 @@ public class GrabHeadCommand implements CommandExecutor {
|
|||
Field field = meta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(meta, profile.getHandle());
|
||||
}
|
||||
catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
|
|
@ -28,10 +28,10 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + msg).create()));
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + msg).create()));
|
||||
msg += 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
Disguise disguise = DisguiseAPI.getDisguise((Entity) sender);
|
||||
|
||||
if (disguise == null) {
|
||||
LibsMsg.NOT_DISGUISED.send(sender);
|
||||
LibsMsg.NOT_DISGUISED_SAVE_DISGUISE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,27 +6,23 @@ import org.bukkit.Material;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum AnimalColor {
|
||||
BLACK(DyeColor.BLACK,
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
|
||||
BLACK(DyeColor.BLACK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
|
||||
BLUE(DyeColor.BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LAPIS_LAZULI") : null),
|
||||
BROWN(DyeColor.BROWN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("COCOA_BEANS") : null),
|
||||
CYAN(DyeColor.CYAN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("CYAN_DYE") : null),
|
||||
GRAY(DyeColor.GRAY, NmsVersion.v1_13.isSupported() ? Material.getMaterial("GRAY_DYE") : null),
|
||||
GREEN(DyeColor.GREEN,
|
||||
NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
|
||||
GREEN(DyeColor.GREEN, NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
|
||||
LIGHT_BLUE(DyeColor.LIGHT_BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_BLUE_DYE") : null),
|
||||
LIME(DyeColor.LIME, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIME_DYE") : null),
|
||||
MAGENTA(DyeColor.MAGENTA, NmsVersion.v1_13.isSupported() ? Material.getMaterial("MAGENTA_DYE") : null),
|
||||
ORANGE(DyeColor.ORANGE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("ORANGE_DYE") : null),
|
||||
PINK(DyeColor.PINK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PINK_DYE") : null),
|
||||
PURPLE(DyeColor.PURPLE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PURPLE_DYE") : null),
|
||||
RED(DyeColor.RED,
|
||||
NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
|
||||
RED(DyeColor.RED, NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
|
||||
LIGHT_GRAY(DyeColor.valueOf(NmsVersion.v1_13.isSupported() ? "LIGHT_GRAY" : "SILVER"),
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null),
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null),
|
||||
WHITE(DyeColor.WHITE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("BONE_MEAL") : null),
|
||||
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") :
|
||||
Material.getMaterial("DANDELION_YELLOW"));
|
||||
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : Material.getMaterial("DANDELION_YELLOW"));
|
||||
|
||||
public static AnimalColor getColorByWool(int woolId) {
|
||||
for (AnimalColor color : values()) {
|
||||
|
|
|
@ -36,12 +36,23 @@ import org.bukkit.boss.BarColor;
|
|||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class Disguise {
|
||||
|
@ -144,6 +155,10 @@ public abstract class Disguise {
|
|||
name = new String[0];
|
||||
}
|
||||
|
||||
for (int i = 0; i < name.length; i++) {
|
||||
name[i] = DisguiseUtilities.getHexedColors(name[i]);
|
||||
}
|
||||
|
||||
name = DisguiseUtilities.reverse(name);
|
||||
|
||||
String[] oldName = multiName;
|
||||
|
@ -246,8 +261,8 @@ public abstract class Disguise {
|
|||
protected void createDisguise() {
|
||||
if (getType().getEntityType() == null) {
|
||||
throw new RuntimeException(
|
||||
"DisguiseType " + getType() + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have " +
|
||||
"that entity");
|
||||
"DisguiseType " + getType() + " was used in a futile attempt to construct a disguise, but this Minecraft version does not have " +
|
||||
"that entity");
|
||||
}
|
||||
|
||||
// Get if they are a adult now..
|
||||
|
@ -359,7 +374,7 @@ public abstract class Disguise {
|
|||
removeBossBar();
|
||||
|
||||
BossBar bar = Bukkit.createBossBar(getBossBar(), BaseComponent.toLegacyText(LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName())), getBossBarColor(),
|
||||
getBossBarStyle());
|
||||
getBossBarStyle());
|
||||
bar.setProgress(1);
|
||||
bar.addPlayer((Player) getEntity());
|
||||
}
|
||||
|
@ -376,7 +391,7 @@ public abstract class Disguise {
|
|||
|
||||
protected void doActionBar() {
|
||||
if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player && !getEntity().hasPermission("libsdisguises.noactionbar") &&
|
||||
DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
||||
DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
||||
((Player) getEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName()));
|
||||
}
|
||||
|
||||
|
@ -497,8 +512,9 @@ public abstract class Disguise {
|
|||
@Deprecated
|
||||
public Disguise setWatcher(FlagWatcher newWatcher) {
|
||||
if (!getType().getWatcherClass().isInstance(newWatcher)) {
|
||||
throw new IllegalArgumentException((newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " +
|
||||
getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name());
|
||||
throw new IllegalArgumentException(
|
||||
(newWatcher == null ? "null" : newWatcher.getClass().getSimpleName()) + " is not a instance of " + getType().getWatcherClass().getSimpleName() +
|
||||
" for DisguiseType " + getType().name());
|
||||
}
|
||||
|
||||
watcher = newWatcher;
|
||||
|
@ -694,7 +710,7 @@ public abstract class Disguise {
|
|||
|
||||
// Can only continue a disguise that's valid
|
||||
if (event.isCancelled() && getEntity() != null && Bukkit.getWorlds().contains(getEntity().getWorld()) &&
|
||||
(!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) {
|
||||
(!(getEntity() instanceof Player) || ((Player) getEntity()).isOnline())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -722,7 +738,7 @@ public abstract class Disguise {
|
|||
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
||||
deleteTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
||||
new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getProfileName()))));
|
||||
new PlayerInfoData(disguise.getGameProfile(), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getProfileName()))));
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -770,8 +786,8 @@ public abstract class Disguise {
|
|||
}
|
||||
|
||||
if (isHidePlayer() && getEntity() instanceof Player && ((Player) getEntity()).isOnline()) {
|
||||
PlayerInfoData playerInfo = new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()),
|
||||
PlayerInfoData playerInfo =
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.fromBukkit(((Player) getEntity()).getGameMode()),
|
||||
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())));
|
||||
|
||||
PacketContainer addTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
|
@ -852,14 +868,15 @@ public abstract class Disguise {
|
|||
getWatcher().setBackupValue(flag, backup == null ? null : backup.getDefault());
|
||||
}
|
||||
|
||||
// Sometimes someone may set the custom name stuff on the actual player... Normally harmless, until I come along..
|
||||
if (getEntity() instanceof Player && !getWatcher().hasCustomName()) {
|
||||
getWatcher().setCustomName("");
|
||||
getWatcher().setCustomNameVisible(false);
|
||||
getWatcher().setInteralCustomName("");
|
||||
getWatcher().setInternalCustomNameVisible(false);
|
||||
}
|
||||
|
||||
// If a horse is disguised as a horse, it should obey parent no gravity rule
|
||||
if ((getEntity() instanceof Boat || getEntity() instanceof AbstractHorse) &&
|
||||
(getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) {
|
||||
(getWatcher() instanceof BoatWatcher || getWatcher() instanceof AbstractHorseWatcher)) {
|
||||
getWatcher().setNoGravity(!getEntity().hasGravity());
|
||||
} else {
|
||||
getWatcher().setNoGravity(true);
|
||||
|
@ -1003,7 +1020,7 @@ public abstract class Disguise {
|
|||
PacketContainer removeTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
removeTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
||||
removeTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(""))));
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
@ -85,7 +85,7 @@ class DisguiseRunnable extends BukkitRunnable {
|
|||
if (disguise.getEntity() instanceof Player && !((Player) disguise.getEntity()).isOnline()) {
|
||||
disguise.removeDisguise();
|
||||
} else if (disguise.disguiseExpires > 0 && (DisguiseConfig.isDynamicExpiry() ? disguise.disguiseExpires-- == 1 :
|
||||
disguise.disguiseExpires < System.currentTimeMillis())) { // If disguise expired
|
||||
disguise.disguiseExpires < System.currentTimeMillis())) { // If disguise expired
|
||||
disguise.removeDisguise();
|
||||
|
||||
if (disguise.getEntity() instanceof Player) {
|
||||
|
@ -183,9 +183,9 @@ class DisguiseRunnable extends BukkitRunnable {
|
|||
Location loc = disguise.getEntity().getLocation();
|
||||
|
||||
mods.write(4,
|
||||
DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
||||
mods.write(5, DisguiseUtilities
|
||||
.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||
DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
||||
mods.write(5,
|
||||
DisguiseUtilities.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||
|
||||
if (disguise.isSelfDisguiseVisible() && disguise.getEntity() instanceof Player) {
|
||||
PacketContainer selfLookPacket = lookPacket.shallowClone();
|
||||
|
|
|
@ -34,7 +34,13 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FlagWatcher {
|
||||
private boolean addEntityAnimations = DisguiseConfig.isAddEntityAnimations();
|
||||
|
@ -65,6 +71,8 @@ public class FlagWatcher {
|
|||
private Float yawLock;
|
||||
@Getter
|
||||
private float yModifier;
|
||||
@Getter
|
||||
private float nameYModifier;
|
||||
|
||||
public FlagWatcher(Disguise disguise) {
|
||||
this.disguise = (TargetedDisguise) disguise;
|
||||
|
@ -83,13 +91,30 @@ public class FlagWatcher {
|
|||
setPitchLock(pitchLocked ? 0F : null);
|
||||
}
|
||||
|
||||
public void setNameYModifier(float yModifier) {
|
||||
this.nameYModifier = yModifier;
|
||||
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled() || !getDisguise().isDisguiseInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
||||
.createPacket(getDisguise().getEntity());
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setYModifier(float yModifier) {
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
double diff = yModifier - getYModifier();
|
||||
|
||||
this.yModifier = yModifier;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse()) {
|
||||
|
@ -97,7 +122,7 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
||||
.createPacket(getDisguise().getEntity());
|
||||
.createPacket(getDisguise().getEntity());
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
|
@ -202,6 +227,7 @@ public class FlagWatcher {
|
|||
cloned.pitchLock = pitchLock;
|
||||
cloned.yawLock = yawLock;
|
||||
cloned.yModifier = yModifier;
|
||||
cloned.nameYModifier = nameYModifier;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
@ -343,7 +369,7 @@ public class FlagWatcher {
|
|||
float health = ((Number) watch.getRawValue()).floatValue();
|
||||
|
||||
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
|
||||
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
|
||||
}
|
||||
|
@ -383,7 +409,7 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
|
||||
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
|
||||
}
|
||||
|
@ -507,7 +533,11 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
public String getCustomName() {
|
||||
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) {
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
return ((PlayerDisguise) getDisguise()).getName();
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) {
|
||||
if (getDisguise().getMultiNameLength() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -539,13 +569,20 @@ public class FlagWatcher {
|
|||
name = name.substring(1);
|
||||
}
|
||||
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
((PlayerDisguise) getDisguise()).setName(name);
|
||||
return;
|
||||
}
|
||||
|
||||
name = DisguiseUtilities.getHexedColors(name);
|
||||
|
||||
String customName = getCustomName();
|
||||
|
||||
if (Objects.equals(customName, name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
||||
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
||||
MetaIndex custom = NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD;
|
||||
|
||||
if (!hasValue(custom)) {
|
||||
|
@ -580,7 +617,7 @@ public class FlagWatcher {
|
|||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
Optional<WrappedChatComponent> optional =
|
||||
Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name))));
|
||||
Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name))));
|
||||
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, optional);
|
||||
} else {
|
||||
|
@ -690,10 +727,19 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
public void setCustomNameVisible(boolean display) {
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
((PlayerDisguise) getDisguise()).setNameVisible(display);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
||||
display = false;
|
||||
}
|
||||
|
||||
setInternalCustomNameVisible(display);
|
||||
}
|
||||
|
||||
protected void setInternalCustomNameVisible(boolean display) {
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||
sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
@ -732,7 +778,7 @@ public class FlagWatcher {
|
|||
|
||||
this.glowColor = glowColor;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse() || getDisguise().getEntity() == null) {
|
||||
if (!getDisguise().isDisguiseInUse() || getDisguise().getEntity() == null || !getDisguise().getEntity().isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1068,11 @@ public class FlagWatcher {
|
|||
|
||||
@Deprecated
|
||||
public <Y> void setUnsafeData(MetaIndex<Y> id, Y value) {
|
||||
setData(id, value);
|
||||
if (!id.getDefault().getClass().isInstance(value)) {
|
||||
setBackupValue(id, value);
|
||||
} else {
|
||||
setData(id, value);
|
||||
}
|
||||
}
|
||||
|
||||
protected <Y> void setData(MetaIndex<Y> id, Y value) {
|
||||
|
|
|
@ -243,13 +243,13 @@ public class LibsEquipment implements EntityEquipment {
|
|||
setHelmet(helmet);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
@Deprecated
|
||||
public void setItem(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
setItem(equipmentSlot, itemStack);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Override
|
||||
@Deprecated
|
||||
public void setItemInMainHand(ItemStack itemStack, boolean silent) {
|
||||
setItemInMainHand(itemStack);
|
||||
|
|
|
@ -1,11 +1,96 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AreaEffectCloudWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AxolotlWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BeeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BlazeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BoatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.CatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ChestedHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.CreeperWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.DolphinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderCrystalWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderDragonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderSignalWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FireballWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FireworkWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FishingHookWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FoxWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GhastWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GlowSquidWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GoatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HoglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IllagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IllagerWizardWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.InsentientWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IronGolemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ItemFrameWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LlamaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartCommandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartFurnaceWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MushroomCowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PandaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ParrotWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PhantomWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PigWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PiglinAbstractWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PiglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PolarBearWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PufferFishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.RabbitWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.RaiderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ShulkerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SnowmanWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SpiderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.StriderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TNTWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ThrowableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TippedArrowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TridentWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TropicalFishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TurtleWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VexWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitchWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherSkullWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZoglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieVillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||
|
@ -19,8 +104,15 @@ import org.bukkit.entity.Villager;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MetaIndex<Y> {
|
||||
private static MetaIndex[] _values = new MetaIndex[0];
|
||||
|
@ -45,7 +137,7 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE =
|
||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
||||
|
||||
@NmsRemovedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0);
|
||||
|
@ -277,7 +369,7 @@ public class MetaIndex<Y> {
|
|||
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
public static MetaIndex<ItemStack> FIREWORK_ITEM =
|
||||
new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
||||
new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
||||
|
||||
public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false);
|
||||
|
||||
|
@ -452,7 +544,7 @@ public class MetaIndex<Y> {
|
|||
public static MetaIndex<String> MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, "");
|
||||
|
||||
public static MetaIndex<WrappedChatComponent> MINECART_COMMAND_LAST_OUTPUT =
|
||||
new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText(""));
|
||||
new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText(""));
|
||||
|
||||
/**
|
||||
* If the minecart furnace is fueled and burning
|
||||
|
@ -606,8 +698,8 @@ public class MetaIndex<Y> {
|
|||
public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
public static MetaIndex<VillagerData> VILLAGER_DATA =
|
||||
new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
|
||||
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
|
||||
|
||||
|
@ -649,7 +741,7 @@ public class MetaIndex<Y> {
|
|||
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
|
||||
/**
|
||||
* Shown for villager conversion
|
||||
|
@ -723,7 +815,7 @@ public class MetaIndex<Y> {
|
|||
|
||||
if (found != null) {
|
||||
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" +
|
||||
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")");
|
||||
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")");
|
||||
continue loop;
|
||||
}
|
||||
|
||||
|
@ -741,7 +833,7 @@ public class MetaIndex<Y> {
|
|||
|
||||
public String toString() {
|
||||
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(),
|
||||
DisguiseUtilities.getGson().toJson(getDefault()));
|
||||
DisguiseUtilities.getGson().toJson(getDefault()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -911,8 +1003,9 @@ public class MetaIndex<Y> {
|
|||
continue;
|
||||
}
|
||||
|
||||
DisguiseUtilities.getLogger().severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() +
|
||||
" has already registered this! (" + metaIndex.getDefault() + "," + index.getDefault() + ")");
|
||||
DisguiseUtilities.getLogger().severe(
|
||||
"MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + " has already registered this! (" +
|
||||
metaIndex.getDefault() + "," + index.getDefault() + ")");
|
||||
}
|
||||
|
||||
values()[i] = metaIndexes[a];
|
||||
|
|
|
@ -28,8 +28,7 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
|
||||
throw new IllegalArgumentException(
|
||||
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
}
|
||||
|
||||
apply(0, itemStack);
|
||||
|
@ -39,8 +38,7 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
|
||||
throw new IllegalArgumentException(
|
||||
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
}
|
||||
|
||||
apply(0, new ItemStack(material));
|
||||
|
@ -56,9 +54,8 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
|
||||
if (!disguiseType.isMisc()) {
|
||||
throw new InvalidParameterException(
|
||||
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType +
|
||||
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") +
|
||||
" instead");
|
||||
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + " instead. Please use " +
|
||||
(disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead");
|
||||
}
|
||||
|
||||
apply(id, new ItemStack(Material.STONE));
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -19,9 +23,8 @@ public class MobDisguise extends TargetedDisguise {
|
|||
|
||||
if (!disguiseType.isMob()) {
|
||||
throw new InvalidParameterException(
|
||||
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType +
|
||||
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") +
|
||||
" instead");
|
||||
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType + " instead. Please use " +
|
||||
(disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + " instead");
|
||||
}
|
||||
|
||||
this.isAdult = isAdult;
|
||||
|
@ -43,8 +46,7 @@ public class MobDisguise extends TargetedDisguise {
|
|||
|
||||
if (getWatcher() != null) {
|
||||
if (getType() == DisguiseType.ARMOR_STAND) {
|
||||
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox())
|
||||
.getY();
|
||||
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox()).getY();
|
||||
} else if (getType() == DisguiseType.SLIME || getType() == DisguiseType.MAGMA_CUBE) {
|
||||
return 0.51 * (0.255 * ((SlimeWatcher) getWatcher()).getSize());
|
||||
}
|
||||
|
@ -73,8 +75,7 @@ public class MobDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
public boolean doesDisguiseAge() {
|
||||
return getWatcher() != null &&
|
||||
(getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||
return getWatcher() != null && (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,8 +31,7 @@ public class ModdedDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.UNKNOWN) {
|
||||
throw new InvalidParameterException(
|
||||
"CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
|
||||
throw new InvalidParameterException("CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
|
||||
}
|
||||
|
||||
createDisguise();
|
||||
|
|
|
@ -147,10 +147,9 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
*/
|
||||
public String getProfileName() {
|
||||
return isUpsideDown() ? "Dinnerbone" :
|
||||
isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName();
|
||||
isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName();
|
||||
}
|
||||
|
||||
|
||||
public boolean isNameVisible() {
|
||||
return nameVisible;
|
||||
}
|
||||
|
@ -291,10 +290,12 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
if (DisguiseConfig.isCopyPlayerTeamInfo() && (DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.TEAMS ||
|
||||
DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) {
|
||||
DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) {
|
||||
name = DisguiseUtilities.getDisplayName(name);
|
||||
}
|
||||
|
||||
name = DisguiseUtilities.getHexedColors(name);
|
||||
|
||||
if (name.equals(playerName)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -62,17 +62,14 @@ public abstract class TargetedDisguise extends Disguise {
|
|||
if (player != null) {
|
||||
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
|
||||
deleteTab.getPlayerInfoAction().write(0,
|
||||
canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
|
||||
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
|
||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
|
||||
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -135,17 +132,14 @@ public abstract class TargetedDisguise extends Disguise {
|
|||
if (player != null) {
|
||||
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
|
||||
deleteTab.getPlayerInfoAction().write(0,
|
||||
canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
|
||||
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
|
||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
|
||||
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,9 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||
}
|
||||
|
||||
private EulerAngle getPose(MetaIndex<Vector3F> type) {
|
||||
if (!hasValue(type))
|
||||
if (!hasValue(type)) {
|
||||
return new EulerAngle(0, 0, 0);
|
||||
}
|
||||
|
||||
Vector3F vec = getData(type);
|
||||
|
||||
|
|
|
@ -17,10 +17,8 @@ public class CreeperWatcher extends InsentientWatcher {
|
|||
|
||||
public void setIgnited(boolean ignited) {
|
||||
// If creeper is already ignited and they want to set it to unignited, then resend disguise
|
||||
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() &&
|
||||
((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
|
||||
(getDisguise().getEntity() instanceof Creeper &&
|
||||
((Creeper) getDisguise().getEntity()).isPowered()));
|
||||
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() && ((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
|
||||
(getDisguise().getEntity() instanceof Creeper && ((Creeper) getDisguise().getEntity()).isPowered()));
|
||||
|
||||
setData(MetaIndex.CREEPER_IGNITED, ignited);
|
||||
sendData(MetaIndex.CREEPER_IGNITED);
|
||||
|
|
|
@ -24,8 +24,7 @@ public class DroppedItemWatcher extends FlagWatcher {
|
|||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager
|
||||
.toReadable((item == null ? Material.AIR : item.getType()).name(), " ")));
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name(), " ")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name(), " ")));
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name(), " ")));
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
|
@ -130,7 +130,7 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " ")));
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " ")));
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
|
|
|
@ -12,8 +12,9 @@ public class FishingHookWatcher extends FlagWatcher {
|
|||
public int getHookedId() {
|
||||
int hooked = getData(MetaIndex.FISHING_HOOK_HOOKED_ID);
|
||||
|
||||
if (hooked > 0)
|
||||
if (hooked > 0) {
|
||||
hooked--;
|
||||
}
|
||||
|
||||
return hooked;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,9 @@ public class GuardianWatcher extends InsentientWatcher {
|
|||
public void setTarget(String playername) {
|
||||
Player player = Bukkit.getPlayer(playername);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
setData(MetaIndex.GUARDIAN_TARGET, player.getEntityId());
|
||||
sendData(MetaIndex.GUARDIAN_TARGET);
|
||||
|
|
|
@ -20,7 +20,12 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class LivingWatcher extends FlagWatcher {
|
||||
private double maxHealth;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
|
@ -26,8 +27,9 @@ public class PlayerWatcher extends LivingWatcher {
|
|||
}
|
||||
|
||||
public void setDisplayedInTab(boolean showPlayerInTab) {
|
||||
if (getDisguise().isDisguiseInUse())
|
||||
if (getDisguise().isDisguiseInUse()) {
|
||||
throw new IllegalStateException("Cannot set this while disguise is in use!");
|
||||
}
|
||||
|
||||
alwaysShowInTab = showPlayerInTab;
|
||||
}
|
||||
|
|
|
@ -42,11 +42,13 @@ public class ShulkerWatcher extends InsentientWatcher {
|
|||
}
|
||||
|
||||
public void setShieldHeight(int newHeight) {
|
||||
if (newHeight < 0)
|
||||
if (newHeight < 0) {
|
||||
newHeight = 0;
|
||||
}
|
||||
|
||||
if (newHeight > 127)
|
||||
if (newHeight > 127) {
|
||||
newHeight = 127;
|
||||
}
|
||||
|
||||
setData(MetaIndex.SHULKER_PEEKING, (byte) newHeight);
|
||||
sendData(MetaIndex.SHULKER_PEEKING);
|
||||
|
|
|
@ -76,8 +76,7 @@ public class TropicalFishWatcher extends FishWatcher {
|
|||
}
|
||||
|
||||
private int getData(final DyeColor patternColor, final DyeColor bodyColor, final TropicalFish.Pattern type) {
|
||||
return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 |
|
||||
CraftPattern.values()[type.ordinal()].getDataValue();
|
||||
return patternColor.getWoolData() << 24 | bodyColor.getWoolData() << 16 | CraftPattern.values()[type.ordinal()].getDataValue();
|
||||
}
|
||||
|
||||
public DyeColor getBodyColor() {
|
||||
|
|
|
@ -22,8 +22,7 @@ public class WitherWatcher extends InsentientWatcher {
|
|||
}
|
||||
|
||||
public int[] getTargets() {
|
||||
return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2),
|
||||
getData(MetaIndex.WITHER_TARGET_3)};
|
||||
return new int[]{getData(MetaIndex.WITHER_TARGET_1), getData(MetaIndex.WITHER_TARGET_2), getData(MetaIndex.WITHER_TARGET_3)};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,8 +35,7 @@ public class WitherWatcher extends InsentientWatcher {
|
|||
|
||||
public void setTargets(int... targets) {
|
||||
if (targets.length != 3) {
|
||||
throw new InvalidParameterException(
|
||||
ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
||||
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
||||
}
|
||||
setData(MetaIndex.WITHER_TARGET_1, targets[0]);
|
||||
setData(MetaIndex.WITHER_TARGET_2, targets[1]);
|
||||
|
|
|
@ -5,11 +5,21 @@ import com.comphenix.protocol.PacketType.Play.Server;
|
|||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers;
|
||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtList;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import lombok.Getter;
|
||||
|
@ -17,12 +27,25 @@ import lombok.Setter;
|
|||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.json.*;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerBlockData;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerChatComponent;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerDisguise;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerFlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerGameProfile;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerItemStack;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerMetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerParticle;
|
||||
import me.libraryaddict.disguise.utilities.json.SerializerWrappedBlockData;
|
||||
import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI;
|
||||
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||
|
@ -42,11 +65,22 @@ import net.md_5.bungee.chat.ComponentSerializer;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
@ -60,14 +94,41 @@ import org.bukkit.scoreboard.Team.Option;
|
|||
import org.bukkit.scoreboard.Team.OptionStatus;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -289,7 +350,15 @@ public class DisguiseUtilities {
|
|||
name = team.getPrefix() + team.getColor() + player.getName() + team.getSuffix();
|
||||
}
|
||||
|
||||
return name.replaceAll("§x§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])", "<#$1$2$3$4$5$6>");
|
||||
return getHexedColors(name);
|
||||
}
|
||||
|
||||
public static String getHexedColors(String string) {
|
||||
if (string == null) {
|
||||
return string;
|
||||
}
|
||||
|
||||
return string.replaceAll("§x§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])§([0-9a-fA-F])", "<#$1$2$3$4$5$6>");
|
||||
}
|
||||
|
||||
public static String getDisplayName(String playerName) {
|
||||
|
@ -2953,7 +3022,7 @@ public class DisguiseUtilities {
|
|||
}
|
||||
|
||||
// Don't need to offset with DisguiseUtilities.getYModifier, because that's a visual offset and not an actual location offset
|
||||
double height = disguise.getHeight() + disguise.getWatcher().getYModifier();
|
||||
double height = disguise.getHeight() + disguise.getWatcher().getYModifier() + disguise.getWatcher().getNameYModifier();
|
||||
|
||||
for (int i = 0; i < newNames.length; i++) {
|
||||
if (i < internalOldNames.length) {
|
||||
|
|
|
@ -172,8 +172,8 @@ public class LibsPremium {
|
|||
try {
|
||||
plugin = getInformation(file);
|
||||
} catch (ClassNotFoundException | NoClassDefFoundError ex) {
|
||||
DisguiseUtilities.getLogger().warning("Found an unrecognized jar in the LibsDisguises folder (" + file.getName() +
|
||||
") - It may need replacing with a newer jar from SpigotMC");
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Found an unrecognized jar in the LibsDisguises folder (" + file.getName() + ") - It may need replacing with a newer jar from SpigotMC");
|
||||
continue;
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Error while trying to handle the file " + file.getName());
|
||||
|
@ -187,10 +187,10 @@ public class LibsPremium {
|
|||
|
||||
if (plugin.isPremium()) {
|
||||
if (!isValidVersion(version, plugin.getVersion()) || plugin.getUserID() == null || plugin.getDownloadID() == null ||
|
||||
plugin.getUserID().equals("666666")) {
|
||||
plugin.getUserID().equals("666666")) {
|
||||
DisguiseUtilities.getLogger().warning("You have an old Lib's Disguises jar (" + file.getName() + " " + fileInfo +
|
||||
") in the LibsDisguises folder! For security purposes, please replace this with a" + " new " +
|
||||
"version from SpigotMC - https://www.spigotmc.org/resources/libs-disguises.32453/");
|
||||
") in the LibsDisguises folder! For security purposes, please replace this with a" + " new " +
|
||||
"version from SpigotMC - https://www.spigotmc.org/resources/libs-disguises.32453/");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ public class LibsPremium {
|
|||
|
||||
// >.>
|
||||
if (plugin.getBuildNumber() == null || !plugin.getBuildNumber().matches("#[0-9]+") ||
|
||||
Integer.parseInt(plugin.getBuildNumber().substring(1)) < 300) {
|
||||
Integer.parseInt(plugin.getBuildNumber().substring(1)) < 300) {
|
||||
file.delete();
|
||||
continue;
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ public class LibsPremium {
|
|||
// You have a non-premium Lib's Disguises jar (LibsDisguises.jar v5.2.6, build #40, created
|
||||
// 16/02/2019) in the LibsDisguises folder!
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("You have a non-premium Lib's Disguises jar (" + file.getName() + " " + fileInfo + ") in the LibsDisguises folder!");
|
||||
.warning("You have a non-premium Lib's Disguises jar (" + file.getName() + " " + fileInfo + ") in the LibsDisguises folder!");
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("Please place the premium jar downloaded from https://www.spigotmc" + ".org/resources/libs-disguises.32453/ " + "in here!");
|
||||
.warning("Please place the premium jar downloaded from https://www.spigotmc" + ".org/resources/libs-disguises.32453/ " + "in here!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class LibsPremium {
|
|||
thisPluginIsPaidFor = true;
|
||||
} else {
|
||||
DisguiseUtilities.getLogger().warning("If you own the plugin, place the premium jar downloaded from https://www.spigotmc" +
|
||||
".org/resources/libs-disguises.32453/ in plugins/LibsDisguises/");
|
||||
".org/resources/libs-disguises.32453/ in plugins/LibsDisguises/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ public class LibsPremium {
|
|||
}
|
||||
|
||||
pluginInformation = new PluginInformation(LibsDisguises.getInstance().getFile().length(), getUserID(), getResourceID(), getDownloadID(),
|
||||
isPremium(getResourceID(), getUserID()), version, buildNo, pluginBuildDate);
|
||||
isPremium(getResourceID(), getUserID()), version, buildNo, pluginBuildDate);
|
||||
}
|
||||
|
||||
if (!isPremium() || !LibsDisguises.getInstance().isReleaseBuild()) {
|
||||
|
@ -304,7 +304,7 @@ public class LibsPremium {
|
|||
DisguiseUtilities.getLogger().info("Ew, I don't recognize " + f.getName());
|
||||
continue;
|
||||
} else if (Integer.parseInt(info.getBuildNumber().replace("#", "")) <
|
||||
Integer.parseInt(LibsDisguises.getInstance().getBuildNo().replace("#", ""))) {
|
||||
Integer.parseInt(LibsDisguises.getInstance().getBuildNo().replace("#", ""))) {
|
||||
f.delete();
|
||||
DisguiseUtilities.getLogger().info("Ew, " + f.getName() + " is so old");
|
||||
continue;
|
||||
|
|
|
@ -36,8 +36,7 @@ public class SkinUtils {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI()
|
||||
.generateFromFile(callback, file, modelType);
|
||||
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromFile(callback, file, modelType);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
@ -52,8 +51,7 @@ public class SkinUtils {
|
|||
handleProfile(response.getGameProfile(), modelType, callback);
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException e) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -69,8 +67,7 @@ public class SkinUtils {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI()
|
||||
.generateFromUrl(callback, url, modelType);
|
||||
MineSkinResponse response = DisguiseUtilities.getMineSkinAPI().generateFromUrl(callback, url, modelType);
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
@ -131,8 +128,7 @@ public class SkinUtils {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
WrappedGameProfile profile = ReflectionManager
|
||||
.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated"));
|
||||
WrappedGameProfile profile = ReflectionManager.getSkullBlob(new WrappedGameProfile(uuid, "AutoGenerated"));
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
@ -184,8 +180,8 @@ public class SkinUtils {
|
|||
return;
|
||||
}
|
||||
|
||||
File file = new File(LibsDisguises.getInstance().getDataFolder(),
|
||||
"/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png"));
|
||||
File file =
|
||||
new File(LibsDisguises.getInstance().getDataFolder(), "/Skins/" + param + (param.toLowerCase(Locale.ENGLISH).endsWith(".png") ? "" : ".png"));
|
||||
|
||||
if (!file.exists()) {
|
||||
file = null;
|
||||
|
@ -209,8 +205,7 @@ public class SkinUtils {
|
|||
callback.onInfo(LibsMsg.SKIN_API_USING_UUID);
|
||||
handleUUID(uuid, modelType, callback);
|
||||
return;
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,17 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 28/01/2021.
|
||||
|
@ -96,8 +104,8 @@ public class DisguiseCommandConfig {
|
|||
configString = configString.replaceAll("\n([a-zA-Z])", "\n\n$1");
|
||||
|
||||
String s =
|
||||
"# The following can be changed to modify how the disguise commands are registered\n# This will only work on server startup\nModifyCommands: " +
|
||||
modifyCommands + "\n\n" + configString;
|
||||
"# The following can be changed to modify how the disguise commands are registered\n# This will only work on server startup\nModifyCommands: " +
|
||||
modifyCommands + "\n\n" + configString;
|
||||
|
||||
commandConfig.delete();
|
||||
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
|
@ -9,11 +14,9 @@ import java.lang.reflect.Type;
|
|||
/**
|
||||
* Created by libraryaddict on 27/11/2018.
|
||||
*/
|
||||
public class SerializerBlockData implements JsonDeserializer<BlockData>,
|
||||
JsonSerializer<BlockData> {
|
||||
public class SerializerBlockData implements JsonDeserializer<BlockData>, JsonSerializer<BlockData> {
|
||||
@Override
|
||||
public BlockData deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public BlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
return Bukkit.createBlockData(json.getAsString());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 27/11/2018.
|
||||
*/
|
||||
public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>,
|
||||
JsonSerializer<WrappedChatComponent> {
|
||||
public class SerializerChatComponent implements JsonDeserializer<WrappedChatComponent>, JsonSerializer<WrappedChatComponent> {
|
||||
|
||||
@Override
|
||||
public WrappedChatComponent deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public WrappedChatComponent deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
if (json.isJsonPrimitive()) {
|
||||
return WrappedChatComponent.fromJson(json.getAsString());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,17 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.InstanceCreator;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.EntityPose;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.VillagerData;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
|
||||
|
@ -47,7 +58,7 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Ins
|
|||
}
|
||||
|
||||
private void correct(FlagWatcher watcher, Class<? extends FlagWatcher> flagWatcher, String name)
|
||||
throws NoSuchFieldException, IllegalAccessException, DisguiseParseException {
|
||||
throws NoSuchFieldException, IllegalAccessException, DisguiseParseException {
|
||||
Field field = FlagWatcher.class.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
HashMap<Integer, Object> map = (HashMap<Integer, Object>) field.get(watcher);
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -18,14 +24,13 @@ public class SerializerGameProfile implements JsonSerializer<WrappedGameProfile>
|
|||
}
|
||||
|
||||
@Override
|
||||
public WrappedGameProfile deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public WrappedGameProfile deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
|
||||
if (obj.has("id") && !obj.get("id").getAsString().contains("-")) {
|
||||
obj.addProperty("id",
|
||||
Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)")
|
||||
.matcher(obj.get("id").getAsString()).replaceFirst("$1-$2-$3-$4-$5"));
|
||||
Pattern.compile("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)").matcher(obj.get("id").getAsString())
|
||||
.replaceFirst("$1-$2-$3-$4-$5"));
|
||||
}
|
||||
|
||||
return WrappedGameProfile.fromHandle(context.deserialize(json, GameProfile.class));
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
@ -26,8 +31,7 @@ public class SerializerItemStack implements JsonSerializer<ItemStack>, JsonDeser
|
|||
}
|
||||
|
||||
@Override
|
||||
public ItemStack deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
HashMap map = context.deserialize(json, HashMap.class);
|
||||
|
||||
if (map.containsKey("meta")) {
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -19,18 +25,19 @@ public class SerializerMetaIndex implements JsonSerializer<MetaIndex>, JsonDeser
|
|||
}
|
||||
|
||||
@Override
|
||||
public MetaIndex deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public MetaIndex deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
String name = obj.get("flagwatcher").getAsString();
|
||||
int index = obj.get("index").getAsInt();
|
||||
|
||||
for (MetaIndex i : MetaIndex.values()) {
|
||||
if (i.getIndex() != index)
|
||||
if (i.getIndex() != index) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!i.getFlagWatcher().getSimpleName().equals(name))
|
||||
if (!i.getFlagWatcher().getSimpleName().equals(name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,13 @@
|
|||
package me.libraryaddict.disguise.utilities.json;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
@ -9,8 +15,7 @@ import java.lang.reflect.Type;
|
|||
/**
|
||||
* Created by libraryaddict on 1/06/2017.
|
||||
*/
|
||||
public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>,
|
||||
JsonDeserializer<WrappedBlockData> {
|
||||
public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockData>, JsonDeserializer<WrappedBlockData> {
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(WrappedBlockData src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
|
@ -21,8 +26,7 @@ public class SerializerWrappedBlockData implements JsonSerializer<WrappedBlockDa
|
|||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockData deserialize(JsonElement json, Type typeOfT,
|
||||
JsonDeserializationContext context) throws JsonParseException {
|
||||
public WrappedBlockData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
JsonObject obj = json.getAsJsonObject();
|
||||
|
||||
return WrappedBlockData.createData(Material.valueOf(obj.get("type").getAsString()), obj.get("data").getAsInt());
|
||||
|
|
|
@ -25,7 +25,11 @@ import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
|||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -36,7 +40,15 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
|
@ -176,7 +188,7 @@ public class DisguiseListener implements Listener {
|
|||
|
||||
private boolean canRetaliate(Entity entity) {
|
||||
return entity.hasMetadata("LD-LastAttacked") &&
|
||||
entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) > System.currentTimeMillis();
|
||||
entity.getMetadata("LD-LastAttacked").get(0).asLong() + (DisguiseConfig.getPvPTimer() * 1000) > System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private void setRetaliation(Entity entity) {
|
||||
|
@ -473,7 +485,7 @@ public class DisguiseListener implements Listener {
|
|||
|
||||
if (!p.hasMetadata("forge_mods")) {
|
||||
Optional<ModdedEntity> required =
|
||||
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||
|
||||
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
||||
}
|
||||
|
@ -497,7 +509,7 @@ public class DisguiseListener implements Listener {
|
|||
|
||||
if (!p.hasMetadata("forge_mods")) {
|
||||
Optional<ModdedEntity> required =
|
||||
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||
ModdedManager.getEntities().values().stream().filter(c -> c.getMod() != null && c.getRequired() != null).findAny();
|
||||
|
||||
required.ifPresent(customEntity -> p.kickPlayer(customEntity.getRequired()));
|
||||
}
|
||||
|
@ -619,6 +631,9 @@ public class DisguiseListener implements Listener {
|
|||
|
||||
switch (event.getReason()) {
|
||||
case TARGET_ATTACKED_ENTITY:
|
||||
if (LibsPremium.isBisectHosted() && !Bukkit.getIp().matches("((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}")) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
case TARGET_ATTACKED_OWNER:
|
||||
case OWNER_ATTACKED_TARGET:
|
||||
case CUSTOM:
|
||||
|
@ -647,7 +662,7 @@ public class DisguiseListener implements Listener {
|
|||
Location from = event.getFrom();
|
||||
|
||||
if (!player.isOp() && !player.hasPermission("minecraft.command.teleport") && LibsPremium.getPaidInformation() != null &&
|
||||
LibsPremium.getPaidInformation().getUserID().equals("1592")) {
|
||||
LibsPremium.getPaidInformation().getUserID().equals("1592")) {
|
||||
player.sendMessage(ChatColor.GOLD + "Your teleport was a success!");
|
||||
}
|
||||
|
||||
|
|
|
@ -14,15 +14,17 @@ import org.bukkit.event.Listener;
|
|||
public class PaperDisguiseListener implements Listener {
|
||||
@EventHandler
|
||||
public void onEntityLoad(EntityAddToWorldEvent event) {
|
||||
if (!DisguiseConfig.isSaveEntityDisguises())
|
||||
if (!DisguiseConfig.isSaveEntityDisguises()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Entity entity = event.getEntity();
|
||||
|
||||
Disguise[] disguises = DisguiseUtilities.getSavedDisguises(entity.getUniqueId(), true);
|
||||
|
||||
if (disguises.length <= 0)
|
||||
if (disguises.length <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
DisguiseUtilities.resetPluginTimer();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class PlayerSkinHandler implements Listener {
|
|||
|
||||
public boolean canRemove(boolean onMoved) {
|
||||
return firstPacketSent + (DisguiseConfig.getTablistRemoveDelay() * 50) + (onMoved ? 0 : DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50) <
|
||||
System.currentTimeMillis();
|
||||
System.currentTimeMillis();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -76,20 +76,20 @@ public class PlayerSkinHandler implements Listener {
|
|||
|
||||
@Getter
|
||||
private final Cache<Player, List<PlayerSkin>> cache =
|
||||
CacheBuilder.newBuilder().weakKeys().expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS)
|
||||
.removalListener((event) -> {
|
||||
if (event.getCause() != RemovalCause.EXPIRED) {
|
||||
return;
|
||||
}
|
||||
CacheBuilder.newBuilder().weakKeys().expireAfterWrite(DisguiseConfig.getPlayerDisguisesSkinExpiresMove() * 50, TimeUnit.MILLISECONDS)
|
||||
.removalListener((event) -> {
|
||||
if (event.getCause() != RemovalCause.EXPIRED) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerSkin> skins = (List<PlayerSkin>) event.getValue();
|
||||
List<PlayerSkin> skins = (List<PlayerSkin>) event.getValue();
|
||||
|
||||
for (PlayerSkin skin : skins) {
|
||||
doPacketRemoval((Player) event.getKey(), skin);
|
||||
}
|
||||
for (PlayerSkin skin : skins) {
|
||||
doPacketRemoval((Player) event.getKey(), skin);
|
||||
}
|
||||
|
||||
skins.clear();
|
||||
}).build();
|
||||
skins.clear();
|
||||
}).build();
|
||||
|
||||
public PlayerSkinHandler() {
|
||||
new BukkitRunnable() {
|
||||
|
@ -262,8 +262,8 @@ public class PlayerSkinHandler implements Listener {
|
|||
WrappedDataWatcher watcher = DisguiseUtilities.createSanitizedDataWatcher(player, WrappedDataWatcher.getEntityWatcher(entity), disguise.getWatcher());
|
||||
|
||||
PacketContainer metaPacket =
|
||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true)
|
||||
.createPacket(entity.getEntityId(), watcher, true);
|
||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entity.getEntityId(), watcher, true)
|
||||
.createPacket(entity.getEntityId(), watcher, true);
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, metaPacket, false);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,13 @@ package me.libraryaddict.disguise.utilities.metrics;
|
|||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.ServicePriority;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -17,7 +17,14 @@ import java.io.IOException;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
|
@ -31,11 +38,9 @@ public class Metrics {
|
|||
static {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this little "trick" ... :D
|
||||
final String defaultPackage = new String(new byte[]{'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's'});
|
||||
final String examplePackage = new String(
|
||||
new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
final String examplePackage = new String(new byte[]{'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e'});
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong package names
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) ||
|
||||
Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
if (Metrics.class.getPackage().getName().equals(defaultPackage) || Metrics.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
|
@ -89,16 +94,13 @@ public class Metrics {
|
|||
config.addDefault("logFailedRequests", false);
|
||||
|
||||
// Inform the server owners about bStats
|
||||
config.options()
|
||||
.header("bStats collects some data for plugin authors like how many servers are using their " +
|
||||
"plugins.\n" + "To honor their work, you should not disable it.\n" +
|
||||
"This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)").copyDefaults(true);
|
||||
config.options().header("bStats collects some data for plugin authors like how many servers are using their " + "plugins.\n" +
|
||||
"To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" +
|
||||
"Check out https://bStats.org/ to learn more :)").copyDefaults(true);
|
||||
try {
|
||||
config.save(configFile);
|
||||
DisguiseUtilities.getLogger().info("Saved bStats config");
|
||||
}
|
||||
catch (IOException ignored) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,8 +115,7 @@ public class Metrics {
|
|||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
found = true; // We aren't the first
|
||||
break;
|
||||
}
|
||||
catch (NoSuchFieldException ignored) {
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
}
|
||||
// Register our service
|
||||
|
@ -243,15 +244,13 @@ public class Metrics {
|
|||
for (Class<?> service : Bukkit.getServicesManager().getKnownServices()) {
|
||||
try {
|
||||
service.getField("B_STATS_VERSION"); // Our identifier :)
|
||||
}
|
||||
catch (NoSuchFieldException ignored) {
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
continue; // Continue "searching"
|
||||
}
|
||||
// Found one!
|
||||
try {
|
||||
pluginData.add(new Gson().toJson(service.getMethod("getPluginData").invoke(Bukkit.getServicesManager().load(service))));
|
||||
}
|
||||
catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,12 +263,10 @@ public class Metrics {
|
|||
try {
|
||||
// Send the data
|
||||
sendData(data);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger()
|
||||
.log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,8 +358,7 @@ public class Metrics {
|
|||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
}
|
||||
catch (Throwable t) {
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
|
|
|
@ -50,8 +50,8 @@ public class MetricsInitalizer {
|
|||
info = LibsPremium.getPluginInformation();
|
||||
}
|
||||
|
||||
boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") ||
|
||||
!info.getResourceID().equals("32453") || !info.getDownloadID().matches("-?[0-9]+");
|
||||
boolean customPremium = !info.getUserID().matches("[0-9]+") || info.getUserID().equals("1") || !info.getResourceID().equals("32453") ||
|
||||
!info.getDownloadID().matches("-?[0-9]+");
|
||||
|
||||
if (customPremium) {
|
||||
if (plugin.isReleaseBuild() && LibsPremium.getPaidInformation() == null) {
|
||||
|
@ -138,8 +138,9 @@ public class MetricsInitalizer {
|
|||
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
||||
for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
||||
for (Disguise disg : list) {
|
||||
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
||||
if (disg.getEntity() == null || !disg.isDisguiseInUse()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = disg.getEntity().getType().name();
|
||||
|
||||
|
@ -156,8 +157,9 @@ public class MetricsInitalizer {
|
|||
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
||||
for (Set<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
||||
for (Disguise disg : list) {
|
||||
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
||||
if (disg.getEntity() == null || !disg.isDisguiseInUse()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = disg.getType().name();
|
||||
|
||||
|
@ -195,20 +197,22 @@ public class MetricsInitalizer {
|
|||
disgs += set.size();
|
||||
}
|
||||
|
||||
if (disgs == 0)
|
||||
if (disgs == 0) {
|
||||
return "0";
|
||||
if (disgs <= 5)
|
||||
}
|
||||
if (disgs <= 5) {
|
||||
return "1 to 5";
|
||||
else if (disgs <= 15)
|
||||
} else if (disgs <= 15) {
|
||||
return "6 to 15";
|
||||
else if (disgs <= 30)
|
||||
} else if (disgs <= 30) {
|
||||
return "16 to 30";
|
||||
else if (disgs <= 60)
|
||||
} else if (disgs <= 60) {
|
||||
return "30 to 60";
|
||||
else if (disgs <= 100)
|
||||
} else if (disgs <= 100) {
|
||||
return "60 to 100";
|
||||
else if (disgs <= 200)
|
||||
} else if (disgs <= 200) {
|
||||
return "100 to 200";
|
||||
}
|
||||
|
||||
return "More than 200";
|
||||
}
|
||||
|
@ -234,8 +238,7 @@ public class MetricsInitalizer {
|
|||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
return "Yes";
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
return "No";
|
||||
}
|
||||
}
|
||||
|
@ -276,13 +279,15 @@ public class MetricsInitalizer {
|
|||
|
||||
Collection<Set<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
||||
|
||||
if (list.isEmpty())
|
||||
if (list.isEmpty()) {
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
for (Set<TargetedDisguise> dList : list) {
|
||||
for (TargetedDisguise disg : dList) {
|
||||
if (disg.getObservers().isEmpty())
|
||||
if (disg.getObservers().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
targetedDisguises = true;
|
||||
return "Yes";
|
||||
|
|
|
@ -8,7 +8,14 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|||
import me.libraryaddict.disguise.utilities.SkinUtils;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
|
@ -158,8 +165,8 @@ public class MineSkinAPI {
|
|||
printDebug("Received status code: " + connection.getResponseCode());
|
||||
|
||||
if (connection.getResponseCode() == 500) {
|
||||
String errorMessage = new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines()
|
||||
.collect(Collectors.joining("\n"));
|
||||
String errorMessage =
|
||||
new BufferedReader(new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8)).lines().collect(Collectors.joining("\n"));
|
||||
|
||||
APIError error = new Gson().fromJson(errorMessage, APIError.class);
|
||||
|
||||
|
@ -214,7 +221,7 @@ public class MineSkinAPI {
|
|||
} catch (Exception ex) {
|
||||
try {
|
||||
if (connection != null && (connection.getResponseCode() == 524 || connection.getResponseCode() == 408 || connection.getResponseCode() == 504 ||
|
||||
connection.getResponseCode() == 599)) {
|
||||
connection.getResponseCode() == 599)) {
|
||||
if (getApiKey() != null && connection.getResponseCode() == 504) {
|
||||
callback.onError(LibsMsg.SKIN_API_TIMEOUT_API_KEY_ERROR);
|
||||
} else {
|
||||
|
|
|
@ -37,8 +37,7 @@ public class ModdedManager {
|
|||
@Getter
|
||||
private static byte[] fmlRegistries;
|
||||
@Getter
|
||||
private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.MINUTES).build();
|
||||
private static final Cache<String, ArrayList<String>> forgeMods = CacheBuilder.newBuilder().expireAfterWrite(1, TimeUnit.MINUTES).build();
|
||||
|
||||
public ModdedManager(ArrayList<String> channels) {
|
||||
if (getEntities().isEmpty()) {
|
||||
|
@ -81,8 +80,7 @@ public class ModdedManager {
|
|||
|
||||
// Only this one thx
|
||||
// s.serializeString(output, "minecraft:entity_type");
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -124,8 +122,7 @@ public class ModdedManager {
|
|||
|
||||
// Or dummied. What is dummied anyways. What are these others?
|
||||
s.serializeVarInt(output, 0);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -203,9 +200,7 @@ public class ModdedManager {
|
|||
ArrayList<DisguisePerm> perms = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<NamespacedKey, ModdedEntity> entry : entities.entrySet()) {
|
||||
perms.add(new DisguisePerm(
|
||||
entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC,
|
||||
entry.getValue().getName()));
|
||||
perms.add(new DisguisePerm(entry.getValue().isLiving() ? DisguiseType.MODDED_LIVING : DisguiseType.MODDED_MISC, entry.getValue().getName()));
|
||||
}
|
||||
|
||||
return perms;
|
||||
|
|
|
@ -6,7 +6,17 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.*;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAnimation;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAttachEntity;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerAttributes;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerCollect;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerEntityStatus;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerEquipment;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerHeadRotation;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerMetadata;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerMovement;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerSpawn;
|
||||
import me.libraryaddict.disguise.utilities.packets.packethandlers.PacketHandlerVelocity;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -36,8 +46,7 @@ public class PacketsHandler {
|
|||
packetHandlers.add(new PacketHandlerHeadRotation());
|
||||
|
||||
// If not prem, if build is from jenkins, else its a custom and needs paid info
|
||||
if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") ||
|
||||
LibsPremium.getPaidInformation() != null) {
|
||||
if (!LibsPremium.isPremium() || LibsDisguises.getInstance().getBuildNo().matches("[0-9]+") || LibsPremium.getPaidInformation() != null) {
|
||||
packetHandlers.add(new PacketHandlerMetadata(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,15 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.*;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerClientCustomPayload;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerClientInteract;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerEntityDestroy;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerInventory;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerMain;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerScoreboardTeam;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerSounds;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerTabList;
|
||||
import me.libraryaddict.disguise.utilities.packets.packetlisteners.PacketListenerViewSelfDisguise;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -85,7 +93,7 @@ public class PacketsManager {
|
|||
|
||||
if (disguise != null) {
|
||||
if (viewDisguisesListenerEnabled && disguise.isSelfDisguiseVisible() &&
|
||||
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +178,7 @@ public class PacketsManager {
|
|||
ProtocolLibrary.getProtocolManager().addPacketListener(mainListener);
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(destroyListener);
|
||||
|
||||
if (NmsVersion.v1_13.isSupported() &&
|
||||
DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
|
||||
if (NmsVersion.v1_13.isSupported() && DisguiseConfig.getPlayerNameType() != DisguiseConfig.PlayerNameType.ARMORSTANDS) {
|
||||
scoreboardTeamListener = new PacketListenerScoreboardTeam();
|
||||
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(scoreboardTeamListener);
|
||||
|
@ -200,8 +207,7 @@ public class PacketsManager {
|
|||
DisguiseUtilities.removeSelfDisguise(disguise);
|
||||
}
|
||||
|
||||
if (inventoryModifierEnabled &&
|
||||
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||
if (inventoryModifierEnabled && (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ public class PacketHandlerAnimation implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
// Else if the disguise is attempting to send players a forbidden packet
|
||||
if (disguise.getType().isMisc()) {
|
||||
packets.clear();
|
||||
|
|
|
@ -20,15 +20,13 @@ public class PacketHandlerAttachEntity implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
if (observer.getVehicle() == null) {
|
||||
DisguiseUtilities.removeInvisibleSlime(observer);
|
||||
return;
|
||||
}
|
||||
|
||||
if (observer.getVehicle() != entity ||
|
||||
!AbstractHorse.class.isAssignableFrom(disguise.getType().getEntityClass())) {
|
||||
if (observer.getVehicle() != entity || !AbstractHorse.class.isAssignableFrom(disguise.getType().getEntityClass())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ public class PacketHandlerAttributes implements IPacketHandler {
|
|||
builder.packet(updateAttributes);
|
||||
|
||||
attributes.add(builder.build());
|
||||
} else if (attribute.getAttributeKey().equals(NmsVersion.v1_16.isSupported() ? "generic.movement_speed" : "generic.movementSpeed") && disguise.getWatcher() instanceof AbstractHorseWatcher) {
|
||||
} else if (attribute.getAttributeKey().equals(NmsVersion.v1_16.isSupported() ? "generic.movement_speed" : "generic.movementSpeed") &&
|
||||
disguise.getWatcher() instanceof AbstractHorseWatcher) {
|
||||
WrappedAttribute.Builder builder = WrappedAttribute.newBuilder(attribute);
|
||||
builder.packet(updateAttributes);
|
||||
|
||||
|
|
|
@ -18,8 +18,7 @@ public class PacketHandlerCollect implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
if (disguise.getType().isMisc()) {
|
||||
packets.clear();
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ public class PacketHandlerEntityStatus implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
// If the entity is updating their status, stop them from showing death
|
||||
if (packets.getPackets().get(0).getBytes().read(0) == (byte) 3) {
|
||||
packets.clear();
|
||||
|
|
|
@ -82,15 +82,15 @@ public class PacketHandlerEquipment implements IPacketHandler {
|
|||
}
|
||||
|
||||
if ((disguise.getWatcher().isMainHandRaised() && slot == EquipmentSlot.HAND) ||
|
||||
(disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() &&
|
||||
slot == EquipmentSlot.OFF_HAND)) {
|
||||
(disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() &&
|
||||
slot == EquipmentSlot.OFF_HAND)) {
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR) {
|
||||
// Convert the datawatcher
|
||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||
|
||||
if (DisguiseConfig.isMetaPacketsEnabled()) {
|
||||
WrappedWatchableObject watch = ReflectionManager.createWatchable(MetaIndex.LIVING_META,
|
||||
WrappedDataWatcher.getEntityWatcher(entity).getByte(MetaIndex.LIVING_META.getIndex()));
|
||||
WrappedDataWatcher.getEntityWatcher(entity).getByte(MetaIndex.LIVING_META.getIndex()));
|
||||
|
||||
if (watch != null) {
|
||||
list.add(watch);
|
||||
|
@ -155,8 +155,7 @@ public class PacketHandlerEquipment implements IPacketHandler {
|
|||
}
|
||||
|
||||
if ((disguise.getWatcher().isMainHandRaised() && slot == EquipmentSlot.HAND) ||
|
||||
(disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() &&
|
||||
slot == EquipmentSlot.OFF_HAND)) {
|
||||
(disguise.getWatcher() instanceof LivingWatcher && ((LivingWatcher) disguise.getWatcher()).isOffhandRaised() && slot == EquipmentSlot.OFF_HAND)) {
|
||||
if (itemStack == null) {
|
||||
itemStack = packets.getPackets().get(0).getItemModifier().read(0);
|
||||
}
|
||||
|
@ -168,7 +167,7 @@ public class PacketHandlerEquipment implements IPacketHandler {
|
|||
|
||||
if (DisguiseConfig.isMetaPacketsEnabled()) {
|
||||
WrappedWatchableObject watch =
|
||||
ReflectionManager.createWatchable(toUse, WrappedDataWatcher.getEntityWatcher(entity).getByte(toUse.getIndex()));
|
||||
ReflectionManager.createWatchable(toUse, WrappedDataWatcher.getEntityWatcher(entity).getByte(toUse.getIndex()));
|
||||
|
||||
if (watch != null) {
|
||||
list.add(watch);
|
||||
|
|
|
@ -26,8 +26,7 @@ public class PacketHandlerHeadRotation implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
if (disguise.getType() == DisguiseType.FALLING_BLOCK) {
|
||||
packets.clear();
|
||||
return;
|
||||
|
@ -37,8 +36,7 @@ public class PacketHandlerHeadRotation implements IPacketHandler {
|
|||
Float yawLock = disguise.getWatcher().getYawLock();
|
||||
boolean riding = observer.getVehicle() == entity;
|
||||
|
||||
if (pitchLock == null && yawLock == null &&
|
||||
(!disguise.getType().isPlayer() || entity.getType() == EntityType.PLAYER)) {
|
||||
if (pitchLock == null && yawLock == null && (!disguise.getType().isPlayer() || entity.getType() == EntityType.PLAYER)) {
|
||||
if (riding) {
|
||||
sentPacket = sentPacket.shallowClone();
|
||||
sentPacket.getModifier().write(0, DisguiseAPI.getEntityAttachmentId());
|
||||
|
@ -87,31 +85,26 @@ public class PacketHandlerHeadRotation implements IPacketHandler {
|
|||
case SNOWBALL:
|
||||
case PAINTING:
|
||||
case PRIMED_TNT:
|
||||
if ((pitchLock == null || yawLock == null) && sentPacket.getBytes().read(0) == 0 &&
|
||||
entity.getVelocity().lengthSquared() > 0) {
|
||||
if ((pitchLock == null || yawLock == null) && sentPacket.getBytes().read(0) == 0 && entity.getVelocity().lengthSquared() > 0) {
|
||||
loc.setDirection(entity.getVelocity());
|
||||
|
||||
if (pitchLock == null) {
|
||||
pitch = DisguiseUtilities
|
||||
.getPitch(DisguiseType.PLAYER, (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
pitch = DisguiseUtilities.getPitch(DisguiseType.PLAYER, (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
}
|
||||
|
||||
if (yawLock == null) {
|
||||
yaw = DisguiseUtilities
|
||||
.getYaw(DisguiseType.PLAYER, (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
yaw = DisguiseUtilities.getYaw(DisguiseType.PLAYER, (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (pitchLock == null) {
|
||||
pitch = DisguiseUtilities.getPitch(DisguiseType.getType(entity.getType()),
|
||||
(byte) (int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
pitch = DisguiseUtilities.getPitch(DisguiseType.getType(entity.getType()), (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
|
||||
}
|
||||
|
||||
if (yawLock == null) {
|
||||
yaw = DisguiseUtilities.getYaw(DisguiseType.getType(entity.getType()),
|
||||
(byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
yaw = DisguiseUtilities.getYaw(DisguiseType.getType(entity.getType()), (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class PacketHandlerMovement implements IPacketHandler {
|
|||
@Override
|
||||
public PacketType[] getHandledPackets() {
|
||||
return new PacketType[]{PacketType.Play.Server.REL_ENTITY_MOVE_LOOK, PacketType.Play.Server.ENTITY_LOOK, PacketType.Play.Server.ENTITY_TELEPORT,
|
||||
PacketType.Play.Server.REL_ENTITY_MOVE};
|
||||
PacketType.Play.Server.REL_ENTITY_MOVE};
|
||||
}
|
||||
|
||||
private short conRel(double oldCord, double newCord) {
|
||||
|
@ -50,7 +50,7 @@ public class PacketHandlerMovement implements IPacketHandler {
|
|||
}
|
||||
|
||||
ArrayList<PacketContainer> toAdd = new ArrayList<>();
|
||||
double height = disguise.getHeight();
|
||||
double height = disguise.getHeight() + disguise.getWatcher().getNameYModifier();
|
||||
|
||||
for (PacketContainer packet : packets.getPackets()) {
|
||||
if (packet.getType() == PacketType.Play.Server.ENTITY_LOOK) {
|
||||
|
@ -158,7 +158,7 @@ public class PacketHandlerMovement implements IPacketHandler {
|
|||
packets.addPacket(movePacket);
|
||||
return;
|
||||
} else if (disguise.getType() == DisguiseType.RABBIT &&
|
||||
(sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE || sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK)) {
|
||||
(sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE || sentPacket.getType() == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK)) {
|
||||
// When did the rabbit disguise last hop
|
||||
long lastHop = 999999;
|
||||
|
||||
|
|
|
@ -9,7 +9,12 @@ import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|||
import com.mojang.datafixers.util.Pair;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.ModdedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
@ -49,7 +54,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
@Override
|
||||
public PacketType[] getHandledPackets() {
|
||||
return new PacketType[]{PacketType.Play.Server.NAMED_ENTITY_SPAWN, PacketType.Play.Server.SPAWN_ENTITY_LIVING,
|
||||
PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_PAINTING};
|
||||
PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB, PacketType.Play.Server.SPAWN_ENTITY, PacketType.Play.Server.SPAWN_ENTITY_PAINTING};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -145,8 +150,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
// Add player to the list, necessary to spawn them
|
||||
sendTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0));
|
||||
|
||||
List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), ReflectionManager
|
||||
.getGameProfileWithThisSkin(playerDisguise.getUUID(), playerDisguise.getProfileName(), playerDisguise.getGameProfile())));
|
||||
List playerList = Collections.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(),
|
||||
ReflectionManager.getGameProfileWithThisSkin(playerDisguise.getUUID(), playerDisguise.getProfileName(), playerDisguise.getGameProfile())));
|
||||
sendTab.getModifier().write(1, playerList);
|
||||
|
||||
packets.addPacket(sendTab);
|
||||
|
@ -175,8 +180,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
|
||||
// If self disguise, or further than 50 blocks, or not in front of entity
|
||||
normalPlayerDisguise = observer == disguisedEntity || disguisedEntity.getPassengers().contains(observer) || dist > (50 * 50) ||
|
||||
(observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector()
|
||||
.distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3;
|
||||
(observer.getLocation().add(observer.getLocation().getDirection().normalize()).toVector()
|
||||
.distanceSquared(disguisedEntity.getLocation().toVector()) - dist) < 0.3;
|
||||
sendArmor = normalPlayerDisguise;
|
||||
|
||||
skin.setSleepPackets(!normalPlayerDisguise);
|
||||
|
@ -209,8 +214,8 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
|
||||
if (NmsVersion.v1_15.isSupported()) {
|
||||
PacketContainer metaPacket =
|
||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entityId, toSend, true)
|
||||
.createPacket(entityId, toSend, true);
|
||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, entityId, toSend, true)
|
||||
.createPacket(entityId, toSend, true);
|
||||
|
||||
packets.addPacket(metaPacket);
|
||||
} else {
|
||||
|
@ -273,12 +278,12 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
mods.write(11, yaw);
|
||||
|
||||
WrappedDataWatcher newWatcher =
|
||||
DisguiseUtilities.createSanitizedDataWatcher(observer, WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher());
|
||||
DisguiseUtilities.createSanitizedDataWatcher(observer, WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher());
|
||||
|
||||
if (NmsVersion.v1_15.isSupported()) {
|
||||
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, disguisedEntity.getEntityId(), newWatcher, true)
|
||||
.createPacket(disguisedEntity.getEntityId(), newWatcher, true);
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, disguisedEntity.getEntityId(), newWatcher, true)
|
||||
.createPacket(disguisedEntity.getEntityId(), newWatcher, true);
|
||||
|
||||
packets.addPacket(metaPacket);
|
||||
} else {
|
||||
|
@ -322,7 +327,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
}
|
||||
|
||||
Object[] params = new Object[]{disguisedEntity.getEntityId(), disguise.getUUID(), x, y, z, loc.getPitch(), loc.getYaw(), entityType, data,
|
||||
ReflectionManager.getVec3D(disguisedEntity.getVelocity())};
|
||||
ReflectionManager.getVec3D(disguisedEntity.getVelocity())};
|
||||
|
||||
spawnEntity = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, params).createPacket(params);
|
||||
} else {
|
||||
|
@ -335,7 +340,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
||||
|
||||
spawnEntity = ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data)
|
||||
.createPacket(nmsEntity, objectId, data);
|
||||
.createPacket(nmsEntity, objectId, data);
|
||||
|
||||
StructureModifier<Double> doubles = spawnEntity.getDoubles();
|
||||
|
||||
|
@ -405,7 +410,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
|
|||
ArrayList<WrappedAttribute> attributes = new ArrayList<>();
|
||||
|
||||
WrappedAttribute.Builder builder =
|
||||
WrappedAttribute.newBuilder().attributeKey(NmsVersion.v1_16.isSupported() ? "generic.max_health" : "generic.maxHealth");
|
||||
WrappedAttribute.newBuilder().attributeKey(NmsVersion.v1_16.isSupported() ? "generic.max_health" : "generic.maxHealth");
|
||||
|
||||
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
||||
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
||||
|
|
|
@ -19,11 +19,9 @@ public class PacketHandlerVelocity implements IPacketHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||
Entity entity) {
|
||||
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity) {
|
||||
// If the disguise isnt a misc or the disguised is the same type
|
||||
if ((!disguise.getType().isMisc() && disguise.getType() != DisguiseType.SQUID) ||
|
||||
DisguiseType.getType(entity) == disguise.getType()) {
|
||||
if ((!disguise.getType().isMisc() && disguise.getType() != DisguiseType.SQUID) || DisguiseType.getType(entity) == disguise.getType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ public class PacketListenerClientCustomPayload extends PacketAdapter {
|
|||
}
|
||||
|
||||
if (player.hasMetadata("ld_tabsend") && !player.getMetadata("ld_tabsend").isEmpty()) {
|
||||
ArrayList<PacketContainer> packets = (ArrayList<PacketContainer>) player.getMetadata("ld_tabsend")
|
||||
.get(0).value();
|
||||
ArrayList<PacketContainer> packets = (ArrayList<PacketContainer>) player.getMetadata("ld_tabsend").get(0).value();
|
||||
|
||||
player.removeMetadata("ld_tabsend", LibsDisguises.getInstance());
|
||||
|
||||
|
@ -61,8 +60,7 @@ public class PacketListenerClientCustomPayload extends PacketAdapter {
|
|||
for (PacketContainer packet : packets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,11 @@ import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.CatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LlamaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||
import me.libraryaddict.disguise.events.DisguiseInteractEvent;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
@ -126,7 +130,7 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||
public void run() {
|
||||
// Fire self interact event
|
||||
DisguiseInteractEvent selfEvent =
|
||||
new DisguiseInteractEvent((TargetedDisguise) disguise, handUsed, interactType == EnumWrappers.EntityUseAction.ATTACK);
|
||||
new DisguiseInteractEvent((TargetedDisguise) disguise, handUsed, interactType == EnumWrappers.EntityUseAction.ATTACK);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(selfEvent);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||
|
||||
public PacketListenerInventory(LibsDisguises plugin) {
|
||||
super(plugin, ListenerPriority.HIGH, Server.SET_SLOT, Server.WINDOW_ITEMS, PacketType.Play.Client.SET_CREATIVE_SLOT,
|
||||
PacketType.Play.Client.WINDOW_CLICK);
|
||||
PacketType.Play.Client.WINDOW_CLICK);
|
||||
|
||||
libsDisguises = plugin;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||
// If player isn't disguise, isn't self disguised, or isn't hiding items from themselves
|
||||
// If player is disguised, views self disguises and has a inventory modifier
|
||||
if (disguise == null || !DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) ||
|
||||
(!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) {
|
||||
(!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ public class PacketListenerInventory extends PacketAdapter {
|
|||
Disguise disguise = DisguiseAPI.getDisguise(player, player);
|
||||
|
||||
if (disguise == null || !DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()) ||
|
||||
(!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) {
|
||||
(!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,13 +25,16 @@ public class PacketListenerMain extends PacketAdapter {
|
|||
|
||||
@Override
|
||||
public void onPacketSending(final PacketEvent event) {
|
||||
if (event.isCancelled())
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Player observer = event.getPlayer();
|
||||
|
||||
if (observer.getName().contains("UNKNOWN[")) // If the player is temporary
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// First get the entity, the one sending this packet
|
||||
|
||||
|
@ -49,15 +52,12 @@ public class PacketListenerMain extends PacketAdapter {
|
|||
LibsPackets packets;
|
||||
|
||||
try {
|
||||
packets = PacketsManager.getPacketsHandler()
|
||||
.transformPacket(event.getPacket(), disguise, observer, disguise.getEntity());
|
||||
packets = PacketsManager.getPacketsHandler().transformPacket(event.getPacket(), disguise, observer, disguise.getEntity());
|
||||
|
||||
if (disguise.isPlayerDisguise()) {
|
||||
LibsDisguises.getInstance().getSkinHandler()
|
||||
.handlePackets(observer, (PlayerDisguise) disguise, packets);
|
||||
LibsDisguises.getInstance().getSkinHandler().handlePackets(observer, (PlayerDisguise) disguise, packets);
|
||||
}
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -75,8 +75,7 @@ public class PacketListenerMain extends PacketAdapter {
|
|||
}
|
||||
|
||||
packets.sendDelayed(observer);
|
||||
}
|
||||
catch (InvocationTargetException ex) {
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,7 @@ import java.util.concurrent.TimeUnit;
|
|||
* Created by libraryaddict on 11/06/2020.
|
||||
*/
|
||||
public class PacketListenerModdedClient extends PacketAdapter {
|
||||
private final Cache<String, String> loginAttempts = CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS)
|
||||
.build();
|
||||
private final Cache<String, String> loginAttempts = CacheBuilder.newBuilder().expireAfterWrite(15, TimeUnit.SECONDS).build();
|
||||
private final int packetId1 = 5555554, packetId2 = 5555555;
|
||||
|
||||
public PacketListenerModdedClient() {
|
||||
|
@ -74,17 +73,14 @@ public class PacketListenerModdedClient extends PacketAdapter {
|
|||
int size = 256;
|
||||
|
||||
if (j > size * 4) {
|
||||
throw new DecoderException(
|
||||
"The received encoded string buffer length is longer than maximum allowed (" + j + " > " +
|
||||
size * 4 + ")");
|
||||
throw new DecoderException("The received encoded string buffer length is longer than maximum allowed (" + j + " > " + size * 4 + ")");
|
||||
} else if (j < 0) {
|
||||
throw new DecoderException("The received encoded string buffer length is less than zero! Weird string!");
|
||||
} else {
|
||||
String s = buf.toString(buf.readerIndex(), j, StandardCharsets.UTF_8);
|
||||
buf.readerIndex(buf.readerIndex() + j);
|
||||
if (s.length() > size) {
|
||||
throw new DecoderException(
|
||||
"The received string length is longer than maximum allowed (" + j + " > " + size + ")");
|
||||
throw new DecoderException("The received string length is longer than maximum allowed (" + j + " > " + size + ")");
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
|
@ -98,8 +94,7 @@ public class PacketListenerModdedClient extends PacketAdapter {
|
|||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().recieveClientPacket(player, packet, false);
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -135,16 +130,15 @@ public class PacketListenerModdedClient extends PacketAdapter {
|
|||
return;
|
||||
}
|
||||
|
||||
loginAttempts
|
||||
.put(event.getPlayer().getAddress().toString(), event.getPacket().getGameProfiles().read(0).getName());
|
||||
loginAttempts.put(event.getPlayer().getAddress().toString(), event.getPacket().getGameProfiles().read(0).getName());
|
||||
|
||||
PacketContainer packet1 = new PacketContainer(PacketType.Login.Server.CUSTOM_PAYLOAD);
|
||||
packet1.getIntegers().write(0, packetId1);
|
||||
packet1.getMinecraftKeys().write(0, new com.comphenix.protocol.wrappers.MinecraftKey("fml", "handshake"));
|
||||
|
||||
try {
|
||||
Object obj1 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class)
|
||||
.newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake()));
|
||||
Object obj1 =
|
||||
ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class).newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlHandshake()));
|
||||
|
||||
packet1.getModifier().write(2, obj1);
|
||||
|
||||
|
@ -152,14 +146,13 @@ public class PacketListenerModdedClient extends PacketAdapter {
|
|||
packet2.getIntegers().write(0, packetId2);
|
||||
packet2.getMinecraftKeys().write(0, new MinecraftKey("fml", "handshake"));
|
||||
Object obj2 = ReflectionManager.getNmsConstructor("PacketDataSerializer", ByteBuf.class)
|
||||
.newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries()));
|
||||
.newInstance(Unpooled.wrappedBuffer(ModdedManager.getFmlRegistries()));
|
||||
|
||||
packet2.getModifier().write(2, obj2);
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet1);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet2);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -156,6 +156,8 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||
newModifs.write(2, mods.read(2));
|
||||
newModifs.write(3, mods.read(3));
|
||||
newModifs.write(4, mods.read(4));
|
||||
|
||||
mods = newModifs;
|
||||
} else {
|
||||
newPacket = event.getPacket().shallowClone();
|
||||
mods = newPacket.getModifier();
|
||||
|
@ -237,7 +239,7 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||
|
||||
Location loc = entity.getLocation();
|
||||
PacketContainer packet =
|
||||
new PacketContainer(sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT);
|
||||
new PacketContainer(sound.getClass().getSimpleName().equals("MinecraftKey") ? Server.CUSTOM_SOUND_EFFECT : Server.NAMED_SOUND_EFFECT);
|
||||
|
||||
mods = packet.getModifier();
|
||||
|
||||
|
|
|
@ -22,13 +22,15 @@ public class PacketListenerTabList extends PacketAdapter {
|
|||
|
||||
@Override
|
||||
public void onPacketSending(final PacketEvent event) {
|
||||
if (event.isCancelled())
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player observer = event.getPlayer();
|
||||
|
||||
if (event.getPacket().getPlayerInfoAction().read(0) != PlayerInfoAction.ADD_PLAYER)
|
||||
if (event.getPacket().getPlayerInfoAction().read(0) != PlayerInfoAction.ADD_PLAYER) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<PlayerInfoData> list = event.getPacket().getPlayerInfoDataLists().read(0);
|
||||
Iterator<PlayerInfoData> itel = list.iterator();
|
||||
|
@ -38,16 +40,19 @@ public class PacketListenerTabList extends PacketAdapter {
|
|||
|
||||
Player player = Bukkit.getPlayer(data.getProfile().getUUID());
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(observer, player);
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!disguise.isHidePlayer())
|
||||
if (!disguise.isHidePlayer()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
|
|
@ -27,10 +27,9 @@ import java.util.Map;
|
|||
|
||||
public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
||||
public PacketListenerViewSelfDisguise(LibsDisguises plugin) {
|
||||
super(plugin, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE,
|
||||
Server.REL_ENTITY_MOVE_LOOK, Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, Server.ENTITY_HEAD_ROTATION,
|
||||
Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.ENTITY_EFFECT,
|
||||
Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS);
|
||||
super(plugin, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE, Server.REL_ENTITY_MOVE_LOOK,
|
||||
Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, Server.ENTITY_HEAD_ROTATION, Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION,
|
||||
Server.ENTITY_EFFECT, Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,8 +63,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
|||
}
|
||||
|
||||
// Here I grab the packets to convert them to, So I can display them as if the disguise sent them.
|
||||
LibsPackets transformed =
|
||||
PacketsManager.getPacketsHandler().transformPacket(packet, disguise, observer, observer);
|
||||
LibsPackets transformed = PacketsManager.getPacketsHandler().transformPacket(packet, disguise, observer, observer);
|
||||
|
||||
if (transformed.isUnhandled()) {
|
||||
transformed.addPacket(packet);
|
||||
|
@ -75,7 +73,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
|||
|
||||
for (PacketContainer newPacket : transformed.getPackets()) {
|
||||
if (newPacket.getType() != Server.PLAYER_INFO && newPacket.getType() != Server.ENTITY_DESTROY &&
|
||||
newPacket.getIntegers().read(0) == observer.getEntityId()) {
|
||||
newPacket.getIntegers().read(0) == observer.getEntityId()) {
|
||||
if (newPacket == packet) {
|
||||
newPacket = newPacket.shallowClone();
|
||||
}
|
||||
|
@ -101,8 +99,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
|||
}
|
||||
|
||||
if (disguise.isPlayerDisguise()) {
|
||||
LibsDisguises.getInstance().getSkinHandler()
|
||||
.handlePackets(observer, (PlayerDisguise) disguise, selfTransformed);
|
||||
LibsDisguises.getInstance().getSkinHandler().handlePackets(observer, (PlayerDisguise) disguise, selfTransformed);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -117,7 +114,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
|||
|
||||
if (event.getPacketType() == Server.ENTITY_METADATA) {
|
||||
if (!LibsPremium.getPluginInformation().isPremium() || LibsPremium.getPaidInformation() != null ||
|
||||
LibsPremium.getPluginInformation().getBuildNumber().matches("#[0-9]+")) {
|
||||
LibsPremium.getPluginInformation().getBuildNumber().matches("#[0-9]+")) {
|
||||
event.setPacket(packet = packet.deepClone());
|
||||
}
|
||||
|
||||
|
@ -166,20 +163,16 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
|
|||
if (packet.getIntegers().read(1) != 2) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (event.getPacketType() == Server.ATTACH_ENTITY ||
|
||||
event.getPacketType() == Server.REL_ENTITY_MOVE ||
|
||||
event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK ||
|
||||
event.getPacketType() == Server.ENTITY_LOOK || event.getPacketType() == Server.ENTITY_TELEPORT ||
|
||||
event.getPacketType() == Server.ENTITY_HEAD_ROTATION ||
|
||||
event.getPacketType() == Server.ENTITY_EQUIPMENT) {
|
||||
} else if (event.getPacketType() == Server.ATTACH_ENTITY || event.getPacketType() == Server.REL_ENTITY_MOVE ||
|
||||
event.getPacketType() == Server.REL_ENTITY_MOVE_LOOK || event.getPacketType() == Server.ENTITY_LOOK ||
|
||||
event.getPacketType() == Server.ENTITY_TELEPORT || event.getPacketType() == Server.ENTITY_HEAD_ROTATION ||
|
||||
event.getPacketType() == Server.ENTITY_EQUIPMENT) {
|
||||
event.setCancelled(true);
|
||||
} else if (event.getPacketType() == Server.ENTITY_STATUS) {
|
||||
if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() &&
|
||||
packet.getBytes().read(0) == 2) {
|
||||
if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer() && packet.getBytes().read(0) == 2) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else if (event.getPacketType() == Server.ENTITY_VELOCITY &&
|
||||
!DisguiseUtilities.isPlayerVelocity(observer)) {
|
||||
} else if (event.getPacketType() == Server.ENTITY_VELOCITY && !DisguiseUtilities.isPlayerVelocity(observer)) {
|
||||
// The player only sees velocity changes when there is a velocity event. As the method claims there
|
||||
// was no velocity event...
|
||||
event.setCancelled(true);
|
||||
|
|
|
@ -3,7 +3,12 @@ package me.libraryaddict.disguise.utilities.params;
|
|||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 7/09/2018.
|
||||
|
@ -48,8 +53,7 @@ public abstract class ParamInfo {
|
|||
this(paramClass, name, name, description, possibleValues);
|
||||
}
|
||||
|
||||
public ParamInfo(Class paramClass, String name, String descriptiveName, String description,
|
||||
Map<String, Object> possibleValues) {
|
||||
public ParamInfo(Class paramClass, String name, String descriptiveName, String description, Map<String, Object> possibleValues) {
|
||||
this(paramClass, name, descriptiveName, description);
|
||||
|
||||
this.possibleValues = new LinkedHashMap<>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.libraryaddict.disguise.utilities.params;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
@ -14,7 +15,6 @@ import me.libraryaddict.disguise.utilities.watchers.DisguiseMethods;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
|
@ -8,23 +8,61 @@ import me.libraryaddict.disguise.disguisetypes.EntityPose;
|
|||
import me.libraryaddict.disguise.disguisetypes.GolemCrack;
|
||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||
import me.libraryaddict.disguise.utilities.params.types.ParamInfoEnum;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.*;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.*;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoBoolean;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoDouble;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoFloat;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoFloatNullable;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoInteger;
|
||||
import me.libraryaddict.disguise.utilities.params.types.base.ParamInfoString;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoBlockData;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoBlockPosition;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoChatColor;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoColor;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoEulerAngle;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoGameProfile;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemStack;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemStackArray;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoParticle;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoPotionEffect;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoSoundGroup;
|
||||
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoTime;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Axolotl;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.Fox;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Llama;
|
||||
import org.bukkit.entity.MushroomCow;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Panda;
|
||||
import org.bukkit.entity.Parrot;
|
||||
import org.bukkit.entity.TropicalFish;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.MainHand;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 7/09/2018.
|
||||
|
@ -47,54 +85,43 @@ public class ParamInfoTypes {
|
|||
// Register enum types
|
||||
//paramInfos.add(new ParamInfoEnum(AnimalColor.class, "Animal Color",
|
||||
// "View all the colors you can use for an animal color"));
|
||||
paramInfos
|
||||
.add(new ParamInfoEnum(Art.class, "Art", "View all the paintings you can use for a painting disguise"));
|
||||
paramInfos.add(new ParamInfoEnum(Horse.Color.class, "Horse Color",
|
||||
"View all the colors you can use for a horses color"));
|
||||
paramInfos.add(new ParamInfoEnum(Art.class, "Art", "View all the paintings you can use for a painting disguise"));
|
||||
paramInfos.add(new ParamInfoEnum(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color"));
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Profession.class, "Villager Profession",
|
||||
"View all the professions you can set on a Villager and Zombie Villager"));
|
||||
paramInfos.add(
|
||||
new ParamInfoEnum(Villager.Profession.class, "Villager Profession", "View all the professions you can set on a Villager and Zombie Villager"));
|
||||
|
||||
if (NmsVersion.v1_14.isSupported()) {
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome",
|
||||
"View all the biomes you can set on a Villager and Zombie Villager"));
|
||||
paramInfos.add(new ParamInfoEnum(Villager.Type.class, "Villager Biome", "View all the biomes you can set on a Villager and Zombie Villager"));
|
||||
}
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(BlockFace.class, "Direction", "Direction (North, East, South, West, Up, Down)",
|
||||
"View the directions usable on player setSleeping and shulker direction",
|
||||
Arrays.copyOf(BlockFace.values(), 6)));
|
||||
paramInfos
|
||||
.add(new ParamInfoEnum(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into"));
|
||||
paramInfos
|
||||
.add(new ParamInfoEnum(TreeSpecies.class, "Tree Species", "View the different types of tree species"));
|
||||
"View the directions usable on player setSleeping and shulker direction", Arrays.copyOf(BlockFace.values(), 6)));
|
||||
paramInfos.add(new ParamInfoEnum(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into"));
|
||||
paramInfos.add(new ParamInfoEnum(TreeSpecies.class, "Tree Species", "View the different types of tree species"));
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(MainHand.class, "Main Hand", "Set the main hand for an entity"));
|
||||
paramInfos.add(new ParamInfoEnum(Llama.Color.class, "Llama Color",
|
||||
"View all the colors you can use for a llama color"));
|
||||
paramInfos.add(new ParamInfoEnum(Parrot.Variant.class, "Parrot Variant",
|
||||
"View the different colors a parrot can be"));
|
||||
paramInfos.add(new ParamInfoEnum(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color"));
|
||||
paramInfos.add(new ParamInfoEnum(Parrot.Variant.class, "Parrot Variant", "View the different colors a parrot can be"));
|
||||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
paramInfos.add(new ParamInfoParticle(WrappedParticle.class, "Particle",
|
||||
"The different particles of Minecraft", Particle.values(), getMaterials()));
|
||||
paramInfos.add(new ParamInfoParticle(WrappedParticle.class, "Particle", "The different particles of Minecraft", Particle.values(), getMaterials()));
|
||||
paramInfos.add(new ParamInfoEnum(TropicalFish.Pattern.class, "Pattern", "Patterns of a tropical fish"));
|
||||
paramInfos.add(new ParamInfoBlockData(BlockData.class, "BlockData",
|
||||
"The block data states, barrel[facing=north,open=false] as example", getMaterials()));
|
||||
paramInfos.add(
|
||||
new ParamInfoBlockData(BlockData.class, "BlockData", "The block data states, barrel[facing=north,open=false] as example", getMaterials()));
|
||||
} else {
|
||||
paramInfos.add(new ParamInfoEnum(Particle.class, "Particle", "The different particles of Minecraft"));
|
||||
}
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(DyeColor.class, "DyeColor", "Dye colors of many different colors"));
|
||||
paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style",
|
||||
"Horse style which is the patterns on the horse"));
|
||||
paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style", "Horse style which is the patterns on the horse"));
|
||||
|
||||
if (NmsVersion.v1_14.isSupported()) {
|
||||
paramInfos.add(new ParamInfoEnum(EntityPose.class, "EntityPose", "The pose the entity should strike"));
|
||||
paramInfos.add(new ParamInfoEnum(Cat.Type.class, "Cat Type", "The type of cat"));
|
||||
paramInfos.add(new ParamInfoEnum(Fox.Type.class, "Fox Type", "The type of fox"));
|
||||
paramInfos.add(new ParamInfoEnum(Panda.Gene.class, "Panda Gene", "The panda gene type"));
|
||||
paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant",
|
||||
"The different variants for mushroom cows"));
|
||||
paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant", "The different variants for mushroom cows"));
|
||||
|
||||
if (NmsVersion.v1_17.isSupported()) {
|
||||
paramInfos.add(new ParamInfoEnum(Axolotl.Variant.class, "Axolotl Variant", "The variant of Axolotl"));
|
||||
|
@ -103,34 +130,25 @@ public class ParamInfoTypes {
|
|||
paramInfos.add(new ParamInfoEnum(Ocelot.Type.class, "Ocelot Type", "The type of ocelot"));
|
||||
}
|
||||
|
||||
paramInfos.add(new ParamInfoEnum(DisguiseConfig.NotifyBar.class, "NotifyBar",
|
||||
"Where the disguised indicator should appear"));
|
||||
paramInfos.add(new ParamInfoEnum(DisguiseConfig.NotifyBar.class, "NotifyBar", "Where the disguised indicator should appear"));
|
||||
paramInfos.add(new ParamInfoEnum(BarColor.class, "BarColor", "The color of the boss bar"));
|
||||
paramInfos.add(new ParamInfoEnum(BarStyle.class, "BarStyle", "The style of the boss bar"));
|
||||
|
||||
// Register custom types
|
||||
paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)",
|
||||
"Set the X,Y,Z directions on an armorstand"));
|
||||
paramInfos.add(new ParamInfoColor(Color.class, "Color", "Colors that can also be defined through RGB",
|
||||
getColors()));
|
||||
paramInfos.add(new ParamInfoEnum(Material.class, "Material", "A material used for blocks and items",
|
||||
getMaterials()));
|
||||
paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)", "Set the X,Y,Z directions on an armorstand"));
|
||||
paramInfos.add(new ParamInfoColor(Color.class, "Color", "Colors that can also be defined through RGB", getColors()));
|
||||
paramInfos.add(new ParamInfoEnum(Material.class, "Material", "A material used for blocks and items", getMaterials()));
|
||||
paramInfos.add(new ParamInfoItemStack(ItemStack.class, "ItemStack", "ItemStack (Material,Amount?,Glow?)",
|
||||
"An ItemStack compromised of Material,Amount,Glow. Only requires Material", getMaterials()));
|
||||
paramInfos.add(new ParamInfoItemStackArray(ItemStack[].class, "ItemStack[]",
|
||||
"Four ItemStacks (Material:Amount?:Glow?,Material:Amount?:Glow?..)",
|
||||
"Four ItemStacks separated by a comma", getMaterials()));
|
||||
paramInfos.add(new ParamInfoPotionEffect(PotionEffectType.class, "Potion Effect",
|
||||
"View all the potion effects you can add", getPotions()));
|
||||
"An ItemStack compromised of Material,Amount,Glow. Only requires Material", getMaterials()));
|
||||
paramInfos.add(new ParamInfoItemStackArray(ItemStack[].class, "ItemStack[]", "Four ItemStacks (Material:Amount?:Glow?,Material:Amount?:Glow?..)",
|
||||
"Four ItemStacks separated by a comma", getMaterials()));
|
||||
paramInfos.add(new ParamInfoPotionEffect(PotionEffectType.class, "Potion Effect", "View all the potion effects you can add", getPotions()));
|
||||
|
||||
paramInfos.add(new ParamInfoBlockPosition(BlockPosition.class, "Block Position", "Block Position (num,num,num)",
|
||||
"Three numbers separated by a ,"));
|
||||
paramInfos.add(new ParamInfoBlockPosition(BlockPosition.class, "Block Position", "Block Position (num,num,num)", "Three numbers separated by a ,"));
|
||||
paramInfos.add(new ParamInfoGameProfile(WrappedGameProfile.class, "GameProfile",
|
||||
"Get the gameprofile here https://sessionserver.mojang" +
|
||||
".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false"));
|
||||
"Get the gameprofile here https://sessionserver.mojang" + ".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false"));
|
||||
paramInfos.add(new ParamInfoTime(long.class, "Expiry Time",
|
||||
"Set how long the disguise lasts, <Num><Time><Num>... where <Time> is (s/sec)(m/min)(h/hour)(d/day) " +
|
||||
"etc. 30m20secs = 30 minutes, 20 seconds"));
|
||||
"Set how long the disguise lasts, <Num><Time><Num>... where <Time> is (s/sec)(m/min)(h/hour)(d/day) " + "etc. 30m20secs = 30 minutes, 20 seconds"));
|
||||
|
||||
paramInfos.add(new ParamInfoChatColor(ChatColor.class, "ChatColor", "A chat color"));
|
||||
paramInfos.add(new ParamInfoEnum(GolemCrack.class, "Golem Cracked", "The stage a golem has been cracked"));
|
||||
|
|
|
@ -17,7 +17,13 @@ public class ParamInfoDouble extends ParamInfo {
|
|||
|
||||
@Override
|
||||
protected Object fromString(String string) {
|
||||
return Double.parseDouble(string);
|
||||
double result = Double.parseDouble(string);
|
||||
|
||||
if (!Double.isFinite(result) || Math.abs(result) > 999_999_999) {
|
||||
throw new NumberFormatException("For input string: \"" + string + "\"");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue