Renable some disguises, fix player sleeping? I forgot what I did
This commit is contained in:
@@ -89,7 +89,7 @@ public class ClassGetter
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -142,7 +142,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return players;
|
||||
@@ -807,7 +807,7 @@ public class DisguiseUtilities
|
||||
runnables.get(playerName).add(runnable);
|
||||
}
|
||||
|
||||
return ReflectionManager.getGameProfile(null, origName);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -895,7 +895,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
@@ -941,7 +941,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
@@ -954,7 +954,7 @@ public class DisguiseUtilities
|
||||
Exception ex)
|
||||
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1008,7 +1008,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
@@ -1018,7 +1018,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1055,7 +1055,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
@@ -1098,7 +1098,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
@@ -1110,7 +1110,7 @@ public class DisguiseUtilities
|
||||
|
||||
Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1162,7 +1162,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// Code to stop player pushing in 1.9
|
||||
@@ -1204,7 +1204,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// Resend entity metadata else he will be invisible to himself until its resent
|
||||
@@ -1218,7 +1218,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
player.updateInventory();
|
||||
@@ -1313,7 +1313,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// Send the velocity packets
|
||||
@@ -1396,7 +1396,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1449,7 +1449,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1457,7 +1457,7 @@ public class DisguiseUtilities
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1053,8 +1053,8 @@ public class PacketsManager
|
||||
|
||||
if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise))
|
||||
{
|
||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager
|
||||
.createDataWatcherItem(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
|
||||
WrappedWatchableObject watch = ReflectionManager.createWatchable(0,
|
||||
WrappedDataWatcher.getEntityWatcher(entity).getByte(0));
|
||||
|
||||
list.add(watch);
|
||||
|
||||
@@ -1172,9 +1172,10 @@ public class PacketsManager
|
||||
*/
|
||||
public static boolean isStaticMetadataDisguiseType(Disguise disguise)
|
||||
{
|
||||
return (disguise.getType() == DisguiseType.WOLF || disguise.getType() == DisguiseType.OCELOT
|
||||
return false;
|
||||
/* return (disguise.getType() == DisguiseType.WOLF || disguise.getType() == DisguiseType.OCELOT
|
||||
|| disguise.getType() == DisguiseType.ENDERMAN || disguise.getType() == DisguiseType.SHULKER
|
||||
|| disguise.getType() == DisguiseType.SPLASH_POTION || disguise.getType() == DisguiseType.FIREWORK
|
||||
|| disguise.getType() == DisguiseType.DROPPED_ITEM || disguise.getType() == DisguiseType.ENDER_CRYSTAL);
|
||||
|| disguise.getType() == DisguiseType.DROPPED_ITEM || disguise.getType() == DisguiseType.ENDER_CRYSTAL);*/
|
||||
}
|
||||
}
|
||||
|
@@ -25,11 +25,14 @@ import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.MinecraftKey;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import com.google.common.base.Optional;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
@@ -71,7 +74,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +140,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -175,7 +178,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -226,7 +229,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -240,7 +243,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -254,7 +257,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -273,7 +276,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -289,7 +292,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -308,7 +311,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -351,7 +354,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -365,7 +368,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -379,7 +382,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -393,7 +396,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -414,7 +417,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -433,7 +436,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -455,7 +458,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -469,7 +472,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -485,7 +488,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -504,7 +507,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -521,7 +524,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -540,7 +543,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -562,7 +565,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -579,7 +582,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (NoSuchMethodException e)
|
||||
{
|
||||
e.printStackTrace(System.out);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -598,7 +601,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -619,7 +622,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -645,7 +648,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -698,7 +701,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -723,7 +726,7 @@ public class ReflectionManager
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -915,12 +918,21 @@ public class ReflectionManager
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
public static Object createDataWatcherItem(int id, Object value)
|
||||
private static Object createDataWatcherItem(int id, Object value)
|
||||
{
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
Serializer serializer = Registry.get(value.getClass());
|
||||
Serializer serializer;
|
||||
|
||||
if (value instanceof Optional)
|
||||
{
|
||||
serializer = Registry.get(((Optional) value).get().getClass(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
serializer = Registry.get(value.getClass());
|
||||
}
|
||||
|
||||
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
||||
|
||||
@@ -938,6 +950,35 @@ public class ReflectionManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WrappedWatchableObject createWatchable(int index, Object obj)
|
||||
{
|
||||
if (obj instanceof Optional)
|
||||
{
|
||||
Object value = ((Optional) obj).get();
|
||||
|
||||
if (value instanceof BlockPosition)
|
||||
{
|
||||
value = BlockPosition.getConverter().getSpecific(value);
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
obj = Optional.of(value);
|
||||
}
|
||||
else if (value instanceof ItemStack)
|
||||
{
|
||||
value = ReflectionManager.getNmsItem((ItemStack) value);
|
||||
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
obj = Optional.of(value);
|
||||
}
|
||||
}
|
||||
|
||||
return new WrappedWatchableObject(createDataWatcherItem(index, obj));
|
||||
}
|
||||
|
||||
public static EntityEquipment createEntityEquipment(Entity entity)
|
||||
{
|
||||
if (!(entity instanceof LivingEntity))
|
||||
|
@@ -1,60 +1,74 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private String latestVersion;
|
||||
|
||||
private boolean checkHigher(String currentVersion, String newVersion) {
|
||||
String current = toReadable(currentVersion);
|
||||
String newVers = toReadable(newVersion);
|
||||
return current.compareTo(newVers) < 0;
|
||||
}
|
||||
|
||||
public void checkUpdate(String currentVersion) {
|
||||
String version = getSpigotVersion();
|
||||
if (version != null) {
|
||||
if (checkHigher(currentVersion, version)) {
|
||||
latestVersion = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks spigot for the version
|
||||
*/
|
||||
private String getSpigotVersion() {
|
||||
try {
|
||||
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestMethod("POST");
|
||||
con.getOutputStream().write(
|
||||
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=81").getBytes("UTF-8"));
|
||||
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||
if (version.length() <= 7) {
|
||||
return version;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.out.print("[LibsDisguises] Failed to check for a update on spigot. Now checking bukkit..");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String toReadable(String version) {
|
||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||
version = "";
|
||||
for (String s : split) {
|
||||
version += String.format("%4s", s);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UpdateChecker
|
||||
{
|
||||
|
||||
private String latestVersion;
|
||||
|
||||
private boolean checkHigher(String currentVersion, String newVersion)
|
||||
{
|
||||
String current = toReadable(currentVersion);
|
||||
String newVers = toReadable(newVersion);
|
||||
return current.compareTo(newVers) < 0;
|
||||
}
|
||||
|
||||
public void checkUpdate(String currentVersion)
|
||||
{
|
||||
String version = getSpigotVersion();
|
||||
|
||||
if (version == null)
|
||||
return;
|
||||
|
||||
if (!checkHigher(currentVersion, version))
|
||||
return;
|
||||
|
||||
latestVersion = version;
|
||||
}
|
||||
|
||||
public String getLatestVersion()
|
||||
{
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Asks spigot for the version
|
||||
*/
|
||||
private String getSpigotVersion()
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpURLConnection con = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
|
||||
con.setDoOutput(true);
|
||||
con.setRequestMethod("POST");
|
||||
con.getOutputStream().write(
|
||||
("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=81").getBytes("UTF-8"));
|
||||
String version = new BufferedReader(new InputStreamReader(con.getInputStream())).readLine();
|
||||
if (version.length() <= 7)
|
||||
{
|
||||
return version;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
System.out.print("[LibsDisguises] Failed to check for a update on spigot.");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String toReadable(String version)
|
||||
{
|
||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||
version = "";
|
||||
for (String s : split)
|
||||
{
|
||||
version += String.format("%4s", s);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
@@ -150,7 +150,7 @@ public class PacketListenerViewDisguises extends PacketAdapter
|
||||
if (observer.isSprinting())
|
||||
b = (byte) (b | 1 << 3);
|
||||
|
||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, b));
|
||||
WrappedWatchableObject watch = ReflectionManager.createWatchable(0, b);
|
||||
|
||||
watchableList.add(watch);
|
||||
packet.getWatchableCollectionModifier().write(0, watchableList);
|
||||
|
Reference in New Issue
Block a user