Add backwards support for 1.11.2, bugfixes, update to 1.12
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
*/
|
||||
public class BackwardMethods {
|
||||
|
||||
public boolean isOrderedIndexes() {
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_1;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
*/
|
||||
public class BackwardsSupport {
|
||||
public static BackwardMethods getMethods() {
|
||||
try {
|
||||
String version = ReflectionManager.getBukkitVersion();
|
||||
|
||||
if (version.equals("v1_11_R1")) {
|
||||
return setupMetadata(Version_1_1.class);
|
||||
}
|
||||
|
||||
return setupMetadata(BackwardMethods.class);
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static BackwardMethods setupMetadata(Class<? extends BackwardMethods> backwardsClass) {
|
||||
try {
|
||||
BackwardMethods backwards = backwardsClass.newInstance();
|
||||
|
||||
for (Field field : backwards.getClass().getFields()) {
|
||||
if (field.getType() != MetaIndex.class)
|
||||
continue;
|
||||
|
||||
MetaIndex.setMetaIndex(field.getName(), (MetaIndex) field.get(backwards));
|
||||
}
|
||||
|
||||
MetaIndex.setValues();
|
||||
|
||||
if (backwards.isOrderedIndexes()) {
|
||||
MetaIndex.fillInBlankIndexes();
|
||||
MetaIndex.orderMetaIndexes();
|
||||
}
|
||||
|
||||
return backwards;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
||||
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 8/06/2017.
|
||||
* Supports 1.11.0 1.11.1 and 1.11.2
|
||||
*/
|
||||
public class Version_1_1 extends BackwardMethods {
|
||||
private MetaIndex ILLAGER_META;
|
||||
private MetaIndex PARROT_VARIANT;
|
||||
private MetaIndex PLAYER_LEFT_SHOULDER_ENTITY;
|
||||
private MetaIndex PLAYER_RIGHT_SHOULDER_ENTITY;
|
||||
}
|
Reference in New Issue
Block a user