Fixed being unable to cast watchers, maybe fixed unconfirmed issue with babys..

This commit is contained in:
Andrew 2013-10-01 23:51:21 +13:00
parent 628c3544d9
commit 9b9829073c

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise; package me.libraryaddict.disguise;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.List; import java.util.List;
@ -22,13 +23,13 @@ import net.minecraft.server.v1_6_R3.WatchableObject;
import net.minecraft.server.v1_6_R3.World; import net.minecraft.server.v1_6_R3.World;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.v1_6_R3.CraftWorld; import org.bukkit.craftbukkit.v1_6_R3.CraftWorld;
import org.bukkit.entity.Ageable; import org.bukkit.entity.Ageable;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public class LibsDisguises extends JavaPlugin { public class LibsDisguises extends JavaPlugin {
private class DisguiseHuman extends EntityHuman { private class DisguiseHuman extends EntityHuman {
@ -52,23 +53,33 @@ public class LibsDisguises extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
saveDefaultConfig(); saveDefaultConfig();
YamlConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); FileConfiguration config = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml"));
if (!config.contains("DisguiseRadiusMax")) try {
config.set("DisguiseRadiusMax", getConfig().getInt("DisguiseRadiusMax")); for (String option : YamlConfiguration
if (!config.contains("UndisguiseRadiusMax")) .loadConfiguration(this.getClassLoader().getResource("config.yml").openStream()).getKeys(false)) {
config.set("UndisguiseRadiusMax", getConfig().getInt("UndisguiseRadiusMax")); if (!config.contains(option)) {
if (!config.contains("DisguiseSounds")) config.set(option, getConfig().get(option));
config.set("DisguiseSounds", getConfig().getBoolean("DisguiseSounds")); }
if (!config.contains("HearSelfDisguise")) }
config.set("HearSelfDisguise", getConfig().getBoolean("HearSelfDisguise")); } catch (IOException e) {
if (!config.contains("SendVelocity")) e.printStackTrace();
config.set("SendVelocity", getConfig().getBoolean("SendVelocity")); }
try {
config.save(new File(getDataFolder(), "config.yml"));
} catch (IOException e) {
e.printStackTrace();
}
PacketsManager.init(this); PacketsManager.init(this);
DisguiseAPI.init(this); DisguiseAPI.init(this);
DisguiseAPI.setSoundsEnabled(getConfig().getBoolean("DisguiseSounds")); DisguiseAPI.setSoundsEnabled(getConfig().getBoolean("DisguiseSounds"));
DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity")); DisguiseAPI.setVelocitySent(getConfig().getBoolean("SendVelocity"));
DisguiseAPI.setViewDisguises(getConfig().getBoolean("ViewDisguises")); DisguiseAPI.setViewDisguises(getConfig().getBoolean("ViewDisguises"));
DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise")); DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise"));
DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
DisguiseAPI.setInventoryListenerEnabled(true);
}
try { try {
// Here I use reflection to set the plugin for Disguise.. // Here I use reflection to set the plugin for Disguise..
// Kinda stupid but I don't want open API calls. // Kinda stupid but I don't want open API calls.
@ -123,7 +134,7 @@ public class LibsDisguises extends JavaPlugin {
name = toReadable(disguiseType.name()); name = toReadable(disguiseType.name());
break; break;
} }
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.Watchers." + name + "Watcher"); watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers." + name + "Watcher");
} catch (Exception ex) { } catch (Exception ex) {
// There is no watcher for this entity, or a error was thrown. // There is no watcher for this entity, or a error was thrown.
try { try {