Update plugin to 1.13, bump maven version, bump java version to 1.8
This commit is contained in:
parent
992385c2d9
commit
49d716f285
@ -129,3 +129,5 @@ permissions:
|
|||||||
description: See the /disguisemodifyradius command in tab-completion
|
description: See the /disguisemodifyradius command in tab-completion
|
||||||
libsdisguises.seecmd.disguisemodifyentity:
|
libsdisguises.seecmd.disguisemodifyentity:
|
||||||
description: See the /disguisemodifyentity command in tab-completion
|
description: See the /disguisemodifyentity command in tab-completion
|
||||||
|
|
||||||
|
api-version: 1.13
|
10
pom.xml
10
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>LibsDisguises</groupId>
|
<groupId>LibsDisguises</groupId>
|
||||||
<artifactId>LibsDisguises</artifactId>
|
<artifactId>LibsDisguises</artifactId>
|
||||||
<version>9.5.2-SNAPSHOT</version>
|
<version>9.6.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
@ -28,8 +28,8 @@
|
|||||||
|
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.7</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -43,12 +43,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.12-pre6-SNAPSHOT</version>
|
<version>1.13-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.12-pre6-SNAPSHOT</version>
|
<version>1.13-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.NativeGameMode;
|
|||||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
@ -39,6 +39,18 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
|
|
||||||
LibsPremium.check(getDescription().getVersion());
|
LibsPremium.check(getDescription().getVersion());
|
||||||
|
|
||||||
|
if (ReflectionManager.getMinecraftVersion().startsWith("1.13")) {
|
||||||
|
if (!LibsPremium.isPremium()) {
|
||||||
|
System.out.println("[LibsDisguises] You must purchase the plugin to use 1.13!");
|
||||||
|
System.out.println(
|
||||||
|
"[LibsDisguises] This will be released free two weeks after all bugs have been fixed!");
|
||||||
|
System.out.println(
|
||||||
|
"[LibsDisguises] If you've already purchased the plugin, place the purchased jar inside the " +
|
||||||
|
"Lib's Disguises plugin folder");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PacketsManager.init(this);
|
PacketsManager.init(this);
|
||||||
DisguiseUtilities.init(this);
|
DisguiseUtilities.init(this);
|
||||||
|
|
||||||
@ -426,6 +438,8 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disguiseType.setTypeId(ReflectionManager.getEntityType(nmsEntity));
|
||||||
|
|
||||||
Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);
|
Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);
|
||||||
int entitySize = 0;
|
int entitySize = 0;
|
||||||
|
|
||||||
@ -449,36 +463,34 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
|
MetaIndex flagType = MetaIndex.getFlag(watcherClass, watch.getIndex());
|
||||||
|
|
||||||
if (flagType == null) {
|
if (flagType == null) {
|
||||||
System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " +
|
System.err.println("[LibsDisguises] MetaIndex not found for " + disguiseType + "! Index: " +
|
||||||
watch.getIndex() + " can't be found!");
|
watch.getIndex());
|
||||||
System.err.println(
|
System.err.println("[LibsDisguises] Value: " + watch.getRawValue() + " (" +
|
||||||
"Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") (" +
|
watch.getRawValue().getClass() + ") (" + nmsEntity.getClass() + ") & " +
|
||||||
nmsEntity.getClass() + ") & " + watcherClass.getSimpleName());
|
watcherClass.getSimpleName());
|
||||||
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
indexes.remove(flagType);
|
indexes.remove(flagType);
|
||||||
|
|
||||||
Object obj1 = ReflectionManager.convertInvalidItem(flagType.getDefault());
|
Object ourValue = ReflectionManager.convertInvalidMeta(flagType.getDefault());
|
||||||
Object obj2 = ReflectionManager.convertInvalidItem(watch.getValue());
|
Object nmsValue = ReflectionManager.convertInvalidMeta(watch.getValue());
|
||||||
|
|
||||||
if (obj1 != obj2 && ((obj1 == null || obj2 == null) || obj1.getClass() != obj2.getClass())) {
|
if (ourValue != nmsValue &&
|
||||||
System.err.println("Mismatch of " + "FlagType's for " + disguiseType.name() + "! Index " +
|
((ourValue == null || nmsValue == null) || ourValue.getClass() != nmsValue.getClass())) {
|
||||||
watch.getIndex() + " has the wrong classtype!");
|
System.err.println("[LibsDisguises] MetaIndex mismatch for " + disguiseType + "! Index: " +
|
||||||
System.err.println("MetaIndex has the " + "default of " + flagType.getDefault() + " (" +
|
watch.getIndex());
|
||||||
|
System.err.println("[LibsDisguises] MetaIndex: " + flagType.getDefault() + " (" +
|
||||||
flagType.getDefault().getClass() + ") (" + nmsEntity.getClass() + ") & " +
|
flagType.getDefault().getClass() + ") (" + nmsEntity.getClass() + ") & " +
|
||||||
watcherClass.getSimpleName());
|
watcherClass.getSimpleName());
|
||||||
System.err.println("Where the internals is " + watch.getRawValue() + " (" +
|
System.err.println("[LibsDisguises] Minecraft: " + watch.getRawValue() + " (" +
|
||||||
watch.getRawValue().getClass());
|
watch.getRawValue().getClass() + ")");
|
||||||
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MetaIndex index : indexes) {
|
for (MetaIndex index : indexes) {
|
||||||
System.out.println(
|
System.out.println("[LibsDisguises] " + disguiseType + " has MetaIndex remaining! " +
|
||||||
disguiseType + " has MetaIndex remaining! " + index.getFlagWatcher().getSimpleName() +
|
index.getFlagWatcher().getSimpleName() + " at index " + index.getIndex());
|
||||||
" at index " + index.getIndex());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
||||||
|
@ -181,7 +181,8 @@ public enum DisguiseType {
|
|||||||
ZOMBIE_VILLAGER;
|
ZOMBIE_VILLAGER;
|
||||||
|
|
||||||
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.
|
||||||
// Without erroring up everything.
|
// Without erroring up everything.
|
||||||
|
|
||||||
for (DisguiseType type : values()) {
|
for (DisguiseType type : values()) {
|
||||||
@ -191,7 +192,8 @@ public enum DisguiseType {
|
|||||||
String name;
|
String name;
|
||||||
|
|
||||||
/* switch (type) {
|
/* switch (type) {
|
||||||
// Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being..
|
// Disguise item frame isn't supported. So we don't give it a entity type which should prevent it
|
||||||
|
from being..
|
||||||
// Usable.
|
// Usable.
|
||||||
case ITEM_FRAME:
|
case ITEM_FRAME:
|
||||||
break;
|
break;
|
||||||
@ -231,6 +233,7 @@ public enum DisguiseType {
|
|||||||
private EntityType entityType;
|
private EntityType entityType;
|
||||||
|
|
||||||
private int objectId = -1, defaultData = 0;
|
private int objectId = -1, defaultData = 0;
|
||||||
|
private int typeId;
|
||||||
|
|
||||||
private Class<? extends FlagWatcher> watcherClass;
|
private Class<? extends FlagWatcher> watcherClass;
|
||||||
|
|
||||||
@ -284,7 +287,11 @@ public enum DisguiseType {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getTypeId() {
|
public int getTypeId() {
|
||||||
return (int) getEntityType().getTypeId();
|
return typeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTypeId(int typeId) {
|
||||||
|
this.typeId = typeId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class<? extends FlagWatcher> getWatcherClass() {
|
public Class<? extends FlagWatcher> getWatcherClass() {
|
||||||
|
@ -4,12 +4,17 @@ import com.comphenix.protocol.PacketType.Play.Server;
|
|||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
import com.comphenix.protocol.wrappers.ComponentConverter;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -152,8 +157,8 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Here we check for if there is a health packet that says they died.
|
// Here we check for if there is a health packet that says they died.
|
||||||
if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null && getDisguise()
|
if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null &&
|
||||||
.getEntity() instanceof Player) {
|
getDisguise().getEntity() instanceof Player) {
|
||||||
for (WrappedWatchableObject watch : newList) {
|
for (WrappedWatchableObject watch : newList) {
|
||||||
// Its a health packet
|
// Its a health packet
|
||||||
if (watch.getIndex() == 6) {
|
if (watch.getIndex() == 6) {
|
||||||
@ -194,7 +199,15 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getCustomName() {
|
public String getCustomName() {
|
||||||
return (String) getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
Optional<WrappedChatComponent> optional = getData(MetaIndex.ENTITY_CUSTOM_NAME);
|
||||||
|
|
||||||
|
if (optional.isPresent()) {
|
||||||
|
BaseComponent[] base = ComponentConverter.fromWrapper(optional.get());
|
||||||
|
|
||||||
|
return TextComponent.toLegacyText(base);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TargetedDisguise getDisguise() {
|
protected TargetedDisguise getDisguise() {
|
||||||
@ -329,8 +342,8 @@ public class FlagWatcher {
|
|||||||
|
|
||||||
Object value = entityValues.get(data.getIndex());
|
Object value = entityValues.get(data.getIndex());
|
||||||
|
|
||||||
if (isEntityAnimationsAdded() && DisguiseConfig
|
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() &&
|
||||||
.isMetadataPacketsEnabled() && data == MetaIndex.ENTITY_META) {
|
data == MetaIndex.ENTITY_META) {
|
||||||
value = addEntityAnimations((byte) value,
|
value = addEntityAnimations((byte) value,
|
||||||
WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
||||||
}
|
}
|
||||||
@ -391,11 +404,16 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomName(String name) {
|
public void setCustomName(String name) {
|
||||||
if (name != null && name.length() > 64) {
|
if (Strings.isNullOrEmpty(name)) {
|
||||||
|
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.<WrappedChatComponent>empty());
|
||||||
|
} else {
|
||||||
|
if (name.length() > 64) {
|
||||||
name = name.substring(0, 64);
|
name = name.substring(0, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, name);
|
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.of(WrappedChatComponent.fromText(name)));
|
||||||
|
}
|
||||||
|
|
||||||
sendData(MetaIndex.ENTITY_CUSTOM_NAME);
|
sendData(MetaIndex.ENTITY_CUSTOM_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,8 +472,8 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void sendItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
protected void sendItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
||||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this || getDisguise()
|
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this ||
|
||||||
.getEntity() == null)
|
getDisguise().getEntity() == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
|
if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.*;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||||
import com.comphenix.protocol.wrappers.Vector3F;
|
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||||
import com.google.common.base.Optional;
|
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
@ -27,11 +26,8 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 2,
|
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 2,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0);
|
public static MetaIndex<Particle> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class,
|
||||||
|
3, Particle.SPELL_MOB);
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_1 = new MetaIndex<>(AreaEffectCloudWatcher.class, 4, 0);
|
|
||||||
|
|
||||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2 = new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
|
||||||
|
|
||||||
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 0F);
|
public static MetaIndex<Float> AREA_EFFECT_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 0, 0F);
|
||||||
|
|
||||||
@ -73,6 +69,8 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Integer> BOAT_TYPE = new MetaIndex<>(BoatWatcher.class, 3, 0);
|
public static MetaIndex<Integer> BOAT_TYPE = new MetaIndex<>(BoatWatcher.class, 3, 0);
|
||||||
|
|
||||||
|
public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> CREEPER_IGNITED = new MetaIndex<>(CreeperWatcher.class, 2, false);
|
public static MetaIndex<Boolean> CREEPER_IGNITED = new MetaIndex<>(CreeperWatcher.class, 2, false);
|
||||||
|
|
||||||
public static MetaIndex<Boolean> CREEPER_POWERED = new MetaIndex<>(CreeperWatcher.class, 1, false);
|
public static MetaIndex<Boolean> CREEPER_POWERED = new MetaIndex<>(CreeperWatcher.class, 1, false);
|
||||||
@ -83,7 +81,7 @@ public class MetaIndex<Y> {
|
|||||||
new ItemStack(Material.STONE));
|
new ItemStack(Material.STONE));
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0,
|
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0,
|
||||||
Optional.<BlockPosition>absent());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ENDER_CRYSTAL_PLATE = new MetaIndex<>(EnderCrystalWatcher.class, 1, false);
|
public static MetaIndex<Boolean> ENDER_CRYSTAL_PLATE = new MetaIndex<>(EnderCrystalWatcher.class, 1, false);
|
||||||
|
|
||||||
@ -92,11 +90,12 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Boolean> ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false);
|
public static MetaIndex<Boolean> ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false);
|
||||||
|
|
||||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0,
|
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0,
|
||||||
Optional.<WrappedBlockData>absent());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 0);
|
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 0);
|
||||||
|
|
||||||
public static MetaIndex<String> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2, "");
|
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2,
|
||||||
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Boolean> ENTITY_CUSTOM_NAME_VISIBLE = new MetaIndex<>(FlagWatcher.class, 3, false);
|
public static MetaIndex<Boolean> ENTITY_CUSTOM_NAME_VISIBLE = new MetaIndex<>(FlagWatcher.class, 3, false);
|
||||||
|
|
||||||
@ -132,7 +131,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Byte> HORSE_META = new MetaIndex<>(AbstractHorseWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> HORSE_META = new MetaIndex<>(AbstractHorseWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1,
|
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1,
|
||||||
Optional.<UUID>absent());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
@ -181,7 +180,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> PIG_SADDLED = new MetaIndex<>(PigWatcher.class, 0, false);
|
public static MetaIndex<Boolean> PIG_SADDLED = new MetaIndex<>(PigWatcher.class, 0, false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> PIG_UNKNOWN = new MetaIndex<>(PigWatcher.class, 1, 0);
|
public static MetaIndex<Integer> PIG_BOOST = new MetaIndex<>(PigWatcher.class, 1, 0);
|
||||||
|
|
||||||
public static MetaIndex<Float> PLAYER_ABSORPTION = new MetaIndex<>(PlayerWatcher.class, 0, 0F);
|
public static MetaIndex<Float> PLAYER_ABSORPTION = new MetaIndex<>(PlayerWatcher.class, 0, 0F);
|
||||||
|
|
||||||
@ -191,11 +190,11 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Byte> PLAYER_SKIN = new MetaIndex<>(PlayerWatcher.class, 2, (byte) 127);
|
public static MetaIndex<Byte> PLAYER_SKIN = new MetaIndex<>(PlayerWatcher.class, 2, (byte) 127);
|
||||||
|
|
||||||
public static MetaIndex<NbtCompound> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4,
|
public static MetaIndex<NbtBase> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4,
|
||||||
NbtFactory.ofCompound("None"));
|
NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||||
|
|
||||||
public static MetaIndex<NbtCompound> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5,
|
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5,
|
||||||
NbtFactory.ofCompound("None"));
|
NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||||
|
|
||||||
public static MetaIndex<Boolean> POLAR_BEAR_STANDING = new MetaIndex<>(PolarBearWatcher.class, 0, false);
|
public static MetaIndex<Boolean> POLAR_BEAR_STANDING = new MetaIndex<>(PolarBearWatcher.class, 0, false);
|
||||||
|
|
||||||
@ -204,7 +203,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
|
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
|
||||||
Optional.<BlockPosition>absent());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 10);
|
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 10);
|
||||||
|
|
||||||
@ -225,7 +224,7 @@ public class MetaIndex<Y> {
|
|||||||
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
|
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
|
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
|
||||||
Optional.<UUID>absent());
|
Optional.empty());
|
||||||
|
|
||||||
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(ArrowWatcher.class, 1, Color.WHITE.asRGB());
|
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(ArrowWatcher.class, 1, Color.WHITE.asRGB());
|
||||||
|
|
||||||
@ -259,6 +258,8 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
|
public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
|
||||||
|
|
||||||
|
public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 3, false);
|
||||||
|
|
||||||
public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
|
public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
|
||||||
|
|
||||||
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
||||||
@ -273,10 +274,13 @@ public class MetaIndex<Y> {
|
|||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0, new ItemStack(Material.POTION));
|
SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0, new ItemStack(Material.POTION));
|
||||||
}
|
}
|
||||||
|
|
||||||
setValues();
|
setValues();
|
||||||
|
orderMetaIndexes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void eliminateBlankIndexes() {
|
@Deprecated
|
||||||
|
private static void eliminateBlankIndexes() {
|
||||||
ArrayList<Entry<Class, ArrayList<MetaIndex>>> list = new ArrayList<>();
|
ArrayList<Entry<Class, ArrayList<MetaIndex>>> list = new ArrayList<>();
|
||||||
|
|
||||||
for (MetaIndex index : values()) {
|
for (MetaIndex index : values()) {
|
||||||
@ -292,6 +296,7 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
if (entry == null) {
|
if (entry == null) {
|
||||||
entry = new AbstractMap.SimpleEntry(index.getFlagWatcher(), new ArrayList<MetaIndex>());
|
entry = new AbstractMap.SimpleEntry(index.getFlagWatcher(), new ArrayList<MetaIndex>());
|
||||||
|
|
||||||
list.add(entry);
|
list.add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,12 +304,7 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Entry<Class, ArrayList<MetaIndex>> entry : list) {
|
for (Entry<Class, ArrayList<MetaIndex>> entry : list) {
|
||||||
Collections.sort(entry.getValue(), new Comparator<MetaIndex>() {
|
entry.getValue().sort(Comparator.comparingInt(MetaIndex::getIndex));
|
||||||
@Override
|
|
||||||
public int compare(MetaIndex o1, MetaIndex o2) {
|
|
||||||
return o1.getIndex() - o2.getIndex();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
for (MetaIndex ind : entry.getValue()) {
|
for (MetaIndex ind : entry.getValue()) {
|
||||||
ind._index = entry.getValue().indexOf(ind);
|
ind._index = entry.getValue().indexOf(ind);
|
||||||
@ -312,7 +312,7 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void orderMetaIndexes() {
|
private static void orderMetaIndexes() {
|
||||||
for (MetaIndex flagType : values()) {
|
for (MetaIndex flagType : values()) {
|
||||||
if (flagType.getFlagWatcher() == FlagWatcher.class)
|
if (flagType.getFlagWatcher() == FlagWatcher.class)
|
||||||
continue;
|
continue;
|
||||||
@ -349,10 +349,10 @@ public class MetaIndex<Y> {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
System.err.println(entry.getKey()
|
System.err.println(
|
||||||
.getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" + type
|
entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " +
|
||||||
.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher()
|
i + " (" + type.getFlagWatcher().getSimpleName() + ", " +
|
||||||
.getSimpleName() + ")");
|
found.getFlagWatcher().getSimpleName() + ")");
|
||||||
continue loop;
|
continue loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,15 +377,16 @@ public class MetaIndex<Y> {
|
|||||||
|
|
||||||
MetaIndex index = (MetaIndex) field.get(null);
|
MetaIndex index = (MetaIndex) field.get(null);
|
||||||
|
|
||||||
toPrint.add(index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index
|
toPrint.add(
|
||||||
.getIndex() + " " + index.getDefault().getClass().getSimpleName());
|
index.getFlagWatcher().getSimpleName() + " " + field.getName() + " " + index.getIndex() + " " +
|
||||||
|
index.getDefault().getClass().getSimpleName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(toPrint, String.CASE_INSENSITIVE_ORDER);
|
toPrint.sort(String.CASE_INSENSITIVE_ORDER);
|
||||||
|
|
||||||
for (String s : toPrint) {
|
for (String s : toPrint) {
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
@ -416,12 +417,7 @@ public class MetaIndex<Y> {
|
|||||||
list.add(type);
|
list.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
Collections.sort(list, new Comparator<MetaIndex>() {
|
list.sort(Comparator.comparingInt(MetaIndex::getIndex));
|
||||||
@Override
|
|
||||||
public int compare(MetaIndex o1, MetaIndex o2) {
|
|
||||||
return Integer.compare(o1.getIndex(), o2.getIndex());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@ -460,15 +456,15 @@ public class MetaIndex<Y> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (MetaIndex metaIndex : values()) {
|
for (MetaIndex metaIndex : values()) {
|
||||||
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() || metaIndex
|
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() ||
|
||||||
.getIndex() != index.getIndex()) {
|
metaIndex.getIndex() != index.getIndex()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
System.err.println("[LibsDisguises] MetaIndex " + metaIndex.getFlagWatcher()
|
System.err.println(
|
||||||
.getSimpleName() + " at index " + metaIndex
|
"[LibsDisguises] MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " +
|
||||||
.getIndex() + " has already registered this! (" + metaIndex.getDefault() + "," + index
|
metaIndex.getIndex() + " has already registered this! (" + metaIndex.getDefault() +
|
||||||
.getDefault() + ")");
|
"," + index.getDefault() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
values()[i] = metaIndexes[a];
|
values()[i] = metaIndexes[a];
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
|
||||||
|
|
||||||
import org.bukkit.Art;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PaintingWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
||||||
|
import org.bukkit.Art;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.security.InvalidParameterException;
|
||||||
|
|
||||||
public class MiscDisguise extends TargetedDisguise {
|
public class MiscDisguise extends TargetedDisguise {
|
||||||
private int id = -1, data = 0;
|
private int id = -1, data = 0;
|
||||||
@ -19,6 +19,18 @@ public class MiscDisguise extends TargetedDisguise {
|
|||||||
this(disguiseType, -1, disguiseType.getDefaultData());
|
this(disguiseType, -1, disguiseType.getDefaultData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MiscDisguise(Material material, int data) {
|
||||||
|
super(DisguiseType.DROPPED_ITEM);
|
||||||
|
|
||||||
|
apply(0, 0, new ItemStack(material, 1, (short) data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public MiscDisguise(ItemStack itemStack) {
|
||||||
|
super(DisguiseType.DROPPED_ITEM);
|
||||||
|
|
||||||
|
apply(0, 0, itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
public MiscDisguise(DisguiseType disguiseType, int id) {
|
public MiscDisguise(DisguiseType disguiseType, int id) {
|
||||||
this(disguiseType, id, disguiseType.getDefaultData());
|
this(disguiseType, id, disguiseType.getDefaultData());
|
||||||
}
|
}
|
||||||
@ -28,34 +40,37 @@ public class MiscDisguise extends TargetedDisguise {
|
|||||||
|
|
||||||
if (!disguiseType.isMisc()) {
|
if (!disguiseType.isMisc()) {
|
||||||
throw new InvalidParameterException(
|
throw new InvalidParameterException(
|
||||||
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + " instead. Please use " + (
|
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType +
|
||||||
disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead");
|
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") +
|
||||||
|
" instead");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apply(id, data, new ItemStack(Material.STONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void apply(int id, int data, ItemStack itemStack) {
|
||||||
createDisguise();
|
createDisguise();
|
||||||
|
|
||||||
this.id = getType().getTypeId();
|
this.id = getType().getTypeId();
|
||||||
this.data = getType().getDefaultData();
|
this.data = getType().getDefaultData();
|
||||||
switch (disguiseType) {
|
|
||||||
|
switch (getType()) {
|
||||||
// The only disguises which should use a custom data.
|
// The only disguises which should use a custom data.
|
||||||
case PAINTING:
|
case PAINTING:
|
||||||
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, id) % Art.values().length]);
|
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, id) % Art.values().length]);
|
||||||
break;
|
break;
|
||||||
case FALLING_BLOCK:
|
case FALLING_BLOCK:
|
||||||
((FallingBlockWatcher) getWatcher()).setBlock(
|
((FallingBlockWatcher) getWatcher()).setBlock(itemStack);
|
||||||
new ItemStack(Math.max(1, id), 1, (short) Math.max(0, data)));
|
|
||||||
break;
|
break;
|
||||||
case SPLASH_POTION:
|
case SPLASH_POTION:
|
||||||
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
|
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, id));
|
||||||
break;
|
break;
|
||||||
case DROPPED_ITEM:
|
case DROPPED_ITEM:
|
||||||
|
((DroppedItemWatcher) getWatcher()).setItemStack(itemStack);
|
||||||
if (id > 0) {
|
|
||||||
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(id, Math.max(1, data)));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
|
case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
|
||||||
case ARROW: // Entity ID of shooter. Used for "Is he on this scoreboard team and do I render it moving through his body?"
|
case ARROW: // Entity ID of shooter. Used for "Is he on this scoreboard team and do I render it moving
|
||||||
|
// through his body?"
|
||||||
case TIPPED_ARROW:
|
case TIPPED_ARROW:
|
||||||
case SPECTRAL_ARROW:
|
case SPECTRAL_ARROW:
|
||||||
case SMALL_FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
|
case SMALL_FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
|
||||||
@ -116,8 +131,9 @@ public class MiscDisguise extends TargetedDisguise {
|
|||||||
*/
|
*/
|
||||||
public int getId() {
|
public int getId() {
|
||||||
if (getType() == DisguiseType.FALLING_BLOCK) {
|
if (getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
return ((FallingBlockWatcher) getWatcher()).getBlock().getTypeId();
|
return ((FallingBlockWatcher) getWatcher()).getBlock().getType().ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
public abstract class AbstractHorseWatcher extends AgeableWatcher {
|
||||||
public AbstractHorseWatcher(Disguise disguise) {
|
public AbstractHorseWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
@ -27,10 +28,6 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
return getData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParticleId() {
|
|
||||||
return getData(MetaIndex.AREA_EFFECT_PARTICLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRadius(float radius) {
|
public void setRadius(float radius) {
|
||||||
if (radius > 30)
|
if (radius > 30)
|
||||||
radius = 30;
|
radius = 30;
|
||||||
@ -49,8 +46,12 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||||||
sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParticleId(int particleId) {
|
public void setParticleType(Particle particle) {
|
||||||
setData(MetaIndex.AREA_EFFECT_PARTICLE, particleId);
|
setData(MetaIndex.AREA_EFFECT_PARTICLE, particle);
|
||||||
sendData(MetaIndex.AREA_EFFECT_PARTICLE);
|
sendData(MetaIndex.AREA_EFFECT_PARTICLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Particle getParticleType() {
|
||||||
|
return getData(MetaIndex.AREA_EFFECT_PARTICLE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.TreeSpecies;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import org.bukkit.TreeSpecies;
|
||||||
|
|
||||||
public class BoatWatcher extends FlagWatcher {
|
public class BoatWatcher extends FlagWatcher {
|
||||||
public BoatWatcher(Disguise disguise) {
|
public BoatWatcher(Disguise disguise) {
|
||||||
@ -45,8 +44,16 @@ public class BoatWatcher extends FlagWatcher {
|
|||||||
sendData(MetaIndex.BOAT_TYPE);
|
sendData(MetaIndex.BOAT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBoatShake(int number) {
|
||||||
|
setData(MetaIndex.BOAT_SHAKE, number);
|
||||||
|
sendData(MetaIndex.BOAT_SHAKE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBoatShake() {
|
||||||
|
return getData(MetaIndex.BOAT_SHAKE);
|
||||||
|
}
|
||||||
|
|
||||||
public TreeSpecies getBoatType() {
|
public TreeSpecies getBoatType() {
|
||||||
return TreeSpecies.getByData(getData(MetaIndex.BOAT_TYPE).byteValue());
|
return TreeSpecies.getByData(getData(MetaIndex.BOAT_TYPE).byteValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
|
@ -1,85 +1,60 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
import java.util.Optional;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
public class EndermanWatcher extends InsentientWatcher {
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
|
|
||||||
public class EndermanWatcher extends InsentientWatcher
|
public EndermanWatcher(Disguise disguise) {
|
||||||
{
|
|
||||||
|
|
||||||
public EndermanWatcher(Disguise disguise)
|
|
||||||
{
|
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand()
|
public ItemStack getItemInMainHand() {
|
||||||
{
|
|
||||||
Optional<WrappedBlockData> value = getData(MetaIndex.ENDERMAN_ITEM);
|
Optional<WrappedBlockData> value = getData(MetaIndex.ENDERMAN_ITEM);
|
||||||
|
|
||||||
if (value.isPresent())
|
if (value.isPresent()) {
|
||||||
{
|
|
||||||
WrappedBlockData pair = value.get();
|
WrappedBlockData pair = value.get();
|
||||||
Material id = pair.getType();
|
Material id = pair.getType();
|
||||||
int data = pair.getData();
|
int data = pair.getData();
|
||||||
|
|
||||||
return new ItemStack(id, 1, (short) data);
|
return new ItemStack(id, 1, (short) data);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemInMainHand(ItemStack itemstack)
|
public void setItemInMainHand(ItemStack itemstack) {
|
||||||
{
|
setItemInMainHand(itemstack.getType(), itemstack.getDurability());
|
||||||
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public void setItemInMainHand(Material type) {
|
||||||
public void setItemInMainHand(int typeId)
|
|
||||||
{
|
|
||||||
setItemInMainHand(typeId, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setItemInMainHand(Material type)
|
|
||||||
{
|
|
||||||
setItemInMainHand(type, 0);
|
setItemInMainHand(type, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemInMainHand(Material type, int data)
|
public void setItemInMainHand(Material type, int data) {
|
||||||
{
|
|
||||||
Optional<WrappedBlockData> optional;
|
Optional<WrappedBlockData> optional;
|
||||||
|
|
||||||
if (type == null)
|
if (type == null)
|
||||||
optional = Optional.<WrappedBlockData> absent();
|
optional = Optional.empty();
|
||||||
else
|
else
|
||||||
optional = Optional.<WrappedBlockData> of(WrappedBlockData.createData(type, data));
|
optional = Optional.of(WrappedBlockData.createData(type, data));
|
||||||
|
|
||||||
setData(MetaIndex.ENDERMAN_ITEM, optional);
|
setData(MetaIndex.ENDERMAN_ITEM, optional);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public boolean isAggressive() {
|
||||||
public void setItemInMainHand(int typeId, int data)
|
|
||||||
{
|
|
||||||
setItemInMainHand(Material.getMaterial(typeId), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAggressive()
|
|
||||||
{
|
|
||||||
return getData(MetaIndex.ENDERMAN_AGRESSIVE);
|
return getData(MetaIndex.ENDERMAN_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive)
|
public void setAggressive(boolean isAggressive) {
|
||||||
{
|
|
||||||
setData(MetaIndex.ENDERMAN_AGRESSIVE, isAggressive);
|
setData(MetaIndex.ENDERMAN_AGRESSIVE, isAggressive);
|
||||||
sendData(MetaIndex.ENDERMAN_AGRESSIVE);
|
sendData(MetaIndex.ENDERMAN_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ public class HorseWatcher extends AbstractHorseWatcher {
|
|||||||
|
|
||||||
switch (horseValue) {
|
switch (horseValue) {
|
||||||
case 1:
|
case 1:
|
||||||
return new ItemStack(Material.IRON_BARDING);
|
return new ItemStack(Material.IRON_HORSE_ARMOR);
|
||||||
case 2:
|
case 2:
|
||||||
return new ItemStack(Material.GOLD_BARDING);
|
return new ItemStack(Material.GOLDEN_HORSE_ARMOR);
|
||||||
case 3:
|
case 3:
|
||||||
return new ItemStack(Material.DIAMOND_BARDING);
|
return new ItemStack(Material.DIAMOND_HORSE_ARMOR);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -67,13 +67,13 @@ public class HorseWatcher extends AbstractHorseWatcher {
|
|||||||
if (item != null) {
|
if (item != null) {
|
||||||
Material mat = item.getType();
|
Material mat = item.getType();
|
||||||
|
|
||||||
if (mat == Material.IRON_BARDING) {
|
if (mat == Material.IRON_HORSE_ARMOR) {
|
||||||
value = 1;
|
value = 1;
|
||||||
}
|
}
|
||||||
else if (mat == Material.GOLD_BARDING) {
|
else if (mat == Material.GOLDEN_HORSE_ARMOR) {
|
||||||
value = 2;
|
value = 2;
|
||||||
}
|
}
|
||||||
else if (mat == Material.DIAMOND_BARDING) {
|
else if (mat == Material.DIAMOND_HORSE_ARMOR) {
|
||||||
value = 3;
|
value = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,43 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
public class MinecartWatcher extends FlagWatcher {
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|
||||||
|
|
||||||
public class MinecartWatcher extends FlagWatcher
|
public MinecartWatcher(Disguise disguise) {
|
||||||
{
|
|
||||||
|
|
||||||
public MinecartWatcher(Disguise disguise)
|
|
||||||
{
|
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getBlockInCart()
|
public ItemStack getBlockInCart() {
|
||||||
{
|
return ReflectionManager.getItemStackByCombinedId(getData(MetaIndex.MINECART_BLOCK));
|
||||||
int id = (int) getData(MetaIndex.MINECART_BLOCK) & 0xffff;
|
|
||||||
int data = (int) getData(MetaIndex.MINECART_BLOCK) >> 16;
|
|
||||||
|
|
||||||
return new ItemStack(id, 1, (short) data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockYOffset()
|
public int getBlockYOffset() {
|
||||||
{
|
return getData(MetaIndex.MINECART_BLOCK_Y);
|
||||||
return (int) getData(MetaIndex.MINECART_BLOCK_Y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isViewBlockInCart()
|
public boolean isViewBlockInCart() {
|
||||||
{
|
return getData(MetaIndex.MINECART_BLOCK_VISIBLE);
|
||||||
return (boolean) getData(MetaIndex.MINECART_BLOCK_VISIBLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockInCart(ItemStack item)
|
public void setBlockInCart(ItemStack item) {
|
||||||
{
|
setData(MetaIndex.MINECART_BLOCK, ReflectionManager.getCombinedIdByItemStack(item));
|
||||||
int id = item.getTypeId();
|
setData(MetaIndex.MINECART_BLOCK_VISIBLE, item != null && item.getType() != Material.AIR);
|
||||||
int data = item.getDurability();
|
|
||||||
|
|
||||||
setData(MetaIndex.MINECART_BLOCK, id & 0xffff | data << 16);
|
sendData(MetaIndex.MINECART_BLOCK, MetaIndex.MINECART_BLOCK_VISIBLE);
|
||||||
setData(MetaIndex.MINECART_BLOCK_VISIBLE, true); // Show block
|
|
||||||
|
|
||||||
sendData(MetaIndex.MINECART_BLOCK);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockOffset(int i)
|
public void setBlockOffset(int i) {
|
||||||
{
|
|
||||||
setData(MetaIndex.MINECART_BLOCK_Y, i);
|
setData(MetaIndex.MINECART_BLOCK_Y, i);
|
||||||
sendData(MetaIndex.MINECART_BLOCK_Y);
|
sendData(MetaIndex.MINECART_BLOCK_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewBlockInCart(boolean viewBlock)
|
public void setViewBlockInCart(boolean viewBlock) {
|
||||||
{
|
|
||||||
setData(MetaIndex.MINECART_BLOCK_VISIBLE, viewBlock);
|
setData(MetaIndex.MINECART_BLOCK_VISIBLE, viewBlock);
|
||||||
sendData(MetaIndex.MINECART_BLOCK_VISIBLE);
|
sendData(MetaIndex.MINECART_BLOCK_VISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,11 @@ public class PigWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSaddled() {
|
public boolean isSaddled() {
|
||||||
return (boolean) getData(MetaIndex.PIG_SADDLED);
|
return getData(MetaIndex.PIG_SADDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSaddled(boolean isSaddled) {
|
public void setSaddled(boolean isSaddled) {
|
||||||
setData(MetaIndex.PIG_SADDLED, isSaddled);
|
setData(MetaIndex.PIG_SADDLED, isSaddled);
|
||||||
sendData(MetaIndex.PIG_SADDLED);
|
sendData(MetaIndex.PIG_SADDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public int getUnknown() {
|
|
||||||
return getData(FlagType.PIG_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnknown(int unknown) {
|
|
||||||
setData(FlagType.PIG_UNKNOWN, unknown);
|
|
||||||
sendData(FlagType.PIG_UNKNOWN);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TameableWatcher extends AgeableWatcher
|
public class TameableWatcher extends AgeableWatcher
|
||||||
{
|
{
|
||||||
public TameableWatcher(Disguise disguise)
|
public TameableWatcher(Disguise disguise)
|
||||||
|
@ -39,4 +39,12 @@ public class ZombieWatcher extends InsentientWatcher {
|
|||||||
sendData(MetaIndex.ZOMBIE_AGGRESSIVE);
|
sendData(MetaIndex.ZOMBIE_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConverting() {
|
||||||
|
return getData(MetaIndex.ZOMBIE_CONVERTING_DROWNED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConverting(boolean converting) {
|
||||||
|
setData(MetaIndex.ZOMBIE_CONVERTING_DROWNED, converting);
|
||||||
|
sendData(MetaIndex.ZOMBIE_CONVERTING_DROWNED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import me.libraryaddict.disguise.disguisetypes.*;
|
|||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
@ -22,6 +23,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class DisguiseParser {
|
public class DisguiseParser {
|
||||||
public static class DisguiseParseException extends Exception {
|
public static class DisguiseParseException extends Exception {
|
||||||
@ -110,13 +112,7 @@ public class DisguiseParser {
|
|||||||
if (disguiseType != other.disguiseType)
|
if (disguiseType != other.disguiseType)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (permName == null) {
|
return Objects.equals(permName, other.permName);
|
||||||
if (other.permName != null)
|
|
||||||
return false;
|
|
||||||
} else if (!permName.equals(other.permName))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -585,6 +581,7 @@ public class DisguiseParser {
|
|||||||
disguise = new MobDisguise(disguisePerm.getType(), adult);
|
disguise = new MobDisguise(disguisePerm.getType(), adult);
|
||||||
} else if (disguisePerm.isMisc()) {
|
} else if (disguisePerm.isMisc()) {
|
||||||
// Its a misc, we are going to use the MiscDisguise constructor.
|
// Its a misc, we are going to use the MiscDisguise constructor.
|
||||||
|
ItemStack itemStack = new ItemStack(Material.STONE);
|
||||||
int miscId = -1;
|
int miscId = -1;
|
||||||
int miscData = -1;
|
int miscData = -1;
|
||||||
String secondArg = null;
|
String secondArg = null;
|
||||||
@ -607,6 +604,7 @@ public class DisguiseParser {
|
|||||||
disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
||||||
for (Material mat : Material.values()) {
|
for (Material mat : Material.values()) {
|
||||||
if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
|
if (mat.name().replace("_", "").equalsIgnoreCase(args[1].replace("_", ""))) {
|
||||||
|
itemStack = new ItemStack(mat);
|
||||||
miscId = mat.getId();
|
miscId = mat.getId();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -681,11 +679,16 @@ public class DisguiseParser {
|
|||||||
doCheck(sender, optionPermissions, usedOptions);
|
doCheck(sender, optionPermissions, usedOptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct the disguise
|
// Construct the disguise
|
||||||
|
if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
||||||
|
disguise = new MiscDisguise(itemStack);
|
||||||
|
} else {
|
||||||
disguise = new MiscDisguise(disguisePerm.getType(), miscId, miscData);
|
disguise = new MiscDisguise(disguisePerm.getType(), miscId, miscData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Copy strings to their new range
|
// Copy strings to their new range
|
||||||
String[] newArgs = new String[args.length - toSkip];
|
String[] newArgs = new String[args.length - toSkip];
|
||||||
@ -888,6 +891,7 @@ public class DisguiseParser {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
@ -907,8 +911,26 @@ public class DisguiseParser {
|
|||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw parseToException(param, valueString, methodName);
|
throw parseToException(param, valueString, methodName);
|
||||||
}
|
}
|
||||||
} else if (param.getName().equals("org.bukkit.entity.Parrot$Variant")) {
|
} else if (param == Parrot.Variant.class) {
|
||||||
value = callValueOf(param, valueString, methodName);
|
value = callValueOf(param, valueString, methodName);
|
||||||
|
} else if (param == Particle.class) {
|
||||||
|
try {
|
||||||
|
for (Particle type : Particle.values()) {
|
||||||
|
if (type.name().replace("_", "")
|
||||||
|
.equalsIgnoreCase(valueString.replace("_", "").replace(" ", ""))) {
|
||||||
|
value = type;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value == null) {
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
throw parseToException(param, valueString, methodName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,21 +1001,13 @@ public class DisguiseParser {
|
|||||||
private static ItemStack parseToItemstack(Class param, String method, String string) throws DisguiseParseException {
|
private static ItemStack parseToItemstack(Class param, String method, String string) throws DisguiseParseException {
|
||||||
String[] split = string.split(":", -1);
|
String[] split = string.split(":", -1);
|
||||||
|
|
||||||
int itemId = -1;
|
|
||||||
|
|
||||||
if (split[0].isEmpty() || split[0].equalsIgnoreCase("null")) {
|
if (split[0].isEmpty() || split[0].equalsIgnoreCase("null")) {
|
||||||
return null;
|
return null;
|
||||||
} else if (isInteger(split[0])) {
|
|
||||||
itemId = Integer.parseInt(split[0]);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
itemId = Material.valueOf(split[0].toUpperCase()).getId();
|
|
||||||
}
|
|
||||||
catch (Exception ignored) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemId != -1) {
|
Material material = Material.getMaterial(split[0]);
|
||||||
|
|
||||||
|
if (material != null) {
|
||||||
short itemDura = 0;
|
short itemDura = 0;
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
boolean enchanted = false;
|
boolean enchanted = false;
|
||||||
@ -1018,7 +1032,7 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack itemStack = new ItemStack(itemId, amount, itemDura);
|
ItemStack itemStack = new ItemStack(material, amount, itemDura);
|
||||||
|
|
||||||
if (enchanted) {
|
if (enchanted) {
|
||||||
itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
|
itemStack.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
|
||||||
|
@ -23,8 +23,6 @@ import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
|||||||
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.utilities.PacketsManager.LibsPackets;
|
import me.libraryaddict.disguise.utilities.PacketsManager.LibsPackets;
|
||||||
import me.libraryaddict.disguise.utilities.backwards.BackwardMethods;
|
|
||||||
import me.libraryaddict.disguise.utilities.backwards.BackwardsSupport;
|
|
||||||
import me.libraryaddict.disguise.utilities.json.*;
|
import me.libraryaddict.disguise.utilities.json.*;
|
||||||
import org.apache.logging.log4j.util.Strings;
|
import org.apache.logging.log4j.util.Strings;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -50,10 +48,7 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.*;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@ -81,7 +76,6 @@ public class DisguiseUtilities {
|
|||||||
private static File profileCache = new File("plugins/LibsDisguises/GameProfiles"), savedDisguises = new File(
|
private static File profileCache = new File("plugins/LibsDisguises/GameProfiles"), savedDisguises = new File(
|
||||||
"plugins/LibsDisguises/SavedDisguises");
|
"plugins/LibsDisguises/SavedDisguises");
|
||||||
private static Gson gson;
|
private static Gson gson;
|
||||||
private static BackwardMethods methods;
|
|
||||||
private static boolean pluginsUsed, commandsUsed;
|
private static boolean pluginsUsed, commandsUsed;
|
||||||
private static long libsDisguisesCalled;
|
private static long libsDisguisesCalled;
|
||||||
|
|
||||||
@ -851,7 +845,6 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
public static void init(LibsDisguises disguises) {
|
public static void init(LibsDisguises disguises) {
|
||||||
libsDisguises = disguises;
|
libsDisguises = disguises;
|
||||||
methods = BackwardsSupport.getMethods();
|
|
||||||
|
|
||||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||||
gsonBuilder.registerTypeAdapter(MetaIndex.class, new SerializerMetaIndex());
|
gsonBuilder.registerTypeAdapter(MetaIndex.class, new SerializerMetaIndex());
|
||||||
@ -867,21 +860,43 @@ public class DisguiseUtilities {
|
|||||||
try {
|
try {
|
||||||
Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
Object server = ReflectionManager.getNmsMethod("MinecraftServer", "getServer").invoke(null);
|
||||||
Object world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
Object world = ((List) server.getClass().getField("worlds").get(server)).get(0);
|
||||||
|
Class chunkClass = ReflectionManager.getNmsClass("Chunk");
|
||||||
|
Object bedChunk = null;
|
||||||
|
|
||||||
Object bedChunk = ReflectionManager.getNmsClass("Chunk")
|
for (Constructor constructor : chunkClass.getConstructors()) {
|
||||||
.getConstructor(ReflectionManager.getNmsClass("World"), int.class, int.class)
|
if (constructor.getParameterTypes().length != 8)
|
||||||
.newInstance(world, 0, 0);
|
continue;
|
||||||
|
|
||||||
Field cSection = bedChunk.getClass().getDeclaredField("sections");
|
bedChunk = constructor
|
||||||
|
.newInstance(world, 0, 0, Array.newInstance(ReflectionManager.getNmsClass("BiomeBase"), 0),
|
||||||
|
null, null, null, 0L);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bedChunk == null) {
|
||||||
|
throw new IllegalStateException("[LibsDisguises] Cannot find constructor to create world chunk");
|
||||||
|
}
|
||||||
|
|
||||||
|
Field cSection = chunkClass.getDeclaredField("sections");
|
||||||
cSection.setAccessible(true);
|
cSection.setAccessible(true);
|
||||||
|
|
||||||
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
|
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
|
||||||
.newInstance(0, true);
|
.newInstance(0, true);
|
||||||
|
|
||||||
Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class)
|
Class blockClass = ReflectionManager.getNmsClass("Block");
|
||||||
.invoke(null, Material.BED_BLOCK.getId());
|
|
||||||
|
Object block = blockClass.getMethod("getByName", String.class).invoke(null, "white_bed");
|
||||||
|
Object blockData = ReflectionManager.getNmsMethod(blockClass, "getBlockData").invoke(block);
|
||||||
|
Method method = null;
|
||||||
|
|
||||||
|
for (Method method1 : blockData.getClass().getMethods()) {
|
||||||
|
if (!method1.getName().equals("set") || method1.getParameterTypes().length != 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
method = method1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Method fromLegacyData = block.getClass().getMethod("fromLegacyData", int.class);
|
|
||||||
Method setType = chunkSection.getClass()
|
Method setType = chunkSection.getClass()
|
||||||
.getMethod("setType", int.class, int.class, int.class, ReflectionManager.getNmsClass("IBlockData"));
|
.getMethod("setType", int.class, int.class, int.class, ReflectionManager.getNmsClass("IBlockData"));
|
||||||
Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
|
Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
|
||||||
@ -889,10 +904,12 @@ public class DisguiseUtilities {
|
|||||||
|
|
||||||
for (BlockFace face : new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}) {
|
for (BlockFace face : new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}) {
|
||||||
int x = 1 + face.getModX();
|
int x = 1 + face.getModX();
|
||||||
|
|
||||||
int z = 1 + face.getModZ();
|
int z = 1 + face.getModZ();
|
||||||
|
|
||||||
setType.invoke(chunkSection, x, 0, z, fromLegacyData.invoke(block, face.ordinal()));
|
Object data = method.invoke(blockData, block.getClass().getField("FACING").get(null),
|
||||||
|
ReflectionManager.getEnumDirection(face.ordinal()));
|
||||||
|
|
||||||
|
setType.invoke(chunkSection, x, 0, z, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16);
|
Object[] array = (Object[]) Array.newInstance(chunkSection.getClass(), 16);
|
||||||
@ -1018,9 +1035,7 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
catch (
|
catch (
|
||||||
|
|
||||||
Exception ex)
|
Exception ex) {
|
||||||
|
|
||||||
{
|
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class LibsPremium {
|
|||||||
public static void check(String version) {
|
public static void check(String version) {
|
||||||
thisPluginIsPaidFor = isPremium();
|
thisPluginIsPaidFor = isPremium();
|
||||||
|
|
||||||
if (!isPremium() && version.contains("SNAPSHOT")) {
|
if (!isPremium()) {
|
||||||
File[] files = new File("plugins/LibsDisguises/").listFiles();
|
File[] files = new File("plugins/LibsDisguises/").listFiles();
|
||||||
|
|
||||||
if (files == null)
|
if (files == null)
|
||||||
@ -58,7 +58,7 @@ public class LibsPremium {
|
|||||||
thisPluginIsPaidFor = (Boolean) m.invoke(null);
|
thisPluginIsPaidFor = (Boolean) m.invoke(null);
|
||||||
|
|
||||||
if (isPremium()) {
|
if (isPremium()) {
|
||||||
System.out.println("[LibsDisguises] Found a premium Lib's Disguises jar");
|
System.out.println("[LibsDisguises] Found a premium Lib's Disguises jar, premium enabled!");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -501,11 +501,8 @@ public class PacketsManager {
|
|||||||
if (watchableObject.getValue() == null)
|
if (watchableObject.getValue() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (Registry.get(watchableObject.getValue().getClass()) == null)
|
WrappedDataWatcherObject obj = ReflectionManager
|
||||||
continue;
|
.createDataWatcherObject(watchableObject.getIndex(), watchableObject.getValue());
|
||||||
|
|
||||||
WrappedDataWatcherObject obj = new WrappedDataWatcherObject(watchableObject.getIndex(),
|
|
||||||
Registry.get(watchableObject.getValue().getClass()));
|
|
||||||
|
|
||||||
newWatcher.setObject(obj, watchableObject.getValue());
|
newWatcher.setObject(obj, watchableObject.getValue());
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,12 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.TreeSpecies;
|
import org.bukkit.TreeSpecies;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Horse;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.entity.Ocelot;
|
|
||||||
import org.bukkit.entity.Villager;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.MainHand;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.util.EulerAngle;
|
import org.bukkit.util.EulerAngle;
|
||||||
|
|
||||||
@ -49,10 +49,6 @@ public class ReflectionFlagWatchers {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ParamInfo(String className, String name, String description) throws ClassNotFoundException {
|
|
||||||
this(Class.forName(className), name, description);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParamInfo(Class paramClass, Enum[] enums, String name, String description) {
|
public ParamInfo(Class paramClass, Enum[] enums, String name, String description) {
|
||||||
this(name, description);
|
this(name, description);
|
||||||
this.enums = new String[enums.length];
|
this.enums = new String[enums.length];
|
||||||
@ -143,14 +139,6 @@ public class ReflectionFlagWatchers {
|
|||||||
static {
|
static {
|
||||||
new ParamInfo(AnimalColor.class, "Animal Color", "View all the colors you can use for an animal color");
|
new ParamInfo(AnimalColor.class, "Animal Color", "View all the colors you can use for an animal color");
|
||||||
new ParamInfo(Art.class, "Art", "View all the paintings you can use for a painting disguise");
|
new ParamInfo(Art.class, "Art", "View all the paintings you can use for a painting disguise");
|
||||||
|
|
||||||
try {
|
|
||||||
new ParamInfo("org.bukkit.entity.Llama.Color", "Llama Color",
|
|
||||||
"View all the colors you can use for a llama color");
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
|
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
|
||||||
|
|
||||||
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
||||||
@ -162,21 +150,10 @@ public class ReflectionFlagWatchers {
|
|||||||
new ParamInfo(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
|
new ParamInfo(RabbitType.class, "Rabbit Type", "View the kinds of rabbits you can turn into");
|
||||||
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
|
new ParamInfo(TreeSpecies.class, "Tree Species", "View the different types of tree species");
|
||||||
new ParamInfo(EulerAngle.class, "Euler Angle (X,Y,Z)", "Set the X,Y,Z directions on an armorstand");
|
new ParamInfo(EulerAngle.class, "Euler Angle (X,Y,Z)", "Set the X,Y,Z directions on an armorstand");
|
||||||
|
new ParamInfo(MainHand.class, "Main Hand", "Set the main hand for an entity");
|
||||||
try {
|
new ParamInfo(Llama.Color.class, "Llama Color", "View all the colors you can use for a llama color");
|
||||||
new ParamInfo("org.bukkit.inventory.MainHand", "Main Hand", "Set the main hand for an entity");
|
new ParamInfo(Parrot.Variant.class, "Parrot Variant", "View the different colors a parrot can be");
|
||||||
new ParamInfo("org.bukkit.entity.Llama.Color", "Llama Color",
|
new ParamInfo(Particle.class, "Particle", "The different particles of Minecraft");
|
||||||
"View all the colors you can use for a llama color");
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
new ParamInfo("org.bukkit.entity.Parrot$Variant", "Parrot Variant",
|
|
||||||
"View the different colors a parrot can be");
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException ex) {// Dont handle
|
|
||||||
}
|
|
||||||
|
|
||||||
ArrayList<String> potionEnums = new ArrayList<>();
|
ArrayList<String> potionEnums = new ArrayList<>();
|
||||||
|
|
||||||
@ -229,8 +206,7 @@ public class ReflectionFlagWatchers {
|
|||||||
new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,");
|
new ParamInfo(int[].class, "number,number,number..", "Numbers separated by an ,");
|
||||||
|
|
||||||
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers separated by a ,");
|
new ParamInfo(BlockPosition.class, "Block Position (num,num,num)", "Three numbers separated by a ,");
|
||||||
new ParamInfo(WrappedGameProfile.class, "GameProfile",
|
new ParamInfo(WrappedGameProfile.class, "GameProfile", "Get the gameprofile here https://sessionserver.mojang" +
|
||||||
"Get the gameprofile here https://sessionserver.mojang" +
|
|
||||||
".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false");
|
".com/session/minecraft/profile/PLAYER_UUID_GOES_HERE?unsigned=false");
|
||||||
|
|
||||||
Collections.sort(paramList, new Comparator<ParamInfo>() {
|
Collections.sort(paramList, new Comparator<ParamInfo>() {
|
||||||
|
@ -5,11 +5,8 @@ import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtCompound;
|
|
||||||
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
@ -17,6 +14,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ReflectionManager {
|
public class ReflectionManager {
|
||||||
@ -780,7 +778,7 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object convertInvalidItem(Object value) {
|
public static Object convertInvalidMeta(Object value) {
|
||||||
if (value instanceof Optional) {
|
if (value instanceof Optional) {
|
||||||
Optional opt = (Optional) value;
|
Optional opt = (Optional) value;
|
||||||
|
|
||||||
@ -810,7 +808,7 @@ public class ReflectionManager {
|
|||||||
val = getNmsItem((ItemStack) val);
|
val = getNmsItem((ItemStack) val);
|
||||||
|
|
||||||
if (val == null)
|
if (val == null)
|
||||||
return Optional.absent();
|
return Optional.empty();
|
||||||
else
|
else
|
||||||
return Optional.of(val);
|
return Optional.of(val);
|
||||||
}
|
}
|
||||||
@ -844,32 +842,39 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
} else if (value instanceof ItemStack) {
|
} else if (value instanceof ItemStack) {
|
||||||
return getNmsItem((ItemStack) value);
|
return getNmsItem((ItemStack) value);
|
||||||
} else if (value instanceof Double)
|
} else if (value instanceof Double) {
|
||||||
return ((Double) value).floatValue();
|
return ((Double) value).floatValue();
|
||||||
else if (value instanceof NbtCompound)
|
} else if (value instanceof NbtWrapper) {
|
||||||
return ((NbtWrapper) value).getHandle();
|
return ((NbtWrapper) value).getHandle();
|
||||||
|
} else if (value instanceof Particle) {
|
||||||
|
return getParticleType((Particle) value);
|
||||||
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Object getParticleType(Particle particle) {
|
||||||
|
try {
|
||||||
|
return getCraftClass("CraftParticle").getMethod("toNMS", Particle.class).invoke(null, particle);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getMinecraftVersion() {
|
public static String getMinecraftVersion() {
|
||||||
String version = Bukkit.getVersion();
|
String version = Bukkit.getVersion();
|
||||||
version = version.substring(version.lastIndexOf(" ") + 1, version.length() - 1);
|
version = version.substring(version.lastIndexOf(" ") + 1, version.length() - 1);
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static WrappedDataWatcherObject createDataWatcherObject(int id, Object value) {
|
||||||
* This creates a DataWatcherItem usable with WrappedWatchableObject
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
* @param value
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static Object createDataWatcherItem(int id, Object value) {
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
value = convertInvalidItem(value);
|
value = convertInvalidMeta(value);
|
||||||
|
|
||||||
Serializer serializer;
|
Serializer serializer;
|
||||||
|
|
||||||
@ -880,7 +885,8 @@ public class ReflectionManager {
|
|||||||
getNmsClass("IBlockData").isInstance(opt.get()) ? getNmsClass("IBlockData") : opt.get().getClass() :
|
getNmsClass("IBlockData").isInstance(opt.get()) ? getNmsClass("IBlockData") : opt.get().getClass() :
|
||||||
UUID.class), true);
|
UUID.class), true);
|
||||||
} else {
|
} else {
|
||||||
serializer = Registry.get(value.getClass());
|
serializer = Registry.get(getNmsClass("ParticleParam").isInstance(value) ? getNmsClass("ParticleParam") :
|
||||||
|
value.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serializer == null) {
|
if (serializer == null) {
|
||||||
@ -894,12 +900,23 @@ public class ReflectionManager {
|
|||||||
"! Are you running " + "the latest " + "version of " + "ProtocolLib?");
|
"! Are you running " + "the latest " + "version of " + "ProtocolLib?");
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedDataWatcherObject watcherObject = new WrappedDataWatcherObject(id, serializer);
|
return new WrappedDataWatcherObject(id, serializer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This creates a DataWatcherItem usable with WrappedWatchableObject
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Object createDataWatcherItem(int id, Object value) {
|
||||||
|
WrappedDataWatcherObject watcherObject = createDataWatcherObject(id, value);
|
||||||
|
|
||||||
Constructor construct = getNmsConstructor("DataWatcher$Item", getNmsClass("DataWatcherObject"), Object.class);
|
Constructor construct = getNmsConstructor("DataWatcher$Item", getNmsClass("DataWatcherObject"), Object.class);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return construct.newInstance(watcherObject.getHandle(), value);
|
return construct.newInstance(watcherObject.getHandle(), convertInvalidMeta(value));
|
||||||
}
|
}
|
||||||
catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -908,6 +925,28 @@ public class ReflectionManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int getEntityType(Object nmsEntity) {
|
||||||
|
try {
|
||||||
|
Class classType = getNmsClass("EntityTypes");
|
||||||
|
|
||||||
|
for (Method m : getNmsClass("Entity").getMethods()) {
|
||||||
|
if (m.getReturnType() != classType) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object entityType = m.invoke(nmsEntity);
|
||||||
|
Object registry = classType.getField("REGISTRY").get(null);
|
||||||
|
|
||||||
|
return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static WrappedWatchableObject createWatchable(int index, Object obj) {
|
public static WrappedWatchableObject createWatchable(int index, Object obj) {
|
||||||
Object watcherItem = createDataWatcherItem(index, obj);
|
Object watcherItem = createDataWatcherItem(index, obj);
|
||||||
|
|
||||||
@ -921,11 +960,41 @@ public class ReflectionManager {
|
|||||||
return id + (data << 12);
|
return id + (data << 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutablePair<Integer, Integer> getFromCombinedId(int combinedId) {
|
public static int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||||
int j = combinedId & 4095;
|
try {
|
||||||
int k = combinedId >> 12 & 15;
|
Object nmsItem = getNmsItem(itemStack);
|
||||||
|
Object item = getNmsMethod("ItemStack", "getItem").invoke(nmsItem);
|
||||||
|
Class blockClass = getNmsClass("Block");
|
||||||
|
|
||||||
return new ImmutablePair<>(j, k);
|
Object nmsBlock = getNmsMethod(blockClass, "asBlock", getNmsClass("Item")).invoke(null, item);
|
||||||
|
|
||||||
|
return (int) getNmsMethod(blockClass, "getBlockData").invoke(nmsBlock);
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack getItemStackByCombinedId(int id) {
|
||||||
|
try {
|
||||||
|
Method idMethod = getNmsMethod("Block", "getByCombinedId", int.class);
|
||||||
|
Object iBlockData = idMethod.invoke(null, id);
|
||||||
|
Class iBlockClass = getNmsClass("IBlockData");
|
||||||
|
|
||||||
|
Method getBlock = getNmsMethod(iBlockClass, "getBlock");
|
||||||
|
Object block = getBlock.invoke(iBlockData);
|
||||||
|
|
||||||
|
Method getItem = getNmsMethod("Block", "t", iBlockClass);
|
||||||
|
|
||||||
|
return getBukkitItem(getItem.invoke(block, iBlockData));
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object getWorldServer(World w) {
|
public static Object getWorldServer(World w) {
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 8/06/2017.
|
|
||||||
*/
|
|
||||||
public class BackwardMethods {
|
|
||||||
|
|
||||||
public boolean isOrderedIndexes() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doReplaceSounds() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replace(String old, String newString) {
|
|
||||||
DisguiseSound.replace(old, newString);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|
||||||
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_10;
|
|
||||||
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_11;
|
|
||||||
import me.libraryaddict.disguise.utilities.backwards.metadata.Version_1_9;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 8/06/2017.
|
|
||||||
*/
|
|
||||||
public class BackwardsSupport {
|
|
||||||
public static BackwardMethods getMethods() {
|
|
||||||
try {
|
|
||||||
String version = ReflectionManager.getMinecraftVersion();
|
|
||||||
|
|
||||||
Class<? extends BackwardMethods> methods = BackwardMethods.class;
|
|
||||||
|
|
||||||
if (version.equals("1.9") || version.equals("1.9.1") || version.equals("1.9.2") || version
|
|
||||||
.equals("1.9.3") || version.equals("1.9.4")) {
|
|
||||||
methods = Version_1_9.class;
|
|
||||||
} else if (version.equals("1.10") || version.equals("1.10.1") || version.equals("1.10.2")) {
|
|
||||||
methods = Version_1_10.class;
|
|
||||||
} else if (version.equals("1.11") || version.equals("1.11.1") || version.equals("1.11.2")) {
|
|
||||||
methods = Version_1_11.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (methods != BackwardMethods.class) {
|
|
||||||
if (!LibsPremium.isPremium()) {
|
|
||||||
System.out.println("[LibsDisguises] You must purchase the plugin to use backwards compatibility!");
|
|
||||||
methods = BackwardMethods.class;
|
|
||||||
} else {
|
|
||||||
System.out.println("[LibsDisguises] Enabled backwards support for " + version);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return setupMetadata(methods);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void getIndexes(Class backwardsClass, BackwardMethods backwards,
|
|
||||||
HashMap<String, MetaIndex> newIndexes) throws IllegalAccessException {
|
|
||||||
for (Field field : backwardsClass.getDeclaredFields()) {
|
|
||||||
if (field.getType() != MetaIndex.class)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
field.setAccessible(true);
|
|
||||||
|
|
||||||
if (newIndexes.containsKey(field.getName()))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (MetaIndex.setMetaIndex(field.getName(), (MetaIndex) field.get(backwards))) {
|
|
||||||
newIndexes.put(field.getName(), MetaIndex.ENTITY_META);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
newIndexes.put(field.getName(), (MetaIndex) field.get(backwards));
|
|
||||||
}
|
|
||||||
|
|
||||||
backwardsClass = backwardsClass.getSuperclass();
|
|
||||||
|
|
||||||
if (backwardsClass.getSimpleName().contains("Version_"))
|
|
||||||
getIndexes(backwardsClass, backwards, newIndexes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static BackwardMethods setupMetadata(Class<? extends BackwardMethods> backwardsClass) {
|
|
||||||
try {
|
|
||||||
BackwardMethods backwards = backwardsClass.newInstance();
|
|
||||||
|
|
||||||
HashMap<String, MetaIndex> newIndexes = new HashMap<>();
|
|
||||||
|
|
||||||
getIndexes(backwardsClass, backwards, newIndexes);
|
|
||||||
|
|
||||||
MetaIndex.setValues();
|
|
||||||
|
|
||||||
HashSet<MetaIndex> indexes = new HashSet<>(newIndexes.values());
|
|
||||||
indexes.remove(MetaIndex.ENTITY_META); // We do the hashmap stuff to prevent multiple versions
|
|
||||||
// registering the same meta index
|
|
||||||
|
|
||||||
MetaIndex.addMetaIndexes(indexes.toArray(new MetaIndex[0]));
|
|
||||||
|
|
||||||
if (backwards.isOrderedIndexes()) {
|
|
||||||
MetaIndex.eliminateBlankIndexes();
|
|
||||||
MetaIndex.orderMetaIndexes();
|
|
||||||
}
|
|
||||||
|
|
||||||
backwards.doReplaceSounds();
|
|
||||||
|
|
||||||
return backwards;
|
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
|
||||||
|
|
||||||
import com.google.common.base.Optional;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 9/06/2017.
|
|
||||||
* <p>
|
|
||||||
* Supports 1.10.0 1.10.1 and 1.10.2
|
|
||||||
*/
|
|
||||||
public class Version_1_10 extends Version_1_11 {
|
|
||||||
private MetaIndex ILLAGER_META;
|
|
||||||
private MetaIndex ILLAGER_SPELL_TICKS;
|
|
||||||
private MetaIndex<Integer> HORSE_VARIANT = new MetaIndex<>(HorseWatcher.class, 1, 0);
|
|
||||||
private MetaIndex<Byte> SHULKER_COLOR;
|
|
||||||
private MetaIndex<Optional<ItemStack>> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0,
|
|
||||||
Optional.of(new ItemStack(Material.STONE)));
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
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_11 extends BackwardMethods {
|
|
||||||
private MetaIndex ILLAGER_META;
|
|
||||||
private MetaIndex PARROT_VARIANT;
|
|
||||||
private MetaIndex PLAYER_LEFT_SHOULDER_ENTITY;
|
|
||||||
private MetaIndex PLAYER_RIGHT_SHOULDER_ENTITY;
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 24/06/2017.
|
|
||||||
*/
|
|
||||||
public class Version_1_7 {
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 24/06/2017.
|
|
||||||
*/
|
|
||||||
public class Version_1_8 {
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.utilities.backwards.metadata;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 24/06/2017.
|
|
||||||
* <p>
|
|
||||||
* Intended for 1.9, 1.9.1, 1.9.2, 1.9.3, 1.9.4
|
|
||||||
*/
|
|
||||||
public class Version_1_9 extends Version_1_10 {
|
|
||||||
}
|
|
@ -1,19 +1,10 @@
|
|||||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
package me.libraryaddict.disguise.utilities.packetlisteners;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Arrow;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.ListenerPriority;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
@ -22,6 +13,10 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
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.DisguiseUtilities;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class PacketListenerClientInteract extends PacketAdapter {
|
public class PacketListenerClientInteract extends PacketAdapter {
|
||||||
public PacketListenerClientInteract(LibsDisguises plugin) {
|
public PacketListenerClientInteract(LibsDisguises plugin) {
|
||||||
@ -43,19 +38,20 @@ public class PacketListenerClientInteract extends PacketAdapter {
|
|||||||
|
|
||||||
Entity entity = entityModifer.read(0);
|
Entity entity = entityModifer.read(0);
|
||||||
|
|
||||||
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow || entity == observer) {
|
if (entity instanceof ExperienceOrb || entity instanceof Item || entity instanceof Arrow ||
|
||||||
|
entity == observer) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (ItemStack item : new ItemStack[]{observer.getInventory().getItemInMainHand(),
|
for (ItemStack item : new ItemStack[]{observer.getInventory().getItemInMainHand(),
|
||||||
observer.getInventory().getItemInOffHand()}) {
|
observer.getInventory().getItemInOffHand()}) {
|
||||||
if (item == null || item.getType() != Material.INK_SACK)
|
if (item == null || item.getType() != Material.INK_SAC)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
|
|
||||||
if (disguise == null || (disguise.getType() != DisguiseType.SHEEP && disguise
|
if (disguise == null ||
|
||||||
.getType() != DisguiseType.WOLF))
|
(disguise.getType() != DisguiseType.SHEEP && disguise.getType() != DisguiseType.WOLF))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
AnimalColor color = AnimalColor.getColor(item.getDurability());
|
AnimalColor color = AnimalColor.getColor(item.getDurability());
|
||||||
|
@ -17,6 +17,7 @@ import me.libraryaddict.disguise.utilities.DisguiseSound.SoundType;
|
|||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@ -153,14 +154,14 @@ public class PacketListenerSounds extends PacketAdapter {
|
|||||||
} else {
|
} else {
|
||||||
if (sound.equals("step.grass")) {
|
if (sound.equals("step.grass")) {
|
||||||
try {
|
try {
|
||||||
int typeId = observer.getWorld().getBlockTypeIdAt((int) Math.floor(soundCords[0] / 8D),
|
Block block = observer.getWorld().getBlockAt((int) Math.floor(soundCords[0] / 8D),
|
||||||
(int) Math.floor(soundCords[1] / 8D), (int) Math.floor(soundCords[2] / 8D));
|
(int) Math.floor(soundCords[1] / 8D), (int) Math.floor(soundCords[2] / 8D));
|
||||||
|
|
||||||
Object block = ReflectionManager.getNmsMethod("RegistryMaterials", "getId", int.class)
|
|
||||||
.invoke(ReflectionManager.getNmsField("Block", "REGISTRY").get(null), typeId);
|
|
||||||
|
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
Object nmsBlock = ReflectionManager.getCraftMethod("block.CraftBlock", "getNMSBlock")
|
||||||
|
.invoke(block);
|
||||||
|
|
||||||
|
Object step = ReflectionManager.getNmsMethod("Block", "getStepSound").invoke(nmsBlock);
|
||||||
|
|
||||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "d").invoke(step));
|
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "d").invoke(step));
|
||||||
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
|
mods.write(1, ReflectionManager.getSoundCategory(disguise.getType()));
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package org.bukkit.inventory;
|
|
||||||
|
|
||||||
public enum EquipmentSlot {
|
|
||||||
HAND,
|
|
||||||
OFF_HAND,
|
|
||||||
FEET,
|
|
||||||
LEGS,
|
|
||||||
CHEST,
|
|
||||||
HEAD
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package org.bukkit.inventory;
|
|
||||||
|
|
||||||
public enum MainHand {
|
|
||||||
LEFT,
|
|
||||||
RIGHT
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user