Do some hacky magic to make ProtocolLib auto download if not there or outdated
This commit is contained in:
parent
35719f8317
commit
07c5abec43
@ -34,6 +34,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@ -60,11 +61,33 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
if (!Bukkit.getServer().getWorlds().isEmpty()) {
|
if (!Bukkit.getServer().getWorlds().isEmpty()) {
|
||||||
reloaded = true;
|
reloaded = true;
|
||||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " +
|
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
||||||
"reloads gracefully!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
|
||||||
|
|
||||||
|
if (plugin == null || DisguiseUtilities.isOlderThan(DisguiseUtilities.getProtocolLibRequiredVersion(), plugin.getDescription().getVersion())) {
|
||||||
|
getLogger().warning("Noticed you're using an older version of ProtocolLib (or not using it)! We're forcibly updating you!");
|
||||||
|
|
||||||
|
try {
|
||||||
|
File dest = DisguiseUtilities.updateProtocolLib();
|
||||||
|
|
||||||
|
if (plugin == null) {
|
||||||
|
getLogger().info("ProtocolLib downloaded and stuck in plugins folder! Now trying to load it!");
|
||||||
|
plugin = Bukkit.getPluginManager().loadPlugin(dest);
|
||||||
|
plugin.onLoad();
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||||
|
} else {
|
||||||
|
getLogger().severe("Please restar the server to complete the ProtocolLib update!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
@ -78,8 +101,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
if (reloaded) {
|
if (reloaded) {
|
||||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " +
|
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
||||||
"reloads gracefully!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -109,16 +131,12 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
LibsPremium.check(getDescription().getVersion(), getFile());
|
LibsPremium.check(getDescription().getVersion(), getFile());
|
||||||
|
|
||||||
if (!LibsPremium.isPremium()) {
|
if (!LibsPremium.isPremium()) {
|
||||||
getLogger()
|
getLogger().info("You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
|
||||||
.info("You are running the free version, commands limited to non-players and operators. (Console," +
|
|
||||||
" Command " + "Blocks, Admins)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ReflectionManager.getVersion() == null) {
|
if (ReflectionManager.getVersion() == null) {
|
||||||
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " +
|
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " + "intended for " +
|
||||||
"intended for " + StringUtils
|
StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!");
|
||||||
.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", "."))
|
|
||||||
.collect(Collectors.toList()), " & ") + "!");
|
|
||||||
getPluginLoader().disablePlugin(this);
|
getPluginLoader().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -128,11 +146,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
if (DisguiseUtilities.isOlderThan(requiredProtocolLib, version)) {
|
||||||
getLogger().severe("!! May I have your attention please !!");
|
getLogger().severe("!! May I have your attention please !!");
|
||||||
getLogger().severe("Update your ProtocolLib! You are running " + version +
|
getLogger().severe("Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
|
||||||
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
"!");
|
||||||
getLogger()
|
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target/ProtocolLib" + ".jar");
|
||||||
.severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target/ProtocolLib" +
|
|
||||||
".jar");
|
|
||||||
getLogger().severe("Or! Use /ld updateprotocollib - To update to the latest development build");
|
getLogger().severe("Or! Use /ld updateprotocollib - To update to the latest development build");
|
||||||
getLogger().severe("!! May I have your attention please !!");
|
getLogger().severe("!! May I have your attention please !!");
|
||||||
|
|
||||||
@ -140,13 +156,11 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
getLogger().severe("!! May I have your attention please !!");
|
getLogger().severe("!! May I have your attention please !!");
|
||||||
getLogger().severe("Update your ProtocolLib! You are running " + version +
|
getLogger().severe("Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " +
|
||||||
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
requiredProtocolLib + "!");
|
||||||
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" +
|
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
||||||
"/ProtocolLib" + ".jar");
|
|
||||||
getLogger().severe("Or! Use /ld updateprotocollib - To update to the latest development build");
|
getLogger().severe("Or! Use /ld updateprotocollib - To update to the latest development build");
|
||||||
getLogger()
|
getLogger().severe("This message is on repeat due to the sheer number of people who don't see this.");
|
||||||
.severe("This message is on repeat due to the sheer number of people who don't see this.");
|
|
||||||
}
|
}
|
||||||
}.runTaskTimer(this, 20, 10 * 60 * 20);
|
}.runTaskTimer(this, 20, 10 * 60 * 20);
|
||||||
}
|
}
|
||||||
@ -204,8 +218,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
registerCommand("disguisemodify", new DisguiseModifyCommand());
|
registerCommand("disguisemodify", new DisguiseModifyCommand());
|
||||||
registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand());
|
registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand());
|
||||||
registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand());
|
registerCommand("disguisemodifyplayer", new DisguiseModifyPlayerCommand());
|
||||||
registerCommand("disguisemodifyradius",
|
registerCommand("disguisemodifyradius", new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
||||||
new DisguiseModifyRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
|
||||||
registerCommand("copydisguise", new CopyDisguiseCommand());
|
registerCommand("copydisguise", new CopyDisguiseCommand());
|
||||||
registerCommand("grabskin", new GrabSkinCommand());
|
registerCommand("grabskin", new GrabSkinCommand());
|
||||||
registerCommand("savedisguise", new SaveDisguiseCommand());
|
registerCommand("savedisguise", new SaveDisguiseCommand());
|
||||||
|
@ -2,6 +2,7 @@ package me.libraryaddict.disguise.commands.libsdisguises;
|
|||||||
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -55,24 +56,7 @@ public class LDUpdateProtocolLib implements LDCommand {
|
|||||||
File protocolLibFile = null;
|
File protocolLibFile = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Method getFile = JavaPlugin.class.getDeclaredMethod("getFile");
|
DisguiseUtilities.updateProtocolLib();
|
||||||
getFile.setAccessible(true);
|
|
||||||
File theirFile = (File) getFile.invoke(ProtocolLibrary.getPlugin());
|
|
||||||
File dest = new File("plugins/update/" + theirFile.getName());
|
|
||||||
|
|
||||||
// We're connecting to spigot's API
|
|
||||||
URL url =
|
|
||||||
new URL("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" +
|
|
||||||
"/ProtocolLib" +
|
|
||||||
".jar");
|
|
||||||
// Creating a connection
|
|
||||||
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
|
||||||
con.setRequestProperty("User-Agent", "libraryaddict/LibsDisguises");
|
|
||||||
|
|
||||||
// Get the input stream, what we receive
|
|
||||||
try (InputStream input = con.getInputStream()) {
|
|
||||||
Files.copy(input, dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,6 +51,7 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scoreboard.Scoreboard;
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
@ -61,6 +62,8 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
@ -107,8 +110,7 @@ public class DisguiseUtilities {
|
|||||||
if (!nameVisible) {
|
if (!nameVisible) {
|
||||||
team.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
team.setOption(Option.NAME_TAG_VISIBILITY, OptionStatus.NEVER);
|
||||||
}
|
}
|
||||||
} else if (team.getOption(Option.NAME_TAG_VISIBILITY) !=
|
} else if (team.getOption(Option.NAME_TAG_VISIBILITY) != (nameVisible ? OptionStatus.ALWAYS : OptionStatus.NEVER)) {
|
||||||
(nameVisible ? OptionStatus.ALWAYS : OptionStatus.NEVER)) {
|
|
||||||
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisible ? OptionStatus.ALWAYS : OptionStatus.NEVER);
|
team.setOption(Option.NAME_TAG_VISIBILITY, nameVisible ? OptionStatus.ALWAYS : OptionStatus.NEVER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -159,8 +161,7 @@ public class DisguiseUtilities {
|
|||||||
@Getter
|
@Getter
|
||||||
private static Gson gson;
|
private static Gson gson;
|
||||||
@Getter
|
@Getter
|
||||||
private static boolean pluginsUsed, commandsUsed, copyDisguiseCommandUsed, grabSkinCommandUsed,
|
private static boolean pluginsUsed, commandsUsed, copyDisguiseCommandUsed, grabSkinCommandUsed, saveDisguiseCommandUsed, grabHeadCommandUsed;
|
||||||
saveDisguiseCommandUsed, grabHeadCommandUsed;
|
|
||||||
private static long libsDisguisesCalled;
|
private static long libsDisguisesCalled;
|
||||||
/**
|
/**
|
||||||
* Keeps track of what tick this occured
|
* Keeps track of what tick this occured
|
||||||
@ -243,8 +244,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(playerName);
|
Team team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(playerName);
|
||||||
|
|
||||||
if (team != null && (team.getColor() != ChatColor.RESET || !StringUtils.isEmpty(team.getPrefix()) ||
|
if (team != null && (team.getColor() != ChatColor.RESET || !StringUtils.isEmpty(team.getPrefix()) || !StringUtils.isEmpty(team.getSuffix()))) {
|
||||||
!StringUtils.isEmpty(team.getSuffix()))) {
|
|
||||||
return team.getPrefix() + team.getColor() + playerName + team.getSuffix();
|
return team.getPrefix() + team.getColor() + playerName + team.getSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,8 +256,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getUniqueId().toString());
|
team = Bukkit.getScoreboardManager().getMainScoreboard().getEntryTeam(player.getUniqueId().toString());
|
||||||
|
|
||||||
if (team == null || (team.getColor() != ChatColor.RESET ||
|
if (team == null || (team.getColor() != ChatColor.RESET || StringUtils.isEmpty(team.getPrefix()) && StringUtils.isEmpty(team.getSuffix()))) {
|
||||||
StringUtils.isEmpty(team.getPrefix()) && StringUtils.isEmpty(team.getSuffix()))) {
|
|
||||||
String name = player.getDisplayName();
|
String name = player.getDisplayName();
|
||||||
|
|
||||||
if (name.equals(playerName)) {
|
if (name.equals(playerName)) {
|
||||||
@ -286,8 +285,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Files.write(viewPreferencesTemp.toPath(), json.getBytes());
|
Files.write(viewPreferencesTemp.toPath(), json.getBytes());
|
||||||
Files.move(viewPreferencesTemp.toPath(), viewPreferences.toPath(), StandardCopyOption.REPLACE_EXISTING,
|
Files.move(viewPreferencesTemp.toPath(), viewPreferences.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
|
||||||
StandardCopyOption.ATOMIC_MOVE);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -305,9 +303,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void sendInvisibleSlime(Player player, int horseId) {
|
public static void sendInvisibleSlime(Player player, int horseId) {
|
||||||
PacketContainer packet =
|
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY_LIVING, player).createPacket(player);
|
||||||
ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY_LIVING, player)
|
|
||||||
.createPacket(player);
|
|
||||||
|
|
||||||
packet.getModifier().write(0, DisguiseAPI.getEntityAttachmentId());
|
packet.getModifier().write(0, DisguiseAPI.getEntityAttachmentId());
|
||||||
packet.getModifier().write(1, UUID.randomUUID());
|
packet.getModifier().write(1, UUID.randomUUID());
|
||||||
@ -315,15 +311,13 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
WrappedDataWatcher watcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
WrappedDataWatcher.WrappedDataWatcherObject obj =
|
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(MetaIndex.SLIME_SIZE, 0);
|
||||||
ReflectionManager.createDataWatcherObject(MetaIndex.SLIME_SIZE, 0);
|
|
||||||
|
|
||||||
watcher.setObject(obj, 0);
|
watcher.setObject(obj, 0);
|
||||||
|
|
||||||
if (NmsVersion.v1_15.isSupported()) {
|
if (NmsVersion.v1_15.isSupported()) {
|
||||||
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
||||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA,
|
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, DisguiseAPI.getEntityAttachmentId(), watcher, true)
|
||||||
DisguiseAPI.getEntityAttachmentId(), watcher, true)
|
|
||||||
.createPacket(DisguiseAPI.getEntityAttachmentId(), watcher, true);
|
.createPacket(DisguiseAPI.getEntityAttachmentId(), watcher, true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -415,6 +409,31 @@ public class DisguiseUtilities {
|
|||||||
return !NmsVersion.v1_13.isSupported() ? "4.4.0" : NmsVersion.v1_16.isSupported() ? "4.6.0" : "4.5.1";
|
return !NmsVersion.v1_13.isSupported() ? "4.4.0" : NmsVersion.v1_16.isSupported() ? "4.6.0" : "4.5.1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static File updateProtocolLib() throws Exception {
|
||||||
|
File dest = new File("plugins/ProtocolLib.jar");
|
||||||
|
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||||
|
Method getFile = JavaPlugin.class.getDeclaredMethod("getFile");
|
||||||
|
getFile.setAccessible(true);
|
||||||
|
|
||||||
|
File theirFile = (File) getFile.invoke(ProtocolLibrary.getPlugin());
|
||||||
|
dest = new File("plugins/update/" + theirFile.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're connecting to spigot's API
|
||||||
|
URL url = new URL("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target/ProtocolLib.jar");
|
||||||
|
// Creating a connection
|
||||||
|
HttpURLConnection con = (HttpURLConnection) url.openConnection();
|
||||||
|
con.setRequestProperty("User-Agent", "libraryaddict/LibsDisguises");
|
||||||
|
|
||||||
|
// Get the input stream, what we receive
|
||||||
|
try (InputStream input = con.getInputStream()) {
|
||||||
|
Files.copy(input, dest.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if this velocity is due to a PlayerVelocityEvent
|
* Returns if this velocity is due to a PlayerVelocityEvent
|
||||||
*/
|
*/
|
||||||
@ -501,8 +520,7 @@ public class DisguiseUtilities {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disg.getEntity() instanceof Player ? !DisguiseConfig.isSavePlayerDisguises() :
|
if (disg.getEntity() instanceof Player ? !DisguiseConfig.isSavePlayerDisguises() : !DisguiseConfig.isSaveEntityDisguises()) {
|
||||||
!DisguiseConfig.isSaveEntityDisguises()) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -582,8 +600,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
// I hear pirates don't obey standards
|
// I hear pirates don't obey standards
|
||||||
@SuppressWarnings("MismatchedStringCase")
|
@SuppressWarnings("MismatchedStringCase")
|
||||||
PrintWriter writer =
|
PrintWriter writer = new PrintWriter(disguiseFile, "12345".equals("%%__USER__%%") ? "US-ASCII" : "UTF-8");
|
||||||
new PrintWriter(disguiseFile, "12345".equals("%%__USER__%%") ? "US-ASCII" : "UTF-8");
|
|
||||||
writer.write(gson.toJson(disguises));
|
writer.write(gson.toJson(disguises));
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|
||||||
@ -703,8 +720,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("a%%__USER__%%a".equals("a12345a") || (LibsPremium.getUserID().matches("[0-9]+") &&
|
if ("a%%__USER__%%a".equals("a12345a") ||
|
||||||
!("" + Integer.parseInt(LibsPremium.getUserID())).equals(LibsPremium.getUserID()))) {
|
(LibsPremium.getUserID().matches("[0-9]+") && !("" + Integer.parseInt(LibsPremium.getUserID())).equals(LibsPremium.getUserID()))) {
|
||||||
if (Bukkit.getOnlinePlayers().stream().noneMatch(p -> p.isOp() || p.hasPermission("*"))) {
|
if (Bukkit.getOnlinePlayers().stream().noneMatch(p -> p.isOp() || p.hasPermission("*"))) {
|
||||||
World world = Bukkit.getWorlds().get(0);
|
World world = Bukkit.getWorlds().get(0);
|
||||||
|
|
||||||
@ -714,8 +731,7 @@ public class DisguiseUtilities {
|
|||||||
ItemStack stack = new ItemStack(Material.GOLD_INGOT);
|
ItemStack stack = new ItemStack(Material.GOLD_INGOT);
|
||||||
ItemMeta meta = stack.getItemMeta();
|
ItemMeta meta = stack.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.GOLD + "Pirate's Treasure");
|
meta.setDisplayName(ChatColor.GOLD + "Pirate's Treasure");
|
||||||
meta.setLore(Arrays.asList(ChatColor.GRAY + "Dis be pirate loot",
|
meta.setLore(Arrays.asList(ChatColor.GRAY + "Dis be pirate loot", ChatColor.GRAY + "for a pirate server"));
|
||||||
ChatColor.GRAY + "for a pirate server"));
|
|
||||||
stack.setItemMeta(meta);
|
stack.setItemMeta(meta);
|
||||||
|
|
||||||
Item item = p.getWorld().dropItemNaturally(p.getLocation(), stack);
|
Item item = p.getWorld().dropItemNaturally(p.getLocation(), stack);
|
||||||
@ -727,8 +743,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
checkConflicts(disguise, null);
|
checkConflicts(disguise, null);
|
||||||
|
|
||||||
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) {
|
||||||
disguise.isModifyBoundingBox()) {
|
|
||||||
doBoundingBox(disguise);
|
doBoundingBox(disguise);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -753,8 +768,7 @@ public class DisguiseUtilities {
|
|||||||
final BukkitRunnable runnable = new BukkitRunnable() {
|
final BukkitRunnable runnable = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!getFutureDisguises().containsKey(entityId) ||
|
if (!getFutureDisguises().containsKey(entityId) || !getFutureDisguises().get(entityId).contains(disguise)) {
|
||||||
!getFutureDisguises().get(entityId).contains(disguise)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -883,8 +897,7 @@ public class DisguiseUtilities {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set trackedPlayers =
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
(Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
|
||||||
|
|
||||||
// If the tracker exists. Remove himself from his tracker
|
// If the tracker exists. Remove himself from his tracker
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||||
@ -918,10 +931,8 @@ public class DisguiseUtilities {
|
|||||||
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
FakeBoundingBox disguiseBox = disguiseValues.getAdultBox();
|
||||||
|
|
||||||
if (disguiseValues.getBabyBox() != null) {
|
if (disguiseValues.getBabyBox() != null) {
|
||||||
if ((disguise.getWatcher() instanceof AgeableWatcher &&
|
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby()) ||
|
||||||
((AgeableWatcher) disguise.getWatcher()).isBaby()) ||
|
(disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()).isBaby())) {
|
||||||
(disguise.getWatcher() instanceof ZombieWatcher &&
|
|
||||||
((ZombieWatcher) disguise.getWatcher()).isBaby())) {
|
|
||||||
disguiseBox = disguiseValues.getBabyBox();
|
disguiseBox = disguiseValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -933,8 +944,7 @@ public class DisguiseUtilities {
|
|||||||
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
FakeBoundingBox entityBox = entityValues.getAdultBox();
|
||||||
|
|
||||||
if (entityValues.getBabyBox() != null) {
|
if (entityValues.getBabyBox() != null) {
|
||||||
if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) ||
|
if ((entity instanceof Ageable && !((Ageable) entity).isAdult()) || (entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
||||||
(entity instanceof Zombie && ((Zombie) entity).isBaby())) {
|
|
||||||
entityBox = entityValues.getBabyBox();
|
entityBox = entityValues.getBabyBox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1024,8 +1034,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
return gson.fromJson(cached, WrappedGameProfile.class);
|
return gson.fromJson(cached, WrappedGameProfile.class);
|
||||||
} catch (JsonSyntaxException ex) {
|
} catch (JsonSyntaxException ex) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger().warning("Gameprofile " + file.getName() + " had invalid gson and has been deleted");
|
||||||
.warning("Gameprofile " + file.getName() + " had invalid gson and has been deleted");
|
|
||||||
cachedNames.remove(playerName);
|
cachedNames.remove(playerName);
|
||||||
file.delete();
|
file.delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1063,8 +1072,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getEntity() == null) {
|
if (disguise.getEntity() == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("The entity for the disguisetype " + disguise.getType().name() + " is null!");
|
||||||
"The entity for the disguisetype " + disguise.getType().name() + " is null!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Player> players = new ArrayList<>();
|
List<Player> players = new ArrayList<>();
|
||||||
@ -1073,8 +1081,7 @@ public class DisguiseUtilities {
|
|||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
|
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
.get(entityTrackerEntry);
|
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
for (Object p : trackedPlayers) {
|
for (Object p : trackedPlayers) {
|
||||||
@ -1100,8 +1107,7 @@ public class DisguiseUtilities {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName()
|
if (DisguiseAPI.isDisguiseInUse(disguise) && (!gameProfile.getName().equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) ||
|
||||||
.equals(disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) ||
|
|
||||||
!gameProfile.getProperties().isEmpty())) {
|
!gameProfile.getProperties().isEmpty())) {
|
||||||
disguise.setGameProfile(gameProfile);
|
disguise.setGameProfile(gameProfile);
|
||||||
|
|
||||||
@ -1124,13 +1130,11 @@ public class DisguiseUtilities {
|
|||||||
* a lookup
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn,
|
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn, boolean contactMojang) {
|
||||||
boolean contactMojang) {
|
|
||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable,
|
private static WrappedGameProfile getProfileFromMojang(final String origName, final Object runnable, boolean contactMojang) {
|
||||||
boolean contactMojang) {
|
|
||||||
final String playerName = origName.toLowerCase(Locale.ENGLISH);
|
final String playerName = origName.toLowerCase(Locale.ENGLISH);
|
||||||
|
|
||||||
if (DisguiseConfig.isSaveGameProfiles() && hasGameProfile(playerName)) {
|
if (DisguiseConfig.isSaveGameProfiles() && hasGameProfile(playerName)) {
|
||||||
@ -1190,8 +1194,7 @@ public class DisguiseUtilities {
|
|||||||
runnables.remove(playerName);
|
runnables.remove(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().severe("Error when fetching " + playerName + "'s uuid from mojang: " +
|
getLogger().severe("Error when fetching " + playerName + "'s uuid from mojang: " + e.getMessage());
|
||||||
e.getMessage());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (runnable != null && contactMojang) {
|
} else if (runnable != null && contactMojang) {
|
||||||
@ -1219,8 +1222,7 @@ public class DisguiseUtilities {
|
|||||||
* a lookup
|
* a lookup
|
||||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||||
*/
|
*/
|
||||||
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn,
|
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn, boolean contactMojang) {
|
||||||
boolean contactMojang) {
|
|
||||||
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
|
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn, contactMojang);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1267,8 +1269,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
cachedNames.addAll(Arrays.asList(profileCache.list()));
|
cachedNames.addAll(Arrays.asList(profileCache.list()));
|
||||||
|
|
||||||
invalidFile = LibsDisguises.getInstance().getFile().getName().toLowerCase(Locale.ENGLISH)
|
invalidFile = LibsDisguises.getInstance().getFile().getName().toLowerCase(Locale.ENGLISH).matches(".*((crack)|(null)|(leak)).*");
|
||||||
.matches(".*((crack)|(null)|(leak)).*");
|
|
||||||
|
|
||||||
for (String key : savedDisguises.list()) {
|
for (String key : savedDisguises.list()) {
|
||||||
try {
|
try {
|
||||||
@ -1358,8 +1359,7 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player &&
|
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player && disguise.getEntity().getName().equalsIgnoreCase(player)) {
|
||||||
disguise.getEntity().getName().equalsIgnoreCase(player)) {
|
|
||||||
removeSelfDisguise(disguise);
|
removeSelfDisguise(disguise);
|
||||||
|
|
||||||
if (disguise.isSelfDisguiseVisible()) {
|
if (disguise.isSelfDisguiseVisible()) {
|
||||||
@ -1382,16 +1382,13 @@ public class DisguiseUtilities {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
.get(entityTrackerEntry);
|
|
||||||
|
|
||||||
Method clear = ReflectionManager
|
Method clear = ReflectionManager
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
|
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
final Method updatePlayer = ReflectionManager
|
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
@ -1438,16 +1435,13 @@ public class DisguiseUtilities {
|
|||||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity);
|
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity);
|
||||||
|
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
.get(entityTrackerEntry);
|
|
||||||
|
|
||||||
Method clear = ReflectionManager
|
Method clear = ReflectionManager
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
|
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
final Method updatePlayer = ReflectionManager
|
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
|
||||||
// ConcurrentModificationException
|
// ConcurrentModificationException
|
||||||
@ -1509,16 +1503,13 @@ public class DisguiseUtilities {
|
|||||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
|
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
.get(entityTrackerEntry);
|
|
||||||
|
|
||||||
final Method clear = ReflectionManager
|
final Method clear = ReflectionManager
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear",
|
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "a" : "clear", ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
final Method updatePlayer = ReflectionManager
|
final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
||||||
.getNmsMethod("EntityTrackerEntry", NmsVersion.v1_14.isSupported() ? "b" : "updatePlayer",
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
|
||||||
|
|
||||||
trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
|
trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
|
||||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
@ -1564,8 +1555,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS &&
|
if (disguise.getDisguiseTarget() == TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS && disguise.isModifyBoundingBox()) {
|
||||||
disguise.isModifyBoundingBox()) {
|
|
||||||
doBoundingBox(disguise);
|
doBoundingBox(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1625,13 +1615,12 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
// If the tracker exists. Remove himself from his tracker
|
// If the tracker exists. Remove himself from his tracker
|
||||||
if (!runningPaper) {
|
if (!runningPaper) {
|
||||||
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
.get(entityTrackerEntry);
|
|
||||||
|
|
||||||
((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getNmsEntity(player));
|
((Set<Object>) trackedPlayersObj).remove(ReflectionManager.getNmsEntity(player));
|
||||||
} else {
|
} else {
|
||||||
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap")
|
((Map<Object, Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayerMap").get(entityTrackerEntry))
|
||||||
.get(entityTrackerEntry)).remove(ReflectionManager.getNmsEntity(player));
|
.remove(ReflectionManager.getNmsEntity(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -1641,8 +1630,7 @@ public class DisguiseUtilities {
|
|||||||
// Resend entity metadata else he will be invisible to himself until its resent
|
// Resend entity metadata else he will be invisible to himself until its resent
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, ProtocolLibrary.getProtocolManager()
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, ProtocolLibrary.getProtocolManager()
|
||||||
.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(),
|
.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true)
|
||||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
|
||||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -1839,8 +1827,7 @@ public class DisguiseUtilities {
|
|||||||
String colors = ChatColor.getLastColors(prefix);
|
String colors = ChatColor.getLastColors(prefix);
|
||||||
|
|
||||||
// We found our prefix. Now we check about seperating it between name and suffix
|
// We found our prefix. Now we check about seperating it between name and suffix
|
||||||
for (int nameLen = Math.min(name.length() - (prefixLen + colors.length()), limit - colors.length());
|
for (int nameLen = Math.min(name.length() - (prefixLen + colors.length()), limit - colors.length()); nameLen > 0; nameLen--) {
|
||||||
nameLen > 0; nameLen--) {
|
|
||||||
String nName = colors + name.substring(prefixLen, nameLen + prefixLen);
|
String nName = colors + name.substring(prefixLen, nameLen + prefixLen);
|
||||||
|
|
||||||
if (nName.endsWith("" + ChatColor.COLOR_CHAR)) {
|
if (nName.endsWith("" + ChatColor.COLOR_CHAR)) {
|
||||||
@ -1940,9 +1927,7 @@ public class DisguiseUtilities {
|
|||||||
OptionStatus collisions = ldTeam.getOption(Option.COLLISION_RULE);
|
OptionStatus collisions = ldTeam.getOption(Option.COLLISION_RULE);
|
||||||
|
|
||||||
if (collisions != OptionStatus.NEVER && collisions != OptionStatus.FOR_OTHER_TEAMS) {
|
if (collisions != OptionStatus.NEVER && collisions != OptionStatus.FOR_OTHER_TEAMS) {
|
||||||
getLogger().warning(
|
getLogger().warning("Scoreboard conflict, the collisions for a self disguise player team has been " + "unexpectedly modifed!");
|
||||||
"Scoreboard conflict, the collisions for a self disguise player team has been " +
|
|
||||||
"unexpectedly modifed!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1971,8 +1956,7 @@ public class DisguiseUtilities {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((LibsPremium.getPluginInformation() != null && LibsPremium.getPluginInformation().isPremium() &&
|
if ((LibsPremium.getPluginInformation() != null && LibsPremium.getPluginInformation().isPremium() && !LibsPremium.getPluginInformation().isLegit()) ||
|
||||||
!LibsPremium.getPluginInformation().isLegit()) ||
|
|
||||||
(LibsPremium.getPaidInformation() != null && !LibsPremium.getPaidInformation().isLegit())) {
|
(LibsPremium.getPaidInformation() != null && !LibsPremium.getPaidInformation().isLegit())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2082,9 +2066,7 @@ public class DisguiseUtilities {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "\"" +
|
return "\"" + string.replaceAll("\\\\(?=\\\\*\"( |$))", "\\\\\\\\").replaceAll("((?<= )\")|(\"(?= ))", "\\\\\"") + "\"";
|
||||||
string.replaceAll("\\\\(?=\\\\*\"( |$))", "\\\\\\\\").replaceAll("((?<= )\")|(\"(?= ))", "\\\\\"") +
|
|
||||||
"\"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String quoteNewLine(String string) {
|
public static String quoteNewLine(String string) {
|
||||||
@ -2236,8 +2218,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() ||
|
if (!disguise.isDisguiseInUse() || !player.isValid() || !player.isOnline() || !disguise.isSelfDisguiseVisible() || !disguise.canSee(player)) {
|
||||||
!disguise.isSelfDisguiseVisible() || !disguise.canSee(player)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2262,8 +2243,7 @@ public class DisguiseUtilities {
|
|||||||
// Check for code differences in PaperSpigot vs Spigot
|
// Check for code differences in PaperSpigot vs Spigot
|
||||||
if (!runningPaper) {
|
if (!runningPaper) {
|
||||||
// Add himself to his own entity tracker
|
// Add himself to his own entity tracker
|
||||||
Object trackedPlayersObj =
|
Object trackedPlayersObj = ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
||||||
ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry);
|
|
||||||
|
|
||||||
((Set<Object>) trackedPlayersObj).add(ReflectionManager.getNmsEntity(player));
|
((Set<Object>) trackedPlayersObj).add(ReflectionManager.getNmsEntity(player));
|
||||||
} else {
|
} else {
|
||||||
@ -2275,20 +2255,17 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||||
// Send the player a packet with himself being spawned
|
// Send the player a packet with himself being spawned
|
||||||
manager.sendServerPacket(player,
|
manager.sendServerPacket(player, manager.createPacketConstructor(Server.NAMED_ENTITY_SPAWN, player).createPacket(player));
|
||||||
manager.createPacketConstructor(Server.NAMED_ENTITY_SPAWN, player).createPacket(player));
|
|
||||||
|
|
||||||
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player);
|
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(player);
|
||||||
|
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true)
|
||||||
manager.createPacketConstructor(Server.ENTITY_METADATA, player.getEntityId(), dataWatcher, true)
|
.createPacket(player.getEntityId(), dataWatcher, true));
|
||||||
.createPacket(player.getEntityId(), dataWatcher, true));
|
|
||||||
|
|
||||||
boolean isMoving = false;
|
boolean isMoving = false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Field field = ReflectionManager.getNmsClass("EntityTrackerEntry")
|
Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField(NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
|
||||||
.getDeclaredField(NmsVersion.v1_14.isSupported() ? "q" : "isMoving");
|
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
isMoving = field.getBoolean(entityTrackerEntry);
|
isMoving = field.getBoolean(entityTrackerEntry);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -2298,37 +2275,31 @@ public class DisguiseUtilities {
|
|||||||
// Send the velocity packets
|
// Send the velocity packets
|
||||||
if (isMoving) {
|
if (isMoving) {
|
||||||
Vector velocity = player.getVelocity();
|
Vector velocity = player.getVelocity();
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_VELOCITY, player).createPacket(player));
|
||||||
manager.createPacketConstructor(Server.ENTITY_VELOCITY, player).createPacket(player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Why the hell would he even need this. Meh.
|
// Why the hell would he even need this. Meh.
|
||||||
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player,
|
||||||
manager.createPacketConstructor(Server.ATTACH_ENTITY, player, player.getVehicle())
|
manager.createPacketConstructor(Server.ATTACH_ENTITY, player, player.getVehicle()).createPacket(player, player.getVehicle()));
|
||||||
.createPacket(player, player.getVehicle()));
|
|
||||||
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
|
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player,
|
||||||
manager.createPacketConstructor(Server.ATTACH_ENTITY, player.getPassenger(), player)
|
manager.createPacketConstructor(Server.ATTACH_ENTITY, player.getPassenger(), player).createPacket(player.getPassenger(), player));
|
||||||
.createPacket(player.getPassenger(), player));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NmsVersion.v1_16.isSupported()) {
|
if (NmsVersion.v1_16.isSupported()) {
|
||||||
List<Pair<Object, Object>> list = new ArrayList<>();
|
List<Pair<Object, Object>> list = new ArrayList<>();
|
||||||
|
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot),
|
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot), ReflectionManager.getNmsItem(player.getInventory().getItem(slot))));
|
||||||
ReflectionManager.getNmsItem(player.getInventory().getItem(slot))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, list).createPacket(0, list));
|
||||||
manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, list).createPacket(0, list));
|
|
||||||
} else {
|
} else {
|
||||||
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
Object item = ReflectionManager.getNmsItem(getSlot(player.getInventory(), slot));
|
Object item = ReflectionManager.getNmsItem(getSlot(player.getInventory(), slot));
|
||||||
|
|
||||||
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0,
|
sendSelfPacket(player, manager.createPacketConstructor(Server.ENTITY_EQUIPMENT, 0, ReflectionManager.createEnumItemSlot(slot), item)
|
||||||
ReflectionManager.createEnumItemSlot(slot), item)
|
|
||||||
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(slot), item));
|
.createPacket(player.getEntityId(), ReflectionManager.createEnumItemSlot(slot), item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2337,8 +2308,7 @@ public class DisguiseUtilities {
|
|||||||
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||||
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player,
|
||||||
manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
|
manager.createPacketConstructor(Server.ENTITY_EFFECT, player.getEntityId(), mobEffect).createPacket(player.getEntityId(), mobEffect));
|
||||||
.createPacket(player.getEntityId(), mobEffect));
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -2410,9 +2380,7 @@ public class DisguiseUtilities {
|
|||||||
String string = color.toString();
|
String string = color.toString();
|
||||||
|
|
||||||
if (string.length() > 2) {
|
if (string.length() > 2) {
|
||||||
builder.append("<#")
|
builder.append("<#").append(string.substring(2).replace(net.md_5.bungee.api.ChatColor.COLOR_CHAR + "", "")).append(">");
|
||||||
.append(string.substring(2).replace(net.md_5.bungee.api.ChatColor.COLOR_CHAR + "", ""))
|
|
||||||
.append(">");
|
|
||||||
} else {
|
} else {
|
||||||
builder.append(string);
|
builder.append(string);
|
||||||
}
|
}
|
||||||
@ -2537,8 +2505,7 @@ public class DisguiseUtilities {
|
|||||||
component = new TextComponent(component);
|
component = new TextComponent(component);
|
||||||
String urlString = message.substring(i, pos);
|
String urlString = message.substring(i, pos);
|
||||||
component.setText(unquoteHex(urlString));
|
component.setText(unquoteHex(urlString));
|
||||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL,
|
component.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, urlString.startsWith("http") ? urlString : "http://" + urlString));
|
||||||
urlString.startsWith("http") ? urlString : "http://" + urlString));
|
|
||||||
components.add(component);
|
components.add(component);
|
||||||
i += pos - i - 1;
|
i += pos - i - 1;
|
||||||
component = old;
|
component = old;
|
||||||
@ -2556,12 +2523,9 @@ public class DisguiseUtilities {
|
|||||||
public static void sendProtocolLibUpdateMessage(CommandSender p, String version, String requiredProtocolLib) {
|
public static void sendProtocolLibUpdateMessage(CommandSender p, String version, String requiredProtocolLib) {
|
||||||
p.sendMessage(ChatColor.RED + "Please ask the server owner to update ProtocolLib! You are running " + version +
|
p.sendMessage(ChatColor.RED + "Please ask the server owner to update ProtocolLib! You are running " + version +
|
||||||
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
" but the minimum version you should be on is " + requiredProtocolLib + "!");
|
||||||
p.sendMessage(ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" +
|
p.sendMessage(ChatColor.RED + "https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
||||||
"/ProtocolLib" + ".jar");
|
p.sendMessage(ChatColor.RED + "Or! Use " + ChatColor.DARK_RED + "/ld updatepl" + ChatColor.RED + " - To update to the latest development build");
|
||||||
p.sendMessage(ChatColor.RED + "Or! Use " + ChatColor.DARK_RED + "/ld updatepl" + ChatColor.RED +
|
p.sendMessage(ChatColor.DARK_GREEN + "This message is `kindly` provided by Lib's Disguises on repeat to all players due to the sheer " +
|
||||||
" - To update to the latest development build");
|
|
||||||
p.sendMessage(ChatColor.DARK_GREEN +
|
|
||||||
"This message is `kindly` provided by Lib's Disguises on repeat to all players due to the sheer " +
|
|
||||||
"number of people who don't see it");
|
"number of people who don't see it");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2622,8 +2586,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.isPlayerDisguise()) {
|
if (disguise.isPlayerDisguise()) {
|
||||||
LibsDisguises.getInstance().getSkinHandler()
|
LibsDisguises.getInstance().getSkinHandler().handlePackets(player, (PlayerDisguise) disguise, newPackets);
|
||||||
.handlePackets(player, (PlayerDisguise) disguise, newPackets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PacketContainer p : newPackets.getPackets()) {
|
for (PacketContainer p : newPackets.getPackets()) {
|
||||||
@ -2641,8 +2604,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
addTab.getPlayerInfoAction().write(0, action);
|
addTab.getPlayerInfoAction().write(0, action);
|
||||||
addTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
addTab.getPlayerInfoDataLists().write(0, Collections.singletonList(
|
||||||
new PlayerInfoData(disguise.getGameProfile(), 0, EnumWrappers.NativeGameMode.SURVIVAL,
|
new PlayerInfoData(disguise.getGameProfile(), 0, EnumWrappers.NativeGameMode.SURVIVAL, WrappedChatComponent.fromText(disguise.getName()))));
|
||||||
WrappedChatComponent.fromText(disguise.getName()))));
|
|
||||||
|
|
||||||
return addTab;
|
return addTab;
|
||||||
}
|
}
|
||||||
@ -2656,8 +2618,7 @@ public class DisguiseUtilities {
|
|||||||
Entity e = disguise.getEntity();
|
Entity e = disguise.getEntity();
|
||||||
|
|
||||||
// If the disguises entity is null, or the disguised entity isn't a player; return
|
// If the disguises entity is null, or the disguised entity isn't a player; return
|
||||||
if (!(e instanceof Player) || !getDisguises().containsKey(e.getEntityId()) ||
|
if (!(e instanceof Player) || !getDisguises().containsKey(e.getEntityId()) || !getDisguises().get(e.getEntityId()).contains(disguise)) {
|
||||||
!getDisguises().get(e.getEntityId()).contains(disguise)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2672,8 +2633,7 @@ public class DisguiseUtilities {
|
|||||||
DisguiseUtilities.removeSelfDisguise(disguise);
|
DisguiseUtilities.removeSelfDisguise(disguise);
|
||||||
|
|
||||||
// If the disguised player can't see himself. Return
|
// If the disguised player can't see himself. Return
|
||||||
if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() ||
|
if (!disguise.isSelfDisguiseVisible() || !PacketsManager.isViewDisguisesListenerEnabled() || player.getVehicle() != null) {
|
||||||
player.getVehicle() != null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2720,10 +2680,9 @@ public class DisguiseUtilities {
|
|||||||
Object value = index.getDefault();
|
Object value = index.getDefault();
|
||||||
|
|
||||||
throw new IllegalArgumentException("Unable to find Serializer for " + value +
|
throw new IllegalArgumentException("Unable to find Serializer for " + value +
|
||||||
(value instanceof Optional && ((Optional) value).isPresent() ?
|
(value instanceof Optional && ((Optional) value).isPresent() ? " (" + ((Optional) value).get().getClass().getName() + ")" :
|
||||||
" (" + ((Optional) value).get().getClass().getName() + ")" :
|
value instanceof Optional || value == null ? "" : " " + value.getClass().getName()) + "! Are you running " + "the latest " +
|
||||||
value instanceof Optional || value == null ? "" : " " + value.getClass().getName()) +
|
"version of " + "ProtocolLib?");
|
||||||
"! Are you running " + "the latest " + "version of " + "ProtocolLib?");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String serialize(NbtBase base) {
|
public static String serialize(NbtBase base) {
|
||||||
@ -2759,8 +2718,7 @@ public class DisguiseUtilities {
|
|||||||
case TAG_LIST:
|
case TAG_LIST:
|
||||||
Collection col = ((NbtList) base).asCollection();
|
Collection col = ((NbtList) base).asCollection();
|
||||||
|
|
||||||
return "[" + StringUtils.join(col.stream().map(b -> serialize(depth + 1, (NbtBase) b)).toArray(), ",") +
|
return "[" + StringUtils.join(col.stream().map(b -> serialize(depth + 1, (NbtBase) b)).toArray(), ",") + "]";
|
||||||
"]";
|
|
||||||
case TAG_BYTE_ARRAY:
|
case TAG_BYTE_ARRAY:
|
||||||
case TAG_INT_ARRAY:
|
case TAG_INT_ARRAY:
|
||||||
case TAG_LONG_ARRAY:
|
case TAG_LONG_ARRAY:
|
||||||
@ -2806,13 +2764,11 @@ public class DisguiseUtilities {
|
|||||||
/**
|
/**
|
||||||
* Create a new datawatcher but with the 'correct' values
|
* Create a new datawatcher but with the 'correct' values
|
||||||
*/
|
*/
|
||||||
public static WrappedDataWatcher createSanitizedDataWatcher(WrappedDataWatcher entityWatcher,
|
public static WrappedDataWatcher createSanitizedDataWatcher(WrappedDataWatcher entityWatcher, FlagWatcher disguiseWatcher) {
|
||||||
FlagWatcher disguiseWatcher) {
|
|
||||||
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<WrappedWatchableObject> list = DisguiseConfig.isMetaPacketsEnabled() ?
|
List<WrappedWatchableObject> list = DisguiseConfig.isMetaPacketsEnabled() ? disguiseWatcher.convert(entityWatcher.getWatchableObjects()) :
|
||||||
disguiseWatcher.convert(entityWatcher.getWatchableObjects()) :
|
|
||||||
disguiseWatcher.getWatchableObjects();
|
disguiseWatcher.getWatchableObjects();
|
||||||
|
|
||||||
for (WrappedWatchableObject watchableObject : list) {
|
for (WrappedWatchableObject watchableObject : list) {
|
||||||
@ -2828,8 +2784,7 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
MetaIndex metaIndex = MetaIndex.getMetaIndex(disguiseWatcher, watchableObject.getIndex());
|
MetaIndex metaIndex = MetaIndex.getMetaIndex(disguiseWatcher, watchableObject.getIndex());
|
||||||
|
|
||||||
WrappedDataWatcher.WrappedDataWatcherObject obj =
|
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(metaIndex, object);
|
||||||
ReflectionManager.createDataWatcherObject(metaIndex, object);
|
|
||||||
|
|
||||||
newWatcher.setObject(obj, object);
|
newWatcher.setObject(obj, object);
|
||||||
}
|
}
|
||||||
@ -2903,8 +2858,7 @@ public class DisguiseUtilities {
|
|||||||
public static ArrayList<PacketContainer> getNamePackets(Disguise disguise, String[] internalOldNames) {
|
public static ArrayList<PacketContainer> getNamePackets(Disguise disguise, String[] internalOldNames) {
|
||||||
ArrayList<PacketContainer> packets = new ArrayList<>();
|
ArrayList<PacketContainer> packets = new ArrayList<>();
|
||||||
String[] newNames =
|
String[] newNames =
|
||||||
(disguise instanceof PlayerDisguise && !((PlayerDisguise) disguise).isNameVisible()) ? new String[0] :
|
(disguise instanceof PlayerDisguise && !((PlayerDisguise) disguise).isNameVisible()) ? new String[0] : reverse(disguise.getMultiName());
|
||||||
reverse(disguise.getMultiName());
|
|
||||||
int[] standIds = disguise.getArmorstandIds();
|
int[] standIds = disguise.getArmorstandIds();
|
||||||
int[] destroyIds = new int[0];
|
int[] destroyIds = new int[0];
|
||||||
|
|
||||||
@ -2942,21 +2896,19 @@ public class DisguiseUtilities {
|
|||||||
Object name;
|
Object name;
|
||||||
|
|
||||||
if (NmsVersion.v1_13.isSupported()) {
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
name = Optional.of(WrappedChatComponent
|
name = Optional.of(WrappedChatComponent.fromJson(ComponentSerializer.toString(DisguiseUtilities.getColoredChat(newNames[i]))));
|
||||||
.fromJson(ComponentSerializer.toString(DisguiseUtilities.getColoredChat(newNames[i]))));
|
|
||||||
} else {
|
} else {
|
||||||
name = newNames[i];
|
name = newNames[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(
|
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager
|
||||||
NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME :
|
.createDataWatcherObject(NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
||||||
MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
|
||||||
|
|
||||||
watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name));
|
watcher.setObject(obj, ReflectionManager.convertInvalidMeta(name));
|
||||||
|
|
||||||
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
PacketContainer metaPacket =
|
||||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, 0, watcher, true)
|
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, 0, watcher, true)
|
||||||
.createPacket(standIds[i], watcher, true);
|
.createPacket(standIds[i], watcher, true);
|
||||||
|
|
||||||
packets.add(metaPacket);
|
packets.add(metaPacket);
|
||||||
} else if (newNames[i].isEmpty()) {
|
} else if (newNames[i].isEmpty()) {
|
||||||
@ -2993,16 +2945,15 @@ public class DisguiseUtilities {
|
|||||||
val = true;
|
val = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedDataWatcher.WrappedDataWatcherObject obj =
|
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager.createDataWatcherObject(index, val);
|
||||||
ReflectionManager.createDataWatcherObject(index, val);
|
|
||||||
|
|
||||||
watcher.setObject(obj, ReflectionManager.convertInvalidMeta(val));
|
watcher.setObject(obj, ReflectionManager.convertInvalidMeta(val));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NmsVersion.v1_15.isSupported()) {
|
if (NmsVersion.v1_15.isSupported()) {
|
||||||
PacketContainer metaPacket = ProtocolLibrary.getProtocolManager()
|
PacketContainer metaPacket =
|
||||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, standIds[i], watcher, true)
|
ProtocolLibrary.getProtocolManager().createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, standIds[i], watcher, true)
|
||||||
.createPacket(standIds[i], watcher, true);
|
.createPacket(standIds[i], watcher, true);
|
||||||
|
|
||||||
packets.add(metaPacket);
|
packets.add(metaPacket);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,7 +6,7 @@ build-date: ${timestamp}
|
|||||||
build-number: ${build.number}
|
build-number: ${build.number}
|
||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
authors: [Byteflux, Navid K.]
|
authors: [Byteflux, Navid K.]
|
||||||
depend: [ProtocolLib]
|
softdepend: [ProtocolLib]
|
||||||
api-version: '1.13'
|
api-version: '1.13'
|
||||||
commands:
|
commands:
|
||||||
libsdisguises:
|
libsdisguises:
|
||||||
|
Loading…
Reference in New Issue
Block a user