2013-05-17 23:05:19 +02:00
|
|
|
package me.libraryaddict.disguise;
|
|
|
|
|
2014-05-30 19:29:40 +02:00
|
|
|
import java.io.BufferedReader;
|
2013-08-05 14:04:01 +02:00
|
|
|
import java.io.File;
|
2014-05-30 19:29:40 +02:00
|
|
|
import java.io.FileReader;
|
|
|
|
import java.io.FileWriter;
|
2013-10-01 12:51:21 +02:00
|
|
|
import java.io.IOException;
|
2014-04-04 16:44:35 +02:00
|
|
|
import java.io.InputStream;
|
2014-05-30 19:29:40 +02:00
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.Reader;
|
2013-07-29 01:21:25 +02:00
|
|
|
import java.lang.reflect.Field;
|
2014-01-21 02:05:32 +01:00
|
|
|
|
2013-09-25 16:49:24 +02:00
|
|
|
import me.libraryaddict.disguise.commands.*;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
2013-11-22 20:22:06 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
2013-09-25 16:49:24 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
2013-11-22 20:22:06 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
2014-05-23 06:40:22 +02:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
2013-11-22 20:22:06 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
2013-11-22 21:10:20 +01:00
|
|
|
import me.libraryaddict.disguise.utilities.DisguiseSound;
|
|
|
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|
|
|
import me.libraryaddict.disguise.utilities.PacketsManager;
|
|
|
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|
|
|
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
2013-05-29 16:25:00 +02:00
|
|
|
|
|
|
|
import org.bukkit.Bukkit;
|
2014-01-21 02:05:32 +01:00
|
|
|
import org.bukkit.ChatColor;
|
2013-07-28 01:00:29 +02:00
|
|
|
import org.bukkit.entity.Ageable;
|
2014-05-23 04:52:21 +02:00
|
|
|
import org.bukkit.entity.Damageable;
|
2013-11-18 04:24:25 +01:00
|
|
|
import org.bukkit.entity.Entity;
|
2013-07-28 01:00:29 +02:00
|
|
|
import org.bukkit.entity.LivingEntity;
|
2014-05-23 06:40:22 +02:00
|
|
|
import org.bukkit.entity.Tameable;
|
2013-12-22 00:36:06 +01:00
|
|
|
import org.bukkit.entity.Zombie;
|
2013-05-17 23:05:19 +02:00
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
2013-11-18 04:24:25 +01:00
|
|
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
|
|
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
2013-07-11 20:38:07 +02:00
|
|
|
|
2013-11-18 04:24:25 +01:00
|
|
|
public class LibsDisguises extends JavaPlugin {
|
2013-07-11 20:38:07 +02:00
|
|
|
|
2013-07-21 05:14:59 +02:00
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
2013-07-31 07:46:24 +02:00
|
|
|
saveDefaultConfig();
|
2014-05-30 19:29:40 +02:00
|
|
|
File configFile = new File(getDataFolder(), "config.yml");
|
2014-04-04 16:47:33 +02:00
|
|
|
InputStream stream = null;
|
2014-05-30 19:29:40 +02:00
|
|
|
FileReader reader = null;
|
|
|
|
String toWrite = "";
|
|
|
|
String toRead = "";
|
2013-10-01 12:51:21 +02:00
|
|
|
try {
|
2014-04-04 16:47:33 +02:00
|
|
|
stream = getClassLoader().getResource("config.yml").openStream();
|
2014-05-30 19:29:40 +02:00
|
|
|
toWrite = read(new InputStreamReader(stream));
|
|
|
|
reader = new FileReader(configFile);
|
|
|
|
toRead = read(reader);
|
|
|
|
|
|
|
|
if (!toRead.equals(toWrite)) {
|
|
|
|
try {
|
|
|
|
FileWriter writer = new FileWriter(configFile);
|
|
|
|
try {
|
|
|
|
writer.write(toWrite);
|
|
|
|
} finally {
|
|
|
|
writer.close();
|
2014-05-22 22:00:10 +02:00
|
|
|
}
|
2014-05-30 19:29:40 +02:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
2013-10-01 12:51:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
2014-04-04 16:47:33 +02:00
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
if (stream != null) {
|
|
|
|
stream.close();
|
|
|
|
}
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2013-11-05 18:05:10 +01:00
|
|
|
try {
|
2014-05-30 19:29:40 +02:00
|
|
|
if (reader != null) {
|
|
|
|
reader.close();
|
|
|
|
}
|
2013-11-05 18:05:10 +01:00
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2013-10-01 12:51:21 +02:00
|
|
|
}
|
2014-05-30 19:29:40 +02:00
|
|
|
|
2013-08-13 05:19:50 +02:00
|
|
|
PacketsManager.init(this);
|
2013-11-22 21:04:31 +01:00
|
|
|
DisguiseUtilities.init(this);
|
2014-01-20 18:01:49 +01:00
|
|
|
DisguiseConfig.setSoundsEnabled(getConfig().getBoolean("DisguiseSounds"));
|
|
|
|
DisguiseConfig.setVelocitySent(getConfig().getBoolean("SendVelocity"));
|
|
|
|
DisguiseConfig.setViewDisguises(getConfig().getBoolean("ViewSelfDisguises"));
|
|
|
|
DisguiseConfig.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise"));
|
|
|
|
DisguiseConfig.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
|
|
|
|
DisguiseConfig.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
|
|
|
|
DisguiseConfig.setAddEntityAnimations(getConfig().getBoolean("AddEntityAnimations"));
|
|
|
|
DisguiseConfig.setNameOfPlayerShownAboveDisguise(getConfig().getBoolean("ShowNamesAboveDisguises"));
|
|
|
|
DisguiseConfig.setNameAboveHeadAlwaysVisible(getConfig().getBoolean("NameAboveHeadAlwaysVisible"));
|
|
|
|
DisguiseConfig.setModifyBoundingBox(getConfig().getBoolean("ModifyBoundingBox"));
|
|
|
|
DisguiseConfig.setMonstersIgnoreDisguises(getConfig().getBoolean("MonstersIgnoreDisguises"));
|
|
|
|
DisguiseConfig.setDisguiseBlownOnAttack(getConfig().getBoolean("BlowDisguises"));
|
2014-01-21 02:05:32 +01:00
|
|
|
DisguiseConfig.setDisguiseBlownMessage(ChatColor.translateAlternateColorCodes('&',
|
|
|
|
getConfig().getString("BlownDisguiseMessage")));
|
2014-04-02 15:39:52 +02:00
|
|
|
DisguiseConfig.setKeepDisguiseOnPlayerDeath(getConfig().getBoolean("KeepDisguises.PlayerDeath"));
|
|
|
|
DisguiseConfig.setKeepDisguiseOnPlayerLogout(getConfig().getBoolean("KeepDisguises.PlayerLogout"));
|
|
|
|
DisguiseConfig.setKeepDisguiseOnEntityDespawn(getConfig().getBoolean("KeepDisguises.EntityDespawn"));
|
2014-05-22 22:14:46 +02:00
|
|
|
DisguiseConfig.setMiscDisguisesForLivingEnabled(getConfig().getBoolean("MiscDisguisesForLiving"));
|
|
|
|
DisguiseConfig.setMovementPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Movement"));
|
|
|
|
DisguiseConfig.setWitherSkullPacketsEnabled(getConfig().getBoolean("PacketsEnabled.WitherSkull"));
|
|
|
|
DisguiseConfig.setEnquipmentPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Enquipment"));
|
|
|
|
DisguiseConfig.setAnimationPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Animation"));
|
|
|
|
DisguiseConfig.setBedPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Bed"));
|
|
|
|
DisguiseConfig.setRidingPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Riding"));
|
|
|
|
DisguiseConfig.setEntityStatusPacketsEnabled(getConfig().getBoolean("PacketsEnabled.EntityStatus"));
|
|
|
|
DisguiseConfig.setCollectPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Collect"));
|
2014-05-23 03:58:21 +02:00
|
|
|
DisguiseConfig.setMetadataPacketsEnabled(getConfig().getBoolean("PacketsEnabled.Metadata"));
|
2014-05-23 04:52:21 +02:00
|
|
|
DisguiseConfig.setMaxHealthDeterminedByDisguisedEntity(getConfig().getBoolean("MaxHealthDeterminedByEntity"));
|
2013-07-29 01:21:25 +02:00
|
|
|
try {
|
|
|
|
// Here I use reflection to set the plugin for Disguise..
|
2013-11-22 21:04:31 +01:00
|
|
|
// Kind of stupid but I don't want open API calls for a commonly used object.
|
2013-07-29 01:21:25 +02:00
|
|
|
Field field = Disguise.class.getDeclaredField("plugin");
|
|
|
|
field.setAccessible(true);
|
|
|
|
field.set(null, this);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
2014-05-22 22:14:46 +02:00
|
|
|
PacketsManager.addPacketListeners();
|
2013-07-16 07:23:11 +02:00
|
|
|
DisguiseListener listener = new DisguiseListener(this);
|
|
|
|
Bukkit.getPluginManager().registerEvents(listener, this);
|
2013-05-21 04:23:58 +02:00
|
|
|
getCommand("disguise").setExecutor(new DisguiseCommand());
|
|
|
|
getCommand("undisguise").setExecutor(new UndisguiseCommand());
|
2013-05-29 00:44:55 +02:00
|
|
|
getCommand("disguiseplayer").setExecutor(new DisguisePlayerCommand());
|
|
|
|
getCommand("undisguiseplayer").setExecutor(new UndisguisePlayerCommand());
|
2013-07-16 07:23:11 +02:00
|
|
|
getCommand("undisguiseentity").setExecutor(new UndisguiseEntityCommand(listener));
|
|
|
|
getCommand("disguiseentity").setExecutor(new DisguiseEntityCommand(listener));
|
2013-07-16 08:53:39 +02:00
|
|
|
getCommand("disguiseradius").setExecutor(new DisguiseRadiusCommand(getConfig().getInt("DisguiseRadiusMax")));
|
|
|
|
getCommand("undisguiseradius").setExecutor(new UndisguiseRadiusCommand(getConfig().getInt("UndisguiseRadiusMax")));
|
2013-11-05 16:16:46 +01:00
|
|
|
getCommand("disguisehelp").setExecutor(new DisguiseHelpCommand());
|
2014-04-06 14:15:47 +02:00
|
|
|
getCommand("libsdisguises").setExecutor(new LibsDisguisesCommand());
|
2013-07-11 20:38:07 +02:00
|
|
|
registerValues();
|
|
|
|
}
|
|
|
|
|
2014-05-30 19:29:40 +02:00
|
|
|
private String read(Reader reader) {
|
|
|
|
String toWrite = "";
|
|
|
|
try {
|
|
|
|
BufferedReader input = new BufferedReader(reader);
|
|
|
|
String currentPath = "";
|
|
|
|
try {
|
|
|
|
String line;
|
|
|
|
|
|
|
|
while ((line = input.readLine()) != null) {
|
|
|
|
if (line.replace(" ", "").startsWith("#")) {
|
|
|
|
toWrite += line;
|
|
|
|
} else if (line.contains(":")) {
|
|
|
|
if (line.substring(line.indexOf(":") + 1).equals("")) {
|
|
|
|
currentPath = line.substring(0, line.length() - 1) + ".";
|
|
|
|
toWrite += line;
|
|
|
|
} else {
|
|
|
|
if (!line.startsWith(" ")) {
|
|
|
|
currentPath = "";
|
|
|
|
}
|
|
|
|
String obj = line.substring(0, line.indexOf(":")).replace(" ", "");
|
|
|
|
Object value = getConfig().get(currentPath + obj);
|
|
|
|
if (value instanceof String) {
|
|
|
|
value = "'" + value + "'";
|
|
|
|
}
|
|
|
|
toWrite += (currentPath.length() == 0 ? "" : " ") + obj + ": " + value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (input.ready()) {
|
|
|
|
toWrite += "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
input.close();
|
|
|
|
}
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
} finally {
|
|
|
|
try {
|
|
|
|
reader.close();
|
|
|
|
} catch (IOException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return toWrite;
|
|
|
|
}
|
|
|
|
|
2013-11-22 21:04:31 +01:00
|
|
|
/**
|
|
|
|
* Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume
|
|
|
|
* for mob noises. As well as setting their watcher class and entity size.
|
|
|
|
*/
|
2013-07-11 20:38:07 +02:00
|
|
|
private void registerValues() {
|
|
|
|
for (DisguiseType disguiseType : DisguiseType.values()) {
|
2013-07-28 01:00:29 +02:00
|
|
|
Class watcherClass = null;
|
|
|
|
try {
|
|
|
|
switch (disguiseType) {
|
|
|
|
case MINECART_FURNACE:
|
|
|
|
case MINECART_HOPPER:
|
|
|
|
case MINECART_MOB_SPAWNER:
|
|
|
|
case MINECART_TNT:
|
|
|
|
case MINECART_CHEST:
|
2013-11-22 20:22:06 +01:00
|
|
|
watcherClass = MinecartWatcher.class;
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case DONKEY:
|
|
|
|
case MULE:
|
|
|
|
case UNDEAD_HORSE:
|
|
|
|
case SKELETON_HORSE:
|
2013-11-22 20:22:06 +01:00
|
|
|
watcherClass = HorseWatcher.class;
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case ZOMBIE_VILLAGER:
|
|
|
|
case PIG_ZOMBIE:
|
2013-11-22 20:22:06 +01:00
|
|
|
watcherClass = ZombieWatcher.class;
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case MAGMA_CUBE:
|
2013-11-22 20:22:06 +01:00
|
|
|
watcherClass = SlimeWatcher.class;
|
2013-08-05 14:08:53 +02:00
|
|
|
break;
|
2013-07-28 01:00:29 +02:00
|
|
|
default:
|
2013-11-22 20:22:06 +01:00
|
|
|
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
|
|
|
|
+ toReadable(disguiseType.name()) + "Watcher");
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
}
|
2013-11-22 20:22:06 +01:00
|
|
|
} catch (ClassNotFoundException ex) {
|
2013-11-22 20:52:15 +01:00
|
|
|
// There is no explicit watcher for this entity.
|
|
|
|
Class entityClass = disguiseType.getEntityType().getEntityClass();
|
2014-05-23 06:40:22 +02:00
|
|
|
if (Tameable.class.isAssignableFrom(entityClass)) {
|
|
|
|
watcherClass = TameableWatcher.class;
|
|
|
|
} else if (Ageable.class.isAssignableFrom(entityClass)) {
|
2013-11-22 15:15:07 +01:00
|
|
|
watcherClass = AgeableWatcher.class;
|
2013-11-22 20:52:15 +01:00
|
|
|
} else if (LivingEntity.class.isAssignableFrom(entityClass)) {
|
2013-11-22 15:15:07 +01:00
|
|
|
watcherClass = LivingWatcher.class;
|
|
|
|
} else {
|
|
|
|
watcherClass = FlagWatcher.class;
|
2013-07-28 01:00:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
disguiseType.setWatcherClass(watcherClass);
|
2013-11-22 21:04:31 +01:00
|
|
|
String nmsEntityName = toReadable(disguiseType.name());
|
2013-07-28 01:00:29 +02:00
|
|
|
switch (disguiseType) {
|
|
|
|
case WITHER_SKELETON:
|
|
|
|
case ZOMBIE_VILLAGER:
|
|
|
|
case DONKEY:
|
|
|
|
case MULE:
|
|
|
|
case UNDEAD_HORSE:
|
|
|
|
case SKELETON_HORSE:
|
2013-08-05 14:21:47 +02:00
|
|
|
continue;
|
2013-07-28 01:00:29 +02:00
|
|
|
case PRIMED_TNT:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "TNTPrimed";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case MINECART_TNT:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "MinecartTNT";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case MINECART:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "MinecartRideable";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case FIREWORK:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "Fireworks";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case SPLASH_POTION:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "Potion";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case GIANT:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "GiantZombie";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case DROPPED_ITEM:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "Item";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
|
|
|
case FIREBALL:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "LargeFireball";
|
2013-07-28 01:00:29 +02:00
|
|
|
break;
|
2013-11-07 21:29:32 +01:00
|
|
|
case LEASH_HITCH:
|
2013-11-22 21:04:31 +01:00
|
|
|
nmsEntityName = "Leash";
|
2013-11-07 21:29:32 +01:00
|
|
|
break;
|
2013-07-28 01:00:29 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-11-27 04:38:51 +01:00
|
|
|
if (DisguiseValues.getDisguiseValues(disguiseType) != null) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-07-11 20:38:07 +02:00
|
|
|
try {
|
2013-11-22 21:04:31 +01:00
|
|
|
Object nmsEntity = ReflectionManager.createEntityInstance(nmsEntityName);
|
2013-11-27 04:54:38 +01:00
|
|
|
if (nmsEntity == null) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-11-27 04:38:51 +01:00
|
|
|
Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);
|
2013-11-22 21:04:31 +01:00
|
|
|
int entitySize = 0;
|
2013-11-18 04:24:25 +01:00
|
|
|
for (Field field : ReflectionManager.getNmsClass("Entity").getFields()) {
|
|
|
|
if (field.getType().getName().equals("EnumEntitySize")) {
|
2013-11-22 21:04:31 +01:00
|
|
|
Enum enumEntitySize = (Enum) field.get(nmsEntity);
|
|
|
|
entitySize = enumEntitySize.ordinal();
|
2013-11-18 04:24:25 +01:00
|
|
|
break;
|
|
|
|
}
|
2013-07-11 20:38:07 +02:00
|
|
|
}
|
2014-05-23 04:52:21 +02:00
|
|
|
DisguiseValues disguiseValues = new DisguiseValues(disguiseType, nmsEntity.getClass(), entitySize,
|
|
|
|
bukkitEntity instanceof Damageable ? ((Damageable) bukkitEntity).getMaxHealth() : 0);
|
2013-12-14 05:01:25 +01:00
|
|
|
for (WrappedWatchableObject watch : WrappedDataWatcher.getEntityWatcher(bukkitEntity).getWatchableObjects()) {
|
2013-11-22 20:52:15 +01:00
|
|
|
disguiseValues.setMetaValue(watch.getIndex(), watch.getValue());
|
2013-12-14 05:01:25 +01:00
|
|
|
// Uncomment when I need to find the new datawatcher values for a class..
|
2013-12-16 20:11:30 +01:00
|
|
|
|
2013-12-14 05:01:25 +01:00
|
|
|
// System.out.print("Disguise: " + disguiseType + ", ID: " + watch.getIndex() + ", Class: "
|
2014-04-26 05:42:35 +02:00
|
|
|
// + (watch.getValue() == null ? "null" : watch.getValue().getClass()) + ", Value: " + watch.getValue());
|
2013-12-14 05:01:25 +01:00
|
|
|
}
|
2013-07-22 15:32:05 +02:00
|
|
|
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
|
|
|
if (sound != null) {
|
2013-11-22 21:04:31 +01:00
|
|
|
Float soundStrength = ReflectionManager.getSoundModifier(nmsEntity);
|
2013-11-18 04:24:25 +01:00
|
|
|
if (soundStrength != null) {
|
2014-01-18 20:39:23 +01:00
|
|
|
sound.setDamageAndIdleSoundVolume((Float) soundStrength);
|
2013-11-18 04:24:25 +01:00
|
|
|
}
|
2013-07-22 15:32:05 +02:00
|
|
|
}
|
2013-12-22 00:36:06 +01:00
|
|
|
|
|
|
|
// Get the bounding box
|
|
|
|
disguiseValues.setAdultBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
|
|
|
if (bukkitEntity instanceof Ageable) {
|
|
|
|
((Ageable) bukkitEntity).setBaby();
|
|
|
|
disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
|
|
|
} else if (bukkitEntity instanceof Zombie) {
|
|
|
|
((Zombie) bukkitEntity).setBaby(true);
|
|
|
|
disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
|
|
|
}
|
2013-12-22 05:35:57 +01:00
|
|
|
disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
|
2013-11-18 13:30:39 +01:00
|
|
|
} catch (Exception ex) {
|
2013-12-16 20:11:30 +01:00
|
|
|
System.out.print("[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name()
|
|
|
|
+ "!");
|
|
|
|
System.out.print("[LibsDisguises] Before reporting this error, "
|
|
|
|
+ "please make sure you are using the latest version of LibsDisguises and ProtocolLib");
|
|
|
|
System.out
|
2013-12-17 10:23:57 +01:00
|
|
|
.print("[LibsDisguises] You can try the latest builds at (ProtocolLib) "
|
2013-12-16 20:11:30 +01:00
|
|
|
+ "http://assets.comphenix.net/job/ProtocolLib/ and (LibsDisguises) http://ci.md-5.net/job/LibsDisguises/");
|
2013-11-18 13:30:39 +01:00
|
|
|
ex.printStackTrace();
|
2013-07-11 20:38:07 +02:00
|
|
|
}
|
|
|
|
}
|
2013-05-31 10:55:55 +02:00
|
|
|
}
|
|
|
|
|
2013-07-11 20:38:38 +02:00
|
|
|
private String toReadable(String string) {
|
2013-07-28 01:00:29 +02:00
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
for (String s : string.split("_")) {
|
|
|
|
builder.append(s.substring(0, 1) + s.substring(1).toLowerCase());
|
|
|
|
}
|
|
|
|
return builder.toString();
|
2013-05-17 23:05:19 +02:00
|
|
|
}
|
2013-08-01 10:29:04 +02:00
|
|
|
|
2013-11-14 06:36:53 +01:00
|
|
|
}
|