Move classes into packages, clean up packet handling into classes, yaw/pitch should be consistent
This commit is contained in:
parent
43701c1fe8
commit
cada0f4f91
@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
@ -3,8 +3,8 @@ package me.libraryaddict.disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -14,7 +14,7 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.UpdateChecker;
|
import me.libraryaddict.disguise.utilities.UpdateChecker;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
|
@ -4,9 +4,16 @@ import com.comphenix.protocol.reflect.FieldAccessException;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import me.libraryaddict.disguise.commands.*;
|
import me.libraryaddict.disguise.commands.*;
|
||||||
import me.libraryaddict.disguise.disguisetypes.*;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||||
import me.libraryaddict.disguise.utilities.*;
|
import me.libraryaddict.disguise.utilities.*;
|
||||||
|
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.DisguiseValues;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -21,9 +28,6 @@ import java.io.File;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
public class LibsDisguises extends JavaPlugin {
|
public class LibsDisguises extends JavaPlugin {
|
||||||
private static LibsDisguises instance;
|
private static LibsDisguises instance;
|
||||||
@ -89,7 +93,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
getLogger().info("Commands has been disabled, as per config");
|
getLogger().info("Commands has been disabled, as per config");
|
||||||
}
|
}
|
||||||
|
|
||||||
infectWithMetrics();
|
new MetricsInitalizer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -101,208 +105,6 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void infectWithMetrics() {
|
|
||||||
String version = getDescription().getVersion();
|
|
||||||
|
|
||||||
// If a release build, attach build number
|
|
||||||
if (!isReleaseBuild() || !LibsPremium.isPremium()) {
|
|
||||||
version += "-";
|
|
||||||
|
|
||||||
// 9.7.0-SNAPSHOT-b30
|
|
||||||
if (isNumberedBuild()) {
|
|
||||||
version += "b";
|
|
||||||
}
|
|
||||||
// else 9.7.0-SNAPSHOT-unknown
|
|
||||||
|
|
||||||
version += getBuildNo();
|
|
||||||
}
|
|
||||||
|
|
||||||
Metrics metrics = new Metrics(this, version);
|
|
||||||
|
|
||||||
final String premium = LibsPremium.isPremium() ?
|
|
||||||
getDescription().getVersion().contains("SNAPSHOT") ? "Paid Builds" : "Paid Plugin" : "Free Builds";
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("premium") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return premium;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("translations") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return LibsPremium.isPremium() && DisguiseConfig.isUseTranslations() ? "Yes" : "No";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("custom_disguises") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
HashMap map = DisguiseConfig.getCustomDisguises();
|
|
||||||
|
|
||||||
return map.size() + (map.containsKey("libraryaddict") ? -1 : 0) > 0 ? "Yes" : "No";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.MultiLineChart("disguised_entities") {
|
|
||||||
@Override
|
|
||||||
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
|
||||||
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
|
||||||
for (Disguise disg : list) {
|
|
||||||
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String name = disg.getEntity().getType().name();
|
|
||||||
|
|
||||||
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashMap;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.MultiLineChart("disguises_used") {
|
|
||||||
@Override
|
|
||||||
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
|
||||||
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
|
||||||
for (Disguise disg : list) {
|
|
||||||
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
String name = disg.getType().name();
|
|
||||||
|
|
||||||
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return hashMap;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("disguised_using") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
if (DisguiseUtilities.isPluginsUsed()) {
|
|
||||||
if (DisguiseUtilities.isCommandsUsed()) {
|
|
||||||
return "Plugins and Commands";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Plugins";
|
|
||||||
} else if (DisguiseUtilities.isCommandsUsed()) {
|
|
||||||
return "Commands";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Unknown";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("active_disguises") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
int disgs = 0;
|
|
||||||
|
|
||||||
for (HashSet set : DisguiseUtilities.getDisguises().values()) {
|
|
||||||
disgs += set.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (disgs == 0)
|
|
||||||
return "0";
|
|
||||||
if (disgs <= 5)
|
|
||||||
return "1 to 5";
|
|
||||||
else if (disgs <= 15)
|
|
||||||
return "6 to 15";
|
|
||||||
else if (disgs <= 30)
|
|
||||||
return "16 to 30";
|
|
||||||
else if (disgs <= 60)
|
|
||||||
return "30 to 60";
|
|
||||||
else if (disgs <= 100)
|
|
||||||
return "60 to 100";
|
|
||||||
else if (disgs <= 200)
|
|
||||||
return "100 to 200";
|
|
||||||
|
|
||||||
return "More than 200";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("self_disguises") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return DisguiseConfig.isViewDisguises() ? "Yes" : "No";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("commands") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return DisguiseConfig.isDisableCommands() ? "Enabled" : "Disabled";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("spigot") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
try {
|
|
||||||
Class.forName("org.spigotmc.SpigotConfig");
|
|
||||||
return "Yes";
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
return "No";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final boolean updates = getConfig().getBoolean("NotifyUpdate");
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("updates") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return updates ? "Enabled" : "Disabled";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (getBuildNo() != null) {
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("build_number") {
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
return getBuildNo();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("targeted_disguises") {
|
|
||||||
/**
|
|
||||||
* Store value just to minimize amount of times it's called, and to persist even when not using anymore
|
|
||||||
*/
|
|
||||||
private boolean targetedDisguises;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getValue() {
|
|
||||||
if (targetedDisguises) {
|
|
||||||
return "Yes";
|
|
||||||
}
|
|
||||||
|
|
||||||
Collection<HashSet<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
|
||||||
|
|
||||||
if (list.isEmpty())
|
|
||||||
return "Unknown";
|
|
||||||
|
|
||||||
for (HashSet<TargetedDisguise> dList : list) {
|
|
||||||
for (TargetedDisguise disg : dList) {
|
|
||||||
if (disg.getObservers().isEmpty())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
targetedDisguises = true;
|
|
||||||
return "Yes";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return "No";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReleaseBuild() {
|
public boolean isReleaseBuild() {
|
||||||
return !getDescription().getVersion().contains("-SNAPSHOT");
|
return !getDescription().getVersion().contains("-SNAPSHOT");
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
|
|||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -5,7 +5,7 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
|
@ -4,7 +4,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -3,8 +3,7 @@ package me.libraryaddict.disguise.commands;
|
|||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||||
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
|
||||||
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.commands;
|
|||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -4,8 +4,8 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -5,10 +5,10 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.ClassGetter;
|
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.*;
|
import me.libraryaddict.disguise.utilities.parser.*;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -2,7 +2,7 @@ package me.libraryaddict.disguise.commands;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -2,7 +2,7 @@ package me.libraryaddict.disguise.commands;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -19,8 +19,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
|||||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -233,10 +232,9 @@ public abstract class Disguise {
|
|||||||
lookPacket.getIntegers().write(0, getEntity().getEntityId());
|
lookPacket.getIntegers().write(0, getEntity().getEntityId());
|
||||||
Location loc = getEntity().getLocation();
|
Location loc = getEntity().getLocation();
|
||||||
|
|
||||||
mods.write(4, PacketsManager.getYaw(getType(), getEntity().getType(),
|
mods.write(4, DisguiseUtilities.getYaw(getType(), getEntity().getType(),
|
||||||
(byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
(byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
||||||
mods.write(5, PacketsManager
|
mods.write(5, DisguiseUtilities.getPitch(getType(), getEntity().getType(),
|
||||||
.getPitch(getType(), DisguiseType.getType(getEntity().getType()),
|
|
||||||
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||||
|
|
||||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
@ -13,7 +13,7 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -11,8 +11,8 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
@ -9,7 +9,7 @@ import com.comphenix.protocol.wrappers.PlayerInfoData;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -6,10 +6,7 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import com.mojang.authlib.properties.PropertyMap;
|
import com.mojang.authlib.properties.PropertyMap;
|
||||||
@ -22,8 +19,14 @@ import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
|
||||||
import me.libraryaddict.disguise.utilities.json.*;
|
import me.libraryaddict.disguise.utilities.json.*;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.DisguiseValues;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -31,10 +34,7 @@ import org.bukkit.Location;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Zombie;
|
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -555,7 +555,7 @@ public class DisguiseUtilities {
|
|||||||
teleport.getIntegers().write(0, entity);
|
teleport.getIntegers().write(0, entity);
|
||||||
|
|
||||||
doubles.write(0, sleepingLocation.getX());
|
doubles.write(0, sleepingLocation.getX());
|
||||||
doubles.write(1, PacketsManager.getYModifier(disguise.getEntity(), disguise) + sleepingLocation.getY());
|
doubles.write(1, DisguiseUtilities.getYModifier(disguise.getEntity(), disguise) + sleepingLocation.getY());
|
||||||
doubles.write(2, sleepingLocation.getZ());
|
doubles.write(2, sleepingLocation.getZ());
|
||||||
|
|
||||||
return new PacketContainer[]{setBed, teleport};
|
return new PacketContainer[]{setBed, teleport};
|
||||||
@ -1649,7 +1649,7 @@ public class DisguiseUtilities {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LibsPackets transformed = PacketsManager.transformPacket(packet, disguise, player, player);
|
LibsPackets transformed = PacketsManager.getPacketsHandler().transformPacket(packet, disguise, player, player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (transformed.isUnhandled())
|
if (transformed.isUnhandled())
|
||||||
@ -1712,4 +1712,159 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new datawatcher but with the 'correct' values
|
||||||
|
*/
|
||||||
|
public static WrappedDataWatcher createSanitizedDataWatcher(WrappedDataWatcher entityWatcher,
|
||||||
|
FlagWatcher disguiseWatcher) {
|
||||||
|
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
|
try {
|
||||||
|
List<WrappedWatchableObject> list = DisguiseConfig.isMetadataPacketsEnabled() ?
|
||||||
|
disguiseWatcher.convert(entityWatcher.getWatchableObjects()) :
|
||||||
|
disguiseWatcher.getWatchableObjects();
|
||||||
|
|
||||||
|
for (WrappedWatchableObject watchableObject : list) {
|
||||||
|
if (watchableObject == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (watchableObject.getValue() == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
WrappedDataWatcher.WrappedDataWatcherObject obj = ReflectionManager
|
||||||
|
.createDataWatcherObject(watchableObject.getIndex(), watchableObject.getValue());
|
||||||
|
|
||||||
|
newWatcher.setObject(obj, watchableObject.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return newWatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getPitch(DisguiseType disguiseType, EntityType entityType, byte value) {
|
||||||
|
return getPitch(disguiseType, getPitch(DisguiseType.getType(entityType), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getPitch(DisguiseType disguiseType, DisguiseType entityType, byte value) {
|
||||||
|
return getPitch(disguiseType, getPitch(entityType, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getPitch(DisguiseType disguiseType, byte value) {
|
||||||
|
if (disguiseType.isMisc()) {
|
||||||
|
return (byte) -value;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (disguiseType) {
|
||||||
|
case PHANTOM:
|
||||||
|
return (byte) -value;
|
||||||
|
default:
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getYaw(DisguiseType disguiseType, EntityType entityType, byte value) {
|
||||||
|
return getYaw(disguiseType, getYaw(DisguiseType.getType(entityType), value));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte getYaw(DisguiseType disguiseType, DisguiseType entityType, byte value) {
|
||||||
|
return getYaw(disguiseType, getYaw(entityType, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the yaw for the disguises
|
||||||
|
*/
|
||||||
|
public static byte getYaw(DisguiseType disguiseType, byte value) {
|
||||||
|
switch (disguiseType) {
|
||||||
|
case MINECART:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
case MINECART_COMMAND:
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
return (byte) (value + 64);
|
||||||
|
case BOAT:
|
||||||
|
case ENDER_DRAGON:
|
||||||
|
case WITHER_SKULL:
|
||||||
|
return (byte) (value - 128);
|
||||||
|
case ARROW:
|
||||||
|
case TIPPED_ARROW:
|
||||||
|
case SPECTRAL_ARROW:
|
||||||
|
return (byte) -value;
|
||||||
|
case PAINTING:
|
||||||
|
case ITEM_FRAME:
|
||||||
|
return (byte) -(value + 128);
|
||||||
|
default:
|
||||||
|
if (disguiseType.isMisc() && disguiseType != DisguiseType.ARMOR_STAND) {
|
||||||
|
return (byte) (value - 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Y level to add to the disguise for realism.
|
||||||
|
*/
|
||||||
|
public static double getYModifier(Entity entity, Disguise disguise) {
|
||||||
|
double yMod = 0;
|
||||||
|
|
||||||
|
if ((disguise.getType() != DisguiseType.PLAYER || !((PlayerWatcher) disguise.getWatcher()).isSleeping()) &&
|
||||||
|
entity.getType() == EntityType.DROPPED_ITEM) {
|
||||||
|
yMod -= 0.13;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (disguise.getType()) {
|
||||||
|
case BAT:
|
||||||
|
if (entity instanceof LivingEntity)
|
||||||
|
return yMod + ((LivingEntity) entity).getEyeHeight();
|
||||||
|
case MINECART:
|
||||||
|
case MINECART_COMMAND:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
switch (entity.getType()) {
|
||||||
|
case MINECART:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
return yMod;
|
||||||
|
default:
|
||||||
|
return yMod + 0.4;
|
||||||
|
}
|
||||||
|
case TIPPED_ARROW:
|
||||||
|
case SPECTRAL_ARROW:
|
||||||
|
case BOAT:
|
||||||
|
case EGG:
|
||||||
|
case ENDER_PEARL:
|
||||||
|
case ENDER_SIGNAL:
|
||||||
|
case FIREWORK:
|
||||||
|
case PAINTING:
|
||||||
|
case SMALL_FIREBALL:
|
||||||
|
case SNOWBALL:
|
||||||
|
case SPLASH_POTION:
|
||||||
|
case THROWN_EXP_BOTTLE:
|
||||||
|
case WITHER_SKULL:
|
||||||
|
return yMod + 0.7;
|
||||||
|
case PLAYER:
|
||||||
|
if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
|
||||||
|
return yMod + 0.35;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case DROPPED_ITEM:
|
||||||
|
return yMod + 0.13;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return yMod;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.metrics;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
@ -0,0 +1,232 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.metrics;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class MetricsInitalizer {
|
||||||
|
private void infectWithMetrics() {
|
||||||
|
LibsDisguises plugin = LibsDisguises.getInstance();
|
||||||
|
|
||||||
|
String version = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
// If a release build, attach build number
|
||||||
|
if (!plugin.isReleaseBuild() || !LibsPremium.isPremium()) {
|
||||||
|
version += "-";
|
||||||
|
|
||||||
|
// 9.7.0-SNAPSHOT-b30
|
||||||
|
if (plugin.isNumberedBuild()) {
|
||||||
|
version += "b";
|
||||||
|
}
|
||||||
|
// else 9.7.0-SNAPSHOT-unknown
|
||||||
|
|
||||||
|
version += plugin.getBuildNo();
|
||||||
|
}
|
||||||
|
|
||||||
|
Metrics metrics = new Metrics(plugin, version);
|
||||||
|
final String premiumType;
|
||||||
|
|
||||||
|
if (LibsPremium.isPremium()) {
|
||||||
|
if (plugin.isReleaseBuild()) {
|
||||||
|
premiumType = "Paid Plugin";
|
||||||
|
} else {
|
||||||
|
premiumType = "Paid Builds";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
premiumType = "Free Builds";
|
||||||
|
}
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("premium") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return premiumType;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("translations") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return LibsPremium.isPremium() && DisguiseConfig.isUseTranslations() ? "Yes" : "No";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("custom_disguises") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
HashMap map = DisguiseConfig.getCustomDisguises();
|
||||||
|
|
||||||
|
return map.size() + (map.containsKey("libraryaddict") ? -1 : 0) > 0 ? "Yes" : "No";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.MultiLineChart("disguised_entities") {
|
||||||
|
@Override
|
||||||
|
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
||||||
|
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
||||||
|
for (Disguise disg : list) {
|
||||||
|
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String name = disg.getEntity().getType().name();
|
||||||
|
|
||||||
|
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.MultiLineChart("disguises_used") {
|
||||||
|
@Override
|
||||||
|
public HashMap<String, Integer> getValues(HashMap<String, Integer> hashMap) {
|
||||||
|
for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
|
||||||
|
for (Disguise disg : list) {
|
||||||
|
if (disg.getEntity() == null || !disg.isDisguiseInUse())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String name = disg.getType().name();
|
||||||
|
|
||||||
|
hashMap.put(name, hashMap.containsKey(name) ? hashMap.get(name) + 1 : 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashMap;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("disguised_using") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
if (DisguiseUtilities.isPluginsUsed()) {
|
||||||
|
if (DisguiseUtilities.isCommandsUsed()) {
|
||||||
|
return "Plugins and Commands";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Plugins";
|
||||||
|
} else if (DisguiseUtilities.isCommandsUsed()) {
|
||||||
|
return "Commands";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Unknown";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("active_disguises") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
int disgs = 0;
|
||||||
|
|
||||||
|
for (HashSet set : DisguiseUtilities.getDisguises().values()) {
|
||||||
|
disgs += set.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disgs == 0)
|
||||||
|
return "0";
|
||||||
|
if (disgs <= 5)
|
||||||
|
return "1 to 5";
|
||||||
|
else if (disgs <= 15)
|
||||||
|
return "6 to 15";
|
||||||
|
else if (disgs <= 30)
|
||||||
|
return "16 to 30";
|
||||||
|
else if (disgs <= 60)
|
||||||
|
return "30 to 60";
|
||||||
|
else if (disgs <= 100)
|
||||||
|
return "60 to 100";
|
||||||
|
else if (disgs <= 200)
|
||||||
|
return "100 to 200";
|
||||||
|
|
||||||
|
return "More than 200";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("self_disguises") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return DisguiseConfig.isViewDisguises() ? "Yes" : "No";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("commands") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return DisguiseConfig.isDisableCommands() ? "Enabled" : "Disabled";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("spigot") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
try {
|
||||||
|
Class.forName("org.spigotmc.SpigotConfig");
|
||||||
|
return "Yes";
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return "No";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final boolean updates = plugin.getConfig().getBoolean("NotifyUpdate");
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("updates") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return updates ? "Enabled" : "Disabled";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (plugin.getBuildNo() != null) {
|
||||||
|
// Initalize final variable so we don't need to hold onto the plugin variable
|
||||||
|
final String buildNo = plugin.getBuildNo();
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("build_number") {
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
return buildNo;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("targeted_disguises") {
|
||||||
|
/**
|
||||||
|
* Store value just to minimize amount of times it's called, and to persist even when not using anymore
|
||||||
|
*/
|
||||||
|
private boolean targetedDisguises;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getValue() {
|
||||||
|
if (targetedDisguises) {
|
||||||
|
return "Yes";
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection<HashSet<TargetedDisguise>> list = DisguiseUtilities.getDisguises().values();
|
||||||
|
|
||||||
|
if (list.isEmpty())
|
||||||
|
return "Unknown";
|
||||||
|
|
||||||
|
for (HashSet<TargetedDisguise> dList : list) {
|
||||||
|
for (TargetedDisguise disg : dList) {
|
||||||
|
if (disg.getObservers().isEmpty())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
targetedDisguises = true;
|
||||||
|
return "Yes";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "No";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public interface IPacketHandler {
|
||||||
|
PacketType[] getHandledPackets();
|
||||||
|
|
||||||
|
void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer, Entity entity);
|
||||||
|
}
|
@ -0,0 +1,94 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class LibsPackets {
|
||||||
|
private ArrayList<PacketContainer> packets = new ArrayList<>();
|
||||||
|
private HashMap<Integer, ArrayList<PacketContainer>> delayedPackets = new HashMap<>();
|
||||||
|
private boolean isSpawnPacket;
|
||||||
|
private Disguise disguise;
|
||||||
|
private boolean doNothing;
|
||||||
|
|
||||||
|
public LibsPackets(Disguise disguise) {
|
||||||
|
this.disguise = disguise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUnhandled() {
|
||||||
|
doNothing = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUnhandled() {
|
||||||
|
return doNothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Disguise getDisguise() {
|
||||||
|
return disguise;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawnPacketCheck(PacketType type) {
|
||||||
|
isSpawnPacket = type.name().contains("SPAWN") && type.name().contains("ENTITY");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPacket(PacketContainer packet) {
|
||||||
|
packets.add(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDelayedPacket(PacketContainer packet) {
|
||||||
|
addDelayedPacket(packet, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clear() {
|
||||||
|
getPackets().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDelayedPacket(PacketContainer packet, int ticksDelayed) {
|
||||||
|
if (!delayedPackets.containsKey(ticksDelayed))
|
||||||
|
delayedPackets.put(ticksDelayed, new ArrayList<>());
|
||||||
|
|
||||||
|
delayedPackets.get(ticksDelayed).add(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<PacketContainer> getPackets() {
|
||||||
|
return packets;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<ArrayList<PacketContainer>> getDelayedPackets() {
|
||||||
|
return delayedPackets.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendDelayed(final Player observer) {
|
||||||
|
for (final Map.Entry<Integer, ArrayList<PacketContainer>> entry : delayedPackets.entrySet()) {
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
for (PacketContainer packet : entry.getValue()) {
|
||||||
|
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSpawnPacket) {
|
||||||
|
PacketsManager.getPacketsHandler().removeCancel(disguise, observer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, entry.getKey());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.packethandlers.*;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketsHandler {
|
||||||
|
private HashMap<Disguise, ArrayList<UUID>> cancelMeta = new HashMap<>();
|
||||||
|
private Collection<IPacketHandler> packetHandlers;
|
||||||
|
|
||||||
|
public PacketsHandler() {
|
||||||
|
registerPacketHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerPacketHandlers() {
|
||||||
|
packetHandlers = new ArrayList<>();
|
||||||
|
|
||||||
|
packetHandlers.add(new PacketHandlerAnimation());
|
||||||
|
packetHandlers.add(new PacketHandlerAttributes());
|
||||||
|
packetHandlers.add(new PacketHandlerBed());
|
||||||
|
packetHandlers.add(new PacketHandlerCollect());
|
||||||
|
packetHandlers.add(new PacketHandlerEntityStatus());
|
||||||
|
packetHandlers.add(new PacketHandlerEquipment());
|
||||||
|
packetHandlers.add(new PacketHandlerHeadRotation());
|
||||||
|
packetHandlers.add(new PacketHandlerMetadata(this));
|
||||||
|
packetHandlers.add(new PacketHandlerMovement());
|
||||||
|
packetHandlers.add(new PacketHandlerSpawn(this));
|
||||||
|
packetHandlers.add(new PacketHandlerVelocity());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCancelMeta(Disguise disguise, Player observer) {
|
||||||
|
return cancelMeta.containsKey(disguise) && cancelMeta.get(disguise).contains(observer.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCancel(Disguise disguise, Player observer) {
|
||||||
|
if (!cancelMeta.containsKey(disguise)) {
|
||||||
|
cancelMeta.put(disguise, new ArrayList<UUID>());
|
||||||
|
}
|
||||||
|
|
||||||
|
cancelMeta.get(disguise).add(observer.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeCancel(Disguise disguise, Player observer) {
|
||||||
|
ArrayList<UUID> cancel;
|
||||||
|
|
||||||
|
if ((cancel = cancelMeta.get(disguise)) == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
cancel.remove(observer.getUniqueId());
|
||||||
|
|
||||||
|
if (!cancel.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
cancelMeta.remove(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform the packet magically into the one I have always dreamed off. My true luv!!! This will return null if
|
||||||
|
* its not
|
||||||
|
* transformed
|
||||||
|
*/
|
||||||
|
public LibsPackets transformPacket(PacketContainer sentPacket, Disguise disguise, Player observer, Entity entity) {
|
||||||
|
LibsPackets packets = new LibsPackets(disguise);
|
||||||
|
|
||||||
|
try {
|
||||||
|
packets.addPacket(sentPacket);
|
||||||
|
|
||||||
|
for (IPacketHandler packetHandler : packetHandlers) {
|
||||||
|
for (PacketType packetType : packetHandler.getHandledPackets()) {
|
||||||
|
if (packetType != sentPacket.getType()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
packetHandler.handle(disguise, sentPacket, packets, observer, entity);
|
||||||
|
return packets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
packets.setUnhandled();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return packets;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,205 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketListener;
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
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 org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class PacketsManager {
|
||||||
|
private static PacketListener clientInteractEntityListener;
|
||||||
|
private static PacketListener inventoryListener;
|
||||||
|
private static boolean inventoryModifierEnabled;
|
||||||
|
private static LibsDisguises libsDisguises;
|
||||||
|
private static PacketListener mainListener;
|
||||||
|
private static PacketListener soundsListener;
|
||||||
|
private static boolean soundsListenerEnabled;
|
||||||
|
private static PacketListener viewDisguisesListener;
|
||||||
|
private static boolean viewDisguisesListenerEnabled;
|
||||||
|
private static PacketsHandler packetsHandler;
|
||||||
|
|
||||||
|
public static void addPacketListeners() {
|
||||||
|
// Add a client listener to cancel them interacting with uninteractable disguised entitys.
|
||||||
|
// You ain't supposed to be allowed to 'interact' with a item that cannot be clicked.
|
||||||
|
// Because it kicks you for hacking.
|
||||||
|
|
||||||
|
clientInteractEntityListener = new PacketListenerClientInteract(libsDisguises);
|
||||||
|
PacketListener tabListListener = new PacketListenerTabList(libsDisguises);
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(clientInteractEntityListener);
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(tabListListener);
|
||||||
|
|
||||||
|
// Now I call this and the main listener is registered!
|
||||||
|
setupMainPacketsListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the packet listeners
|
||||||
|
*/
|
||||||
|
public static void init(LibsDisguises plugin) {
|
||||||
|
libsDisguises = plugin;
|
||||||
|
soundsListener = new PacketListenerSounds(libsDisguises);
|
||||||
|
|
||||||
|
// Self disguise (/vsd) listener
|
||||||
|
viewDisguisesListener = new PacketListenerViewSelfDisguise(libsDisguises);
|
||||||
|
|
||||||
|
inventoryListener = new PacketListenerInventory(libsDisguises);
|
||||||
|
packetsHandler = new PacketsHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PacketsHandler getPacketsHandler() {
|
||||||
|
return packetsHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHearDisguisesEnabled() {
|
||||||
|
return soundsListenerEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInventoryListenerEnabled() {
|
||||||
|
return inventoryModifierEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isViewDisguisesListenerEnabled() {
|
||||||
|
return viewDisguisesListenerEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setHearDisguisesListener(boolean enabled) {
|
||||||
|
if (soundsListenerEnabled != enabled) {
|
||||||
|
soundsListenerEnabled = enabled;
|
||||||
|
|
||||||
|
if (soundsListenerEnabled) {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(soundsListener);
|
||||||
|
} else {
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(soundsListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setInventoryListenerEnabled(boolean enabled) {
|
||||||
|
if (inventoryModifierEnabled != enabled) {
|
||||||
|
inventoryModifierEnabled = enabled;
|
||||||
|
|
||||||
|
if (inventoryModifierEnabled) {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(inventoryListener);
|
||||||
|
} else {
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(inventoryListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise(player, player);
|
||||||
|
|
||||||
|
if (disguise != null) {
|
||||||
|
if (viewDisguisesListenerEnabled && disguise.isSelfDisguiseVisible() &&
|
||||||
|
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||||
|
player.updateInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setupMainPacketsListener() {
|
||||||
|
if (clientInteractEntityListener != null) {
|
||||||
|
if (mainListener != null) {
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(mainListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayList<PacketType> packetsToListen = new ArrayList<>();
|
||||||
|
// Add spawn packets
|
||||||
|
{
|
||||||
|
packetsToListen.add(Server.NAMED_ENTITY_SPAWN);
|
||||||
|
packetsToListen.add(Server.SPAWN_ENTITY_EXPERIENCE_ORB);
|
||||||
|
packetsToListen.add(Server.SPAWN_ENTITY);
|
||||||
|
packetsToListen.add(Server.SPAWN_ENTITY_LIVING);
|
||||||
|
packetsToListen.add(Server.SPAWN_ENTITY_PAINTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add packets that always need to be enabled to ensure safety
|
||||||
|
{
|
||||||
|
packetsToListen.add(Server.ENTITY_METADATA);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisguiseConfig.isCollectPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.COLLECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||||
|
packetsToListen.add(Server.UPDATE_ATTRIBUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The bed packet.
|
||||||
|
if (DisguiseConfig.isBedPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.BED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add movement packets
|
||||||
|
if (DisguiseConfig.isMovementPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.ENTITY_LOOK);
|
||||||
|
packetsToListen.add(Server.REL_ENTITY_MOVE_LOOK);
|
||||||
|
packetsToListen.add(Server.ENTITY_HEAD_ROTATION);
|
||||||
|
packetsToListen.add(Server.ENTITY_TELEPORT);
|
||||||
|
packetsToListen.add(Server.REL_ENTITY_MOVE);
|
||||||
|
packetsToListen.add(Server.ENTITY_VELOCITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add equipment packet
|
||||||
|
if (DisguiseConfig.isEquipmentPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.ENTITY_EQUIPMENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the packet that ensures if they are sleeping or not
|
||||||
|
if (DisguiseConfig.isAnimationPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.ANIMATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the packet that makes sure that entities with armor do not send unpickupable armor on death
|
||||||
|
if (DisguiseConfig.isEntityStatusPacketsEnabled()) {
|
||||||
|
packetsToListen.add(Server.ENTITY_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainListener = new PacketListenerMain(libsDisguises, packetsToListen);
|
||||||
|
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(mainListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setViewDisguisesListener(boolean enabled) {
|
||||||
|
if (viewDisguisesListenerEnabled != enabled) {
|
||||||
|
viewDisguisesListenerEnabled = enabled;
|
||||||
|
|
||||||
|
if (viewDisguisesListenerEnabled) {
|
||||||
|
ProtocolLibrary.getProtocolManager().addPacketListener(viewDisguisesListener);
|
||||||
|
} else {
|
||||||
|
ProtocolLibrary.getProtocolManager().removePacketListener(viewDisguisesListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
Disguise disguise = DisguiseAPI.getDisguise(player, player);
|
||||||
|
|
||||||
|
if (disguise != null) {
|
||||||
|
if (disguise.isSelfDisguiseVisible()) {
|
||||||
|
if (enabled) {
|
||||||
|
DisguiseUtilities.setupFakeDisguise(disguise);
|
||||||
|
} else {
|
||||||
|
DisguiseUtilities.removeSelfDisguise(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inventoryModifierEnabled &&
|
||||||
|
(disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||||
|
player.updateInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerAnimation implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ANIMATION};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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() || (sentPacket.getIntegers().read(1) == 2 && (!disguise.getType().isPlayer() ||
|
||||||
|
(DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping())))) {
|
||||||
|
packets.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,71 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.DisguiseValues;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerAttributes implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.UPDATE_ATTRIBUTES};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
if (disguise.isMiscDisguise()) {
|
||||||
|
packets.clear();
|
||||||
|
} else {
|
||||||
|
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||||
|
|
||||||
|
for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) {
|
||||||
|
if (attribute.getAttributeKey().equals("generic.maxHealth")) {
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
PacketContainer updateAttributes = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
|
packets.addPacket(updateAttributes);
|
||||||
|
|
||||||
|
WrappedAttribute.Builder builder;
|
||||||
|
|
||||||
|
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
||||||
|
builder = WrappedAttribute.newBuilder();
|
||||||
|
builder.attributeKey("generic.maxHealth");
|
||||||
|
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
||||||
|
} else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity()) {
|
||||||
|
builder = WrappedAttribute.newBuilder(attribute);
|
||||||
|
} else {
|
||||||
|
builder = WrappedAttribute.newBuilder();
|
||||||
|
builder.attributeKey("generic.maxHealth");
|
||||||
|
builder.baseValue(DisguiseValues.getDisguiseValues(disguise.getType()).getMaxHealth());
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.packet(updateAttributes);
|
||||||
|
|
||||||
|
attributes.add(builder.build());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!attributes.isEmpty()) {
|
||||||
|
packets.getPackets().get(0).getIntegers().write(0, entity.getEntityId());
|
||||||
|
packets.getPackets().get(0).getAttributeCollectionModifier().write(0, attributes);
|
||||||
|
} else {
|
||||||
|
packets.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerBed implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.BED};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
// If the entity is going into a bed, stop everything but players from doing this
|
||||||
|
if (!disguise.getType().isPlayer()) {
|
||||||
|
packets.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerCollect implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.COLLECT};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
if (disguise.getType().isMisc()) {
|
||||||
|
packets.clear();
|
||||||
|
} else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer() &&
|
||||||
|
((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
|
||||||
|
PacketContainer newPacket = new PacketContainer(PacketType.Play.Server.ANIMATION);
|
||||||
|
|
||||||
|
StructureModifier<Integer> mods = newPacket.getIntegers();
|
||||||
|
mods.write(0, disguise.getEntity().getEntityId());
|
||||||
|
mods.write(1, 3);
|
||||||
|
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
packets.addPacket(newPacket);
|
||||||
|
packets.addPacket(sentPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerEntityStatus implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ENTITY_STATUS};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerEquipment implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ENTITY_EQUIPMENT};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
// Else if the disguise is updating equipment
|
||||||
|
|
||||||
|
EquipmentSlot slot = ReflectionManager.createEquipmentSlot(packets.getPackets().get(0).getModifier().read(1));
|
||||||
|
|
||||||
|
org.bukkit.inventory.ItemStack itemStack = disguise.getWatcher().getItemStack(slot);
|
||||||
|
|
||||||
|
if (itemStack != null) {
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
PacketContainer equipPacket = sentPacket.shallowClone();
|
||||||
|
|
||||||
|
packets.addPacket(equipPacket);
|
||||||
|
|
||||||
|
equipPacket.getModifier()
|
||||||
|
.write(2, ReflectionManager.getNmsItem(itemStack.getType() == Material.AIR ? null : itemStack));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disguise.getWatcher().isRightClicking() && slot == EquipmentSlot.HAND) {
|
||||||
|
ItemStack heldItem = packets.getPackets().get(0).getItemModifier().read(0);
|
||||||
|
|
||||||
|
if (heldItem != null && heldItem.getType() != Material.AIR) {
|
||||||
|
// Convert the datawatcher
|
||||||
|
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (DisguiseConfig.isMetadataPacketsEnabled()) {
|
||||||
|
WrappedWatchableObject watch = ReflectionManager
|
||||||
|
.createWatchable(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
|
||||||
|
|
||||||
|
if (watch != null)
|
||||||
|
list.add(watch);
|
||||||
|
|
||||||
|
list = disguise.getWatcher().convert(list);
|
||||||
|
} else {
|
||||||
|
for (WrappedWatchableObject obj : disguise.getWatcher().getWatchableObjects()) {
|
||||||
|
if (obj.getIndex() == 0) {
|
||||||
|
list.add(obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Construct the packets to return
|
||||||
|
PacketContainer packetBlock = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
|
|
||||||
|
packetBlock.getModifier().write(0, entity.getEntityId());
|
||||||
|
packetBlock.getWatchableCollectionModifier().write(0, list);
|
||||||
|
|
||||||
|
PacketContainer packetUnblock = packetBlock.deepClone();
|
||||||
|
// Make a packet to send the 'unblock'
|
||||||
|
for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) {
|
||||||
|
watcher.setValue((byte) ((byte) watcher.getValue() & ~(1 << 4)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the unblock before the itemstack change so that the 2nd metadata packet works. Why?
|
||||||
|
// Scheduler
|
||||||
|
// delay.
|
||||||
|
|
||||||
|
PacketContainer packet1 = packets.getPackets().get(0);
|
||||||
|
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
packets.addPacket(packetUnblock);
|
||||||
|
packets.addPacket(packet1);
|
||||||
|
packets.addPacket(packetBlock);
|
||||||
|
// Silly mojang made the right clicking datawatcher value only valid for one use. So I have
|
||||||
|
// to reset
|
||||||
|
// it.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerHeadRotation implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ENTITY_HEAD_ROTATION};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) {
|
||||||
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
|
byte pitch = DisguiseUtilities
|
||||||
|
.getPitch(disguise.getType(), entity.getType(), (byte) (int) (loc.getPitch() * 256.0F / 360.0F));
|
||||||
|
byte yaw = DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), sentPacket.getBytes().read(0));
|
||||||
|
|
||||||
|
PacketContainer rotation = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = rotation.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, entity.getEntityId());
|
||||||
|
mods.write(1, yaw);
|
||||||
|
|
||||||
|
PacketContainer look = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
|
||||||
|
|
||||||
|
look.getIntegers().write(0, entity.getEntityId());
|
||||||
|
look.getBytes().write(0, yaw);
|
||||||
|
look.getBytes().write(1, pitch);
|
||||||
|
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
packets.addPacket(look);
|
||||||
|
packets.addPacket(rotation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.PacketsHandler;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerMetadata implements IPacketHandler {
|
||||||
|
private PacketsHandler packetsHandler;
|
||||||
|
|
||||||
|
public PacketHandlerMetadata(PacketsHandler packetsHandler) {
|
||||||
|
this.packetsHandler = packetsHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ENTITY_METADATA};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
if (DisguiseConfig.isMetadataPacketsEnabled() && packetsHandler.isCancelMeta(disguise, observer)) {
|
||||||
|
List<WrappedWatchableObject> watchableObjects = disguise.getWatcher()
|
||||||
|
.convert(sentPacket.getWatchableCollectionModifier().read(0));
|
||||||
|
|
||||||
|
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
|
|
||||||
|
packets.addPacket(metaPacket);
|
||||||
|
|
||||||
|
StructureModifier<Object> newMods = metaPacket.getModifier();
|
||||||
|
|
||||||
|
newMods.write(0, entity.getEntityId());
|
||||||
|
|
||||||
|
metaPacket.getWatchableCollectionModifier().write(0, watchableObjects);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
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};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
|
||||||
|
if (disguise.getType() == DisguiseType.RABBIT &&
|
||||||
|
(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;
|
||||||
|
|
||||||
|
// If hop meta exists, set the last hop time
|
||||||
|
if (!entity.getMetadata("LibsRabbitHop").isEmpty()) {
|
||||||
|
// Last hop was 3 minutes ago, so subtract current time with the last hop time and get 3
|
||||||
|
// minutes ago in milliseconds
|
||||||
|
lastHop = System.currentTimeMillis() - entity.getMetadata("LibsRabbitHop").get(0).asLong();
|
||||||
|
}
|
||||||
|
|
||||||
|
// If last hop was less than 0.1 or more than 0.5 seconds ago
|
||||||
|
if (lastHop < 100 || lastHop > 500) {
|
||||||
|
if (lastHop > 500) {
|
||||||
|
entity.removeMetadata("LibsRabbitHop", LibsDisguises.getInstance());
|
||||||
|
entity.setMetadata("LibsRabbitHop",
|
||||||
|
new FixedMetadataValue(LibsDisguises.getInstance(), System.currentTimeMillis()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketContainer statusPacket = new PacketContainer(PacketType.Play.Server.ENTITY_STATUS);
|
||||||
|
packets.addPacket(statusPacket);
|
||||||
|
|
||||||
|
statusPacket.getIntegers().write(0, entity.getEntityId());
|
||||||
|
statusPacket.getBytes().write(0, (byte) 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stop wither skulls from looking
|
||||||
|
if (sentPacket.getType() == PacketType.Play.Server.ENTITY_LOOK &&
|
||||||
|
disguise.getType() == DisguiseType.WITHER_SKULL) {
|
||||||
|
packets.clear();
|
||||||
|
} else if (sentPacket.getType() != PacketType.Play.Server.REL_ENTITY_MOVE) {
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
PacketContainer movePacket = sentPacket.shallowClone();
|
||||||
|
|
||||||
|
packets.addPacket(movePacket);
|
||||||
|
|
||||||
|
StructureModifier<Byte> bytes = movePacket.getBytes();
|
||||||
|
|
||||||
|
byte yawValue = bytes.read(0);
|
||||||
|
byte pitchValue = bytes.read(1);
|
||||||
|
|
||||||
|
bytes.write(0, DisguiseUtilities.getYaw(disguise.getType(), entity.getType(), yawValue));
|
||||||
|
bytes.write(1, DisguiseUtilities.getPitch(disguise.getType(), entity.getType(), pitchValue));
|
||||||
|
|
||||||
|
if (sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT &&
|
||||||
|
disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
|
StructureModifier<Double> doubles = movePacket.getDoubles();
|
||||||
|
|
||||||
|
Location loc = entity.getLocation();
|
||||||
|
|
||||||
|
double data = (((loc.getYaw() % 360) + 720 + 45) / 90) % 4;
|
||||||
|
|
||||||
|
if (data % 2 == 0) {
|
||||||
|
if (data % 2 == 0) {
|
||||||
|
doubles.write(3, loc.getZ());
|
||||||
|
} else {
|
||||||
|
doubles.write(1, loc.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
double y = DisguiseUtilities.getYModifier(entity, disguise);
|
||||||
|
|
||||||
|
if (y != 0) {
|
||||||
|
doubles.write(2, doubles.read(2) + y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,403 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.*;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.PacketsHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.DisguiseValues;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
import org.bukkit.Art;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Damageable;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerSpawn implements IPacketHandler {
|
||||||
|
private PacketsHandler packetsHandler;
|
||||||
|
|
||||||
|
public PacketHandlerSpawn(PacketsHandler packetsHandler) {
|
||||||
|
this.packetsHandler = packetsHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
@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};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
|
||||||
|
packets.clear();
|
||||||
|
|
||||||
|
constructSpawnPackets(observer, packets, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct the packets I need to spawn in the disguise
|
||||||
|
*/
|
||||||
|
private void constructSpawnPackets(final Player observer, LibsPackets packets, Entity disguisedEntity) {
|
||||||
|
Disguise disguise = packets.getDisguise();
|
||||||
|
|
||||||
|
if (disguise.getEntity() == null) {
|
||||||
|
disguise.setEntity(disguisedEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This sends the armor packets so that the player isn't naked.
|
||||||
|
// Please note it only sends the packets that wouldn't be sent normally
|
||||||
|
if (DisguiseConfig.isEquipmentPacketsEnabled()) {
|
||||||
|
for (EquipmentSlot slot : EquipmentSlot.values()) {
|
||||||
|
ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
|
||||||
|
|
||||||
|
if (itemstack == null || itemstack.getType() == Material.AIR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disguisedEntity instanceof LivingEntity) {
|
||||||
|
ItemStack item = ReflectionManager.getEquipment(slot, disguisedEntity);
|
||||||
|
|
||||||
|
if (item != null && item.getType() != Material.AIR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||||
|
mods.write(2, ReflectionManager.getNmsItem(itemstack));
|
||||||
|
|
||||||
|
packets.addDelayedPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||||
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
|
|
||||||
|
ArrayList<WrappedAttribute> attributes = new ArrayList<>();
|
||||||
|
|
||||||
|
WrappedAttribute.Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");
|
||||||
|
|
||||||
|
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
||||||
|
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
||||||
|
} else if (DisguiseConfig.isMaxHealthDeterminedByDisguisedEntity() &&
|
||||||
|
disguisedEntity instanceof Damageable) {
|
||||||
|
builder.baseValue(((Damageable) disguisedEntity).getMaxHealth());
|
||||||
|
} else {
|
||||||
|
builder.baseValue(DisguiseValues.getDisguiseValues(disguise.getType()).getMaxHealth());
|
||||||
|
}
|
||||||
|
|
||||||
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
|
|
||||||
|
builder.packet(packet);
|
||||||
|
|
||||||
|
attributes.add(builder.build());
|
||||||
|
|
||||||
|
packet.getIntegers().write(0, disguisedEntity.getEntityId());
|
||||||
|
packet.getAttributeCollectionModifier().write(0, attributes);
|
||||||
|
|
||||||
|
packets.addPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Location loc = disguisedEntity.getLocation().clone()
|
||||||
|
.add(0, DisguiseUtilities.getYModifier(disguisedEntity, disguise), 0);
|
||||||
|
|
||||||
|
byte yaw = (byte) (int) (loc.getYaw() * 256.0F / 360.0F);
|
||||||
|
byte pitch = (byte) (int) (loc.getPitch() * 256.0F / 360.0F);
|
||||||
|
|
||||||
|
if (DisguiseConfig.isMovementPacketsEnabled()) {
|
||||||
|
yaw = DisguiseUtilities.getYaw(disguise.getType(), disguisedEntity.getType(), yaw);
|
||||||
|
pitch = DisguiseUtilities.getPitch(disguise.getType(), disguisedEntity.getType(), pitch);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
||||||
|
PacketContainer spawnOrb = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB);
|
||||||
|
packets.addPacket(spawnOrb);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = spawnOrb.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, loc.getX());
|
||||||
|
mods.write(2, loc.getY() + 0.06);
|
||||||
|
mods.write(3, loc.getZ());
|
||||||
|
mods.write(4, 1);
|
||||||
|
} else if (disguise.getType() == DisguiseType.PAINTING) {
|
||||||
|
PacketContainer spawnPainting = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
|
||||||
|
packets.addPacket(spawnPainting);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = spawnPainting.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, disguisedEntity.getUniqueId());
|
||||||
|
mods.write(2, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
|
mods.write(3, ReflectionManager.getEnumDirection(((int) loc.getYaw()) % 4));
|
||||||
|
|
||||||
|
int id = ((MiscDisguise) disguise).getData();
|
||||||
|
|
||||||
|
mods.write(4, ReflectionManager.getEnumArt(Art.values()[id]));
|
||||||
|
|
||||||
|
// Make the teleport packet to make it visible..
|
||||||
|
PacketContainer teleportPainting = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||||
|
packets.addPacket(teleportPainting);
|
||||||
|
|
||||||
|
mods = teleportPainting.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, loc.getX());
|
||||||
|
mods.write(2, loc.getY());
|
||||||
|
mods.write(3, loc.getZ());
|
||||||
|
mods.write(4, yaw);
|
||||||
|
mods.write(5, pitch);
|
||||||
|
} else if (disguise.getType().isPlayer()) {
|
||||||
|
PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
|
||||||
|
|
||||||
|
String name = playerDisguise.getName();
|
||||||
|
WrappedGameProfile gameProfile = playerDisguise.getGameProfile();
|
||||||
|
|
||||||
|
int entityId = disguisedEntity.getEntityId();
|
||||||
|
|
||||||
|
// Send player info along with the disguise
|
||||||
|
PacketContainer sendTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||||
|
|
||||||
|
if (!((PlayerDisguise) disguise).isDisplayedInTab()) {
|
||||||
|
// Add player to the list, necessary to spawn them
|
||||||
|
sendTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0));
|
||||||
|
|
||||||
|
List playerList = Collections
|
||||||
|
.singletonList(ReflectionManager.getPlayerInfoData(sendTab.getHandle(), gameProfile));
|
||||||
|
sendTab.getModifier().write(1, playerList);
|
||||||
|
|
||||||
|
packets.addPacket(sendTab);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn the player
|
||||||
|
PacketContainer spawnPlayer = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||||
|
|
||||||
|
spawnPlayer.getIntegers().write(0, entityId); // Id
|
||||||
|
spawnPlayer.getModifier().write(1, gameProfile.getUUID());
|
||||||
|
|
||||||
|
Location spawnAt = disguisedEntity.getLocation();
|
||||||
|
|
||||||
|
boolean selfDisguise = observer == disguisedEntity;
|
||||||
|
|
||||||
|
WrappedDataWatcher newWatcher;
|
||||||
|
|
||||||
|
if (selfDisguise) {
|
||||||
|
newWatcher = DisguiseUtilities
|
||||||
|
.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity),
|
||||||
|
disguise.getWatcher());
|
||||||
|
} else {
|
||||||
|
newWatcher = new WrappedDataWatcher();
|
||||||
|
|
||||||
|
spawnAt = observer.getLocation();
|
||||||
|
spawnAt.add(spawnAt.getDirection().normalize().multiply(20));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn him in front of the observer
|
||||||
|
StructureModifier<Double> doubles = spawnPlayer.getDoubles();
|
||||||
|
doubles.write(0, spawnAt.getX());
|
||||||
|
doubles.write(1, spawnAt.getY());
|
||||||
|
doubles.write(2, spawnAt.getZ());
|
||||||
|
|
||||||
|
StructureModifier<Byte> bytes = spawnPlayer.getBytes();
|
||||||
|
bytes.write(0, yaw);
|
||||||
|
bytes.write(1, pitch);
|
||||||
|
|
||||||
|
spawnPlayer.getDataWatcherModifier().write(0, newWatcher);
|
||||||
|
|
||||||
|
// Make him invisible
|
||||||
|
newWatcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(MetaIndex.ENTITY_META.getIndex(),
|
||||||
|
WrappedDataWatcher.Registry.get(Byte.class)), (byte) 32);
|
||||||
|
|
||||||
|
packets.addPacket(spawnPlayer);
|
||||||
|
|
||||||
|
if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
|
||||||
|
PacketContainer[] bedPackets = DisguiseUtilities.getBedPackets(
|
||||||
|
loc.clone().subtract(0, DisguiseUtilities.getYModifier(disguisedEntity, disguise), 0),
|
||||||
|
observer.getLocation(), ((PlayerDisguise) disguise));
|
||||||
|
|
||||||
|
for (PacketContainer packet : bedPackets) {
|
||||||
|
packets.addPacket(packet);
|
||||||
|
}
|
||||||
|
} else if (!selfDisguise) {
|
||||||
|
// Teleport the player back to where he's supposed to be
|
||||||
|
PacketContainer teleportPacket = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||||
|
|
||||||
|
doubles = teleportPacket.getDoubles();
|
||||||
|
|
||||||
|
teleportPacket.getIntegers().write(0, entityId); // Id
|
||||||
|
doubles.write(0, loc.getX());
|
||||||
|
doubles.write(1, loc.getY());
|
||||||
|
doubles.write(2, loc.getZ());
|
||||||
|
|
||||||
|
bytes = teleportPacket.getBytes();
|
||||||
|
bytes.write(0, yaw);
|
||||||
|
bytes.write(1, pitch);
|
||||||
|
|
||||||
|
packets.addPacket(teleportPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selfDisguise) {
|
||||||
|
// Send a metadata packet
|
||||||
|
PacketContainer metaPacket = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
|
|
||||||
|
newWatcher = DisguiseUtilities
|
||||||
|
.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity),
|
||||||
|
disguise.getWatcher());
|
||||||
|
|
||||||
|
metaPacket.getIntegers().write(0, entityId); // Id
|
||||||
|
metaPacket.getWatchableCollectionModifier().write(0, newWatcher.getWatchableObjects());
|
||||||
|
|
||||||
|
packetsHandler.addCancel(disguise, observer);
|
||||||
|
|
||||||
|
// Add a delay to remove the entry from 'cancelMeta'
|
||||||
|
|
||||||
|
packets.addDelayedPacket(metaPacket, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove player from the list
|
||||||
|
PacketContainer deleteTab = sendTab.shallowClone();
|
||||||
|
deleteTab.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4));
|
||||||
|
|
||||||
|
if (!((PlayerDisguise) disguise).isDisplayedInTab()) {
|
||||||
|
packets.addDelayedPacket(deleteTab, 40);
|
||||||
|
}
|
||||||
|
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
||||||
|
Vector vec = disguisedEntity.getVelocity();
|
||||||
|
|
||||||
|
PacketContainer spawnEntity = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||||
|
packets.addPacket(spawnEntity);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = spawnEntity.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, disguisedEntity.getUniqueId());
|
||||||
|
mods.write(2, disguise.getType().getTypeId());
|
||||||
|
|
||||||
|
// region Vector calculations
|
||||||
|
double d1 = 3.9D;
|
||||||
|
double d2 = vec.getX();
|
||||||
|
double d3 = vec.getY();
|
||||||
|
double d4 = vec.getZ();
|
||||||
|
if (d2 < -d1)
|
||||||
|
d2 = -d1;
|
||||||
|
if (d3 < -d1)
|
||||||
|
d3 = -d1;
|
||||||
|
if (d4 < -d1)
|
||||||
|
d4 = -d1;
|
||||||
|
if (d2 > d1)
|
||||||
|
d2 = d1;
|
||||||
|
if (d3 > d1)
|
||||||
|
d3 = d1;
|
||||||
|
if (d4 > d1)
|
||||||
|
d4 = d1;
|
||||||
|
// endregion
|
||||||
|
|
||||||
|
mods.write(3, loc.getX());
|
||||||
|
mods.write(4, loc.getY());
|
||||||
|
mods.write(5, loc.getZ());
|
||||||
|
mods.write(6, (int) (d2 * 8000.0D));
|
||||||
|
mods.write(7, (int) (d3 * 8000.0D));
|
||||||
|
mods.write(8, (int) (d4 * 8000.0D));
|
||||||
|
mods.write(9, yaw);
|
||||||
|
mods.write(10, pitch);
|
||||||
|
mods.write(11, yaw);
|
||||||
|
|
||||||
|
spawnEntity.getDataWatcherModifier().write(0, DisguiseUtilities
|
||||||
|
.createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity),
|
||||||
|
disguise.getWatcher()));
|
||||||
|
} else if (disguise.getType().isMisc()) {
|
||||||
|
int objectId = disguise.getType().getObjectId();
|
||||||
|
int data = ((MiscDisguise) disguise).getData();
|
||||||
|
|
||||||
|
if (disguise.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
|
ItemStack block = ((FallingBlockWatcher) disguise.getWatcher()).getBlock();
|
||||||
|
|
||||||
|
data = ReflectionManager.getCombinedIdByItemStack(block);
|
||||||
|
} else if (disguise.getType() == DisguiseType.FISHING_HOOK && data == -1) {
|
||||||
|
// If the MiscDisguise data isn't set. Then no entity id was provided, so default to the owners
|
||||||
|
// entity id
|
||||||
|
data = observer.getEntityId();
|
||||||
|
} else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
|
data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
||||||
|
|
||||||
|
PacketContainer spawnEntity = ProtocolLibrary.getProtocolManager()
|
||||||
|
.createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data)
|
||||||
|
.createPacket(nmsEntity, objectId, data);
|
||||||
|
packets.addPacket(spawnEntity);
|
||||||
|
|
||||||
|
// If it's not the same type, then highly likely they have different velocity settings which we'd want to
|
||||||
|
// cancel
|
||||||
|
if (DisguiseType.getType(disguisedEntity) != disguise.getType()) {
|
||||||
|
StructureModifier<Integer> ints = spawnEntity.getIntegers();
|
||||||
|
|
||||||
|
ints.write(1, 0);
|
||||||
|
ints.write(2, 0);
|
||||||
|
ints.write(3, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
spawnEntity.getModifier().write(8, pitch);
|
||||||
|
spawnEntity.getModifier().write(9, yaw);
|
||||||
|
|
||||||
|
if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
|
if (data % 2 == 0) {
|
||||||
|
spawnEntity.getModifier().write(4, loc.getZ() + (data == 0 ? -1 : 1));
|
||||||
|
} else {
|
||||||
|
spawnEntity.getModifier().write(2, loc.getX() + (data == 3 ? -1 : 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packets.getPackets().size() <= 1 || disguise.isPlayerDisguise()) {
|
||||||
|
PacketContainer rotateHead = new PacketContainer(PacketType.Play.Server.ENTITY_HEAD_ROTATION);
|
||||||
|
packets.addPacket(rotateHead);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = rotateHead.getModifier();
|
||||||
|
|
||||||
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
|
mods.write(1, yaw);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (disguise.getType() == DisguiseType.EVOKER_FANGS) {
|
||||||
|
PacketContainer newPacket = new PacketContainer(PacketType.Play.Server.ENTITY_STATUS);
|
||||||
|
|
||||||
|
StructureModifier<Object> mods = newPacket.getModifier();
|
||||||
|
mods.write(0, disguise.getEntity().getEntityId());
|
||||||
|
mods.write(1, (byte) 4);
|
||||||
|
|
||||||
|
packets.addPacket(newPacket);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package me.libraryaddict.disguise.utilities.packets.packethandlers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.IPacketHandler;
|
||||||
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by libraryaddict on 3/01/2019.
|
||||||
|
*/
|
||||||
|
public class PacketHandlerVelocity implements IPacketHandler {
|
||||||
|
@Override
|
||||||
|
public PacketType[] getHandledPackets() {
|
||||||
|
return new PacketType[]{PacketType.Play.Server.ENTITY_VELOCITY};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
|
||||||
|
Entity entity) {
|
||||||
|
// If the disguise is a misc and the disguised is not the same type
|
||||||
|
if (disguise.getType().isMisc() && DisguiseType.getType(entity) != disguise.getType()) {
|
||||||
|
packets.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -21,7 +21,7 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
|
|
||||||
public class PacketListenerInventory extends PacketAdapter {
|
public class PacketListenerInventory extends PacketAdapter {
|
||||||
private LibsDisguises libsDisguises;
|
private LibsDisguises libsDisguises;
|
@ -1,10 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
@ -14,12 +8,16 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class PacketListenerMain extends PacketAdapter {
|
public class PacketListenerMain extends PacketAdapter {
|
||||||
public PacketListenerMain(LibsDisguises plugin, ArrayList<PacketType> packetsToListen) {
|
public PacketListenerMain(LibsDisguises plugin, ArrayList<PacketType> packetsToListen) {
|
||||||
@ -54,7 +52,7 @@ public class PacketListenerMain extends PacketAdapter {
|
|||||||
LibsPackets packets;
|
LibsPackets packets;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
packets = PacketsManager.transformPacket(event.getPacket(), disguise, observer, entity);
|
packets = PacketsManager.getPacketsHandler().transformPacket(event.getPacket(), disguise, observer, entity);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -80,7 +78,5 @@ public class PacketListenerMain extends PacketAdapter {
|
|||||||
catch (InvocationTargetException ex) {
|
catch (InvocationTargetException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
@ -15,7 +15,7 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
|||||||
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packets.packetlisteners;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.PacketType.Play.Server;
|
import com.comphenix.protocol.PacketType.Play.Server;
|
||||||
@ -12,9 +12,9 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
|||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.packets.LibsPackets;
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -67,7 +67,8 @@ 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.
|
// Here I grab the packets to convert them to, So I can display them as if the disguise sent them.
|
||||||
LibsPackets transformed = PacketsManager.transformPacket(packet, disguise, observer, observer);
|
LibsPackets transformed = PacketsManager.getPacketsHandler()
|
||||||
|
.transformPacket(packet, disguise, observer, observer);
|
||||||
|
|
||||||
if (transformed.isUnhandled()) {
|
if (transformed.isUnhandled()) {
|
||||||
transformed.getPackets().add(packet);
|
transformed.getPackets().add(packet);
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser;
|
package me.libraryaddict.disguise.utilities.parser;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by libraryaddict on 7/09/2018.
|
* Created by libraryaddict on 7/09/2018.
|
||||||
|
@ -3,8 +3,8 @@ package me.libraryaddict.disguise.utilities.parser;
|
|||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.*;
|
import me.libraryaddict.disguise.disguisetypes.*;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser.params;
|
package me.libraryaddict.disguise.utilities.parser.params;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser.params.types.base;
|
package me.libraryaddict.disguise.utilities.parser.params.types.base;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser.params.types.custom;
|
package me.libraryaddict.disguise.utilities.parser.params.types.custom;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
|
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
@ -2,7 +2,7 @@ package me.libraryaddict.disguise.utilities.parser.params.types.custom;
|
|||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
|
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
public class FakeBoundingBox {
|
public class FakeBoundingBox {
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
@ -1,4 +1,4 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.reflection;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.*;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.translations;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
@ -1,6 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.translations;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
|
||||||
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
|
||||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
@ -1,6 +1,8 @@
|
|||||||
package me.libraryaddict.disguise.utilities;
|
package me.libraryaddict.disguise.utilities.translations;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||||
import org.apache.commons.lang.StringEscapeUtils;
|
import org.apache.commons.lang.StringEscapeUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
Loading…
Reference in New Issue
Block a user