Updated for 1.8.6.
Code cleanup. Fixed permissions.
This commit is contained in:
@@ -45,7 +45,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||
ArrayList<String> allowedDisguises = new ArrayList<String>();
|
||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||
for (DisguiseType type : hashMap.keySet()) {
|
||||
allowedDisguises.add(type.toReadable().replace(" ", "_"));
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
case SPLASH_POTION:
|
||||
case FISHING_HOOK:
|
||||
case DROPPED_ITEM:
|
||||
HashMap<String, Boolean> returns = new HashMap<String, Boolean>();
|
||||
HashMap<String, Boolean> returns = new HashMap<>();
|
||||
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
|
||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||
String lowerPerm = permission.getPermission().toLowerCase();
|
||||
@@ -82,7 +82,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
return returns;
|
||||
default:
|
||||
return new HashMap<String, Boolean>();
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,8 +108,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
* @return
|
||||
*/
|
||||
protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) {
|
||||
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>>();
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>();
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> rangeDisguises = new HashMap<>();
|
||||
HashMap<String, Boolean> perms = new HashMap<>();
|
||||
|
||||
@@ -142,7 +141,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
if (singleDisguises.containsKey(dType)) {
|
||||
list = singleDisguises.get(dType);
|
||||
} else {
|
||||
list = new HashMap<ArrayList<String>, Boolean>();
|
||||
list = new HashMap<>();
|
||||
singleDisguises.put(dType, list);
|
||||
}
|
||||
HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm);
|
||||
@@ -179,7 +178,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
if (rangeDisguises.containsKey(type)) {
|
||||
list = rangeDisguises.get(type);
|
||||
} else {
|
||||
list = new HashMap<ArrayList<String>, Boolean>();
|
||||
list = new HashMap<>();
|
||||
rangeDisguises.put(type, list);
|
||||
}
|
||||
HashMap<ArrayList<String>, Boolean> map1 = getOptions(perm);
|
||||
@@ -237,9 +236,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>>();
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map = new HashMap<>();
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
HashMap<ArrayList<String>, Boolean> temp = new HashMap<ArrayList<String>, Boolean>();
|
||||
HashMap<ArrayList<String>, Boolean> temp = new HashMap<>();
|
||||
if (singleDisguises.containsKey(type)) {
|
||||
temp.putAll(singleDisguises.get(type));
|
||||
}
|
||||
@@ -254,7 +253,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private HashMap<ArrayList<String>, Boolean> getOptions(String perm) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
boolean isRemove = true;
|
||||
String[] split = perm.split("\\.");
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
@@ -268,7 +267,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
option = "setbaby";
|
||||
list.add(option);
|
||||
}
|
||||
HashMap<ArrayList<String>, Boolean> options = new HashMap<ArrayList<String>, Boolean>();
|
||||
HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
|
||||
options.put(list, isRemove);
|
||||
return options;
|
||||
}
|
||||
@@ -295,9 +294,15 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The
|
||||
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the
|
||||
* disguise has been feed a proper disguisetype.
|
||||
* @param sender
|
||||
* @param args
|
||||
* @param map
|
||||
* @return
|
||||
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
*/
|
||||
protected Disguise parseDisguise(CommandSender sender, String[] args,
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException,
|
||||
protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
if (map.isEmpty()) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "You are forbidden to use this command.");
|
||||
@@ -310,7 +315,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
// Time to start constructing the disguise.
|
||||
// We will need to check between all 3 kinds of disguises
|
||||
int toSkip = 1;
|
||||
ArrayList<String> usedOptions = new ArrayList<String>();
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
Disguise disguise = null;
|
||||
HashMap<ArrayList<String>, Boolean> optionPermissions;
|
||||
if (args[0].startsWith("@")) {
|
||||
|
@@ -19,7 +19,7 @@ import java.util.jar.JarFile;
|
||||
public class ClassGetter {
|
||||
|
||||
public static ArrayList<Class<?>> getClassesForPackage(String pkgname) {
|
||||
ArrayList<Class<?>> classes = new ArrayList<Class<?>>();
|
||||
ArrayList<Class<?>> classes = new ArrayList<>();
|
||||
// String relPath = pkgname.replace('.', '/');
|
||||
|
||||
// Get a File object for the package
|
||||
|
@@ -123,9 +123,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
}
|
||||
|
||||
private HashSet<String> cancelSounds = new HashSet<String>();
|
||||
private HashSet<String> cancelSounds = new HashSet<>();
|
||||
private float damageSoundVolume = 1F;
|
||||
private HashMap<SoundType, String> disguiseSounds = new HashMap<SoundType, String>();
|
||||
private HashMap<SoundType, String> disguiseSounds = new HashMap<>();
|
||||
|
||||
private DisguiseSound(Object... sounds) {
|
||||
for (int i = 0; i < sounds.length; i++) {
|
||||
|
@@ -55,25 +55,25 @@ public class DisguiseUtilities {
|
||||
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of
|
||||
* the plugin to do that.
|
||||
*/
|
||||
private static HashSet<String> addedByPlugins = new HashSet<String>();
|
||||
private static HashSet<String> addedByPlugins = new HashSet<>();
|
||||
private static Object bedChunk;
|
||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<String, Disguise>();
|
||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
|
||||
/**
|
||||
* A hashmap of the uuid's of entitys, alive and dead. And their disguises in use
|
||||
**/
|
||||
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<UUID, HashSet<TargetedDisguise>>();
|
||||
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
|
||||
/**
|
||||
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for
|
||||
* a max of a second.
|
||||
*/
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<Integer, HashSet<TargetedDisguise>>();
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
||||
/**
|
||||
* A hashmap storing the uuid and skin of a playername
|
||||
*/
|
||||
private static HashMap<String, WrappedGameProfile> gameProfiles = new HashMap<String, WrappedGameProfile>();
|
||||
private static HashMap<String, WrappedGameProfile> gameProfiles = new HashMap<>();
|
||||
private static LibsDisguises libsDisguises;
|
||||
private static HashMap<String, ArrayList<Object>> runnables = new HashMap<String, ArrayList<Object>>();
|
||||
private static HashSet<UUID> selfDisguised = new HashSet<UUID>();
|
||||
private static HashMap<String, ArrayList<Object>> runnables = new HashMap<>();
|
||||
private static HashSet<UUID> selfDisguised = new HashSet<>();
|
||||
private static Field xChunk, zChunk;
|
||||
|
||||
static {
|
||||
@@ -149,6 +149,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
futureDisguises.get(entityId).add(disguise);
|
||||
final BukkitRunnable runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (futureDisguises.containsKey(entityId) && futureDisguises.get(entityId).contains(disguise)) {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
@@ -210,7 +211,7 @@ public class DisguiseUtilities {
|
||||
d.removePlayer(name);
|
||||
}
|
||||
} else {
|
||||
for (String playername : new ArrayList<String>(d.getObservers())) {
|
||||
for (String playername : new ArrayList<>(d.getObservers())) {
|
||||
if (!disguise.getObservers().contains(playername)) {
|
||||
d.silentlyRemovePlayer(playername);
|
||||
}
|
||||
@@ -434,7 +435,7 @@ public class DisguiseUtilities {
|
||||
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
|
||||
*/
|
||||
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
try {
|
||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||
if (entityTrackerEntry != null) {
|
||||
@@ -501,10 +502,12 @@ public class DisguiseUtilities {
|
||||
// Add null so that if this is called again. I already know I'm doing something about it
|
||||
gameProfiles.put(playerName, null);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final WrappedGameProfile gameProfile = lookupGameProfile(origName);
|
||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!gameProfile.getProperties().isEmpty()) {
|
||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||
@@ -537,7 +540,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
if (runnable != null) {
|
||||
if (!runnables.containsKey(playerName)) {
|
||||
runnables.put(playerName, new ArrayList<Object>());
|
||||
runnables.put(playerName, new ArrayList<>());
|
||||
}
|
||||
runnables.get(playerName).add(runnable);
|
||||
}
|
||||
@@ -585,8 +588,8 @@ public class DisguiseUtilities {
|
||||
List<WrappedWatchableObject> list) {
|
||||
if (true) // Use for future protocol compatibility
|
||||
return list;
|
||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>();
|
||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>();
|
||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>();
|
||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<>();
|
||||
for (WrappedWatchableObject obj : list) {
|
||||
if (obj.getValue().getClass().getName().startsWith("org.")) {
|
||||
backups.add(obj);
|
||||
@@ -624,6 +627,7 @@ public class DisguiseUtilities {
|
||||
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
||||
@@ -648,6 +652,7 @@ public class DisguiseUtilities {
|
||||
clear.invoke(entityTrackerEntry, p);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
updatePlayer.invoke(entityTrackerEntry, p);
|
||||
@@ -689,6 +694,7 @@ public class DisguiseUtilities {
|
||||
clear.invoke(entityTrackerEntry, p);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
updatePlayer.invoke(entityTrackerEntry, p);
|
||||
@@ -718,6 +724,7 @@ public class DisguiseUtilities {
|
||||
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
||||
@@ -742,6 +749,7 @@ public class DisguiseUtilities {
|
||||
clear.invoke(entityTrackerEntry, p);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
updatePlayer.invoke(entityTrackerEntry, p);
|
||||
@@ -837,6 +845,7 @@ public class DisguiseUtilities {
|
||||
// Else its going to run in a infinite loop hue hue hue..
|
||||
// At least until this disguise is discarded
|
||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (DisguiseAPI.getDisguise(player, player) == disguise) {
|
||||
sendSelfDisguise(player, disguise);
|
||||
@@ -942,6 +951,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
if (delayed != null && delayed.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayed) {
|
||||
|
@@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
|
||||
public class DisguiseValues {
|
||||
|
||||
private static HashMap<DisguiseType, DisguiseValues> values = new HashMap<DisguiseType, DisguiseValues>();
|
||||
private static HashMap<DisguiseType, DisguiseValues> values = new HashMap<>();
|
||||
|
||||
public static DisguiseValues getDisguiseValues(DisguiseType type) {
|
||||
switch (type) {
|
||||
@@ -49,7 +49,7 @@ public class DisguiseValues {
|
||||
private float[] entitySize;
|
||||
private int enumEntitySize;
|
||||
private double maxHealth;
|
||||
private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>();
|
||||
private HashMap<Integer, Object> metaValues = new HashMap<>();
|
||||
private Class nmsEntityClass;
|
||||
|
||||
public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) {
|
||||
|
@@ -176,6 +176,7 @@ public class Metrics {
|
||||
task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide with the disable method.
|
||||
@@ -218,12 +219,7 @@ public class Metrics {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(getConfigFile());
|
||||
} catch (IOException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
if (debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
|
||||
}
|
||||
@@ -389,12 +385,13 @@ public class Metrics {
|
||||
OutputStream os = connection.getOutputStream();
|
||||
os.write(compressed);
|
||||
os.flush();
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String response = reader.readLine();
|
||||
// close resources
|
||||
String response;
|
||||
try ( // Now read the response
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
response = reader.readLine();
|
||||
// close resources
|
||||
os.close();
|
||||
reader.close();
|
||||
}
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
response = "null";
|
||||
@@ -551,7 +548,7 @@ public class Metrics {
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
|
@@ -122,7 +122,7 @@ public class PacketsManager {
|
||||
if (disguise.getEntity() == null)
|
||||
disguise.setEntity(disguisedEntity);
|
||||
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
||||
ArrayList<PacketContainer> packets = new ArrayList<PacketContainer>();
|
||||
ArrayList<PacketContainer> packets = new ArrayList<>();
|
||||
// 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()) {
|
||||
@@ -154,7 +154,7 @@ public class PacketsManager {
|
||||
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||
List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>();
|
||||
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||
Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");
|
||||
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
||||
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
||||
@@ -265,11 +265,12 @@ public class PacketsManager {
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<PacketContainer> newPackets = new ArrayList<PacketContainer>();
|
||||
ArrayList<PacketContainer> newPackets = new ArrayList<>();
|
||||
newPackets.add(null);
|
||||
for (int i = 0; i < spawnPackets.length; i++) {
|
||||
if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists.
|
||||
newPackets.add(spawnPackets[i]);
|
||||
for (PacketContainer spawnPacket : spawnPackets) {
|
||||
if (spawnPacket != null) {
|
||||
// Get rid of empty packet '1' if it exists.
|
||||
newPackets.add(spawnPacket);
|
||||
}
|
||||
}
|
||||
spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]);
|
||||
@@ -550,8 +551,7 @@ public class PacketsManager {
|
||||
DisguiseSound entitySound = null;
|
||||
Disguise disguise = null;
|
||||
Entity[] entities = soundLoc.getChunk().getEntities();
|
||||
for (int i = 0; i < entities.length; i++) {
|
||||
Entity entity = entities[i];
|
||||
for (Entity entity : entities) {
|
||||
Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity);
|
||||
if (entityDisguise != null) {
|
||||
Location loc = entity.getLocation();
|
||||
@@ -581,7 +581,7 @@ public class PacketsManager {
|
||||
if (entity instanceof LivingEntity) {
|
||||
hasInvun = ReflectionManager.getNmsField("Entity", "noDamageTicks").getInt(
|
||||
nmsEntity) == ReflectionManager.getNmsField("EntityLiving",
|
||||
"maxNoDamageTicks").getInt(nmsEntity);
|
||||
"maxNoDamageTicks").getInt(nmsEntity);
|
||||
} else {
|
||||
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable", DamageSource.class)
|
||||
.invoke(nmsEntity, DamageSource.GENERIC);
|
||||
@@ -792,6 +792,7 @@ public class PacketsManager {
|
||||
}
|
||||
if (delayedPackets != null && delayedPackets.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayedPackets) {
|
||||
@@ -959,6 +960,7 @@ public class PacketsManager {
|
||||
// Rather than predict the clients actions
|
||||
// Lets just update the entire inventory..
|
||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
@@ -1146,7 +1148,7 @@ public class PacketsManager {
|
||||
if (mainListener != null) {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(mainListener);
|
||||
}
|
||||
List<PacketType> packetsToListen = new ArrayList<PacketType>();
|
||||
List<PacketType> packetsToListen = new ArrayList<>();
|
||||
// Add spawn packets
|
||||
{
|
||||
packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||
@@ -1213,6 +1215,7 @@ public class PacketsManager {
|
||||
final PacketContainer[] delayed = packets[1];
|
||||
if (delayed.length > 0) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (PacketContainer packet : delayed) {
|
||||
@@ -1278,7 +1281,7 @@ public class PacketsManager {
|
||||
if (disguise.isMiscDisguise()) {
|
||||
packets = new PacketContainer[0];
|
||||
} else {
|
||||
List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>();
|
||||
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||
for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) {
|
||||
if (attribute.getAttributeKey().equals("generic.maxHealth")) {
|
||||
packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||
@@ -1426,7 +1429,7 @@ public class PacketsManager {
|
||||
ItemStack heldItem = packets[0].getItemModifier().read(0);
|
||||
if (heldItem != null && heldItem.getType() != Material.AIR) {
|
||||
// Convert the datawatcher
|
||||
List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>();
|
||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||
if (DisguiseConfig.isMetadataPacketsEnabled()) {
|
||||
list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
|
||||
list = disguise.getWatcher().convert(list);
|
||||
|
@@ -88,9 +88,9 @@ public class ReflectionManager {
|
||||
|
||||
if (isForge) {
|
||||
// Initialize the maps by reading the srg file
|
||||
ForgeClassMappings = new HashMap<String, String>();
|
||||
ForgeFieldMappings = new HashMap<String, Map<String, String>>();
|
||||
ForgeMethodMappings = new HashMap<String, Map<String, Map<String, String>>>();
|
||||
ForgeClassMappings = new HashMap<>();
|
||||
ForgeFieldMappings = new HashMap<>();
|
||||
ForgeMethodMappings = new HashMap<>();
|
||||
try {
|
||||
InputStream stream = Class.forName("net.minecraftforge.common.MinecraftForge").getClassLoader()
|
||||
.getResourceAsStream("mappings/" + getBukkitVersion() + "/cb2numpkg.srg");
|
||||
@@ -131,7 +131,7 @@ public class ReflectionManager {
|
||||
// by CB class name
|
||||
Map<String, String> innerMap = ForgeFieldMappings.get(dir2fqn(fieldMatcher.group(3)));
|
||||
if (innerMap == null) {
|
||||
innerMap = new HashMap<String, String>();
|
||||
innerMap = new HashMap<>();
|
||||
ForgeFieldMappings.put(dir2fqn(fieldMatcher.group(3)), innerMap);
|
||||
}
|
||||
// by CB field name to Forge field name
|
||||
@@ -143,13 +143,13 @@ public class ReflectionManager {
|
||||
// get by CB class name
|
||||
Map<String, Map<String, String>> middleMap = ForgeMethodMappings.get(dir2fqn(methodMatcher.group(5)));
|
||||
if (middleMap == null) {
|
||||
middleMap = new HashMap<String, Map<String, String>>();
|
||||
middleMap = new HashMap<>();
|
||||
ForgeMethodMappings.put(dir2fqn(methodMatcher.group(5)), middleMap);
|
||||
}
|
||||
// get by CB method name
|
||||
Map<String, String> innerMap = middleMap.get(methodMatcher.group(2));
|
||||
if (innerMap == null) {
|
||||
innerMap = new HashMap<String, String>();
|
||||
innerMap = new HashMap<>();
|
||||
middleMap.put(methodMatcher.group(2), innerMap);
|
||||
}
|
||||
// store the parameter strings
|
||||
@@ -161,11 +161,7 @@ public class ReflectionManager {
|
||||
System.out.println("[LibsDisguises] Loaded " + ForgeClassMappings.size() + " Cauldron class mappings");
|
||||
System.out.println("[LibsDisguises] Loaded " + ForgeFieldMappings.size() + " Cauldron field mappings");
|
||||
System.out.println("[LibsDisguises] Loaded " + ForgeMethodMappings.size() + " Cauldron method mappings");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace(System.out);
|
||||
System.err
|
||||
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
||||
} catch (IOException e) {
|
||||
} catch (ClassNotFoundException | IOException e) {
|
||||
e.printStackTrace(System.out);
|
||||
System.err
|
||||
.println("Warning: Running on Cauldron server, but couldn't load mappings file. LibsDisguises will likely crash!");
|
||||
|
Reference in New Issue
Block a user