- Changed entire project to gradle
- Updated for 1.8.3 - No more errors, woo
This commit is contained in:
parent
14757a035b
commit
573f4cdc88
5
.gitignore
vendored
5
.gitignore
vendored
@ -16,6 +16,10 @@ local.properties
|
|||||||
.settings/
|
.settings/
|
||||||
.loadpath
|
.loadpath
|
||||||
target/
|
target/
|
||||||
|
build
|
||||||
|
lib
|
||||||
|
dist
|
||||||
|
|
||||||
|
|
||||||
# External tool builders
|
# External tool builders
|
||||||
.externalToolBuilders/
|
.externalToolBuilders/
|
||||||
@ -214,3 +218,4 @@ pip-log.txt
|
|||||||
|
|
||||||
#Mr Developer
|
#Mr Developer
|
||||||
.mr.developer.cfg
|
.mr.developer.cfg
|
||||||
|
/.nb-gradle/private/
|
1
.gradle/2.2.1/taskArtifacts/cache.properties
Normal file
1
.gradle/2.2.1/taskArtifacts/cache.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
#Thu Feb 26 11:28:25 EST 2015
|
BIN
.gradle/2.2.1/taskArtifacts/cache.properties.lock
Normal file
BIN
.gradle/2.2.1/taskArtifacts/cache.properties.lock
Normal file
Binary file not shown.
BIN
.gradle/2.2.1/taskArtifacts/fileHashes.bin
Normal file
BIN
.gradle/2.2.1/taskArtifacts/fileHashes.bin
Normal file
Binary file not shown.
BIN
.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
Normal file
BIN
.gradle/2.2.1/taskArtifacts/fileSnapshots.bin
Normal file
Binary file not shown.
BIN
.gradle/2.2.1/taskArtifacts/outputFileStates.bin
Normal file
BIN
.gradle/2.2.1/taskArtifacts/outputFileStates.bin
Normal file
Binary file not shown.
BIN
.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
Normal file
BIN
.gradle/2.2.1/taskArtifacts/taskArtifacts.bin
Normal file
Binary file not shown.
57
build.gradle
Normal file
57
build.gradle
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
apply plugin: 'java'
|
||||||
|
|
||||||
|
sourceCompatibility = '1.8'
|
||||||
|
ext.spigotVersion = '1.8.3-R0.1-SNAPSHOT'
|
||||||
|
|
||||||
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
|
||||||
|
mavenCentral()
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name 'Spigot'
|
||||||
|
url 'https://hub.spigotmc.org/nexus/content/groups/public/'
|
||||||
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name 'Vault-Repo'
|
||||||
|
url 'http://nexus.theyeticave.net/content/repositories/pub_releases'
|
||||||
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
name 'shadowvolt-repo'
|
||||||
|
url 'http://ci.shadowvolt.com/plugin/repository/everything'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.build.doLast {
|
||||||
|
File export = file('build/libs/LibsDisguises.jar')
|
||||||
|
File dest = file('dist')
|
||||||
|
dest.mkdir()
|
||||||
|
dest.listFiles().each {
|
||||||
|
it.delete()
|
||||||
|
}
|
||||||
|
export.renameTo(new File(dest, "LibsDisguises.jar"))
|
||||||
|
file('build').delete()
|
||||||
|
println "Copied LibsDisguises.jar into /dist"
|
||||||
|
println "LibsDisguises is finished compiling, have a nice day!"
|
||||||
|
}
|
||||||
|
|
||||||
|
file('libs').mkdirs()
|
||||||
|
|
||||||
|
//Retrieves spigot-1.8.jar server file from link
|
||||||
|
ant.get src: 'https://www.dropbox.com/s/k7simfgpdun3f8q/spigot-1.8.jar?dl=1', dest: file('libs'), verbose: false, skipexisting: true
|
||||||
|
|
||||||
|
jar {
|
||||||
|
baseName "LibsDisguises"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile files(
|
||||||
|
'libs/spigot-1.8.jar'
|
||||||
|
)
|
||||||
|
compile 'org.bukkit:bukkit:' + project.ext.spigotVersion
|
||||||
|
compile 'com.comphenix.protocol:ProtocolLib:3.6.3-SNAPSHOT'
|
||||||
|
testCompile group: 'junit', name: 'junit', version: '4.10'
|
||||||
|
}
|
BIN
libs/spigot-1.8.jar
Normal file
BIN
libs/spigot-1.8.jar
Normal file
Binary file not shown.
107
pom.xml
107
pom.xml
@ -1,107 +0,0 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
<groupId>LibsDisguises</groupId>
|
|
||||||
<artifactId>LibsDisguises</artifactId>
|
|
||||||
<version>8.2.6-SNAPSHOT</version>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<sourceDirectory>src</sourceDirectory>
|
|
||||||
<testSourceDirectory>test</testSourceDirectory>
|
|
||||||
<defaultGoal>clean package</defaultGoal>
|
|
||||||
<directory>target</directory>
|
|
||||||
<finalName>LibsDisguises</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>2.3.2</version>
|
|
||||||
<configuration>
|
|
||||||
<source>1.6</source>
|
|
||||||
<target>1.6</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
|
||||||
<version>1.5</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>shade</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<artifactSet>
|
|
||||||
<includes>
|
|
||||||
<include>com.fasterxml.uuid:java-uuid-generator</include>
|
|
||||||
</includes>
|
|
||||||
</artifactSet>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<targetPath>.</targetPath>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<directory>${project.basedir}</directory>
|
|
||||||
<includes>
|
|
||||||
<include>plugin.yml</include>
|
|
||||||
<include>config.yml</include>
|
|
||||||
<include>README.md</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>md_5-repo</id>
|
|
||||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>shadowvolt-repo</id>
|
|
||||||
<name>Shadowvolt Maven Repository</name>
|
|
||||||
<url>http://ci.shadowvolt.com/plugin/repository/everything/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
|
||||||
<artifactId>ProtocolLib</artifactId>
|
|
||||||
<version>3.6.3-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>1.7.8-R0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>junit</groupId>
|
|
||||||
<artifactId>junit</artifactId>
|
|
||||||
<version>4.11</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<distributionManagement>
|
|
||||||
<repository>
|
|
||||||
<id>md_5-releases</id>
|
|
||||||
<url>http://repo.md-5.net/content/repositories/releases/</url>
|
|
||||||
</repository>
|
|
||||||
<snapshotRepository>
|
|
||||||
<id>md_5-snapshots</id>
|
|
||||||
<url>http://repo.md-5.net/content/repositories/snapshots/</url>
|
|
||||||
</snapshotRepository>
|
|
||||||
</distributionManagement>
|
|
||||||
</project>
|
|
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'LibsDisguises'
|
@ -15,7 +15,6 @@ import me.libraryaddict.disguise.commands.*;
|
|||||||
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.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FutureDisguiseType;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||||
@ -26,11 +25,9 @@ import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.FakeBoundingBox;
|
|
||||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Ageable;
|
import org.bukkit.entity.Ageable;
|
||||||
@ -154,7 +151,7 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void registerValues() {
|
private void registerValues() {
|
||||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||||
if (disguiseType.getEntityType() == null && !(disguiseType.is1_8() && LibVersion.is1_8())) {
|
if (disguiseType.getEntityType() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Class watcherClass = null;
|
Class watcherClass = null;
|
||||||
@ -209,25 +206,6 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
if (DisguiseValues.getDisguiseValues(disguiseType) != null) {
|
if (DisguiseValues.getDisguiseValues(disguiseType) != null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (disguiseType.is1_8()) {
|
|
||||||
int entitySize = 0;
|
|
||||||
FutureDisguiseType futureType = disguiseType.getFutureType();
|
|
||||||
DisguiseValues disguiseValues = new DisguiseValues(disguiseType, null, entitySize, futureType.getMaxHealth());
|
|
||||||
Object[] objs = disguiseType.getFutureType().getDataWatcher();
|
|
||||||
for (int i = 0; i < objs.length; i += 2) {
|
|
||||||
disguiseValues.setMetaValue((Integer) objs[i], objs[i + 1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the bounding box
|
|
||||||
float[] box = futureType.getBoundingBox();
|
|
||||||
disguiseValues.setAdultBox(new FakeBoundingBox(box[0], box[1], box[2]));
|
|
||||||
/* if (disguiseType == DisguiseType.RABBIT) {
|
|
||||||
((Ageable) bukkitEntity).setBaby();
|
|
||||||
disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
|
||||||
}
|
|
||||||
disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));*/
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String nmsEntityName = toReadable(disguiseType.name());
|
String nmsEntityName = toReadable(disguiseType.name());
|
||||||
switch (disguiseType) {
|
switch (disguiseType) {
|
||||||
case WITHER_SKELETON:
|
case WITHER_SKELETON:
|
||||||
@ -264,6 +242,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
case LEASH_HITCH:
|
case LEASH_HITCH:
|
||||||
nmsEntityName = "Leash";
|
nmsEntityName = "Leash";
|
||||||
break;
|
break;
|
||||||
|
case ELDER_GUARDIAN:
|
||||||
|
nmsEntityName = "Guardian";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -64,7 +64,7 @@ public abstract class Disguise {
|
|||||||
protected void createDisguise(DisguiseType newType) {
|
protected void createDisguise(DisguiseType newType) {
|
||||||
if (getWatcher() != null)
|
if (getWatcher() != null)
|
||||||
return;
|
return;
|
||||||
if (!(LibVersion.is1_8() && newType.is1_8()) && newType.getEntityType() == null) {
|
if (newType.getEntityType() == null) {
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"DisguiseType "
|
"DisguiseType "
|
||||||
+ newType
|
+ newType
|
||||||
@ -101,7 +101,7 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||||
getWatcher().setValue(14, 0 | 4);
|
getWatcher().setValue(16, 0 | 4);
|
||||||
}
|
}
|
||||||
// Else if its a horse. Set the horse watcher type
|
// Else if its a horse. Set the horse watcher type
|
||||||
else if (getWatcher() instanceof HorseWatcher) {
|
else if (getWatcher() instanceof HorseWatcher) {
|
@ -2,17 +2,16 @@ package me.libraryaddict.disguise.disguisetypes;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|
||||||
|
|
||||||
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;
|
||||||
|
import org.bukkit.entity.Guardian;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.Horse;
|
||||||
import org.bukkit.entity.Skeleton;
|
import org.bukkit.entity.Skeleton;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
|
|
||||||
public enum DisguiseType {
|
public enum DisguiseType {
|
||||||
ARMOR_STAND(FutureDisguiseType.ARMOR_STAND),
|
ARMOR_STAND(78),
|
||||||
|
|
||||||
ARROW(60),
|
ARROW(60),
|
||||||
|
|
||||||
@ -36,7 +35,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
EGG(62),
|
EGG(62),
|
||||||
|
|
||||||
ELDER_GUARDIAN(FutureDisguiseType.ELDER_GUARDIAN),
|
ELDER_GUARDIAN,
|
||||||
|
|
||||||
ENDER_CRYSTAL(51),
|
ENDER_CRYSTAL(51),
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
ENDERMAN,
|
ENDERMAN,
|
||||||
|
|
||||||
ENDERMITE(FutureDisguiseType.ENDERMITE),
|
ENDERMITE,
|
||||||
|
|
||||||
EXPERIENCE_ORB,
|
EXPERIENCE_ORB,
|
||||||
|
|
||||||
@ -64,7 +63,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
GIANT,
|
GIANT,
|
||||||
|
|
||||||
GUARDIAN(FutureDisguiseType.GUARDIAN),
|
GUARDIAN,
|
||||||
|
|
||||||
HORSE,
|
HORSE,
|
||||||
|
|
||||||
@ -106,7 +105,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
PRIMED_TNT(50),
|
PRIMED_TNT(50),
|
||||||
|
|
||||||
RABBIT(FutureDisguiseType.RABBIT),
|
RABBIT,
|
||||||
|
|
||||||
SHEEP,
|
SHEEP,
|
||||||
|
|
||||||
@ -150,7 +149,7 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
ZOMBIE_VILLAGER;
|
ZOMBIE_VILLAGER;
|
||||||
|
|
||||||
private static Method isVillager, getVariant, getSkeletonType;
|
private static Method isVillager, getVariant, getSkeletonType, isElder;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
// We set the entity type in this so that we can safely ignore disguisetypes which don't exist in older versions of MC.
|
// We set the entity type in this so that we can safely ignore disguisetypes which don't exist in older versions of MC.
|
||||||
@ -175,6 +174,9 @@ public enum DisguiseType {
|
|||||||
case WITHER_SKELETON:
|
case WITHER_SKELETON:
|
||||||
toUse = DisguiseType.SKELETON;
|
toUse = DisguiseType.SKELETON;
|
||||||
break;
|
break;
|
||||||
|
case ELDER_GUARDIAN:
|
||||||
|
toUse = DisguiseType.GUARDIAN;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,6 +198,10 @@ public enum DisguiseType {
|
|||||||
getSkeletonType = Skeleton.class.getMethod("getSkeletonType");
|
getSkeletonType = Skeleton.class.getMethod("getSkeletonType");
|
||||||
} catch (Throwable ignored) {
|
} catch (Throwable ignored) {
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
isElder = Guardian.class.getMethod("isElder");
|
||||||
|
} catch (Throwable ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DisguiseType getType(Entity entity) {
|
public static DisguiseType getType(Entity entity) {
|
||||||
@ -228,6 +234,15 @@ public enum DisguiseType {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GUARDIAN:
|
||||||
|
try {
|
||||||
|
if ((Boolean) isElder.invoke(entity)) {
|
||||||
|
disguiseType = DisguiseType.ELDER_GUARDIAN;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -244,10 +259,9 @@ public enum DisguiseType {
|
|||||||
|
|
||||||
private int defaultId, entityId;
|
private int defaultId, entityId;
|
||||||
private EntityType entityType;
|
private EntityType entityType;
|
||||||
private FutureDisguiseType futureType;
|
|
||||||
private Class<? extends FlagWatcher> watcherClass;
|
private Class<? extends FlagWatcher> watcherClass;
|
||||||
|
|
||||||
private DisguiseType(FutureDisguiseType disguiseType, int... ints) {
|
private DisguiseType(int... ints) {
|
||||||
for (int i = 0; i < ints.length; i++) {
|
for (int i = 0; i < ints.length; i++) {
|
||||||
int value = ints[i];
|
int value = ints[i];
|
||||||
switch (i) {
|
switch (i) {
|
||||||
@ -261,13 +275,6 @@ public enum DisguiseType {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (LibVersion.is1_8()) {
|
|
||||||
futureType = disguiseType;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private DisguiseType(int... ints) {
|
|
||||||
this(null, ints);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultId() {
|
public int getDefaultId() {
|
||||||
@ -275,9 +282,6 @@ public enum DisguiseType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends Entity> getEntityClass() {
|
public Class<? extends Entity> getEntityClass() {
|
||||||
if (futureType != null) {
|
|
||||||
return futureType.getEntityClass();
|
|
||||||
}
|
|
||||||
if (entityType != null) {
|
if (entityType != null) {
|
||||||
return getEntityType().getEntityClass();
|
return getEntityType().getEntityClass();
|
||||||
}
|
}
|
||||||
@ -292,28 +296,20 @@ public enum DisguiseType {
|
|||||||
return entityType;
|
return entityType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FutureDisguiseType getFutureType() {
|
|
||||||
return futureType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTypeId() {
|
public int getTypeId() {
|
||||||
return is1_8() ? futureType.getEntityId() : (int) getEntityType().getTypeId();
|
return (int) getEntityType().getTypeId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getWatcherClass() {
|
public Class getWatcherClass() {
|
||||||
return watcherClass;
|
return watcherClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean is1_8() {
|
|
||||||
return futureType != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMisc() {
|
public boolean isMisc() {
|
||||||
return is1_8() ? !futureType.isAlive() : getEntityType() != null && !getEntityType().isAlive();
|
return getEntityType() != null && !getEntityType().isAlive();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMob() {
|
public boolean isMob() {
|
||||||
return is1_8() ? futureType.isAlive() : getEntityType() != null && getEntityType().isAlive() && !isPlayer();
|
return getEntityType() != null && getEntityType().isAlive() && !isPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPlayer() {
|
public boolean isPlayer() {
|
@ -158,7 +158,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomName() {
|
public String getCustomName() {
|
||||||
return (String) getValue(10, null);
|
return (String) getValue(2, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TargetedDisguise getDisguise() {
|
protected TargetedDisguise getDisguise() {
|
||||||
@ -207,7 +207,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCustomNameVisible() {
|
public boolean isCustomNameVisible() {
|
||||||
return (Byte) getValue(11, (byte) 0) == 1;
|
return (Byte) getValue(3, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEntityAnimationsAdded() {
|
public boolean isEntityAnimationsAdded() {
|
||||||
@ -296,13 +296,13 @@ public class FlagWatcher {
|
|||||||
if (name != null && name.length() > 64) {
|
if (name != null && name.length() > 64) {
|
||||||
name = name.substring(0, 64);
|
name = name.substring(0, 64);
|
||||||
}
|
}
|
||||||
setValue(10, name);
|
setValue(2, name);
|
||||||
sendData(10);
|
sendData(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomNameVisible(boolean display) {
|
public void setCustomNameVisible(boolean display) {
|
||||||
setValue(11, (byte) (display ? 1 : 0));
|
setValue(3, (byte) (display ? 1 : 0));
|
||||||
sendData(11);
|
sendData(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFlag(int byteValue, boolean flag) {
|
private void setFlag(int byteValue, boolean flag) {
|
@ -153,32 +153,30 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PlayerDisguise setSkin(String skinToUse) {
|
public PlayerDisguise setSkin(String skinToUse) {
|
||||||
if (LibVersion.is1_7_6()) {
|
this.skinToUse = skinToUse;
|
||||||
this.skinToUse = skinToUse;
|
if (skinToUse == null) {
|
||||||
if (skinToUse == null) {
|
this.currentLookup = null;
|
||||||
this.currentLookup = null;
|
this.gameProfile = null;
|
||||||
this.gameProfile = null;
|
} else {
|
||||||
} else {
|
if (skinToUse.length() > 16) {
|
||||||
if (skinToUse.length() > 16) {
|
this.skinToUse = skinToUse.substring(0, 16);
|
||||||
this.skinToUse = skinToUse.substring(0, 16);
|
}
|
||||||
}
|
currentLookup = new LibsProfileLookup() {
|
||||||
currentLookup = new LibsProfileLookup() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLookup(WrappedGameProfile gameProfile) {
|
public void onLookup(WrappedGameProfile gameProfile) {
|
||||||
if (currentLookup == this && gameProfile != null) {
|
if (currentLookup == this && gameProfile != null) {
|
||||||
setSkin(gameProfile);
|
setSkin(gameProfile);
|
||||||
if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
|
if (!gameProfile.getProperties().isEmpty() && DisguiseUtilities.isDisguiseInUse(PlayerDisguise.this)) {
|
||||||
DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
|
DisguiseUtilities.refreshTrackers(PlayerDisguise.this);
|
||||||
}
|
|
||||||
currentLookup = null;
|
|
||||||
}
|
}
|
||||||
|
currentLookup = null;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup);
|
|
||||||
if (gameProfile != null) {
|
|
||||||
setSkin(gameProfile);
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup);
|
||||||
|
if (gameProfile != null) {
|
||||||
|
setSkin(gameProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
@ -17,7 +17,7 @@ public class AgeableWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby() {
|
||||||
return (Integer) getValue(12, 0) < 0;
|
return ((Byte) getValue(12, (byte) 0)).intValue() < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult() {
|
||||||
@ -25,7 +25,7 @@ public class AgeableWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setAge(int newAge) {
|
public void setAge(int newAge) {
|
||||||
setValue(12, newAge);
|
setValue(12, (byte) newAge);
|
||||||
sendData(12);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ public class AgeableWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(boolean isBaby) {
|
public void setBaby(boolean isBaby) {
|
||||||
setValue(12, isBaby ? -24000 : 0);
|
setValue(12, (byte) (isBaby ? -1 : 0));
|
||||||
sendData(12);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
@ -36,7 +36,7 @@ public class EndermanWatcher extends LivingWatcher {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemInHand(ItemStack itemstack) {
|
public void setItemInHand(ItemStack itemstack) {
|
||||||
setValue(16, (byte) (itemstack.getTypeId() & 255));
|
setValue(16, (short) (itemstack.getTypeId() & 255));
|
||||||
setValue(17, (byte) (itemstack.getDurability() & 255));
|
setValue(17, (byte) (itemstack.getDurability() & 255));
|
||||||
}
|
}
|
||||||
|
|
@ -13,11 +13,11 @@ public class ItemFrameWatcher extends FlagWatcher {
|
|||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
if (getValue(2, null) == null)
|
if (getValue(2, null) == null)
|
||||||
return new ItemStack(0);
|
return new ItemStack(0);
|
||||||
return (ItemStack) getValue(2, null);
|
return (ItemStack) getValue(8, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRotation() {
|
public int getRotation() {
|
||||||
return (Integer) getValue(3, 0);
|
return (Integer) getValue(9, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack newItem) {
|
public void setItem(ItemStack newItem) {
|
||||||
@ -25,13 +25,13 @@ public class ItemFrameWatcher extends FlagWatcher {
|
|||||||
newItem = new ItemStack(0);
|
newItem = new ItemStack(0);
|
||||||
newItem = newItem.clone();
|
newItem = newItem.clone();
|
||||||
newItem.setAmount(1);
|
newItem.setAmount(1);
|
||||||
setValue(2, newItem);
|
setValue(8, newItem);
|
||||||
sendData(2);
|
sendData(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(int rotation) {
|
public void setRotation(int rotation) {
|
||||||
setValue(3, (byte) (rotation % 4));
|
setValue(9, (byte) (rotation % 4));
|
||||||
sendData(3);
|
sendData(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -110,7 +110,7 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ANIMATION);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ANIMATION);
|
||||||
StructureModifier<Integer> mods = packet.getIntegers();
|
StructureModifier<Integer> mods = packet.getIntegers();
|
||||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||||
mods.write(1, LibVersion.is1_7() ? 3 : 2);
|
mods.write(1, 3);
|
||||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
|
|
@ -339,7 +339,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
|||||||
throw new DisguiseParseException(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0]
|
throw new DisguiseParseException(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0]
|
||||||
+ ChatColor.RED + " doesn't exist!");
|
+ ChatColor.RED + " doesn't exist!");
|
||||||
}
|
}
|
||||||
if (!(LibVersion.is1_8() && disguiseType.is1_8()) && disguiseType.getEntityType() == null) {
|
if (disguiseType.getEntityType() == null) {
|
||||||
throw new DisguiseParseException(ChatColor.RED + "Error! This version of minecraft does not have that disguise!");
|
throw new DisguiseParseException(ChatColor.RED + "Error! This version of minecraft does not have that disguise!");
|
||||||
}
|
}
|
||||||
if (!map.containsKey(disguiseType)) {
|
if (!map.containsKey(disguiseType)) {
|
@ -66,8 +66,7 @@ public enum DisguiseSound {
|
|||||||
|
|
||||||
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
|
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
|
||||||
|
|
||||||
PLAYER(LibVersion.is1_7() ? "game.player.hurt" : "damage.hit", "step.grass", LibVersion.is1_7() ? "game.player.hurt"
|
PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null),
|
||||||
: "damage.hit", null),
|
|
||||||
|
|
||||||
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
|
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
|
||||||
|
|
@ -23,13 +23,9 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ItemFrameWatcher;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
|
||||||
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.disguisetypes.TargetedDisguise.TargetType;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -41,6 +37,7 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Zombie;
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -97,30 +94,15 @@ public class DisguiseUtilities {
|
|||||||
block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId").get(null))[Material.BED_BLOCK
|
block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId").get(null))[Material.BED_BLOCK
|
||||||
.getId()];
|
.getId()];
|
||||||
}
|
}
|
||||||
|
Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class);
|
||||||
if (LibVersion.is1_8()) {
|
Method setType = chunkSection.getClass().getMethod("setType", int.class, int.class, int.class,
|
||||||
Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class);
|
ReflectionManager.getNmsClass("IBlockData"));
|
||||||
Method setType = chunkSection.getClass().getMethod("setType", int.class, int.class, int.class,
|
Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
|
||||||
ReflectionManager.getNmsClass("IBlockData"));
|
Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
|
||||||
Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
|
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
||||||
Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
|
setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal()));
|
||||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||||
setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal()));
|
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
||||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
|
||||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Method setId = chunkSection.getClass().getMethod("setTypeId", int.class, int.class, int.class,
|
|
||||||
ReflectionManager.getNmsClass("Block"));
|
|
||||||
Method setData = chunkSection.getClass().getMethod("setData", int.class, int.class, int.class, int.class);
|
|
||||||
Method setSky = chunkSection.getClass().getMethod("setSkyLight", int.class, int.class, int.class, int.class);
|
|
||||||
Method setEmitted = chunkSection.getClass().getMethod("setEmittedLight", int.class, int.class, int.class, int.class);
|
|
||||||
for (BlockFace face : new BlockFace[] { BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH }) {
|
|
||||||
setId.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), block);
|
|
||||||
setData.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), face.ordinal());
|
|
||||||
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
|
||||||
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16);
|
Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16);
|
||||||
@ -341,7 +323,7 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0, 40)
|
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0, 40)
|
||||||
.createPacket(bedChunk, true, 0, LibVersion.is1_8() ? 48 : 0);
|
.createPacket(bedChunk, true, 0, 48);
|
||||||
} catch (IllegalArgumentException ex) {
|
} catch (IllegalArgumentException ex) {
|
||||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0)
|
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, true, 0)
|
||||||
@ -350,15 +332,9 @@ public class DisguiseUtilities {
|
|||||||
i++;
|
i++;
|
||||||
// Make load packets
|
// Make load packets
|
||||||
if (oldLoc == null || i > 1) {
|
if (oldLoc == null || i > 1) {
|
||||||
try {
|
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk))
|
||||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk), 40)
|
.createPacket(Arrays.asList(bedChunk));
|
||||||
.createPacket(Arrays.asList(bedChunk), LibVersion.is1_8() ? 48 : 0);
|
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
|
||||||
.createPacketConstructor(PacketType.Play.Server.MAP_CHUNK_BULK, List.class)
|
|
||||||
.createPacket(Arrays.asList(bedChunk));
|
|
||||||
}
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,19 +346,13 @@ public class DisguiseUtilities {
|
|||||||
PacketContainer setBed = new PacketContainer(PacketType.Play.Server.BED);
|
PacketContainer setBed = new PacketContainer(PacketType.Play.Server.BED);
|
||||||
StructureModifier<Integer> bedInts = setBed.getIntegers();
|
StructureModifier<Integer> bedInts = setBed.getIntegers();
|
||||||
bedInts.write(0, entity.getEntityId());
|
bedInts.write(0, entity.getEntityId());
|
||||||
if (LibVersion.is1_8()) {
|
PlayerWatcher watcher = disguise.getWatcher();
|
||||||
PlayerWatcher watcher = disguise.getWatcher();
|
int chunkX = (int) Math.floor(playerLocation.getX() / 16D) - 17, chunkZ = (int) Math
|
||||||
int chunkX = (int) Math.floor(playerLocation.getX() / 16D) - 17, chunkZ = (int) Math
|
.floor(playerLocation.getZ() / 16D) - 17;
|
||||||
.floor(playerLocation.getZ() / 16D) - 17;
|
chunkX -= chunkX % 8;
|
||||||
chunkX -= chunkX % 8;
|
chunkZ -= chunkZ % 8;
|
||||||
chunkZ -= chunkZ % 8;
|
bedInts.write(1, (chunkX * 16) + 1 + watcher.getSleepingDirection().getModX());
|
||||||
bedInts.write(1, (chunkX * 16) + 1 + watcher.getSleepingDirection().getModX());
|
bedInts.write(3, (chunkZ * 16) + 1 + watcher.getSleepingDirection().getModZ());
|
||||||
bedInts.write(3, (chunkZ * 16) + 1 + watcher.getSleepingDirection().getModZ());
|
|
||||||
} else {
|
|
||||||
bedInts.write(1, loc.getBlockX());
|
|
||||||
bedInts.write(2, loc.getBlockY());
|
|
||||||
bedInts.write(3, loc.getBlockZ());
|
|
||||||
}
|
|
||||||
PacketContainer teleport = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
PacketContainer teleport = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||||
StructureModifier<Integer> ints = teleport.getIntegers();
|
StructureModifier<Integer> ints = teleport.getIntegers();
|
||||||
ints.write(0, entity.getEntityId());
|
ints.write(0, entity.getEntityId());
|
||||||
@ -495,8 +465,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
if (DisguiseAPI.isDisguiseInUse(disguise)
|
if (DisguiseAPI.isDisguiseInUse(disguise)
|
||||||
&& (!gameProfile.getName().equals(
|
&& (!gameProfile.getName().equals(
|
||||||
disguise.getSkin() != null && LibVersion.is1_7_6() ? disguise.getSkin() : disguise.getName()) || (LibVersion
|
disguise.getSkin() != null ? disguise.getSkin() : disguise.getName())
|
||||||
.is1_7_6() && !gameProfile.getProperties().isEmpty()))) {
|
|| !gameProfile.getProperties().isEmpty())) {
|
||||||
disguise.setGameProfile(gameProfile);
|
disguise.setGameProfile(gameProfile);
|
||||||
DisguiseUtilities.refreshTrackers(disguise);
|
DisguiseUtilities.refreshTrackers(disguise);
|
||||||
}
|
}
|
||||||
@ -523,7 +493,7 @@ public class DisguiseUtilities {
|
|||||||
Player player = Bukkit.getPlayerExact(playerName);
|
Player player = Bukkit.getPlayerExact(playerName);
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player);
|
WrappedGameProfile gameProfile = ReflectionManager.getGameProfile(player);
|
||||||
if (!LibVersion.is1_7_6() || !gameProfile.getProperties().isEmpty()) {
|
if (!gameProfile.getProperties().isEmpty()) {
|
||||||
gameProfiles.put(playerName, gameProfile);
|
gameProfiles.put(playerName, gameProfile);
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
}
|
}
|
||||||
@ -536,7 +506,7 @@ public class DisguiseUtilities {
|
|||||||
final WrappedGameProfile gameProfile = lookupGameProfile(origName);
|
final WrappedGameProfile gameProfile = lookupGameProfile(origName);
|
||||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!LibVersion.is1_7_6() || !gameProfile.getProperties().isEmpty()) {
|
if (!gameProfile.getProperties().isEmpty()) {
|
||||||
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
if (gameProfiles.containsKey(playerName) && gameProfiles.get(playerName) == null) {
|
||||||
gameProfiles.put(playerName, gameProfile);
|
gameProfiles.put(playerName, gameProfile);
|
||||||
}
|
}
|
||||||
@ -613,54 +583,17 @@ public class DisguiseUtilities {
|
|||||||
*/
|
*/
|
||||||
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
|
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
|
||||||
List<WrappedWatchableObject> list) {
|
List<WrappedWatchableObject> list) {
|
||||||
if (!LibVersion.is1_8())
|
if (true) // Use for future protocol compatibility
|
||||||
return list;
|
return list;
|
||||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>();
|
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<WrappedWatchableObject>();
|
||||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>();
|
ArrayList<WrappedWatchableObject> backups = new ArrayList<WrappedWatchableObject>();
|
||||||
// TODO Player and Minecart
|
|
||||||
for (WrappedWatchableObject obj : list) {
|
for (WrappedWatchableObject obj : list) {
|
||||||
if (obj.getValue().getClass().getName().startsWith("org.")) {
|
if (obj.getValue().getClass().getName().startsWith("org.")) {
|
||||||
backups.add(obj);
|
backups.add(obj);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
switch (obj.getIndex()) {
|
switch (obj.getIndex()) {
|
||||||
case 2:
|
// TODO: Future version support
|
||||||
case 3:
|
|
||||||
if (watcher instanceof ItemFrameWatcher) {
|
|
||||||
rebuiltList.add(new WrappedWatchableObject(obj.getIndex() + 6, obj.getValue()));
|
|
||||||
} else {
|
|
||||||
backups.add(obj);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
rebuiltList.add(new WrappedWatchableObject(obj.getIndex() - 8, obj.getValue()));
|
|
||||||
break;
|
|
||||||
case 12:
|
|
||||||
if (watcher instanceof AgeableWatcher) {
|
|
||||||
int i = (Integer) obj.getValue();
|
|
||||||
rebuiltList.add(new WrappedWatchableObject(obj.getIndex(), (byte) (i < 0 ? -1 : (i >= 6000 ? 1 : 0))));
|
|
||||||
} else {
|
|
||||||
backups.add(obj);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 16:
|
|
||||||
if (watcher instanceof EndermanWatcher) {
|
|
||||||
rebuiltList.add(new WrappedWatchableObject(obj.getIndex(), ((Byte) obj.getValue()).shortValue()));
|
|
||||||
} else {
|
|
||||||
backups.add(obj);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 20:
|
|
||||||
if (watcher instanceof MinecartWatcher) {
|
|
||||||
// TODO
|
|
||||||
backups.add(obj);
|
|
||||||
} else {
|
|
||||||
backups.add(obj);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
backups.add(obj);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Iterator<WrappedWatchableObject> itel = backups.iterator();
|
Iterator<WrappedWatchableObject> itel = backups.iterator();
|
||||||
@ -687,6 +620,8 @@ public class DisguiseUtilities {
|
|||||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
|
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
|
||||||
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
|
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
|
||||||
removeSelfDisguise((Player) disguise.getEntity());
|
removeSelfDisguise((Player) disguise.getEntity());
|
||||||
|
if (disguise.isSelfDisguiseVisible())
|
||||||
|
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -697,7 +632,6 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 2);
|
}, 2);
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity(), disguise);
|
|
||||||
} else {
|
} else {
|
||||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
if (entityTrackerEntry != null) {
|
if (entityTrackerEntry != null) {
|
||||||
@ -781,6 +715,7 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) {
|
if (selfDisguised.contains(disguise.getEntity().getUniqueId()) && disguise.isDisguiseInUse()) {
|
||||||
removeSelfDisguise((Player) disguise.getEntity());
|
removeSelfDisguise((Player) disguise.getEntity());
|
||||||
|
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -850,8 +785,7 @@ public class DisguiseUtilities {
|
|||||||
public static void removeSelfDisguise(Player player) {
|
public static void removeSelfDisguise(Player player) {
|
||||||
if (selfDisguised.contains(player.getUniqueId())) {
|
if (selfDisguised.contains(player.getUniqueId())) {
|
||||||
// Send a packet to destroy the fake entity
|
// Send a packet to destroy the fake entity
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
|
PacketContainer packet = getDestroyPacket(DisguiseAPI.getSelfDisguiseId());
|
||||||
packet.getModifier().write(0, new int[] { DisguiseAPI.getSelfDisguiseId() });
|
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -979,10 +913,11 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Resend any active potion effects
|
// Resend any active potion effects
|
||||||
for (Object potionEffect : player.getActivePotionEffects()) {
|
for (PotionEffect potionEffect : player.getActivePotionEffects()) {
|
||||||
|
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
||||||
sendSelfPacket(player,
|
sendSelfPacket(player,
|
||||||
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), potionEffect)
|
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
|
||||||
.createPacket(player.getEntityId(), potionEffect));
|
.createPacket(player.getEntityId(), mobEffect));
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
@ -2,8 +2,8 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
|
||||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
import com.mojang.authlib.GameProfile;
|
||||||
import net.minecraft.util.com.mojang.authlib.ProfileLookupCallback;
|
import com.mojang.authlib.ProfileLookupCallback;
|
||||||
|
|
||||||
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
||||||
private WrappedGameProfile gameProfile;
|
private WrappedGameProfile gameProfile;
|
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
@ -21,7 +22,6 @@ import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
|
||||||
|
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -84,7 +84,7 @@ public class PacketsManager {
|
|||||||
try {
|
try {
|
||||||
Player observer = event.getPlayer();
|
Player observer = event.getPlayer();
|
||||||
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
|
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
|
||||||
Entity entity = entityModifer.read(LibVersion.is1_7() ? 0 : 1);
|
Entity entity = entityModifer.read(0);
|
||||||
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow
|
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow
|
||||||
|| entity == observer) {
|
|| entity == observer) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -196,12 +196,10 @@ public class PacketsManager {
|
|||||||
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
|
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_PAINTING);
|
||||||
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
||||||
mods.write(0, disguisedEntity.getEntityId());
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
mods.write(1, loc.getBlockX());
|
mods.write(1, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
mods.write(2, loc.getBlockY());
|
mods.write(2, ReflectionManager.getEnumDirection(((int) loc.getYaw()) % 4));
|
||||||
mods.write(3, loc.getBlockZ());
|
|
||||||
mods.write(4, ((int) loc.getYaw()) % 4);
|
|
||||||
int id = ((MiscDisguise) disguise).getData();
|
int id = ((MiscDisguise) disguise).getData();
|
||||||
mods.write(5, ReflectionManager.getEnumArt(Art.values()[id]));
|
mods.write(3, ReflectionManager.getEnumArt(Art.values()[id]));
|
||||||
|
|
||||||
// Make the teleport packet to make it visible..
|
// Make the teleport packet to make it visible..
|
||||||
spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
spawnPackets[1] = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
|
||||||
@ -217,7 +215,7 @@ public class PacketsManager {
|
|||||||
|
|
||||||
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||||
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
|
StructureModifier<String> stringMods = spawnPackets[0].getStrings();
|
||||||
WrappedGameProfile gameProfile = null; // TODO Will this throw a error for older MC's? Namely pre-1.7
|
WrappedGameProfile gameProfile;
|
||||||
if (stringMods.size() > 0) {
|
if (stringMods.size() > 0) {
|
||||||
for (int i = 0; i < stringMods.size(); i++) {
|
for (int i = 0; i < stringMods.size(); i++) {
|
||||||
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
||||||
@ -233,7 +231,7 @@ public class PacketsManager {
|
|||||||
if (removeName) {
|
if (removeName) {
|
||||||
DisguiseUtilities.getAddedByPlugins().remove(name);
|
DisguiseUtilities.getAddedByPlugins().remove(name);
|
||||||
}
|
}
|
||||||
spawnPackets[0].getGameProfiles().write(0, gameProfile);
|
spawnPackets[0].getSpecificModifier(UUID.class).write(0, gameProfile.getUUID());
|
||||||
}
|
}
|
||||||
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
StructureModifier<Integer> intMods = spawnPackets[0].getIntegers();
|
||||||
intMods.write(0, disguisedEntity.getEntityId());
|
intMods.write(0, disguisedEntity.getEntityId());
|
||||||
@ -266,22 +264,23 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LibVersion.is1_8()) {
|
ArrayList<PacketContainer> newPackets = new ArrayList<PacketContainer>();
|
||||||
ArrayList<PacketContainer> newPackets = new ArrayList<PacketContainer>();
|
newPackets.add(null);
|
||||||
newPackets.add(null);
|
for (int i = 0; i < spawnPackets.length; i++) {
|
||||||
for (int i = 0; i < spawnPackets.length; i++) {
|
if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists.
|
||||||
if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists.
|
newPackets.add(spawnPackets[i]);
|
||||||
newPackets.add(spawnPackets[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]);
|
|
||||||
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
|
||||||
spawnPackets[0].getGameProfiles().write(0, gameProfile);
|
|
||||||
spawnPackets[0].getModifier().write(4, gameProfile.getName());
|
|
||||||
PacketContainer delayedPacket = spawnPackets[0].shallowClone();
|
|
||||||
delayedPacket.getModifier().write(0, 4);
|
|
||||||
delayedPackets = new PacketContainer[] { delayedPacket };
|
|
||||||
}
|
}
|
||||||
|
spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]);
|
||||||
|
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||||
|
spawnPackets[0].getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(0));
|
||||||
|
List playerList = new ArrayList();
|
||||||
|
PlayerDisguise playerDisguise = (PlayerDisguise) disguise;
|
||||||
|
playerList.add(ReflectionManager.getPlayerInfoData(spawnPackets[0].getHandle(), playerDisguise.getGameProfile()));
|
||||||
|
spawnPackets[0].getModifier().write(1, playerList);
|
||||||
|
PacketContainer delayedPacket = spawnPackets[0].shallowClone();
|
||||||
|
delayedPacket.getModifier().write(0, ReflectionManager.getEnumPlayerInfoAction(4));
|
||||||
|
delayedPackets = new PacketContainer[] { delayedPacket };
|
||||||
|
|
||||||
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
||||||
|
|
||||||
@ -615,14 +614,9 @@ public class PacketsManager {
|
|||||||
try {
|
try {
|
||||||
int typeId = soundLoc.getWorld().getBlockTypeIdAt(soundLoc.getBlockX(),
|
int typeId = soundLoc.getWorld().getBlockTypeIdAt(soundLoc.getBlockX(),
|
||||||
soundLoc.getBlockY() - 1, soundLoc.getBlockZ());
|
soundLoc.getBlockY() - 1, soundLoc.getBlockZ());
|
||||||
Object block;
|
Object block = ReflectionManager.getNmsMethod("RegistryMaterials", "a", int.class)
|
||||||
if (LibVersion.is1_7()) {
|
.invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null),
|
||||||
block = ReflectionManager.getNmsMethod("RegistryMaterials", "a", int.class)
|
typeId);
|
||||||
.invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null),
|
|
||||||
typeId);
|
|
||||||
} else {
|
|
||||||
block = ((Object[]) ReflectionManager.getNmsField("Block", "byId").get(null))[typeId];
|
|
||||||
}
|
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
||||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound")
|
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound")
|
||||||
@ -689,7 +683,7 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
if ((Byte) mods.read(1) == (LibVersion.is1_7() ? 2 : 1)) {
|
if ((Byte) mods.read(1) == 2) {
|
||||||
// It made a damage animation
|
// It made a damage animation
|
||||||
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
@ -836,7 +830,7 @@ public class PacketsManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else if (event.getPacketType() == PacketType.Play.Server.ANIMATION) {
|
} else if (event.getPacketType() == PacketType.Play.Server.ANIMATION) {
|
||||||
if (event.getPacket().getIntegers().read(1) != (LibVersion.is1_7() ? 2 : 3)) {
|
if (event.getPacket().getIntegers().read(1) != 2) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
} else if (event.getPacketType() == PacketType.Play.Server.ATTACH_ENTITY
|
} else if (event.getPacketType() == PacketType.Play.Server.ATTACH_ENTITY
|
||||||
@ -853,7 +847,7 @@ public class PacketsManager {
|
|||||||
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
|
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
|
||||||
if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer()
|
if (disguise.isSelfDisguiseSoundsReplaced() && !disguise.getType().isPlayer()
|
||||||
&& event.getPacket().getBytes().read(0) == (LibVersion.is1_7() ? 2 : 1)) {
|
&& event.getPacket().getBytes().read(0) == 2) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1342,7 +1336,7 @@ public class PacketsManager {
|
|||||||
// Else if the disguise is attempting to send players a forbidden packet
|
// Else if the disguise is attempting to send players a forbidden packet
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.ANIMATION) {
|
else if (sentPacket.getType() == PacketType.Play.Server.ANIMATION) {
|
||||||
if (disguise.getType().isMisc()
|
if (disguise.getType().isMisc()
|
||||||
|| (packets[0].getIntegers().read(1) == (LibVersion.is1_7() ? 2 : 3) && (!disguise.getType()
|
|| (packets[0].getIntegers().read(1) == 2 && (!disguise.getType()
|
||||||
.isPlayer() || (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise
|
.isPlayer() || (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise
|
||||||
.getWatcher()).isSleeping())))) {
|
.getWatcher()).isSleeping())))) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
@ -1357,7 +1351,7 @@ public class PacketsManager {
|
|||||||
PacketContainer newPacket = new PacketContainer(PacketType.Play.Server.ANIMATION);
|
PacketContainer newPacket = new PacketContainer(PacketType.Play.Server.ANIMATION);
|
||||||
StructureModifier<Integer> mods = newPacket.getIntegers();
|
StructureModifier<Integer> mods = newPacket.getIntegers();
|
||||||
mods.write(0, disguise.getEntity().getEntityId());
|
mods.write(0, disguise.getEntity().getEntityId());
|
||||||
mods.write(1, LibVersion.is1_7() ? 3 : 2);
|
mods.write(1, 3);
|
||||||
packets = new PacketContainer[] { newPacket, sentPacket };
|
packets = new PacketContainer[] { newPacket, sentPacket };
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@ -25,58 +26,29 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
public class ReflectionManager {
|
public class ReflectionManager {
|
||||||
|
|
||||||
public enum LibVersion {
|
public enum LibVersion {
|
||||||
V1_6, V1_7, V1_7_10, V1_7_6, V1_8;
|
V1_8;
|
||||||
private static LibVersion currentVersion;
|
private static LibVersion currentVersion;
|
||||||
static {
|
static {
|
||||||
String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
||||||
if (mcVersion.startsWith("1.")) {
|
currentVersion = V1_8;
|
||||||
if (mcVersion.compareTo("1.7") < 0) {
|
|
||||||
currentVersion = LibVersion.V1_6;
|
|
||||||
} else if (mcVersion.startsWith("1.7")) {
|
|
||||||
if (mcVersion.equals("1.7.10")) {
|
|
||||||
currentVersion = LibVersion.V1_7_10;
|
|
||||||
} else {
|
|
||||||
currentVersion = mcVersion.compareTo("1.7.6") < 0 ? LibVersion.V1_7 : LibVersion.V1_7_6;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
currentVersion = V1_8;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LibVersion getGameVersion() {
|
public static LibVersion getGameVersion() {
|
||||||
return currentVersion;
|
return currentVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_6() {
|
|
||||||
return getGameVersion() == V1_6;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean is1_7() {
|
|
||||||
return getGameVersion() == V1_7 || is1_7_6();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean is1_7_10() {
|
|
||||||
return getGameVersion() == V1_7_10 || is1_8();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean is1_7_6() {
|
|
||||||
return getGameVersion() == V1_7_6 || is1_7_10();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean is1_8() {
|
|
||||||
return getGameVersion() == V1_8;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 Class<?> craftItemClass;
|
private static final Class<?> craftItemClass;
|
||||||
private static Method damageAndIdleSoundMethod;
|
private static Method damageAndIdleSoundMethod;
|
||||||
private static final Field entitiesField;
|
private static final Field entitiesField;
|
||||||
|
private static final Constructor<?> boundingBoxConstructor;
|
||||||
|
private static final Method setBoundingBoxMethod;
|
||||||
/**
|
/**
|
||||||
* 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.
|
||||||
*/
|
*/
|
||||||
@ -92,7 +64,6 @@ public class ReflectionManager {
|
|||||||
*/
|
*/
|
||||||
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
||||||
private static final Method ihmGet;
|
private static final Method ihmGet;
|
||||||
private static HashMap<String, Boolean> is1_8 = new HashMap<String, Boolean>();
|
|
||||||
private static final boolean isForge = Bukkit.getServer().getName().contains("Cauldron")
|
private static final boolean isForge = Bukkit.getServer().getName().contains("Cauldron")
|
||||||
|| Bukkit.getServer().getName().contains("MCPC-Plus");
|
|| Bukkit.getServer().getName().contains("MCPC-Plus");
|
||||||
private static final Field pingField;
|
private static final Field pingField;
|
||||||
@ -224,6 +195,9 @@ public class ReflectionManager {
|
|||||||
trackerField = getNmsField("WorldServer", "tracker");
|
trackerField = getNmsField("WorldServer", "tracker");
|
||||||
entitiesField = getNmsField("EntityTracker", "trackedEntities");
|
entitiesField = getNmsField("EntityTracker", "trackedEntities");
|
||||||
ihmGet = getNmsMethod("IntHashMap", "get", int.class);
|
ihmGet = getNmsMethod("IntHashMap", "get", int.class);
|
||||||
|
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB",double.class, double.class, double.class,
|
||||||
|
double.class, double.class, double.class);
|
||||||
|
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object createEntityInstance(String entityName) {
|
public static Object createEntityInstance(String entityName) {
|
||||||
@ -235,19 +209,13 @@ public class ReflectionManager {
|
|||||||
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||||
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
|
||||||
.newInstance(world);
|
.newInstance(world);
|
||||||
if (LibVersion.is1_7()) {
|
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
|
||||||
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
|
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
||||||
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
gameProfile.getHandle(), playerinteractmanager);
|
||||||
gameProfile.getHandle(), playerinteractmanager);
|
} else if (entityName.equals("EnderPearl")) {
|
||||||
} else {
|
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
|
|
||||||
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
|
|
||||||
playerinteractmanager);
|
|
||||||
}
|
|
||||||
} else if (LibVersion.is1_8() && entityName.equals("EnderPearl")) {
|
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
||||||
.newInstance(world, createEntityInstance("Sheep"));
|
.newInstance(world, createEntityInstance("Cow"));
|
||||||
} else {
|
} else {
|
||||||
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
|
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);
|
||||||
}
|
}
|
||||||
@ -258,18 +226,27 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
||||||
|
try {
|
||||||
|
return getNmsClass("MobEffect").getConstructor(int.class, int.class, int.class, boolean.class, boolean.class)
|
||||||
|
.newInstance(id, duration, amplification, ambient, particles);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object createMobEffect(PotionEffect effect) {
|
||||||
|
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
|
||||||
|
}
|
||||||
|
|
||||||
private static String dir2fqn(String s) {
|
private static String dir2fqn(String s) {
|
||||||
return s.replaceAll("/", ".");
|
return s.replaceAll("/", ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FakeBoundingBox getBoundingBox(Entity entity) {
|
public static FakeBoundingBox getBoundingBox(Entity entity) {
|
||||||
try {
|
try {
|
||||||
Object boundingBox;
|
Object boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity));
|
||||||
if (LibVersion.is1_8()) {
|
|
||||||
boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity));
|
|
||||||
} else {
|
|
||||||
boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
|
||||||
}
|
|
||||||
double x = 0, y = 0, z = 0;
|
double x = 0, y = 0, z = 0;
|
||||||
int stage = 0;
|
int stage = 0;
|
||||||
for (Field field : boundingBox.getClass().getFields()) {
|
for (Field field : boundingBox.getClass().getFields()) {
|
||||||
@ -368,13 +345,51 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WrappedGameProfile getGameProfile(Player player) {
|
public static Object getBlockPosition(int x, int y, int z) {
|
||||||
if (LibVersion.is1_7() || LibVersion.is1_8()) {
|
try {
|
||||||
return WrappedGameProfile.fromPlayer(player);
|
return getNmsClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(x, y, z);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Enum getEnumDirection(int direction) {
|
||||||
|
try {
|
||||||
|
return (Enum) getNmsMethod("EnumDirection", "fromType2", int.class).invoke(null, direction);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Enum getEnumPlayerInfoAction(int action) {
|
||||||
|
try {
|
||||||
|
return (Enum) getNmsClass("PacketPlayOutPlayerInfo$EnumPlayerInfoAction").getEnumConstants()[action];
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Object getPlayerInfoData(Object playerInfoPacket, WrappedGameProfile gameProfile) {
|
||||||
|
try {
|
||||||
|
Object playerListName = getNmsClass("ChatComponentText").getConstructor(String.class)
|
||||||
|
.newInstance(gameProfile.getName());
|
||||||
|
return getNmsClass("PacketPlayOutPlayerInfo$PlayerInfoData").getConstructor(getNmsClass("PacketPlayOutPlayerInfo"),
|
||||||
|
gameProfile.getHandleType(), int.class, getNmsClass("WorldSettings$EnumGamemode"), getNmsClass("IChatBaseComponent"))
|
||||||
|
.newInstance(playerInfoPacket, gameProfile.getHandle(), 0,
|
||||||
|
getNmsClass("WorldSettings$EnumGamemode").getEnumConstants()[1], playerListName);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WrappedGameProfile getGameProfile(Player player) {
|
||||||
|
return WrappedGameProfile.fromPlayer(player);
|
||||||
|
}
|
||||||
|
|
||||||
public static WrappedGameProfile getGameProfile(UUID uuid, String playerName) {
|
public static WrappedGameProfile getGameProfile(UUID uuid, String playerName) {
|
||||||
try {
|
try {
|
||||||
return new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
return new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
||||||
@ -387,9 +402,7 @@ public class ReflectionManager {
|
|||||||
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) {
|
public static WrappedGameProfile getGameProfileWithThisSkin(UUID uuid, String playerName, WrappedGameProfile profileWithSkin) {
|
||||||
try {
|
try {
|
||||||
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
WrappedGameProfile gameProfile = new WrappedGameProfile(uuid != null ? uuid : UUID.randomUUID(), playerName);
|
||||||
if (LibVersion.is1_7_6()) {
|
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
|
||||||
gameProfile.getProperties().putAll(profileWithSkin.getProperties());
|
|
||||||
}
|
|
||||||
return gameProfile;
|
return gameProfile;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -418,6 +431,19 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Constructor getNmsConstructor(Class clazz, Class<?>... parameters) {
|
||||||
|
try {
|
||||||
|
return clazz.getConstructor(parameters);
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Constructor getNmsConstructor(String className, Class<?>... parameters) {
|
||||||
|
return getNmsConstructor(getNmsClass(className), parameters);
|
||||||
|
}
|
||||||
|
|
||||||
public static Object getNmsEntity(Entity entity) {
|
public static Object getNmsEntity(Entity entity) {
|
||||||
try {
|
try {
|
||||||
return getCraftClass("entity.CraftEntity").getMethod("getHandle").invoke(entity);
|
return getCraftClass("entity.CraftEntity").getMethod("getHandle").invoke(entity);
|
||||||
@ -496,12 +522,7 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
|
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
|
||||||
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
|
||||||
float height;
|
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
||||||
if (LibVersion.is1_8()) {
|
|
||||||
height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
|
|
||||||
} else {
|
|
||||||
height = getNmsField("Entity", "height").getFloat(getNmsEntity(entity));
|
|
||||||
}
|
|
||||||
return new float[] { length, width, height };
|
return new float[] { length, width, height };
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -550,12 +571,12 @@ public class ReflectionManager {
|
|||||||
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
for (Method method : getNmsClass("MinecraftServer").getMethods()) {
|
||||||
if (method.getReturnType().getSimpleName().equals("GameProfileRepository")) {
|
if (method.getReturnType().getSimpleName().equals("GameProfileRepository")) {
|
||||||
Object profileRepo = method.invoke(minecraftServer);
|
Object profileRepo = method.invoke(minecraftServer);
|
||||||
Object agent = Class.forName("net.minecraft.util.com.mojang.authlib.Agent").getField("MINECRAFT").get(null);
|
Object agent = Class.forName("com.mojang.authlib.Agent").getField("MINECRAFT").get(null);
|
||||||
LibsProfileLookupCaller callback = new LibsProfileLookupCaller();
|
LibsProfileLookupCaller callback = new LibsProfileLookupCaller();
|
||||||
profileRepo
|
profileRepo
|
||||||
.getClass()
|
.getClass()
|
||||||
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
||||||
Class.forName("net.minecraft.util.com.mojang.authlib.ProfileLookupCallback"))
|
Class.forName("com.mojang.authlib.ProfileLookupCallback"))
|
||||||
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
||||||
if (callback.getGameProfile() != null) {
|
if (callback.getGameProfile() != null) {
|
||||||
return callback.getGameProfile();
|
return callback.getGameProfile();
|
||||||
@ -569,26 +590,6 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_8(Player player) {
|
|
||||||
if (LibVersion.is1_8()) {
|
|
||||||
if (is1_8.containsKey(player.getName())) {
|
|
||||||
return is1_8.get(player.getName());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Object nmsEntity = getNmsEntity(player);
|
|
||||||
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity);
|
|
||||||
Field networkManager = getNmsField(connection.getClass(), "networkManager");
|
|
||||||
Method getVersion = getNmsMethod(networkManager.getType(), "getVersion");
|
|
||||||
boolean is18 = (Integer) getVersion.invoke(networkManager.get(connection)) >= 28;
|
|
||||||
is1_8.put(player.getName(), is18);
|
|
||||||
return is18;
|
|
||||||
} catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isForge() {
|
public static boolean isForge() {
|
||||||
return isForge;
|
return isForge;
|
||||||
}
|
}
|
||||||
@ -604,7 +605,7 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void removePlayer(Player player) {
|
public static void removePlayer(Player player) {
|
||||||
is1_8.remove(player.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAllowSleep(Player player) {
|
public static void setAllowSleep(Player player) {
|
||||||
@ -620,43 +621,13 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) {
|
public static void setBoundingBox(Entity entity, FakeBoundingBox newBox) {
|
||||||
try {
|
try {
|
||||||
Object boundingBox;
|
|
||||||
if (LibVersion.is1_8()) {
|
|
||||||
boundingBox = getNmsMethod("Entity", "getBoundingBox").invoke(getNmsEntity(entity));
|
|
||||||
} else {
|
|
||||||
boundingBox = getNmsField("Entity", "boundingBox").get(getNmsEntity(entity));
|
|
||||||
}
|
|
||||||
int stage = 0;
|
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
for (Field field : boundingBox.getClass().getFields()) {
|
Object boundingBox = boundingBoxConstructor.newInstance(loc.getX() - newBox.getX(), loc.getY() - newBox.getY(),
|
||||||
if (field.getType().getSimpleName().equals("double")) {
|
loc.getZ() - newBox.getZ(), loc.getX() + newBox.getX(), loc.getY() + newBox.getY(), loc.getZ() + newBox.getZ());
|
||||||
stage++;
|
setBoundingBoxMethod.invoke(getNmsEntity(entity), boundingBox);
|
||||||
switch (stage) {
|
|
||||||
case 1:
|
|
||||||
field.setDouble(boundingBox, loc.getX() - newBox.getX());
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// field.setDouble(boundingBox, loc.getY() - newBox.getY());
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
field.setDouble(boundingBox, loc.getZ() - newBox.getZ());
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
field.setDouble(boundingBox, loc.getX() + newBox.getX());
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
field.setDouble(boundingBox, loc.getY() + newBox.getY());
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
field.setDouble(boundingBox, loc.getZ() + newBox.getZ());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,7 +1,8 @@
|
|||||||
name: LibsDisguises
|
name: LibsDisguises
|
||||||
main: me.libraryaddict.disguise.LibsDisguises
|
main: me.libraryaddict.disguise.LibsDisguises
|
||||||
version: ${project.version}
|
version: 8.3 Unofficial
|
||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
|
authors: [Byteflux, Navid K.]
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
commands:
|
commands:
|
||||||
libsdisguises:
|
libsdisguises:
|
@ -1,178 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Animals;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Monster;
|
|
||||||
|
|
||||||
public enum FutureDisguiseType {
|
|
||||||
|
|
||||||
ARMOR_STAND(Entity.class, 30, 2, new float[] { 0F, 0F, 0F }, new Object[] {
|
|
||||||
|
|
||||||
1, (short) 300,
|
|
||||||
|
|
||||||
2, "",
|
|
||||||
|
|
||||||
3, (byte) 0,
|
|
||||||
|
|
||||||
4, (byte) 0,
|
|
||||||
|
|
||||||
6, 1F,
|
|
||||||
|
|
||||||
7, 0,
|
|
||||||
|
|
||||||
8, (byte) 0,
|
|
||||||
|
|
||||||
9, (byte) 0,
|
|
||||||
|
|
||||||
10, (byte) 0,
|
|
||||||
|
|
||||||
// 11,
|
|
||||||
// 12,
|
|
||||||
// 13,
|
|
||||||
// 14,
|
|
||||||
// 15,
|
|
||||||
// 16
|
|
||||||
}),
|
|
||||||
|
|
||||||
ELDER_GUARDIAN(Monster.class, 68, 80, new float[] { 0F, 0F, 0F }, new Object[] {
|
|
||||||
|
|
||||||
1, (short) 300,
|
|
||||||
|
|
||||||
2, "",
|
|
||||||
|
|
||||||
3, (byte) 0,
|
|
||||||
|
|
||||||
4, (byte) 0,
|
|
||||||
|
|
||||||
6, 1F,
|
|
||||||
|
|
||||||
7, 0,
|
|
||||||
|
|
||||||
8, (byte) 0,
|
|
||||||
|
|
||||||
9, (byte) 0,
|
|
||||||
|
|
||||||
15, (byte) 0,
|
|
||||||
|
|
||||||
16, 0 | 4,
|
|
||||||
|
|
||||||
17, 0
|
|
||||||
|
|
||||||
}),
|
|
||||||
|
|
||||||
ENDERMITE(Monster.class, 67, 8, new float[] { 0F, 0F, 0F }, new Object[] {
|
|
||||||
|
|
||||||
0, (byte) 0,
|
|
||||||
|
|
||||||
1, (short) 300,
|
|
||||||
|
|
||||||
2, "",
|
|
||||||
|
|
||||||
3, (byte) 0,
|
|
||||||
|
|
||||||
4, (byte) 0,
|
|
||||||
|
|
||||||
6, 1F,
|
|
||||||
|
|
||||||
7, 0,
|
|
||||||
|
|
||||||
8, (byte) 0,
|
|
||||||
|
|
||||||
9, (byte) 0,
|
|
||||||
|
|
||||||
15, (byte) 0
|
|
||||||
|
|
||||||
}),
|
|
||||||
|
|
||||||
GUARDIAN(Monster.class, 68, 30, new float[] { 0F, 0F, 0F }, new Object[] {
|
|
||||||
|
|
||||||
1, (short) 300,
|
|
||||||
|
|
||||||
2, "",
|
|
||||||
|
|
||||||
3, (byte) 0,
|
|
||||||
|
|
||||||
4, (byte) 0,
|
|
||||||
|
|
||||||
6, 1F,
|
|
||||||
|
|
||||||
7, 0,
|
|
||||||
|
|
||||||
8, (byte) 0,
|
|
||||||
|
|
||||||
9, (byte) 0,
|
|
||||||
|
|
||||||
15, (byte) 0,
|
|
||||||
|
|
||||||
16, 0,
|
|
||||||
|
|
||||||
17, 0
|
|
||||||
|
|
||||||
}),
|
|
||||||
|
|
||||||
RABBIT(Animals.class, 101, 10, new float[] { 0F, 0F, 0F }, new Object[] { 1, (short) 300,
|
|
||||||
|
|
||||||
2, "",
|
|
||||||
|
|
||||||
3, (byte) 0,
|
|
||||||
|
|
||||||
4, (byte) 0,
|
|
||||||
|
|
||||||
6, 1F,
|
|
||||||
|
|
||||||
7, 0,
|
|
||||||
|
|
||||||
8, (byte) 0,
|
|
||||||
|
|
||||||
9, (byte) 0,
|
|
||||||
|
|
||||||
12, 0,
|
|
||||||
|
|
||||||
15, (byte) 0,
|
|
||||||
|
|
||||||
18, (byte) 0
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
private float[] boundingBox;
|
|
||||||
private Object[] dataWatcher;
|
|
||||||
private Class<? extends Entity> entityClass;
|
|
||||||
private int entityId;
|
|
||||||
private float maxHealth;
|
|
||||||
|
|
||||||
private FutureDisguiseType(Class<? extends Entity> entityClass, int entityId, float maxHealth, float[] boundingBox,
|
|
||||||
Object[] watcherValues) {
|
|
||||||
this.entityClass = entityClass;
|
|
||||||
this.dataWatcher = watcherValues;
|
|
||||||
this.boundingBox = boundingBox;
|
|
||||||
if (watcherValues.length % 2 != 0) {
|
|
||||||
System.out.print("Error! " + name() + " has odd number of params!");
|
|
||||||
}
|
|
||||||
this.entityId = entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float[] getBoundingBox() {
|
|
||||||
return boundingBox;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[] getDataWatcher() {
|
|
||||||
return dataWatcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<? extends Entity> getEntityClass() {
|
|
||||||
return entityClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getEntityId() {
|
|
||||||
return entityId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getMaxHealth() {
|
|
||||||
return maxHealth;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlive() {
|
|
||||||
return this != ARMOR_STAND;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user