Fetch the watcher that it will use. And stop using empty watchers
This commit is contained in:
parent
593f3f492b
commit
cd44c50f2e
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class ChickenWatcher extends AgeableWatcher {
|
|
||||||
|
|
||||||
public ChickenWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class CowWatcher extends AgeableWatcher {
|
|
||||||
|
|
||||||
public CowWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class EnderDragonWatcher extends LivingWatcher {
|
|
||||||
|
|
||||||
public EnderDragonWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class MagmaCubeWatcher extends SlimeWatcher {
|
|
||||||
|
|
||||||
public MagmaCubeWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class MushroomCowWatcher extends AgeableWatcher {
|
|
||||||
|
|
||||||
public MushroomCowWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class PigZombieWatcher extends ZombieWatcher {
|
|
||||||
|
|
||||||
public PigZombieWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class SkeletonWatcher extends LivingWatcher {
|
|
||||||
|
|
||||||
public SkeletonWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.DisguiseTypes.Watchers;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
|
||||||
|
|
||||||
public class WitherWatcher extends EnderDragonWatcher {
|
|
||||||
|
|
||||||
public WitherWatcher(Disguise disguise) {
|
|
||||||
super(disguise);
|
|
||||||
}
|
|
||||||
}
|
|
@ -11,8 +11,11 @@ import me.libraryaddict.disguise.Commands.*;
|
|||||||
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
import me.libraryaddict.disguise.DisguiseTypes.Disguise;
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.DisguiseSound;
|
import me.libraryaddict.disguise.DisguiseTypes.DisguiseSound;
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.DisguiseType;
|
import me.libraryaddict.disguise.DisguiseTypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.PlayerDisguise;
|
import me.libraryaddict.disguise.DisguiseTypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.DisguiseTypes.Values;
|
import me.libraryaddict.disguise.DisguiseTypes.Values;
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.Watchers.AgeableWatcher;
|
||||||
|
import me.libraryaddict.disguise.DisguiseTypes.Watchers.LivingWatcher;
|
||||||
import net.minecraft.server.v1_6_R2.AttributeSnapshot;
|
import net.minecraft.server.v1_6_R2.AttributeSnapshot;
|
||||||
import net.minecraft.server.v1_6_R2.ChatMessage;
|
import net.minecraft.server.v1_6_R2.ChatMessage;
|
||||||
import net.minecraft.server.v1_6_R2.ChunkCoordinates;
|
import net.minecraft.server.v1_6_R2.ChunkCoordinates;
|
||||||
@ -24,10 +27,12 @@ import net.minecraft.server.v1_6_R2.World;
|
|||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_6_R2.CraftWorld;
|
||||||
|
import org.bukkit.entity.Ageable;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import com.comphenix.protocol.Packets;
|
import com.comphenix.protocol.Packets;
|
||||||
@ -236,35 +241,89 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
private void registerValues() {
|
private void registerValues() {
|
||||||
World world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
World world = ((CraftWorld) Bukkit.getWorlds().get(0)).getHandle();
|
||||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||||
|
Class watcherClass = null;
|
||||||
|
try {
|
||||||
|
String name;
|
||||||
|
switch (disguiseType) {
|
||||||
|
case MINECART_FURNACE:
|
||||||
|
case MINECART_HOPPER:
|
||||||
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case MINECART_TNT:
|
||||||
|
case MINECART_CHEST:
|
||||||
|
name = "Minecart";
|
||||||
|
break;
|
||||||
|
case DONKEY:
|
||||||
|
case MULE:
|
||||||
|
case UNDEAD_HORSE:
|
||||||
|
case SKELETON_HORSE:
|
||||||
|
name = "Horse";
|
||||||
|
break;
|
||||||
|
case ZOMBIE_VILLAGER:
|
||||||
|
case PIG_ZOMBIE:
|
||||||
|
name = "Zombie";
|
||||||
|
break;
|
||||||
|
case MAGMA_CUBE:
|
||||||
|
name = "Slime";
|
||||||
|
default:
|
||||||
|
name = toReadable(disguiseType.name());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
watcherClass = Class.forName("me.libraryaddict.disguise.DisguiseTypes.Watchers." + name + "Watcher");
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// There is no watcher for this entity, or a error was thrown.
|
||||||
|
try {
|
||||||
|
Class c = disguiseType.getEntityType().getEntityClass();
|
||||||
|
if (c.isAssignableFrom(Ageable.class))
|
||||||
|
watcherClass = AgeableWatcher.class;
|
||||||
|
else if (c.isAssignableFrom(LivingEntity.class))
|
||||||
|
watcherClass = LivingWatcher.class;
|
||||||
|
else
|
||||||
|
watcherClass = FlagWatcher.class;
|
||||||
|
} catch (Exception ex1) {
|
||||||
|
ex1.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
disguiseType.setWatcherClass(watcherClass);
|
||||||
String name = toReadable(disguiseType.name());
|
String name = toReadable(disguiseType.name());
|
||||||
if (disguiseType == DisguiseType.WITHER_SKELETON) {
|
boolean dontDo = false;
|
||||||
continue;
|
switch (disguiseType) {
|
||||||
} else if (disguiseType == DisguiseType.ZOMBIE_VILLAGER) {
|
case WITHER_SKELETON:
|
||||||
continue;
|
case ZOMBIE_VILLAGER:
|
||||||
} else if (disguiseType == DisguiseType.PRIMED_TNT) {
|
case DONKEY:
|
||||||
|
case MULE:
|
||||||
|
case UNDEAD_HORSE:
|
||||||
|
case SKELETON_HORSE:
|
||||||
|
dontDo = true;
|
||||||
|
break;
|
||||||
|
case PRIMED_TNT:
|
||||||
name = "TNTPrimed";
|
name = "TNTPrimed";
|
||||||
} else if (disguiseType == DisguiseType.DONKEY) {
|
break;
|
||||||
continue;
|
case MINECART_TNT:
|
||||||
} else if (disguiseType == DisguiseType.MULE) {
|
|
||||||
continue;
|
|
||||||
} else if (disguiseType == DisguiseType.UNDEAD_HORSE) {
|
|
||||||
continue;
|
|
||||||
} else if (disguiseType == DisguiseType.SKELETON_HORSE) {
|
|
||||||
continue;
|
|
||||||
} else if (disguiseType == DisguiseType.MINECART_TNT) {
|
|
||||||
name = "MinecartTNT";
|
name = "MinecartTNT";
|
||||||
} else if (disguiseType == DisguiseType.MINECART) {
|
break;
|
||||||
|
case MINECART:
|
||||||
name = "MinecartRideable";
|
name = "MinecartRideable";
|
||||||
} else if (disguiseType == DisguiseType.FIREWORK) {
|
break;
|
||||||
|
case FIREWORK:
|
||||||
name = "Fireworks";
|
name = "Fireworks";
|
||||||
} else if (disguiseType == DisguiseType.SPLASH_POTION)
|
break;
|
||||||
|
case SPLASH_POTION:
|
||||||
name = "Potion";
|
name = "Potion";
|
||||||
else if (disguiseType == DisguiseType.GIANT)
|
break;
|
||||||
|
case GIANT:
|
||||||
name = "GiantZombie";
|
name = "GiantZombie";
|
||||||
else if (disguiseType == DisguiseType.DROPPED_ITEM)
|
break;
|
||||||
|
case DROPPED_ITEM:
|
||||||
name = "Item";
|
name = "Item";
|
||||||
else if (disguiseType == DisguiseType.FIREBALL)
|
break;
|
||||||
|
case FIREBALL:
|
||||||
name = "LargeFireball";
|
name = "LargeFireball";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (dontDo)
|
||||||
|
continue;
|
||||||
try {
|
try {
|
||||||
net.minecraft.server.v1_6_R2.Entity entity = null;
|
net.minecraft.server.v1_6_R2.Entity entity = null;
|
||||||
Class entityClass;
|
Class entityClass;
|
||||||
@ -299,10 +358,10 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String toReadable(String string) {
|
private String toReadable(String string) {
|
||||||
String[] strings = string.split("_");
|
StringBuilder builder = new StringBuilder();
|
||||||
string = "";
|
for (String s : string.split("_")) {
|
||||||
for (String s : strings)
|
builder.append(s.substring(0, 1) + s.substring(1).toLowerCase());
|
||||||
string += s.substring(0, 1) + s.substring(1).toLowerCase();
|
}
|
||||||
return string;
|
return builder.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user