Formatting by project
This commit is contained in:
parent
1edc05d9ff
commit
0496134dee
@ -14,9 +14,9 @@ public class DisguiseConfig {
|
|||||||
private static String disguiseBlownMessage;
|
private static String disguiseBlownMessage;
|
||||||
private static int disguiseCloneExpire;
|
private static int disguiseCloneExpire;
|
||||||
private static int disguiseEntityExpire;
|
private static int disguiseEntityExpire;
|
||||||
private static boolean equipmentEnabled;
|
|
||||||
private static boolean entityAnimationsAdded;
|
private static boolean entityAnimationsAdded;
|
||||||
private static boolean entityStatusEnabled;
|
private static boolean entityStatusEnabled;
|
||||||
|
private static boolean equipmentEnabled;
|
||||||
private static boolean hearSelfDisguise;
|
private static boolean hearSelfDisguise;
|
||||||
private static boolean hidingArmor;
|
private static boolean hidingArmor;
|
||||||
private static boolean hidingHeldItem;
|
private static boolean hidingHeldItem;
|
||||||
@ -105,13 +105,13 @@ public class DisguiseConfig {
|
|||||||
return blowDisguisesOnAttack;
|
return blowDisguisesOnAttack;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isEquipmentPacketsEnabled() {
|
|
||||||
return equipmentEnabled;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Spelling mistake.
|
* @deprecated Spelling mistake.
|
||||||
*/
|
*/
|
||||||
@Deprecated public static boolean isEnquipmentPacketsEnabled() { return equipmentEnabled; }
|
@Deprecated
|
||||||
|
public static boolean isEnquipmentPacketsEnabled() {
|
||||||
|
return equipmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isEntityAnimationsAdded() {
|
public static boolean isEntityAnimationsAdded() {
|
||||||
return entityAnimationsAdded;
|
return entityAnimationsAdded;
|
||||||
@ -121,6 +121,10 @@ public class DisguiseConfig {
|
|||||||
return entityStatusEnabled;
|
return entityStatusEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isEquipmentPacketsEnabled() {
|
||||||
|
return equipmentEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around
|
* Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around
|
||||||
*/
|
*/
|
||||||
|
@ -32,7 +32,8 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
|||||||
boolean doSneak = false;
|
boolean doSneak = false;
|
||||||
boolean doSprint = false;
|
boolean doSprint = false;
|
||||||
for (String option : args) {
|
for (String option : args) {
|
||||||
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip") || StringUtils.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
if (StringUtils.startsWithIgnoreCase(option, "ignoreEquip")
|
||||||
|
|| StringUtils.startsWithIgnoreCase(option, "ignoreEnquip")) {
|
||||||
doEquipment = false;
|
doEquipment = false;
|
||||||
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
} else if (option.equalsIgnoreCase("doSneakSprint")) {
|
||||||
doSneak = true;
|
doSneak = true;
|
||||||
@ -62,8 +63,9 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
|||||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN
|
sender.sendMessage(ChatColor.DARK_GREEN
|
||||||
+ "Right click a entity to get a disguise reference you can pass to other disguise commands!");
|
+ "Right click a entity to get a disguise reference you can pass to other disguise commands!");
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "Security note: Any references you create will be available to all players able to use disguise references.");
|
sender.sendMessage(ChatColor.DARK_GREEN
|
||||||
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "("
|
+ "Security note: Any references you create will be available to all players able to use disguise references.");
|
||||||
+ ChatColor.GREEN + "Optional" + ChatColor.DARK_GREEN + ")");
|
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseclone IgnoreEquipment" + ChatColor.DARK_GREEN + "(" + ChatColor.GREEN
|
||||||
|
+ "Optional" + ChatColor.DARK_GREEN + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -10,7 +9,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class UndisguiseCommand implements CommandExecutor {
|
public class UndisguiseCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -10,7 +9,6 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class UndisguisePlayerCommand implements CommandExecutor {
|
public class UndisguisePlayerCommand implements CommandExecutor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -10,7 +9,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||||
private int maxRadius = 30;
|
private int maxRadius = 30;
|
||||||
|
|
||||||
|
@ -62,8 +62,7 @@ public class MobDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesDisguiseAge() {
|
public boolean doesDisguiseAge() {
|
||||||
return getWatcher() != null &&
|
return getWatcher() != null && (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||||
(getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdult() {
|
public boolean isAdult() {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.libraryaddict.disguise.events;
|
package me.libraryaddict.disguise.events;
|
||||||
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -8,7 +7,6 @@ import org.bukkit.event.Cancellable;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
|
||||||
public class UndisguiseEvent extends Event implements Cancellable {
|
public class UndisguiseEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
@ -98,8 +98,8 @@ public enum DisguiseSound {
|
|||||||
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
|
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
|
||||||
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
|
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
|
||||||
|
|
||||||
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect", "mob.zombie.woodbreak",
|
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
|
||||||
"mob.zombie.metal", "mob.zombie.wood");
|
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
|
||||||
|
|
||||||
public enum SoundType {
|
public enum SoundType {
|
||||||
CANCEL, DEATH, HURT, IDLE, STEP;
|
CANCEL, DEATH, HURT, IDLE, STEP;
|
||||||
|
@ -204,8 +204,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||||
PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
||||||
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() });
|
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() });
|
||||||
@ -323,8 +323,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
for (Object p : trackedPlayers) {
|
for (Object p : trackedPlayers) {
|
||||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||||
if (((TargetedDisguise) disguise).canSee(player)) {
|
if (((TargetedDisguise) disguise).canSee(player)) {
|
||||||
@ -460,8 +460,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||||
@ -489,8 +489,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity);
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(entity);
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||||
@ -520,8 +520,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
Method clear = ReflectionManager.getNmsMethod("EntityTrackerEntry", "clear",
|
||||||
ReflectionManager.getNmsClass("EntityPlayer"));
|
ReflectionManager.getNmsClass("EntityPlayer"));
|
||||||
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
|
||||||
@ -582,8 +582,8 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(player);
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
HashSet trackedPlayers = (HashSet) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(
|
||||||
.get(entityTrackerEntry);
|
entityTrackerEntry);
|
||||||
// If the tracker exists. Remove himself from his tracker
|
// If the tracker exists. Remove himself from his tracker
|
||||||
trackedPlayers.remove(ReflectionManager.getNmsEntity(player));
|
trackedPlayers.remove(ReflectionManager.getNmsEntity(player));
|
||||||
}
|
}
|
||||||
@ -631,7 +631,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
int fakeId = selfDisguisesIds.get(player.getUniqueId());
|
int fakeId = selfDisguisesIds.get(player.getUniqueId());
|
||||||
// Add himself to his own entity tracker
|
// Add himself to his own entity tracker
|
||||||
((HashSet<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager.getNmsEntity(player));
|
((HashSet<Object>) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers").get(entityTrackerEntry))
|
||||||
|
.add(ReflectionManager.getNmsEntity(player));
|
||||||
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
|
||||||
// Send the player a packet with himself being spawned
|
// Send the player a packet with himself being spawned
|
||||||
manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
|
manager.sendServerPacket(player, manager.createPacketConstructor(PacketType.Play.Server.NAMED_ENTITY_SPAWN, player)
|
||||||
|
@ -64,8 +64,10 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||||
private static final boolean isForge = Bukkit.getServer().getName().equalsIgnoreCase("Cauldron");
|
private static final Class<?> craftItemClass;
|
||||||
|
|
||||||
|
private static Method damageAndIdleSoundMethod;
|
||||||
|
private static final Field entitiesField;
|
||||||
/**
|
/**
|
||||||
* Map of mc-dev simple class name to fully qualified Forge class name.
|
* Map of mc-dev simple class name to fully qualified Forge class name.
|
||||||
*/
|
*/
|
||||||
@ -74,26 +76,25 @@ public class ReflectionManager {
|
|||||||
* Map of Forge fully qualified class names to a map from mc-dev field names to Forge field names.
|
* Map of Forge fully qualified class names to a map from mc-dev field names to Forge field names.
|
||||||
*/
|
*/
|
||||||
private static Map<String, Map<String, String>> ForgeFieldMappings;
|
private static Map<String, Map<String, String>> ForgeFieldMappings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method names.
|
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method
|
||||||
|
* names.
|
||||||
*/
|
*/
|
||||||
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
||||||
private static Map<Class<?>, String> primitiveTypes;
|
|
||||||
|
|
||||||
|
private static final Method ihmGet;
|
||||||
|
private static final boolean isForge = Bukkit.getServer().getName().equalsIgnoreCase("Cauldron");
|
||||||
|
private static final Field pingField;
|
||||||
|
private static Map<Class<?>, String> primitiveTypes;
|
||||||
|
private static final Field trackerField;
|
||||||
static {
|
static {
|
||||||
final String nameseg_class = "a-zA-Z0-9$_";
|
final String nameseg_class = "a-zA-Z0-9$_";
|
||||||
final String fqn_class = nameseg_class + "/";
|
final String fqn_class = nameseg_class + "/";
|
||||||
|
|
||||||
primitiveTypes = ImmutableMap.<Class<?>, String>builder()
|
primitiveTypes = ImmutableMap.<Class<?>, String> builder().put(boolean.class, "Z").put(byte.class, "B")
|
||||||
.put(boolean.class,"Z")
|
.put(char.class, "C").put(short.class, "S").put(int.class, "I").put(long.class, "J").put(float.class, "F")
|
||||||
.put(byte.class, "B")
|
.put(double.class, "D").put(void.class, "V").build();
|
||||||
.put(char.class, "C")
|
|
||||||
.put(short.class, "S")
|
|
||||||
.put(int.class, "I")
|
|
||||||
.put(long.class, "J")
|
|
||||||
.put(float.class, "F")
|
|
||||||
.put(double.class, "D")
|
|
||||||
.put(void.class, "V").build();
|
|
||||||
|
|
||||||
if (isForge) {
|
if (isForge) {
|
||||||
// Initialize the maps by reading the srg file
|
// Initialize the maps by reading the srg file
|
||||||
@ -107,12 +108,14 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
// 1: cb-simpleName
|
// 1: cb-simpleName
|
||||||
// 2: forge-fullName (Needs dir2fqn())
|
// 2: forge-fullName (Needs dir2fqn())
|
||||||
Pattern classPattern = Pattern.compile("^CL: net/minecraft/server/([" + nameseg_class + "]+) ([" + fqn_class + "]+)$");
|
Pattern classPattern = Pattern.compile("^CL: net/minecraft/server/([" + nameseg_class + "]+) ([" + fqn_class
|
||||||
|
+ "]+)$");
|
||||||
// 1: cb-simpleName
|
// 1: cb-simpleName
|
||||||
// 2: cb-fieldName
|
// 2: cb-fieldName
|
||||||
// 3: forge-fullName (Needs dir2fqn())
|
// 3: forge-fullName (Needs dir2fqn())
|
||||||
// 4: forge-fieldName
|
// 4: forge-fieldName
|
||||||
Pattern fieldPattern = Pattern.compile("^FD: net/minecraft/server/([" + nameseg_class + "]+)/([" + nameseg_class + "]+) ([" + fqn_class + "]+)/([" + nameseg_class + "]+)$");
|
Pattern fieldPattern = Pattern.compile("^FD: net/minecraft/server/([" + nameseg_class + "]+)/([" + nameseg_class
|
||||||
|
+ "]+) ([" + fqn_class + "]+)/([" + nameseg_class + "]+)$");
|
||||||
// 1: cb-simpleName
|
// 1: cb-simpleName
|
||||||
// 2: cb-methodName
|
// 2: cb-methodName
|
||||||
// 3: cb-signature-args
|
// 3: cb-signature-args
|
||||||
@ -121,8 +124,9 @@ public class ReflectionManager {
|
|||||||
// 6: forge-methodName
|
// 6: forge-methodName
|
||||||
// 7: forge-signature-args
|
// 7: forge-signature-args
|
||||||
// 8: forge-signature-ret
|
// 8: forge-signature-ret
|
||||||
Pattern methodPattern = Pattern.compile("^MD: net/minecraft/server/([" + fqn_class + "]+)/([" + nameseg_class + "]+) \\(([;\\[" + fqn_class + "]*)\\)([;\\[" + fqn_class + "]+) " +
|
Pattern methodPattern = Pattern.compile("^MD: net/minecraft/server/([" + fqn_class + "]+)/([" + nameseg_class
|
||||||
"([" + fqn_class + "]+)/([" + nameseg_class + "]+) \\(([;\\[" + fqn_class + "]*)\\)([;\\[" + fqn_class + "]+)$");
|
+ "]+) \\(([;\\[" + fqn_class + "]*)\\)([;\\[" + fqn_class + "]+) " + "([" + fqn_class + "]+)/(["
|
||||||
|
+ nameseg_class + "]+) \\(([;\\[" + fqn_class + "]*)\\)([;\\[" + fqn_class + "]+)$");
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
@ -169,21 +173,16 @@ public class ReflectionManager {
|
|||||||
System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings");
|
System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings");
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
System.err
|
||||||
|
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
System.err
|
||||||
|
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> craftItemClass;
|
|
||||||
private static final Field pingField;
|
|
||||||
private static final Field trackerField;
|
|
||||||
private static final Field entitiesField;
|
|
||||||
private static final Method ihmGet;
|
|
||||||
private static Method damageAndIdleSoundMethod;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
|
for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
|
||||||
try {
|
try {
|
||||||
@ -213,12 +212,6 @@ public class ReflectionManager {
|
|||||||
DisguiseType.ARROW.isMisc();
|
DisguiseType.ARROW.isMisc();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String dir2fqn(String s) {
|
|
||||||
return s.replaceAll("/", ".");
|
|
||||||
}
|
|
||||||
|
|
||||||
// ===
|
|
||||||
|
|
||||||
public static Object createEntityInstance(String entityName) {
|
public static Object createEntityInstance(String entityName) {
|
||||||
try {
|
try {
|
||||||
Class<?> entityClass = getNmsClass("Entity" + entityName);
|
Class<?> entityClass = getNmsClass("Entity" + entityName);
|
||||||
@ -248,6 +241,12 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===
|
||||||
|
|
||||||
|
private static String dir2fqn(String s) {
|
||||||
|
return s.replaceAll("/", ".");
|
||||||
|
}
|
||||||
|
|
||||||
public static FakeBoundingBox getBoundingBox(Entity entity) {
|
public static FakeBoundingBox getBoundingBox(Entity entity) {
|
||||||
try {
|
try {
|
||||||
Object boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
Object boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
||||||
@ -328,6 +327,13 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Object getEntityTrackerEntry(Entity target) throws Exception {
|
||||||
|
Object world = getWorld(target.getWorld());
|
||||||
|
Object tracker = trackerField.get(world);
|
||||||
|
Object trackedEntities = entitiesField.get(tracker);
|
||||||
|
return ihmGet.invoke(trackedEntities, target.getEntityId());
|
||||||
|
}
|
||||||
|
|
||||||
public static String getEnumArt(Art art) {
|
public static String getEnumArt(Art art) {
|
||||||
try {
|
try {
|
||||||
Object enumArt = getCraftClass("CraftArt").getMethod("BukkitToNotch", Art.class).invoke(null, art);
|
Object enumArt = getCraftClass("CraftArt").getMethod("BukkitToNotch", Art.class).invoke(null, art);
|
||||||
@ -342,13 +348,6 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Object getEntityTrackerEntry(Entity target) throws Exception {
|
|
||||||
Object world = getWorld(target.getWorld());
|
|
||||||
Object tracker = trackerField.get(world);
|
|
||||||
Object trackedEntities = entitiesField.get(tracker);
|
|
||||||
return ihmGet.invoke(trackedEntities, target.getEntityId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static WrappedGameProfile getGameProfile(Player player) {
|
public static WrappedGameProfile getGameProfile(Player player) {
|
||||||
if (LibVersion.is1_7()) {
|
if (LibVersion.is1_7()) {
|
||||||
return WrappedGameProfile.fromPlayer(player);
|
return WrappedGameProfile.fromPlayer(player);
|
||||||
@ -406,19 +405,6 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getNmsItem(ItemStack itemstack) {
|
|
||||||
try {
|
|
||||||
return craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(null, itemstack);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Field getNmsField(String className, String fieldName) {
|
|
||||||
return getNmsField(getNmsClass(className), fieldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Field getNmsField(Class clazz, String fieldName) {
|
public static Field getNmsField(Class clazz, String fieldName) {
|
||||||
if (isForge) {
|
if (isForge) {
|
||||||
try {
|
try {
|
||||||
@ -436,18 +422,17 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method getNmsMethod(String className, String methodName, Class<?>... parameters) {
|
public static Field getNmsField(String className, String fieldName) {
|
||||||
return getNmsMethod(getNmsClass(className), methodName, parameters);
|
return getNmsField(getNmsClass(className), fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String methodSignaturePart(Class<?> param) {
|
public static Object getNmsItem(ItemStack itemstack) {
|
||||||
if (param.isArray()) {
|
try {
|
||||||
return "[" + methodSignaturePart(param.getComponentType());
|
return craftItemClass.getMethod("asNMSCopy", ItemStack.class).invoke(null, itemstack);
|
||||||
} else if (param.isPrimitive()) {
|
} catch (Exception e) {
|
||||||
return primitiveTypes.get(param);
|
e.printStackTrace();
|
||||||
} else {
|
|
||||||
return "L" + param.getName().replaceAll("\\.", "/") + ";";
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Method getNmsMethod(Class<?> clazz, String methodName, Class<?>... parameters) {
|
public static Method getNmsMethod(Class<?> clazz, String methodName, Class<?>... parameters) {
|
||||||
@ -472,6 +457,10 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Method getNmsMethod(String className, String methodName, Class<?>... parameters) {
|
||||||
|
return getNmsMethod(getNmsClass(className), methodName, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
public static double getPing(Player player) {
|
public static double getPing(Player player) {
|
||||||
try {
|
try {
|
||||||
return (double) pingField.getInt(ReflectionManager.getNmsEntity(player));
|
return (double) pingField.getInt(ReflectionManager.getNmsEntity(player));
|
||||||
@ -554,6 +543,16 @@ public class ReflectionManager {
|
|||||||
return !gameProfile.getProperties().isEmpty();
|
return !gameProfile.getProperties().isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String methodSignaturePart(Class<?> param) {
|
||||||
|
if (param.isArray()) {
|
||||||
|
return "[" + methodSignaturePart(param.getComponentType());
|
||||||
|
} else if (param.isPrimitive()) {
|
||||||
|
return primitiveTypes.get(param);
|
||||||
|
} else {
|
||||||
|
return "L" + param.getName().replaceAll("\\.", "/") + ";";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setAllowSleep(Player player) {
|
public static void setAllowSleep(Player player) {
|
||||||
try {
|
try {
|
||||||
Object nmsEntity = getNmsEntity(player);
|
Object nmsEntity = getNmsEntity(player);
|
||||||
|
Loading…
Reference in New Issue
Block a user