Fixed bug where players switching worlds would become invisible.

Fixed bug where arrows wouldn't blow disguises.
Added default permission for /libsdisguises reload (only ops can use by default)
This commit is contained in:
NavidK0 2015-08-02 18:39:44 -04:00
parent 3e19045a2c
commit 41cfa8eeaa
51 changed files with 2032 additions and 2009 deletions

View File

@ -13,7 +13,7 @@ println 'Compiling LibsDisguises via Gradle ver. ' + gradle.gradleVersion
sourceCompatibility = '1.7' sourceCompatibility = '1.7'
ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT' ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT'
ext.disguisesVersion = '8.6.3' ext.disguisesVersion = '8.6.4'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

View File

@ -90,7 +90,7 @@ public class DisguiseAPI {
int firstCapitalWatcher = firstCapital(watcherMethod.getName()); int firstCapitalWatcher = firstCapital(watcherMethod.getName());
if (firstCapitalWatcher > 0 if (firstCapitalWatcher > 0
&& method.getName().substring(firstCapitalMethod) && method.getName().substring(firstCapitalMethod)
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) { .equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) {
Class methodParam = watcherMethod.getParameterTypes()[0]; Class methodParam = watcherMethod.getParameterTypes()[0];
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) { if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
methodParam = double.class; methodParam = double.class;
@ -143,8 +143,9 @@ public class DisguiseAPI {
public static void disguiseEntity(Entity entity, Disguise disguise) { public static void disguiseEntity(Entity entity, Disguise disguise) {
// If they are trying to disguise a null entity or use a null disguise // If they are trying to disguise a null entity or use a null disguise
// Just return. // Just return.
if (entity == null || disguise == null) if (entity == null || disguise == null) {
return; return;
}
// The event wasn't cancelled. // The event wasn't cancelled.
// If the disguise entity isn't the same as the one we are disguising // If the disguise entity isn't the same as the one we are disguising
if (disguise.getEntity() != entity) { if (disguise.getEntity() != entity) {
@ -192,12 +193,14 @@ public class DisguiseAPI {
/** /**
* Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn. * Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn.
*
* @param disguise * @param disguise
* @return * @return
*/ */
public static int disguiseNextEntity(Disguise disguise) { public static int disguiseNextEntity(Disguise disguise) {
if (disguise == null) if (disguise == null) {
return -1; return -1;
}
if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) { if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
disguise = disguise.clone(); disguise = disguise.clone();
} }
@ -215,6 +218,7 @@ public class DisguiseAPI {
/** /**
* Disguise this entity with this disguise * Disguise this entity with this disguise
*
* @param entity * @param entity
* @param disguise * @param disguise
*/ */
@ -224,8 +228,9 @@ public class DisguiseAPI {
} }
// You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!! // You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!!
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS); ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
for (String observer : ((TargetedDisguise) disguise).getObservers()) for (String observer : ((TargetedDisguise) disguise).getObservers()) {
((TargetedDisguise) disguise).removePlayer(observer); ((TargetedDisguise) disguise).removePlayer(observer);
}
disguiseEntity(entity, disguise); disguiseEntity(entity, disguise);
} }
@ -268,42 +273,49 @@ public class DisguiseAPI {
/** /**
* Get the disguise of a entity * Get the disguise of a entity
*
* @param disguised * @param disguised
* @return * @return
*/ */
public static Disguise getDisguise(Entity disguised) { public static Disguise getDisguise(Entity disguised) {
if (disguised == null) if (disguised == null) {
return null; return null;
}
return DisguiseUtilities.getMainDisguise(disguised.getUniqueId()); return DisguiseUtilities.getMainDisguise(disguised.getUniqueId());
} }
/** /**
* Get the disguise of a entity * Get the disguise of a entity
*
* @param observer * @param observer
* @param disguised * @param disguised
* @return * @return
*/ */
public static Disguise getDisguise(Player observer, Entity disguised) { public static Disguise getDisguise(Player observer, Entity disguised) {
if (disguised == null || observer == null) if (disguised == null || observer == null) {
return null; return null;
}
return DisguiseUtilities.getDisguise(observer, disguised); return DisguiseUtilities.getDisguise(observer, disguised);
} }
/** /**
* Get the disguises of a entity * Get the disguises of a entity
*
* @param disguised * @param disguised
* @return * @return
*/ */
public static Disguise[] getDisguises(Entity disguised) { public static Disguise[] getDisguises(Entity disguised) {
if (disguised == null) if (disguised == null) {
return null; return null;
}
return DisguiseUtilities.getDisguises(disguised.getUniqueId()); return DisguiseUtilities.getDisguises(disguised.getUniqueId());
} }
/** /**
* Get the ID of a fake disguise for a entityplayer * Get the ID of a fake disguise for a entityplayer
*
* @param entityId * @param entityId
* @return * @return
*/ */
@Deprecated @Deprecated
public static int getFakeDisguise(UUID entityId) { public static int getFakeDisguise(UUID entityId) {
@ -316,8 +328,9 @@ public class DisguiseAPI {
/** /**
* Is this entity disguised * Is this entity disguised
*
* @param disguised * @param disguised
* @return * @return
*/ */
public static boolean isDisguised(Entity disguised) { public static boolean isDisguised(Entity disguised) {
return getDisguise(disguised) != null; return getDisguise(disguised) != null;
@ -325,9 +338,10 @@ public class DisguiseAPI {
/** /**
* Is this entity disguised * Is this entity disguised
*
* @param observer * @param observer
* @param disguised * @param disguised
* @return * @return
*/ */
public static boolean isDisguised(Player observer, Entity disguised) { public static boolean isDisguised(Player observer, Entity disguised) {
return getDisguise(observer, disguised) != null; return getDisguise(observer, disguised) != null;
@ -340,20 +354,20 @@ public class DisguiseAPI {
public static boolean isSelfDisguised(Player player) { public static boolean isSelfDisguised(Player player) {
return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId()); return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId());
} }
/** /**
* Returns true if the entitiy has /disguiseviewself toggled * Returns true if the entitiy has /disguiseviewself toggled on.
* on. *
* @param entity * @param entity
* @return * @return
*/ */
public static boolean isViewSelfToggled(Entity entity) { public static boolean isViewSelfToggled(Entity entity) {
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() : Disguise.getViewSelf().contains(entity.getUniqueId()); return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() : Disguise.getViewSelf().contains(entity.getUniqueId());
} }
/** /**
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from * Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from the world.
* the world. *
* @param entity * @param entity
*/ */
public static void undisguiseToAll(Entity entity) { public static void undisguiseToAll(Entity entity) {
@ -362,12 +376,12 @@ public class DisguiseAPI {
disguise.removeDisguise(); disguise.removeDisguise();
} }
} }
/** /**
* Set whether this player can see his * Set whether this player can see his own disguise or not.
* own disguise or not. *
* @param entity * @param entity
* @param toggled * @param toggled
*/ */
public static void setViewDisguiseToggled(Entity entity, boolean toggled) { public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
if (isDisguised(entity)) { if (isDisguised(entity)) {
@ -375,8 +389,9 @@ public class DisguiseAPI {
disguise.setViewSelfDisguise(toggled); disguise.setViewSelfDisguise(toggled);
} }
if (toggled) { if (toggled) {
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
Disguise.getViewSelf().add(entity.getUniqueId()); Disguise.getViewSelf().add(entity.getUniqueId());
}
} else { } else {
Disguise.getViewSelf().remove(entity.getUniqueId()); Disguise.getViewSelf().remove(entity.getUniqueId());
} }

View File

@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
public class DisguiseConfig { public class DisguiseConfig {
private static boolean animationEnabled; private static boolean animationEnabled;
private static boolean bedEnabled; private static boolean bedEnabled;
private static boolean blowDisguisesOnAttack; private static boolean blowDisguisesOnAttack;
@ -218,7 +219,8 @@ public class DisguiseConfig {
/** /**
* Is the velocity packets sent * Is the velocity packets sent
* @return *
* @return
*/ */
public static boolean isVelocitySent() { public static boolean isVelocitySent() {
return sendVelocity; return sendVelocity;
@ -226,7 +228,8 @@ public class DisguiseConfig {
/** /**
* The default value if a player views his own disguise * The default value if a player views his own disguise
* @return *
* @return
*/ */
public static boolean isViewDisguises() { public static boolean isViewDisguises() {
return viewSelfDisguise; return viewSelfDisguise;
@ -408,6 +411,7 @@ public class DisguiseConfig {
/** /**
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get? * Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
*
* @param sendVelocityPackets * @param sendVelocityPackets
*/ */
public static void setVelocitySent(boolean sendVelocityPackets) { public static void setVelocitySent(boolean sendVelocityPackets) {

View File

@ -38,6 +38,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.comphenix.protocol.ProtocolLibrary; import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.events.PacketContainer;
import org.bukkit.entity.Arrow;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
public class DisguiseListener implements Listener { public class DisguiseListener implements Listener {
@ -66,10 +67,12 @@ public class DisguiseListener implements Listener {
Bukkit.getScheduler().runTask(plugin, new Runnable() { Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
for (Player p : Bukkit.getOnlinePlayers()) for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) {
p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion, p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion,
latestVersion)); latestVersion));
}
}
} }
}); });
} }
@ -81,7 +84,7 @@ public class DisguiseListener implements Listener {
// 20 ticks * 60 seconds * 60 minutes * 6 hours // 20 ticks * 60 seconds * 60 minutes * 6 hours
} }
} }
public void cleanup() { public void cleanup() {
for (BukkitRunnable r : disguiseRunnable.values()) { for (BukkitRunnable r : disguiseRunnable.values()) {
r.cancel(); r.cancel();
@ -159,6 +162,8 @@ public class DisguiseListener implements Listener {
/** /**
* Most likely faster if we don't bother doing checks if he sees a player disguise * Most likely faster if we don't bother doing checks if he sees a player disguise
*
* @param event
*/ */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) { public void onMove(PlayerMoveEvent event) {
@ -266,8 +271,9 @@ public class DisguiseListener implements Listener {
if (DisguiseAPI.isDisguised(entity)) { if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(entity); DisguiseAPI.undisguiseToAll(entity);
p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName); p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName);
} else } else {
p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!"); p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!");
}
} }
} }
} }
@ -278,20 +284,23 @@ public class DisguiseListener implements Listener {
if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null && event.getTarget() instanceof Player if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null && event.getTarget() instanceof Player
&& DisguiseAPI.isDisguised(event.getTarget())) { && DisguiseAPI.isDisguised(event.getTarget())) {
switch (event.getReason()) { switch (event.getReason()) {
case TARGET_ATTACKED_ENTITY: case TARGET_ATTACKED_ENTITY:
case TARGET_ATTACKED_OWNER: case TARGET_ATTACKED_OWNER:
case OWNER_ATTACKED_TARGET: case OWNER_ATTACKED_TARGET:
case CUSTOM: case CUSTOM:
break; break;
default: default:
event.setCancelled(true); event.setCancelled(true);
break; break;
} }
} }
} }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) { public void onTeleport(final PlayerTeleportEvent event) {
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
return;
}
Location to = event.getTo(); Location to = event.getTo();
Location from = event.getFrom(); Location from = event.getFrom();
if (DisguiseConfig.isBedPacketsEnabled()) { if (DisguiseConfig.isBedPacketsEnabled()) {
@ -301,7 +310,7 @@ public class DisguiseListener implements Listener {
int z2 = (int) Math.floor(from.getZ() / 16D) - 17; int z2 = (int) Math.floor(from.getZ() / 16D) - 17;
if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) { if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) {
chunkMove(event.getPlayer(), null, from); chunkMove(event.getPlayer(), null, from);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
if (!event.isCancelled()) { if (!event.isCancelled()) {
@ -318,6 +327,17 @@ public class DisguiseListener implements Listener {
for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) { for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
disguise.removeDisguise(); disguise.removeDisguise();
} }
} else {
//Stupid hack to fix worldswitch invisibility bug
final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer());
final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer());
disguise.setViewSelfDisguise(!viewSelfToggled);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
disguise.setViewSelfDisguise(viewSelfToggled);
}
}, 20L); //I wish I could use lambdas here, so badly
} }
} }
@ -347,6 +367,9 @@ public class DisguiseListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldSwitch(final PlayerChangedWorldEvent event) { public void onWorldSwitch(final PlayerChangedWorldEvent event) {
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
return;
}
if (DisguiseConfig.isBedPacketsEnabled()) { if (DisguiseConfig.isBedPacketsEnabled()) {
chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null); chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null);
} }

View File

@ -37,7 +37,7 @@ import me.libraryaddict.disguise.utilities.Metrics;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class LibsDisguises extends JavaPlugin { public class LibsDisguises extends JavaPlugin {
public static LibsDisguises instance; //I'm sorry Sun MicroSystems and all mighty Java God public static LibsDisguises instance; //I'm sorry Sun MicroSystems and all mighty Java God
private DisguiseListener listener; private DisguiseListener listener;
@ -69,21 +69,21 @@ public class LibsDisguises extends JavaPlugin {
try { try {
Metrics metrics = new Metrics(this); Metrics metrics = new Metrics(this);
metrics.start(); metrics.start();
} catch (IOException e) {} } catch (IOException e) {
}
} }
/** /**
* Reloads the config with new config options. * Reloads the config with new config options.
*/ */
public void reload() { public void reload() {
HandlerList.unregisterAll(listener); HandlerList.unregisterAll(listener);
reloadConfig(); reloadConfig();
DisguiseConfig.initConfig(getConfig()); DisguiseConfig.initConfig(getConfig());
} }
/** /**
* Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume * 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.
* for mob noises. As well as setting their watcher class and entity size.
*/ */
private void registerValues() { private void registerValues() {
for (DisguiseType disguiseType : DisguiseType.values()) { for (DisguiseType disguiseType : DisguiseType.values()) {
@ -93,37 +93,37 @@ public class LibsDisguises extends JavaPlugin {
Class watcherClass; Class watcherClass;
try { try {
switch (disguiseType) { switch (disguiseType) {
case MINECART_CHEST: case MINECART_CHEST:
case MINECART_COMMAND: case MINECART_COMMAND:
case MINECART_FURNACE: case MINECART_FURNACE:
case MINECART_HOPPER: case MINECART_HOPPER:
case MINECART_MOB_SPAWNER: case MINECART_MOB_SPAWNER:
case MINECART_TNT: case MINECART_TNT:
watcherClass = MinecartWatcher.class; watcherClass = MinecartWatcher.class;
break; break;
case DONKEY: case DONKEY:
case MULE: case MULE:
case UNDEAD_HORSE: case UNDEAD_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
watcherClass = HorseWatcher.class; watcherClass = HorseWatcher.class;
break; break;
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
case PIG_ZOMBIE: case PIG_ZOMBIE:
watcherClass = ZombieWatcher.class; watcherClass = ZombieWatcher.class;
break; break;
case MAGMA_CUBE: case MAGMA_CUBE:
watcherClass = SlimeWatcher.class; watcherClass = SlimeWatcher.class;
break; break;
case ELDER_GUARDIAN: case ELDER_GUARDIAN:
watcherClass = GuardianWatcher.class; watcherClass = GuardianWatcher.class;
break; break;
case ENDERMITE: case ENDERMITE:
watcherClass = LivingWatcher.class; watcherClass = LivingWatcher.class;
break; break;
default: default:
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers." watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
+ toReadable(disguiseType.name()) + "Watcher"); + toReadable(disguiseType.name()) + "Watcher");
break; break;
} }
} catch (ClassNotFoundException ex) { } catch (ClassNotFoundException ex) {
// There is no explicit watcher for this entity. // There is no explicit watcher for this entity.
@ -148,45 +148,45 @@ public class LibsDisguises extends JavaPlugin {
} }
String nmsEntityName = toReadable(disguiseType.name()); String nmsEntityName = toReadable(disguiseType.name());
switch (disguiseType) { switch (disguiseType) {
case WITHER_SKELETON: case WITHER_SKELETON:
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
case DONKEY: case DONKEY:
case MULE: case MULE:
case UNDEAD_HORSE: case UNDEAD_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
continue; continue;
case PRIMED_TNT: case PRIMED_TNT:
nmsEntityName = "TNTPrimed"; nmsEntityName = "TNTPrimed";
break; break;
case MINECART_TNT: case MINECART_TNT:
nmsEntityName = "MinecartTNT"; nmsEntityName = "MinecartTNT";
break; break;
case MINECART: case MINECART:
nmsEntityName = "MinecartRideable"; nmsEntityName = "MinecartRideable";
break; break;
case FIREWORK: case FIREWORK:
nmsEntityName = "Fireworks"; nmsEntityName = "Fireworks";
break; break;
case SPLASH_POTION: case SPLASH_POTION:
nmsEntityName = "Potion"; nmsEntityName = "Potion";
break; break;
case GIANT: case GIANT:
nmsEntityName = "GiantZombie"; nmsEntityName = "GiantZombie";
break; break;
case DROPPED_ITEM: case DROPPED_ITEM:
nmsEntityName = "Item"; nmsEntityName = "Item";
break; break;
case FIREBALL: case FIREBALL:
nmsEntityName = "LargeFireball"; nmsEntityName = "LargeFireball";
break; break;
case LEASH_HITCH: case LEASH_HITCH:
nmsEntityName = "Leash"; nmsEntityName = "Leash";
break; break;
case ELDER_GUARDIAN: case ELDER_GUARDIAN:
nmsEntityName = "Guardian"; nmsEntityName = "Guardian";
break; break;
default: default:
break; break;
} }
try { try {
if (nmsEntityName.equalsIgnoreCase("Unknown")) { if (nmsEntityName.equalsIgnoreCase("Unknown")) {

View File

@ -43,7 +43,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
return true; return true;
} }
} }
LibsDisguises.instance.getListener().setDisguiseClone(sender.getName(), new Boolean[] { doEquipment, doSneak, doSprint }); LibsDisguises.instance.getListener().setDisguiseClone(sender.getName(), new Boolean[]{doEquipment, doSneak, doSprint});
sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire() sender.sendMessage(ChatColor.RED + "Right click a entity in the next " + DisguiseConfig.getDisguiseCloneExpire()
+ " seconds to grab the disguise reference!"); + " seconds to grab the disguise reference!");
} else { } else {

View File

@ -62,10 +62,12 @@ public class DisguiseCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!"); sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player")) if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>");
}
} }
} }

View File

@ -42,6 +42,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
/** /**
* Send the player the information * Send the player the information
*
* @param sender * @param sender
* @param map * @param map
*/ */
@ -51,11 +52,13 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!"); sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player")) if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
}
} }
} }

View File

@ -22,7 +22,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
public class DisguiseHelpCommand extends BaseDisguiseCommand { public class DisguiseHelpCommand extends BaseDisguiseCommand {
private class EnumHelp { private class EnumHelp {
private String enumDescription; private String enumDescription;
private String enumName; private String enumName;
private String[] enums; private String[] enums;
@ -81,38 +83,39 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
try { try {
enumHelp.add(new EnumHelp("HorseColor", "Horse colors", ChatColor.RED + "/disguisehelp HorseColors " enumHelp.add(new EnumHelp("HorseColor", "Horse colors", ChatColor.RED + "/disguisehelp HorseColors "
+ ChatColor.GREEN + "- View all the colors you can use for a horses color", (Enum[]) Class.forName( + ChatColor.GREEN + "- View all the colors you can use for a horses color", (Enum[]) Class.forName(
"org.bukkit.entity.Horse$Color").getEnumConstants())); "org.bukkit.entity.Horse$Color").getEnumConstants()));
} catch (Exception ex) { } catch (Exception ex) {
} }
try { try {
enumHelp.add(new EnumHelp("HorseStyle", "Horse styles", ChatColor.RED + "/disguisehelp HorseStyles " enumHelp.add(new EnumHelp("HorseStyle", "Horse styles", ChatColor.RED + "/disguisehelp HorseStyles "
+ ChatColor.GREEN + "- View all the styles you can use for a horses style", (Enum[]) Class.forName( + ChatColor.GREEN + "- View all the styles you can use for a horses style", (Enum[]) Class.forName(
"org.bukkit.entity.Horse$Style").getEnumConstants())); "org.bukkit.entity.Horse$Style").getEnumConstants()));
} catch (Exception ex) { } catch (Exception ex) {
} }
try { try {
enumHelp.add(new EnumHelp("OcelotType", "Ocelot types", ChatColor.RED + "/disguisehelp OcelotTypes " enumHelp.add(new EnumHelp("OcelotType", "Ocelot types", ChatColor.RED + "/disguisehelp OcelotTypes "
+ ChatColor.GREEN + "- View all the ocelot types you can use for ocelots", (Enum[]) Class.forName( + ChatColor.GREEN + "- View all the ocelot types you can use for ocelots", (Enum[]) Class.forName(
"org.bukkit.entity.Ocelot$Type").getEnumConstants())); "org.bukkit.entity.Ocelot$Type").getEnumConstants()));
} catch (Exception ex) { } catch (Exception ex) {
} }
try { try {
ArrayList<String> enumReturns = new ArrayList<>(); ArrayList<String> enumReturns = new ArrayList<>();
for (PotionEffectType potionType : PotionEffectType.values()) { for (PotionEffectType potionType : PotionEffectType.values()) {
if (potionType != null) if (potionType != null) {
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId() enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
+ ChatColor.RED + ")"); + ChatColor.RED + ")");
}
} }
enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect", ChatColor.RED + "/disguisehelp PotionEffect " enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect", ChatColor.RED + "/disguisehelp PotionEffect "
+ ChatColor.GREEN + "- View all the potion effects you can set", enumReturns.toArray(new String[enumReturns + ChatColor.GREEN + "- View all the potion effects you can set", enumReturns.toArray(new String[enumReturns
.size()]))); .size()])));
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(System.out); ex.printStackTrace(System.out);
} }
try { try {
enumHelp.add(new EnumHelp("Profession", "Villager professions", ChatColor.RED + "/disguisehelp Professions " enumHelp.add(new EnumHelp("Profession", "Villager professions", ChatColor.RED + "/disguisehelp Professions "
+ ChatColor.GREEN + "- View all the professions you can set on a villager", (Enum[]) Class.forName( + ChatColor.GREEN + "- View all the professions you can set on a villager", (Enum[]) Class.forName(
"org.bukkit.entity.Villager$Profession").getEnumConstants())); "org.bukkit.entity.Villager$Profession").getEnumConstants()));
} catch (Exception ex) { } catch (Exception ex) {
} }
enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
@ -123,7 +126,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
for (String node : new String[] { "disguise", "disguiseradius", "disguiseentity", "disguiseplayer" }) { for (String node : new String[]{"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"}) {
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> permMap = getPermissions(sender, "libsdisguises." + node HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> permMap = getPermissions(sender, "libsdisguises." + node
+ "."); + ".");
if (!permMap.isEmpty()) { if (!permMap.isEmpty()) {
@ -273,8 +276,9 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
public String toReadable(String string) { public String toReadable(String string) {
String[] split = string.split("_"); String[] split = string.split("_");
for (int i = 0; i < split.length; i++) for (int i = 0; i < split.length; i++) {
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
}
return StringUtils.join(split, "_"); return StringUtils.join(split, "_");
} }
} }

View File

@ -85,11 +85,13 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!"); sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN)); + StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player")) if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>"); sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN sender.sendMessage(ChatColor.DARK_GREEN
+ "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>"); + "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
}
} }
} }

View File

@ -21,6 +21,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class DisguiseRadiusCommand extends BaseDisguiseCommand { public class DisguiseRadiusCommand extends BaseDisguiseCommand {
private int maxRadius = 30; private int maxRadius = 30;
private ArrayList<Class> validClasses = new ArrayList<>(); private ArrayList<Class> validClasses = new ArrayList<>();
@ -111,8 +112,9 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
int disguisedEntitys = 0; int disguisedEntitys = 0;
int miscDisguises = 0; int miscDisguises = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) { for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender) if (entity == sender) {
continue; continue;
}
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) { if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
&& entity instanceof LivingEntity) { && entity instanceof LivingEntity) {
@ -165,7 +167,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) { if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional
+ "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace("<", + "> <Radius> <Dropped_Item/Falling_Block> <Id> <Durability" + optional + ">").replace("<",
"<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">")); "<" + ChatColor.GREEN).replace(">", ChatColor.DARK_GREEN + ">"));
} }
sender.sendMessage(ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN sender.sendMessage(ChatColor.DARK_GREEN + "See the EntityType's usable by " + ChatColor.GREEN
+ "/disguiseradius EntityTypes"); + "/disguiseradius EntityTypes");

View File

@ -11,26 +11,26 @@ public class LibsDisguisesCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (args.length == 0) { if (args.length == 0) {
sender.sendMessage(ChatColor.DARK_GREEN sender.sendMessage(ChatColor.DARK_GREEN
+ "This server is running " + "This server is running "
+ "Lib's Disguises v." + "Lib's Disguises v."
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion() + Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
+ " by libraryaddict, maintained by NavidK0.\n" + " by libraryaddict, maintained by NavidK0.\n"
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this."); + "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
} else if (args.length > 0) { } else if (args.length > 0) {
if (!sender.hasPermission("libsdisguises.reload")) { if (sender.hasPermission("libsdisguises.reload")) {
if (args[0].equalsIgnoreCase("reload")) { if (args[0].equalsIgnoreCase("reload")) {
LibsDisguises.instance.reload(); LibsDisguises.instance.reload();
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config."); sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
return true; return true;
} else {
sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
}
} else { } else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
} }
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
} }
}
return true; return true;
} }
} }

View File

@ -21,10 +21,12 @@ public class UndisguiseCommand implements CommandExecutor {
if (DisguiseAPI.isDisguised((Entity) sender)) { if (DisguiseAPI.isDisguised((Entity) sender)) {
DisguiseAPI.undisguiseToAll((Player) sender); DisguiseAPI.undisguiseToAll((Player) sender);
sender.sendMessage(ChatColor.RED + "You are no longer disguised"); sender.sendMessage(ChatColor.RED + "You are no longer disguised");
} else } else {
sender.sendMessage(ChatColor.RED + "You are not disguised!"); sender.sendMessage(ChatColor.RED + "You are not disguised!");
} else }
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true; return true;
} }
} }

View File

@ -19,8 +19,9 @@ public class UndisguiseEntityCommand implements CommandExecutor {
if (sender.hasPermission("libsdisguises.undisguiseentity")) { if (sender.hasPermission("libsdisguises.undisguiseentity")) {
LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), null); LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), null);
sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!"); sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!");
} else } else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true; return true;
} }
} }

View File

@ -20,14 +20,18 @@ public class UndisguisePlayerCommand implements CommandExecutor {
if (DisguiseAPI.isDisguised(p)) { if (DisguiseAPI.isDisguised(p)) {
DisguiseAPI.undisguiseToAll(p); DisguiseAPI.undisguiseToAll(p);
sender.sendMessage(ChatColor.RED + "The player is no longer disguised"); sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
} else } else {
sender.sendMessage(ChatColor.RED + "The player is not disguised!"); sender.sendMessage(ChatColor.RED + "The player is not disguised!");
} else }
} else {
sender.sendMessage(ChatColor.RED + "Player not found"); sender.sendMessage(ChatColor.RED + "Player not found");
} else }
} else {
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>"); sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
} else }
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true; return true;
} }
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class UndisguiseRadiusCommand implements CommandExecutor { public class UndisguiseRadiusCommand implements CommandExecutor {
private int maxRadius = 30; private int maxRadius = 30;
public UndisguiseRadiusCommand(int maxRadius) { public UndisguiseRadiusCommand(int maxRadius) {
@ -48,16 +49,18 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
} }
int disguisedEntitys = 0; int disguisedEntitys = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) { for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender) if (entity == sender) {
continue; continue;
}
if (DisguiseAPI.isDisguised(entity)) { if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(entity); DisguiseAPI.undisguiseToAll(entity);
disguisedEntitys++; disguisedEntitys++;
} }
} }
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!"); sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
} else } else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command."); sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true; return true;
} }
} }

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
public enum AnimalColor { public enum AnimalColor {
BLACK(15), BLUE(11), BROWN(12), CYAN(9), GRAY(7), GREEN(13), LIGHT_BLUE(3), LIME(5), MAGENTA(2), ORANGE(1), PINK(6), PURPLE( BLACK(15), BLUE(11), BROWN(12), CYAN(9), GRAY(7), GREEN(13), LIGHT_BLUE(3), LIME(5), MAGENTA(2), ORANGE(1), PINK(6), PURPLE(
10), RED(14), SILVER(8), WHITE(0), YELLOW(4); 10), RED(14), SILVER(8), WHITE(0), YELLOW(4);

View File

@ -39,6 +39,7 @@ import java.util.Map;
import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.LibsDisguises;
public abstract class Disguise { public abstract class Disguise {
private boolean disguiseInUse; private boolean disguiseInUse;
private DisguiseType disguiseType; private DisguiseType disguiseType;
private Entity entity; private Entity entity;
@ -56,24 +57,26 @@ public abstract class Disguise {
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
private FlagWatcher watcher; private FlagWatcher watcher;
private boolean showName = false; private boolean showName = false;
private static List<UUID> viewSelf = new ArrayList<>(); private static List<UUID> viewSelf = new ArrayList<>();
@Override @Override
public abstract Disguise clone(); public abstract Disguise clone();
/** /**
* Seems I do this method so I can make cleaner constructors on disguises.. * Seems I do this method so I can make cleaner constructors on disguises..
*
* @param newType * @param newType
*/ */
protected void createDisguise(DisguiseType newType) { protected void createDisguise(DisguiseType newType) {
if (getWatcher() != null) if (getWatcher() != null) {
return; return;
}
if (newType.getEntityType() == null) { if (newType.getEntityType() == null) {
throw new RuntimeException( throw new RuntimeException(
"DisguiseType " "DisguiseType "
+ newType + newType
+ " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity"); + " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity");
} }
// Set the disguise type // Set the disguise type
disguiseType = newType; disguiseType = newType;
@ -99,16 +102,12 @@ public abstract class Disguise {
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton // If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
if (getType() == DisguiseType.WITHER_SKELETON) { if (getType() == DisguiseType.WITHER_SKELETON) {
getWatcher().setValue(13, (byte) 1); getWatcher().setValue(13, (byte) 1);
} } // Else if its a zombie, but the disguise type is a zombie villager. Set the value.
// Else if its a zombie, but the disguise type is a zombie villager. Set the value.
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) { else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
getWatcher().setValue(13, (byte) 1); getWatcher().setValue(13, (byte) 1);
} } else if (getType() == DisguiseType.ELDER_GUARDIAN) {
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
getWatcher().setValue(16, 0 | 4); getWatcher().setValue(16, 0 | 4);
} } // Else if its a horse. Set the horse watcher type
// Else if its a horse. Set the horse watcher type
else if (getWatcher() instanceof HorseWatcher) { else if (getWatcher() instanceof HorseWatcher) {
try { try {
// Don't mess with this because Varient is something like ZombieHorse and so on. // Don't mess with this because Varient is something like ZombieHorse and so on.
@ -121,65 +120,65 @@ public abstract class Disguise {
} }
final boolean alwaysSendVelocity; final boolean alwaysSendVelocity;
switch (getType()) { switch (getType()) {
case EGG: case EGG:
case ENDER_PEARL: case ENDER_PEARL:
case BAT: case BAT:
case EXPERIENCE_ORB: case EXPERIENCE_ORB:
case FIREBALL: case FIREBALL:
case SMALL_FIREBALL: case SMALL_FIREBALL:
case SNOWBALL: case SNOWBALL:
case SPLASH_POTION: case SPLASH_POTION:
case THROWN_EXP_BOTTLE: case THROWN_EXP_BOTTLE:
case WITHER_SKULL: case WITHER_SKULL:
case FIREWORK: case FIREWORK:
alwaysSendVelocity = true; alwaysSendVelocity = true;
break; break;
default: default:
alwaysSendVelocity = false; alwaysSendVelocity = false;
break; break;
} }
double velocitySpeed = 0.0005; double velocitySpeed = 0.0005;
switch (getType()) { switch (getType()) {
case FIREWORK: case FIREWORK:
velocitySpeed = -0.040; velocitySpeed = -0.040;
break; break;
case WITHER_SKULL: case WITHER_SKULL:
velocitySpeed = 0.000001D; velocitySpeed = 0.000001D;
break; break;
case ARROW: case ARROW:
case BOAT: case BOAT:
case ENDER_CRYSTAL: case ENDER_CRYSTAL:
case ENDER_DRAGON: case ENDER_DRAGON:
case GHAST: case GHAST:
case ITEM_FRAME: case ITEM_FRAME:
case MINECART: case MINECART:
case MINECART_CHEST: case MINECART_CHEST:
case MINECART_COMMAND: case MINECART_COMMAND:
case MINECART_FURNACE: case MINECART_FURNACE:
case MINECART_HOPPER: case MINECART_HOPPER:
case MINECART_MOB_SPAWNER: case MINECART_MOB_SPAWNER:
case MINECART_TNT: case MINECART_TNT:
case PAINTING: case PAINTING:
case PLAYER: case PLAYER:
case SQUID: case SQUID:
velocitySpeed = 0; velocitySpeed = 0;
break; break;
case DROPPED_ITEM: case DROPPED_ITEM:
case PRIMED_TNT: case PRIMED_TNT:
case WITHER: case WITHER:
case FALLING_BLOCK: case FALLING_BLOCK:
velocitySpeed = 0.04; velocitySpeed = 0.04;
break; break;
case EXPERIENCE_ORB: case EXPERIENCE_ORB:
velocitySpeed = 0.0221; velocitySpeed = 0.0221;
break; break;
case SPIDER: case SPIDER:
case BAT: case BAT:
case CAVE_SPIDER: case CAVE_SPIDER:
velocitySpeed = 0.004; velocitySpeed = 0.004;
break; break;
default: default:
break; break;
} }
final double vectorY = velocitySpeed; final double vectorY = velocitySpeed;
final TargetedDisguise disguise = (TargetedDisguise) this; final TargetedDisguise disguise = (TargetedDisguise) this;
@ -328,7 +327,8 @@ public abstract class Disguise {
/** /**
* Get the disguised entity * Get the disguised entity
* @return *
* @return
*/ */
public Entity getEntity() { public Entity getEntity() {
return entity; return entity;
@ -336,7 +336,8 @@ public abstract class Disguise {
/** /**
* Get the disguise type * Get the disguise type
* @return *
* @return
*/ */
public DisguiseType getType() { public DisguiseType getType() {
return disguiseType; return disguiseType;
@ -344,16 +345,17 @@ public abstract class Disguise {
/** /**
* Get the flag watcher * Get the flag watcher
* @return *
* @return
*/ */
public FlagWatcher getWatcher() { public FlagWatcher getWatcher() {
return watcher; return watcher;
} }
/** /**
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. * In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. getEntity() can still return null if this disguise is active after despawn, logout, etc.
* getEntity() can still return null if this disguise is active after despawn, logout, etc. *
* @return * @return
*/ */
public boolean isDisguiseInUse() { public boolean isDisguiseInUse() {
return disguiseInUse; return disguiseInUse;
@ -397,17 +399,16 @@ public abstract class Disguise {
/** /**
* Internal use * Internal use
* @return *
* @return
*/ */
public boolean isRemoveDisguiseOnDeath() { public boolean isRemoveDisguiseOnDeath() {
if (getEntity() == null) return true; if (getEntity() == null) {
return getEntity() instanceof Player ? return true;
}
(!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) return getEntity() instanceof Player
? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
: : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
(!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
} }
public boolean isSelfDisguiseSoundsReplaced() { public boolean isSelfDisguiseSoundsReplaced() {
@ -416,7 +417,8 @@ public abstract class Disguise {
/** /**
* Can the disguised view himself as the disguise * Can the disguised view himself as the disguise
* @return *
* @return
*/ */
public boolean isSelfDisguiseVisible() { public boolean isSelfDisguiseVisible() {
return viewSelfDisguise; return viewSelfDisguise;
@ -432,7 +434,8 @@ public abstract class Disguise {
/** /**
* Returns true if the entity's name is showing through the disguise * Returns true if the entity's name is showing through the disguise
* @return *
* @return
*/ */
public boolean isShowName() { public boolean isShowName() {
return showName; return showName;
@ -440,7 +443,7 @@ public abstract class Disguise {
/** /**
* Removes the disguise and undisguises the entity if its using this disguise. * Removes the disguise and undisguises the entity if its using this disguise.
* *
* @return * @return
*/ */
public boolean removeDisguise() { public boolean removeDisguise() {
@ -503,13 +506,15 @@ public abstract class Disguise {
/** /**
* Set the entity of the disguise. Only used for internal things. * Set the entity of the disguise. Only used for internal things.
*
* @param entity * @param entity
* @return * @return
*/ */
public Disguise setEntity(Entity entity) { public Disguise setEntity(Entity entity) {
if (this.getEntity() != null) { if (this.getEntity() != null) {
if (getEntity() == entity) if (getEntity() == entity) {
return this; return this;
}
throw new RuntimeException("This disguise is already in use! Try .clone()"); throw new RuntimeException("This disguise is already in use! Try .clone()");
} }
if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) { if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
@ -582,8 +587,7 @@ public abstract class Disguise {
} }
/** /**
* Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the * Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the datawatcher.
* datawatcher.
*/ */
private void setupWatcher() { private void setupWatcher() {
HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType()); HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
@ -611,8 +615,9 @@ public abstract class Disguise {
} }
// STEP 2. As the watcher has not set data on it, check if I need to set the default data. // STEP 2. As the watcher has not set data on it, check if I need to set the default data.
// If neither of them touch it // If neither of them touch it
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) {
continue; continue;
}
// If the disguise has this, but not the entity. Then better set it! // If the disguise has this, but not the entity. Then better set it!
if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) { if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) {
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo)); getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
@ -626,9 +631,9 @@ public abstract class Disguise {
Object eObj = entityValues.get(dataNo); Object eObj = entityValues.get(dataNo);
Object dObj = disguiseValues.get(dataNo); Object dObj = disguiseValues.get(dataNo);
if (eObj == null || dObj == null) { if (eObj == null || dObj == null) {
if (eObj == null && dObj == null) if (eObj == null && dObj == null) {
continue; continue;
else { } else {
getWatcher().setBackupValue(dataNo, dObj); getWatcher().setBackupValue(dataNo, dObj);
continue; continue;
} }
@ -645,40 +650,41 @@ public abstract class Disguise {
// EntityInsentient is 10 & 11 // EntityInsentient is 10 & 11
// EntityZombie is 12 & 13 & 14 - But it overrides other values and another check already does this. // EntityZombie is 12 & 13 & 14 - But it overrides other values and another check already does this.
// EntityLiving is 6 & 7 & 8 & 9 // EntityLiving is 6 & 7 & 8 & 9
// Lets use switch // Lets use switch
Class baseClass = null; Class baseClass = null;
switch (dataNo) { switch (dataNo) {
case 6: case 6:
case 7: case 7:
case 8: case 8:
case 9: case 9:
baseClass = ReflectionManager.getNmsClass("EntityLiving"); baseClass = ReflectionManager.getNmsClass("EntityLiving");
break; break;
case 10: case 10:
case 11: case 11:
baseClass = ReflectionManager.getNmsClass("EntityInsentient"); baseClass = ReflectionManager.getNmsClass("EntityInsentient");
break; break;
case 16: case 16:
baseClass = ReflectionManager.getNmsClass("EntityAgeable"); baseClass = ReflectionManager.getNmsClass("EntityAgeable");
break; break;
default: default:
break; break;
} }
Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass(); Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass();
Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType()); Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType());
if (nmsDisguiseClass != null) { if (nmsDisguiseClass != null) {
// If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..? // If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..?
if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass) if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass)
&& baseClass.isAssignableFrom(nmsEntityClass)) && baseClass.isAssignableFrom(nmsEntityClass)) {
continue; continue;
}
// So they don't extend a basic class. // So they don't extend a basic class.
// Maybe if I check that they extend each other.. // Maybe if I check that they extend each other..
// Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared // Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared
// datawatchers. // datawatchers.
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) {
continue; continue;
}
} }
// Well I can't find a reason I should leave it alone. They will probably conflict. // Well I can't find a reason I should leave it alone. They will probably conflict.
// Time to set the value to the disguises value so no conflicts! // Time to set the value to the disguises value so no conflicts!
@ -693,7 +699,7 @@ public abstract class Disguise {
/** /**
* Can the disguised view himself as the disguise * Can the disguised view himself as the disguise
* *
* @param viewSelfDisguise * @param viewSelfDisguise
* @return * @return
*/ */
@ -704,8 +710,9 @@ public abstract class Disguise {
if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) { if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) {
if (isSelfDisguiseVisible()) { if (isSelfDisguiseVisible()) {
DisguiseUtilities.setupFakeDisguise(this); DisguiseUtilities.setupFakeDisguise(this);
} else } else {
DisguiseUtilities.removeSelfDisguise((Player) getEntity()); DisguiseUtilities.removeSelfDisguise((Player) getEntity());
}
} }
} }
} }
@ -762,9 +769,9 @@ public abstract class Disguise {
} }
/** /**
* Returns the list of people who have /disguiseViewSelf * Returns the list of people who have /disguiseViewSelf toggled on
* toggled on *
* @return * @return
*/ */
public static List<UUID> getViewSelf() { public static List<UUID> getViewSelf() {
return viewSelf; return viewSelf;

View File

@ -11,146 +11,78 @@ import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie; import org.bukkit.entity.Zombie;
public enum DisguiseType { public enum DisguiseType {
ARMOR_STAND(78), ARMOR_STAND(78),
ARROW(60), ARROW(60),
BAT, BAT,
BLAZE, BLAZE,
BOAT(1), BOAT(1),
CAVE_SPIDER, CAVE_SPIDER,
CHICKEN, CHICKEN,
COW, COW,
CREEPER, CREEPER,
DONKEY, DONKEY,
DROPPED_ITEM(2, 1), DROPPED_ITEM(2, 1),
EGG(62), EGG(62),
ELDER_GUARDIAN, ELDER_GUARDIAN,
ENDER_CRYSTAL(51), ENDER_CRYSTAL(51),
ENDER_DRAGON, ENDER_DRAGON,
ENDER_PEARL(65), ENDER_PEARL(65),
ENDER_SIGNAL(72), ENDER_SIGNAL(72),
ENDERMAN, ENDERMAN,
ENDERMITE, ENDERMITE,
EXPERIENCE_ORB, EXPERIENCE_ORB,
FALLING_BLOCK(70, 1), FALLING_BLOCK(70, 1),
FIREBALL(63, 0), FIREBALL(63, 0),
FIREWORK(76), FIREWORK(76),
FISHING_HOOK(90), FISHING_HOOK(90),
GHAST, GHAST,
GIANT, GIANT,
GUARDIAN, GUARDIAN,
HORSE, HORSE,
IRON_GOLEM, IRON_GOLEM,
ITEM_FRAME(71), ITEM_FRAME(71),
LEASH_HITCH(77), LEASH_HITCH(77),
MAGMA_CUBE, MAGMA_CUBE,
MINECART(10, 0), MINECART(10, 0),
MINECART_CHEST(10, 1), MINECART_CHEST(10, 1),
MINECART_COMMAND(10, 6), MINECART_COMMAND(10, 6),
MINECART_FURNACE(10, 2), MINECART_FURNACE(10, 2),
MINECART_HOPPER(10, 5), MINECART_HOPPER(10, 5),
MINECART_MOB_SPAWNER(10, 4), MINECART_MOB_SPAWNER(10, 4),
MINECART_TNT(10, 3), MINECART_TNT(10, 3),
MULE, MULE,
MUSHROOM_COW, MUSHROOM_COW,
OCELOT, OCELOT,
PAINTING, PAINTING,
PIG, PIG,
PIG_ZOMBIE, PIG_ZOMBIE,
PLAYER, PLAYER,
PRIMED_TNT(50), PRIMED_TNT(50),
RABBIT, RABBIT,
SHEEP, SHEEP,
SILVERFISH, SILVERFISH,
SKELETON, SKELETON,
SKELETON_HORSE, SKELETON_HORSE,
SLIME, SLIME,
SMALL_FIREBALL(64, 0), SMALL_FIREBALL(64, 0),
SNOWBALL(61), SNOWBALL(61),
SNOWMAN, SNOWMAN,
SPIDER, SPIDER,
SPLASH_POTION(73), SPLASH_POTION(73),
SQUID, SQUID,
THROWN_EXP_BOTTLE(75), THROWN_EXP_BOTTLE(75),
UNDEAD_HORSE, UNDEAD_HORSE,
VILLAGER, VILLAGER,
WITCH, WITCH,
WITHER, WITHER,
WITHER_SKELETON, WITHER_SKELETON,
WITHER_SKULL(66), WITHER_SKULL(66),
WOLF, WOLF,
ZOMBIE, ZOMBIE,
ZOMBIE_VILLAGER, ZOMBIE_VILLAGER,
UNKNOWN; UNKNOWN;
private static Method isVillager, getVariant, getSkeletonType, isElder; private static Method isVillager, getVariant, getSkeletonType, isElder;
static { static {
@ -160,27 +92,27 @@ public enum DisguiseType {
try { try {
DisguiseType toUse = type; DisguiseType toUse = type;
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;
case DONKEY: case DONKEY:
case MULE: case MULE:
case UNDEAD_HORSE: case UNDEAD_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
toUse = DisguiseType.HORSE; toUse = DisguiseType.HORSE;
break; break;
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
toUse = DisguiseType.ZOMBIE; toUse = DisguiseType.ZOMBIE;
break; break;
case WITHER_SKELETON: case WITHER_SKELETON:
toUse = DisguiseType.SKELETON; toUse = DisguiseType.SKELETON;
break; break;
case ELDER_GUARDIAN: case ELDER_GUARDIAN:
toUse = DisguiseType.GUARDIAN; toUse = DisguiseType.GUARDIAN;
break; break;
default: default:
break; break;
} }
type.setEntityType(EntityType.valueOf(toUse.name())); type.setEntityType(EntityType.valueOf(toUse.name()));
} catch (Throwable ex) { } catch (Throwable ex) {
@ -209,44 +141,44 @@ public enum DisguiseType {
public static DisguiseType getType(Entity entity) { public static DisguiseType getType(Entity entity) {
DisguiseType disguiseType = getType(entity.getType()); DisguiseType disguiseType = getType(entity.getType());
switch (disguiseType) { switch (disguiseType) {
case ZOMBIE: case ZOMBIE:
try { try {
if ((Boolean) isVillager.invoke(entity)) { if ((Boolean) isVillager.invoke(entity)) {
disguiseType = DisguiseType.ZOMBIE_VILLAGER; disguiseType = DisguiseType.ZOMBIE_VILLAGER;
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
} }
} catch (Exception ex) { break;
ex.printStackTrace(System.out); case HORSE:
} try {
break; Object variant = getVariant.invoke(entity);
case HORSE: disguiseType = DisguiseType.valueOf(((Enum) variant).name());
try { } catch (Exception ex) {
Object variant = getVariant.invoke(entity); ex.printStackTrace(System.out);
disguiseType = DisguiseType.valueOf(((Enum) variant).name());
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
break;
case SKELETON:
try {
Object type = getSkeletonType.invoke(entity);
if (type == Skeleton.SkeletonType.WITHER) {
disguiseType = DisguiseType.WITHER_SKELETON;
} }
} catch (Exception ex) { break;
ex.printStackTrace(System.out); case SKELETON:
} try {
break; Object type = getSkeletonType.invoke(entity);
case GUARDIAN: if (type == Skeleton.SkeletonType.WITHER) {
try { disguiseType = DisguiseType.WITHER_SKELETON;
if ((Boolean) isElder.invoke(entity)) { }
disguiseType = DisguiseType.ELDER_GUARDIAN; } catch (Exception ex) {
ex.printStackTrace(System.out);
} }
} catch (Exception ex) { break;
ex.printStackTrace(System.out); case GUARDIAN:
} try {
break; if ((Boolean) isElder.invoke(entity)) {
default: disguiseType = DisguiseType.ELDER_GUARDIAN;
break; }
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
break;
default:
break;
} }
return disguiseType; return disguiseType;
} }
@ -267,14 +199,14 @@ public enum DisguiseType {
for (int i = 0; i < ints.length; i++) { for (int i = 0; i < ints.length; i++) {
int value = ints[i]; int value = ints[i];
switch (i) { switch (i) {
case 0: case 0:
entityId = value; entityId = value;
break; break;
case 1: case 1:
defaultId = value; defaultId = value;
break; break;
default: default:
break; break;
} }
} }
} }
@ -317,7 +249,7 @@ public enum DisguiseType {
public boolean isPlayer() { public boolean isPlayer() {
return this == DisguiseType.PLAYER; return this == DisguiseType.PLAYER;
} }
public boolean isUnknown() { public boolean isUnknown() {
return this == DisguiseType.UNKNOWN; return this == DisguiseType.UNKNOWN;
} }
@ -332,8 +264,9 @@ public enum DisguiseType {
public String toReadable() { public String toReadable() {
String[] split = name().split("_"); String[] split = name().split("_");
for (int i = 0; i < split.length; i++) for (int i = 0; i < split.length; i++) {
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase(); split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
}
return StringUtils.join(split, " "); return StringUtils.join(split, " ");
} }
} }

View File

@ -24,7 +24,9 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
public class FlagWatcher { public class FlagWatcher {
public enum SlotType { public enum SlotType {
BOOTS(0), CHESTPLATE(2), HELD_ITEM(4), HELMET(3), LEGGINGS(1); BOOTS(0), CHESTPLATE(2), HELD_ITEM(4), HELMET(3), LEGGINGS(1);
// The ints is for bukkit. Not nms slots. // The ints is for bukkit. Not nms slots.
private int slotNo = 0; private int slotNo = 0;
@ -89,16 +91,19 @@ public class FlagWatcher {
sentValues.add(dataType); sentValues.add(dataType);
// Its sending the air metadata. This is the least commonly sent metadata which all entitys still share. // Its sending the air metadata. This is the least commonly sent metadata which all entitys still share.
// I send my custom values if I see this! // I send my custom values if I see this!
if (dataType == 1) if (dataType == 1) {
sendAllCustom = true; sendAllCustom = true;
}
Object value = null; Object value = null;
if (entityValues.containsKey(dataType)) { if (entityValues.containsKey(dataType)) {
if (entityValues.get(dataType) == null) if (entityValues.get(dataType) == null) {
continue; continue;
}
value = entityValues.get(dataType); value = entityValues.get(dataType);
} else if (backupEntityValues.containsKey(dataType)) { } else if (backupEntityValues.containsKey(dataType)) {
if (backupEntityValues.get(dataType) == null) if (backupEntityValues.get(dataType) == null) {
continue; continue;
}
value = backupEntityValues.get(dataType); value = backupEntityValues.get(dataType);
} }
if (value != null) { if (value != null) {
@ -107,24 +112,28 @@ public class FlagWatcher {
} }
boolean isDirty = watch.getDirtyState(); boolean isDirty = watch.getDirtyState();
watch = new WrappedWatchableObject(dataType, value); watch = new WrappedWatchableObject(dataType, value);
if (!isDirty) if (!isDirty) {
watch.setDirtyState(false); watch.setDirtyState(false);
}
} else { } else {
boolean isDirty = watch.getDirtyState(); boolean isDirty = watch.getDirtyState();
watch = new WrappedWatchableObject(dataType, watch.getValue()); watch = new WrappedWatchableObject(dataType, watch.getValue());
if (!isDirty) if (!isDirty) {
watch.setDirtyState(false); watch.setDirtyState(false);
}
} }
newList.add(watch); newList.add(watch);
} }
if (sendAllCustom) { if (sendAllCustom) {
// Its sending the entire meta data. Better add the custom meta // Its sending the entire meta data. Better add the custom meta
for (int value : entityValues.keySet()) { for (int value : entityValues.keySet()) {
if (sentValues.contains(value)) if (sentValues.contains(value)) {
continue; continue;
}
Object obj = entityValues.get(value); Object obj = entityValues.get(value);
if (obj == null) if (obj == null) {
continue; continue;
}
WrappedWatchableObject watch = new WrappedWatchableObject(value, obj); WrappedWatchableObject watch = new WrappedWatchableObject(value, obj);
newList.add(watch); newList.add(watch);
} }
@ -182,8 +191,9 @@ public class FlagWatcher {
} }
protected Object getValue(int no, Object backup) { protected Object getValue(int no, Object backup) {
if (entityValues.containsKey(no)) if (entityValues.containsKey(no)) {
return entityValues.get(no); return entityValues.get(no);
}
return backup; return backup;
} }
@ -246,12 +256,14 @@ public class FlagWatcher {
} }
protected void sendData(int... dataValues) { protected void sendData(int... dataValues) {
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) {
return; return;
}
List<WrappedWatchableObject> list = new ArrayList<>(); List<WrappedWatchableObject> list = new ArrayList<>();
for (int data : dataValues) { for (int data : dataValues) {
if (!entityValues.containsKey(data) || entityValues.get(data) == null) if (!entityValues.containsKey(data) || entityValues.get(data) == null) {
continue; continue;
}
Object value = entityValues.get(data); Object value = entityValues.get(data);
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) {
value = addEntityAnimations((Byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); value = addEntityAnimations((Byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
@ -348,8 +360,9 @@ public class FlagWatcher {
items[slot] = itemStack; items[slot] = itemStack;
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) { if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
slot++; slot++;
if (slot > 4) if (slot > 4) {
slot = 0; slot = 0;
}
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT); PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Object> mods = packet.getModifier(); StructureModifier<Object> mods = packet.getModifier();
mods.write(0, getDisguise().getEntity().getEntityId()); mods.write(0, getDisguise().getEntity().getEntityId());

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class MiscDisguise extends TargetedDisguise { public class MiscDisguise extends TargetedDisguise {
private int id = -1, data = 0; private int id = -1, data = 0;
public MiscDisguise(DisguiseType disguiseType) { public MiscDisguise(DisguiseType disguiseType) {
@ -52,31 +53,31 @@ public class MiscDisguise extends TargetedDisguise {
this.id = getType().getEntityId(); this.id = getType().getEntityId();
this.data = getType().getDefaultId(); this.data = getType().getDefaultId();
switch (disguiseType) { switch (disguiseType) {
// 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, firstParam) % Art.values().length]); ((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, firstParam) % Art.values().length]);
break; break;
case FALLING_BLOCK: case FALLING_BLOCK:
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, firstParam), 1, (short) Math.max(0, ((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, firstParam), 1, (short) Math.max(0,
secondParam))); secondParam)));
break; break;
case SPLASH_POTION: case SPLASH_POTION:
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, firstParam)); ((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, firstParam));
break; break;
case DROPPED_ITEM: case DROPPED_ITEM:
if (firstParam > 0) { if (firstParam > 0) {
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(firstParam, Math.max(0, secondParam))); ((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(firstParam, Math.max(0, secondParam)));
} }
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 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
case FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter case FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
case WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter case WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter
this.data = firstParam; this.data = firstParam;
break; break;
default: default:
break; break;
} }
} }
@ -134,14 +135,14 @@ public class MiscDisguise extends TargetedDisguise {
*/ */
public int getData() { public int getData() {
switch (getType()) { switch (getType()) {
case FALLING_BLOCK: case FALLING_BLOCK:
return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability(); return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
case PAINTING: case PAINTING:
return ((PaintingWatcher) getWatcher()).getArt().getId(); return ((PaintingWatcher) getWatcher()).getArt().getId();
case SPLASH_POTION: case SPLASH_POTION:
return ((SplashPotionWatcher) getWatcher()).getPotionId(); return ((SplashPotionWatcher) getWatcher()).getPotionId();
default: default:
return data; return data;
} }
} }
@ -245,4 +246,4 @@ public class MiscDisguise extends TargetedDisguise {
return (MiscDisguise) super.silentlyRemovePlayer(playername); return (MiscDisguise) super.silentlyRemovePlayer(playername);
} }
} }

View File

@ -184,4 +184,4 @@ public class MobDisguise extends TargetedDisguise {
public MobDisguise silentlyRemovePlayer(String playername) { public MobDisguise silentlyRemovePlayer(String playername) {
return (MobDisguise) super.silentlyRemovePlayer(playername); return (MobDisguise) super.silentlyRemovePlayer(playername);
} }
} }

View File

@ -13,14 +13,16 @@ import me.libraryaddict.disguise.utilities.LibsProfileLookup;
import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
public class PlayerDisguise extends TargetedDisguise { public class PlayerDisguise extends TargetedDisguise {
private LibsProfileLookup currentLookup; private LibsProfileLookup currentLookup;
private WrappedGameProfile gameProfile; private WrappedGameProfile gameProfile;
private String playerName; private String playerName;
private String skinToUse; private String skinToUse;
public PlayerDisguise(String name) { public PlayerDisguise(String name) {
if (name.length() > 16) if (name.length() > 16) {
name = name.substring(0, 16); name = name.substring(0, 16);
}
playerName = name; playerName = name;
createDisguise(DisguiseType.PLAYER); createDisguise(DisguiseType.PLAYER);
} }
@ -198,9 +200,8 @@ public class PlayerDisguise extends TargetedDisguise {
/** /**
* Set the GameProfile, without tampering. * Set the GameProfile, without tampering.
* *
* @param gameProfile * @param gameProfile GameProfile
* GameProfile
* @return * @return
*/ */
public PlayerDisguise setSkin(WrappedGameProfile gameProfile) { public PlayerDisguise setSkin(WrappedGameProfile gameProfile) {

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.disguisetypes; package me.libraryaddict.disguise.disguisetypes;
public enum RabbitType { public enum RabbitType {
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1); BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
public static RabbitType getType(int id) { public static RabbitType getType(int id) {

View File

@ -10,7 +10,9 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class TargetedDisguise extends Disguise { public abstract class TargetedDisguise extends Disguise {
public enum TargetType { public enum TargetType {
HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS; HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS;
} }

View File

@ -30,9 +30,9 @@ public class ArmorStandWatcher extends LivingWatcher {
private void set10(int value, boolean isTrue) { private void set10(int value, boolean isTrue) {
byte b1 = (Byte) getValue(10, (byte) 0); byte b1 = (Byte) getValue(10, (byte) 0);
if (isTrue) if (isTrue) {
b1 = (byte) (b1 | value); b1 = (byte) (b1 | value);
else { } else {
b1 = (byte) (b1 & value); b1 = (byte) (b1 & value);
} }
setValue(10, b1); setValue(10, b1);

View File

@ -9,6 +9,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class FallingBlockWatcher extends FlagWatcher { public class FallingBlockWatcher extends FlagWatcher {
private ItemStack block; private ItemStack block;
public FallingBlockWatcher(Disguise disguise) { public FallingBlockWatcher(Disguise disguise) {

View File

@ -23,14 +23,14 @@ public class HorseWatcher extends AgeableWatcher {
public ItemStack getHorseArmor() { public ItemStack getHorseArmor() {
int horseValue = getHorseArmorAsInt(); int horseValue = getHorseArmorAsInt();
switch (horseValue) { switch (horseValue) {
case 1: case 1:
return new ItemStack(Material.getMaterial("IRON_BARDING")); return new ItemStack(Material.getMaterial("IRON_BARDING"));
case 2: case 2:
return new ItemStack(Material.getMaterial("GOLD_BARDING")); return new ItemStack(Material.getMaterial("GOLD_BARDING"));
case 3: case 3:
return new ItemStack(Material.getMaterial("DIAMOND_BARDING")); return new ItemStack(Material.getMaterial("DIAMOND_BARDING"));
default: default:
break; break;
} }
return null; return null;
} }

View File

@ -11,8 +11,9 @@ public class ItemFrameWatcher extends FlagWatcher {
} }
public ItemStack getItem() { public ItemStack getItem() {
if (getValue(2, null) == null) if (getValue(2, null) == null) {
return new ItemStack(0); return new ItemStack(0);
}
return (ItemStack) getValue(8, null); return (ItemStack) getValue(8, null);
} }
@ -21,8 +22,9 @@ public class ItemFrameWatcher extends FlagWatcher {
} }
public void setItem(ItemStack newItem) { public void setItem(ItemStack newItem) {
if (newItem == null) if (newItem == null) {
newItem = new ItemStack(0); newItem = new ItemStack(0);
}
newItem = newItem.clone(); newItem = newItem.clone();
newItem.setAmount(1); newItem.setAmount(1);
setValue(8, newItem); setValue(8, newItem);

View File

@ -23,8 +23,10 @@ import com.comphenix.protocol.wrappers.WrappedAttribute;
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder; import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
public class LivingWatcher extends FlagWatcher { public class LivingWatcher extends FlagWatcher {
static Object[] list; static Object[] list;
static Method potionNo; static Method potionNo;
static { static {
try { try {
list = (Object[]) ReflectionManager.getNmsField("MobEffectList", "byId").get(null); list = (Object[]) ReflectionManager.getNmsField("MobEffectList", "byId").get(null);

View File

@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class PaintingWatcher extends FlagWatcher { public class PaintingWatcher extends FlagWatcher {
private Art painting; private Art painting;
public PaintingWatcher(Disguise disguise) { public PaintingWatcher(Disguise disguise) {

View File

@ -16,6 +16,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion; import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
public class PlayerWatcher extends LivingWatcher { public class PlayerWatcher extends LivingWatcher {
private boolean isInBed; private boolean isInBed;
private BlockFace sleepingDirection; private BlockFace sleepingDirection;
@ -82,6 +83,7 @@ public class PlayerWatcher extends LivingWatcher {
/** /**
* If no BlockFace is supplied. It grabs it from the entities facing direction if applicable. * If no BlockFace is supplied. It grabs it from the entities facing direction if applicable.
*
* @param sleeping * @param sleeping
* @param sleepingDirection * @param sleepingDirection
*/ */

View File

@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class SplashPotionWatcher extends FlagWatcher { public class SplashPotionWatcher extends FlagWatcher {
private int potionId; private int potionId;
public SplashPotionWatcher(Disguise disguise) { public SplashPotionWatcher(Disguise disguise) {

View File

@ -17,11 +17,11 @@ public class VillagerWatcher extends AgeableWatcher {
return Profession.values()[(Integer) getValue(16, 0)]; return Profession.values()[(Integer) getValue(16, 0)];
} }
public void setProfession(int professionId){ public void setProfession(int professionId) {
setValue(16, professionId % 6); setValue(16, professionId % 6);
sendData(16); sendData(16);
} }
public void setProfession(Profession newProfession) { public void setProfession(Profession newProfession) {
setProfession(newProfession.getId()); setProfession(newProfession.getId());
} }

View File

@ -21,7 +21,7 @@ public class WitherWatcher extends LivingWatcher {
} }
public int[] getTargets() { public int[] getTargets() {
return new int[] { (Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0) }; return new int[]{(Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0)};
} }
public void setInvul(int invulnerability) { public void setInvul(int invulnerability) {

View File

@ -8,6 +8,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class DisguiseEvent extends Event implements Cancellable { public class DisguiseEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
@ -45,4 +46,4 @@ public class DisguiseEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
isCancelled = cancelled; isCancelled = cancelled;
} }
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
public class UndisguiseEvent extends Event implements Cancellable { public class UndisguiseEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
@ -45,4 +46,4 @@ public class UndisguiseEvent extends Event implements Cancellable {
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
isCancelled = cancelled; isCancelled = cancelled;
} }
} }

View File

@ -35,6 +35,7 @@ import org.bukkit.potion.PotionEffectType;
public abstract class BaseDisguiseCommand implements CommandExecutor { public abstract class BaseDisguiseCommand implements CommandExecutor {
public class DisguiseParseException extends Exception { public class DisguiseParseException extends Exception {
private static final long serialVersionUID = 1276971370793124510L; private static final long serialVersionUID = 1276971370793124510L;
public DisguiseParseException() { public DisguiseParseException() {
@ -45,7 +46,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
super(string); super(string);
} }
} }
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) { protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
ArrayList<String> allowedDisguises = new ArrayList<>(); ArrayList<String> allowedDisguises = new ArrayList<>();
for (DisguiseType type : hashMap.keySet()) { for (DisguiseType type : hashMap.keySet()) {
@ -61,30 +62,30 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
protected HashMap<String, Boolean> getDisguisePermission(CommandSender sender, DisguiseType type) { protected HashMap<String, Boolean> getDisguisePermission(CommandSender sender, DisguiseType type) {
switch (type) { switch (type) {
case PLAYER: case PLAYER:
case FALLING_BLOCK: case FALLING_BLOCK:
case PAINTING: case PAINTING:
case SPLASH_POTION: case SPLASH_POTION:
case FISHING_HOOK: case FISHING_HOOK:
case DROPPED_ITEM: case DROPPED_ITEM:
HashMap<String, Boolean> returns = new HashMap<>(); HashMap<String, Boolean> returns = new HashMap<>();
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + "."; String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) { for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
String lowerPerm = permission.getPermission().toLowerCase(); String lowerPerm = permission.getPermission().toLowerCase();
if (lowerPerm.startsWith(beginning)) { if (lowerPerm.startsWith(beginning)) {
String[] split = lowerPerm.substring(beginning.length()).split("\\."); String[] split = lowerPerm.substring(beginning.length()).split("\\.");
if (split.length > 1) { if (split.length > 1) {
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) { if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
for (int i = 1; i < split.length; i++) { for (int i = 1; i < split.length; i++) {
returns.put(split[i], permission.getValue()); returns.put(split[i], permission.getValue());
}
} }
} }
} }
} }
} return returns;
return returns; default:
default: return new HashMap<>();
return new HashMap<>();
} }
} }
@ -92,8 +93,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
Method[] methods = watcherClass.getMethods(); Method[] methods = watcherClass.getMethods();
methods = Arrays.copyOf(methods, methods.length + 4); methods = Arrays.copyOf(methods, methods.length + 4);
int i = 4; int i = 4;
for (String methodName : new String[] { "setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf", for (String methodName : new String[]{"setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
"setHearSelfDisguise" }) { "setHearSelfDisguise"}) {
try { try {
methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class); methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class);
} catch (Exception ex) { } catch (Exception ex) {
@ -105,9 +106,10 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
/** /**
* Get perms for the node. Returns a hashmap of allowed disguisetypes and their options * Get perms for the node. Returns a hashmap of allowed disguisetypes and their options
*
* @param sender * @param sender
* @param permissionNode * @param permissionNode
* @return * @return
*/ */
protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) { protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) {
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>(); HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>();
@ -265,8 +267,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
option = option.substring(1); option = option.substring(1);
isRemove = false; isRemove = false;
} }
if (option.equals("baby")) if (option.equals("baby")) {
option = "setbaby"; option = "setbaby";
}
list.add(option); list.add(option);
} }
HashMap<ArrayList<String>, Boolean> options = new HashMap<>(); HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
@ -293,16 +296,15 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} }
/** /**
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The * Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the disguise has been feed a proper disguisetype.
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the *
* disguise has been feed a proper disguisetype.
* @param sender * @param sender
* @param args * @param args
* @param map * @param map
* @return * @return
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException * @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
* @throws java.lang.IllegalAccessException * @throws java.lang.IllegalAccessException
* @throws java.lang.reflect.InvocationTargetException * @throws java.lang.reflect.InvocationTargetException
*/ */
protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException, protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException,
IllegalAccessException, InvocationTargetException { IllegalAccessException, InvocationTargetException {
@ -366,7 +368,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} else { } else {
if (!disguiseOptions.isEmpty() if (!disguiseOptions.isEmpty()
&& (!disguiseOptions.containsKey(args[1].toLowerCase()) || !disguiseOptions && (!disguiseOptions.containsKey(args[1].toLowerCase()) || !disguiseOptions
.get(args[1].toLowerCase()))) { .get(args[1].toLowerCase()))) {
throw new DisguiseParseException(ChatColor.RED + "Error! You don't have permission to use that name!"); throw new DisguiseParseException(ChatColor.RED + "Error! You don't have permission to use that name!");
} }
args[1] = args[1].replace("\\_", " "); args[1] = args[1].replace("\\_", " ");
@ -415,19 +417,19 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} }
if (miscId != -1) { if (miscId != -1) {
switch (disguiseType) { switch (disguiseType) {
case PAINTING: case PAINTING:
case FALLING_BLOCK: case FALLING_BLOCK:
case SPLASH_POTION: case SPLASH_POTION:
case DROPPED_ITEM: case DROPPED_ITEM:
case FISHING_HOOK: case FISHING_HOOK:
case ARROW: case ARROW:
case SMALL_FIREBALL: case SMALL_FIREBALL:
case FIREBALL: case FIREBALL:
case WITHER_SKULL: case WITHER_SKULL:
break; break;
default: default:
throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable() throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable()
+ " doesn't know what to do with " + args[1] + "!"); + " doesn't know what to do with " + args[1] + "!");
} }
toSkip++; toSkip++;
// If they also defined a data value // If they also defined a data value
@ -577,8 +579,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
if (potionType == null && isNumeric(valueString)) { if (potionType == null && isNumeric(valueString)) {
potionType = PotionEffectType.getById(Integer.parseInt(valueString)); potionType = PotionEffectType.getById(Integer.parseInt(valueString));
} }
if (potionType == null) if (potionType == null) {
throw new DisguiseParseException(); throw new DisguiseParseException();
}
value = potionType; value = potionType;
} catch (Exception ex) { } catch (Exception ex) {
throw parseToException("a potioneffect type", valueString, methodName); throw parseToException("a potioneffect type", valueString, methodName);
@ -597,8 +600,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} else if (param == BlockFace.class) { } else if (param == BlockFace.class) {
try { try {
BlockFace face = BlockFace.valueOf(valueString.toUpperCase()); BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
if (face.ordinal() > 4) if (face.ordinal() > 4) {
throw new DisguiseParseException(); throw new DisguiseParseException();
}
value = face; value = face;
} catch (Exception ex) { } catch (Exception ex) {
throw parseToException("a direction (north, east, south, west, up)", valueString, methodName); throw parseToException("a direction (north, east, south, west, up)", valueString, methodName);
@ -661,10 +665,11 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
usedOptions.add(methodName.toLowerCase()); usedOptions.add(methodName.toLowerCase());
} }
doCheck(optionPermissions, usedOptions); doCheck(optionPermissions, usedOptions);
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
methodToUse.invoke(disguise.getWatcher(), value); methodToUse.invoke(disguise.getWatcher(), value);
else } else {
methodToUse.invoke(disguise, value); methodToUse.invoke(disguise, value);
}
} }
// Alright. We've constructed our disguise. // Alright. We've constructed our disguise.
return disguise; return disguise;

View File

@ -13,7 +13,6 @@ import java.util.jar.JarFile;
/** /**
* User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester * User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester
*/ */
// Code for this taken and slightly modified from // Code for this taken and slightly modified from
// https://github.com/ddopson/java-class-enumerator // https://github.com/ddopson/java-class-enumerator
public class ClassGetter { public class ClassGetter {
@ -59,8 +58,9 @@ public class ClassGetter {
} }
if (className != null) { if (className != null) {
Class<?> c = loadClass(className); Class<?> c = loadClass(className);
if (c != null) if (c != null) {
classes.add(c); classes.add(c);
}
} }
} }
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -11,107 +11,69 @@ import org.bukkit.Sound;
* Only living disguises go in here! * Only living disguises go in here!
*/ */
public enum DisguiseSound { public enum DisguiseSound {
ARROW(null, null, null, null, "random.bowhit"),
ARROW(null, null, null, null, "random.bowhit"),
BAT("mob.bat.hurt", null, "mob.bat.death", "mob.bat.idle", "damage.fallsmall", "mob.bat.loop", "damage.fallbig", BAT("mob.bat.hurt", null, "mob.bat.death", "mob.bat.idle", "damage.fallsmall", "mob.bat.loop", "damage.fallbig",
"mob.bat.takeoff"), "mob.bat.takeoff"),
BLAZE("mob.blaze.hit", null, "mob.blaze.death", "mob.blaze.breathe", "damage.fallsmall", "damage.fallbig"), BLAZE("mob.blaze.hit", null, "mob.blaze.death", "mob.blaze.breathe", "damage.fallsmall", "damage.fallbig"),
CAVE_SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"), CAVE_SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall", CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall",
"mob.chicken.plop", "damage.fallbig"), "mob.chicken.plop", "damage.fallbig"),
COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"), COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
CREEPER("mob.creeper.say", "step.grass", "mob.creeper.death", null), CREEPER("mob.creeper.say", "step.grass", "mob.creeper.death", null),
DONKEY("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle", "mob.horse.gallop", DONKEY("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle", "mob.horse.gallop",
"mob.horse.leather", "mob.horse.donkey.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.leather", "mob.horse.donkey.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft",
"mob.horse.land", "mob.horse.jump", "mob.horse.angry"), "mob.horse.land", "mob.horse.jump", "mob.horse.angry"),
ELDER_GUARDIAN("mob.guardian.elder.hit", null, "mob.guardian.elder.death", "mob.guardian.elder.death"), ELDER_GUARDIAN("mob.guardian.elder.hit", null, "mob.guardian.elder.death", "mob.guardian.elder.death"),
ENDER_DRAGON("mob.enderdragon.hit", null, "mob.enderdragon.end", "mob.enderdragon.growl", "damage.fallsmall", ENDER_DRAGON("mob.enderdragon.hit", null, "mob.enderdragon.end", "mob.enderdragon.growl", "damage.fallsmall",
"mob.enderdragon.wings", "damage.fallbig"), "mob.enderdragon.wings", "damage.fallbig"),
ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream", ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream",
"mob.endermen.portal", "mob.endermen.stare"), "mob.endermen.portal", "mob.endermen.stare"),
ENDERMITE("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"), ENDERMITE("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
GHAST("mob.ghast.scream", null, "mob.ghast.death", "mob.ghast.moan", "damage.fallsmall", "mob.ghast.fireball", GHAST("mob.ghast.scream", null, "mob.ghast.death", "mob.ghast.moan", "damage.fallsmall", "mob.ghast.fireball",
"damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"), "damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"),
GIANT("damage.hit", "step.grass", null, null), GIANT("damage.hit", "step.grass", null, null),
GUARDIAN("mob.guardian.hit", null, "mob.guardian.death", "mob.guardian.death"), GUARDIAN("mob.guardian.hit", null, "mob.guardian.death", "mob.guardian.death"),
HORSE("mob.horse.hit", "step.grass", "mob.horse.death", "mob.horse.idle", "mob.horse.gallop", "mob.horse.leather", HORSE("mob.horse.hit", "step.grass", "mob.horse.death", "mob.horse.idle", "mob.horse.gallop", "mob.horse.leather",
"mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry",
"mob.horse.leather"), "mob.horse.leather"),
IRON_GOLEM("mob.irongolem.hit", "mob.irongolem.walk", "mob.irongolem.death", "mob.irongolem.throw"), IRON_GOLEM("mob.irongolem.hit", "mob.irongolem.walk", "mob.irongolem.death", "mob.irongolem.throw"),
MAGMA_CUBE("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"), MAGMA_CUBE("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
MULE("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle"), MULE("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle"),
MUSHROOM_COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"), MUSHROOM_COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
OCELOT("mob.cat.hitt", "step.grass", "mob.cat.hitt", "mob.cat.meow", "mob.cat.purreow", "mob.cat.purr"), OCELOT("mob.cat.hitt", "step.grass", "mob.cat.hitt", "mob.cat.meow", "mob.cat.purreow", "mob.cat.purr"),
PIG("mob.pig.say", "mob.pig.step", "mob.pig.death", "mob.pig.say"), PIG("mob.pig.say", "mob.pig.step", "mob.pig.death", "mob.pig.say"),
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"), PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null), PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null),
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"), RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
SHEEP("mob.sheep.say", "mob.sheep.step", null, "mob.sheep.say", "mob.sheep.shear"), SHEEP("mob.sheep.say", "mob.sheep.step", null, "mob.sheep.say", "mob.sheep.shear"),
SILVERFISH("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"), SILVERFISH("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"), SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
SKELETON_HORSE("mob.horse.skeleton.hit", "step.grass", "mob.horse.skeleton.death", "mob.horse.skeleton.idle", SKELETON_HORSE("mob.horse.skeleton.hit", "step.grass", "mob.horse.skeleton.death", "mob.horse.skeleton.idle",
"mob.horse.gallop", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.gallop", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land",
"mob.horse.jump", "mob.horse.angry"), "mob.horse.jump", "mob.horse.angry"),
SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"), SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
SNOWMAN(), SNOWMAN(),
SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"), SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
SQUID(), SQUID(),
UNDEAD_HORSE("mob.horse.zombie.hit", "step.grass", "mob.horse.zombie.death", "mob.horse.zombie.idle", "mob.horse.gallop", UNDEAD_HORSE("mob.horse.zombie.hit", "step.grass", "mob.horse.zombie.death", "mob.horse.zombie.idle", "mob.horse.gallop",
"mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump",
"mob.horse.angry"), "mob.horse.angry"),
VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no", VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no",
"mob.villager.yes"), "mob.villager.yes"),
WITCH("mob.witch.hurt", null, "mob.witch.death", "mob.witch.idle"), WITCH("mob.witch.hurt", null, "mob.witch.death", "mob.witch.idle"),
WITHER("mob.wither.hurt", null, "mob.wither.death", "mob.wither.idle", "damage.fallsmall", "mob.wither.spawn", WITHER("mob.wither.hurt", null, "mob.wither.death", "mob.wither.idle", "damage.fallsmall", "mob.wither.spawn",
"damage.fallbig", "mob.wither.shoot"), "damage.fallbig", "mob.wither.shoot"),
WITHER_SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"), WITHER_SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine", WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"), "mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect", ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"), "mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"),
ZOMBIE_VILLAGER("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect", ZOMBIE_VILLAGER("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"); "mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
public enum SoundType { public enum SoundType {
CANCEL, DEATH, HURT, IDLE, STEP; CANCEL, DEATH, HURT, IDLE, STEP;
} }
@ -131,9 +93,9 @@ public enum DisguiseSound {
for (int i = 0; i < sounds.length; i++) { for (int i = 0; i < sounds.length; i++) {
Object obj = sounds[i]; Object obj = sounds[i];
String s; String s;
if (obj == null) if (obj == null) {
continue; continue;
else if (obj instanceof String) { } else if (obj instanceof String) {
s = (String) obj; s = (String) obj;
} else if (obj instanceof Sound) { } else if (obj instanceof Sound) {
s = ReflectionManager.getCraftSound((Sound) obj); s = ReflectionManager.getCraftSound((Sound) obj);
@ -142,21 +104,21 @@ public enum DisguiseSound {
throw new RuntimeException("Was given a unknown object " + obj); throw new RuntimeException("Was given a unknown object " + obj);
} }
switch (i) { switch (i) {
case 0: case 0:
disguiseSounds.put(SoundType.HURT, s); disguiseSounds.put(SoundType.HURT, s);
break; break;
case 1: case 1:
disguiseSounds.put(SoundType.STEP, s); disguiseSounds.put(SoundType.STEP, s);
break; break;
case 2: case 2:
disguiseSounds.put(SoundType.DEATH, s); disguiseSounds.put(SoundType.DEATH, s);
break; break;
case 3: case 3:
disguiseSounds.put(SoundType.IDLE, s); disguiseSounds.put(SoundType.IDLE, s);
break; break;
default: default:
cancelSounds.add(s); cancelSounds.add(s);
break; break;
} }
} }
} }
@ -166,8 +128,9 @@ public enum DisguiseSound {
} }
public String getSound(SoundType type) { public String getSound(SoundType type) {
if (type == null || !disguiseSounds.containsKey(type)) if (type == null || !disguiseSounds.containsKey(type)) {
return null; return null;
}
return disguiseSounds.get(type); return disguiseSounds.get(type);
} }
@ -179,18 +142,22 @@ public enum DisguiseSound {
* Used to check if this sound name is owned by this disguise sound. * Used to check if this sound name is owned by this disguise sound.
*/ */
public SoundType getType(String sound, boolean ignoreDamage) { public SoundType getType(String sound, boolean ignoreDamage) {
if (isCancelSound(sound)) if (isCancelSound(sound)) {
return SoundType.CANCEL; return SoundType.CANCEL;
}
if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.") if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.")
&& sound.startsWith("step.")) && sound.startsWith("step.")) {
return SoundType.STEP; return SoundType.STEP;
}
for (SoundType type : SoundType.values()) { for (SoundType type : SoundType.values()) {
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) {
continue; continue;
}
String s = disguiseSounds.get(type); String s = disguiseSounds.get(type);
if (s != null) { if (s != null) {
if (s.equals(sound)) if (s.equals(sound)) {
return type; return type;
}
} }
} }
return null; return null;
@ -205,9 +172,9 @@ public enum DisguiseSound {
} }
public void removeSound(SoundType type, String sound) { public void removeSound(SoundType type, String sound) {
if (type == SoundType.CANCEL) if (type == SoundType.CANCEL) {
cancelSounds.remove(sound); cancelSounds.remove(sound);
else { } else {
disguiseSounds.remove(type); disguiseSounds.remove(type);
} }
} }
@ -221,9 +188,9 @@ public enum DisguiseSound {
} }
public void setSound(SoundType type, String sound) { public void setSound(SoundType type, String sound) {
if (type == SoundType.CANCEL) if (type == SoundType.CANCEL) {
cancelSounds.add(sound); cancelSounds.add(sound);
else { } else {
disguiseSounds.put(type, sound); disguiseSounds.put(type, sound);
} }
} }

View File

@ -51,20 +51,20 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedWatchableObject; import com.comphenix.protocol.wrappers.WrappedWatchableObject;
public class DisguiseUtilities { public class DisguiseUtilities {
/** /**
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of * This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of the plugin to do that.
* the plugin to do that.
*/ */
private static HashSet<String> addedByPlugins = new HashSet<>(); private static HashSet<String> addedByPlugins = new HashSet<>();
private static Object bedChunk; private static Object bedChunk;
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>(); private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
/** /**
* A hashmap of the uuid's of entitys, alive and dead. And their disguises in use * A hashmap of the uuid's of entitys, alive and dead. And their disguises in use
**/ *
*/
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>(); private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
/** /**
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for * Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for a max of a second.
* a max of a second.
*/ */
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>(); private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
/** /**
@ -99,7 +99,7 @@ public class DisguiseUtilities {
ReflectionManager.getNmsClass("IBlockData")); 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);
Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class); Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
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}) {
setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal())); setType.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), fromLegacyData.invoke(block, face.ordinal()));
setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0); setSky.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0); setEmitted.invoke(chunkSection, 1 + face.getModX(), 0, 1 + face.getModZ(), 0);
@ -179,8 +179,7 @@ public class DisguiseUtilities {
} }
/** /**
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the * If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the observers in the disguise don't see any other disguise.
* observers in the disguise don't see any other disguise.
*/ */
public static void checkConflicts(TargetedDisguise disguise, String name) { public static void checkConflicts(TargetedDisguise disguise, String name) {
// If the disguise is being used.. Else we may accidentally undisguise something else // If the disguise is being used.. Else we may accidentally undisguise something else
@ -237,7 +236,6 @@ public class DisguiseUtilities {
// System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS // System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS
// + " on a entity. Removed the old disguise."); // + " on a entity. Removed the old disguise.");
disguiseItel.remove(); disguiseItel.remove();
d.removeDisguise(); d.removeDisguise();
} }
@ -258,7 +256,7 @@ public class DisguiseUtilities {
entityTrackerEntry); entityTrackerEntry);
HashSet cloned = (HashSet) trackedPlayers.clone(); HashSet cloned = (HashSet) trackedPlayers.clone();
PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY); PacketContainer destroyPacket = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY);
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() }); destroyPacket.getIntegerArrays().write(0, new int[]{disguise.getEntity().getEntityId()});
for (Object p : cloned) { for (Object p : cloned) {
Player player = (Player) ReflectionManager.getBukkitEntity(p); Player player = (Player) ReflectionManager.getBukkitEntity(p);
if (player == disguise.getEntity() || disguise.canSee(player)) { if (player == disguise.getEntity() || disguise.canSee(player)) {
@ -281,7 +279,7 @@ public class DisguiseUtilities {
if (disguiseValues.getBabyBox() != null) { if (disguiseValues.getBabyBox() != null) {
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby()) if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby())
|| (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher()) || (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher())
.isBaby())) { .isBaby())) {
disguiseBox = disguiseValues.getBabyBox(); disguiseBox = disguiseValues.getBabyBox();
} }
} }
@ -307,7 +305,7 @@ public class DisguiseUtilities {
public static PacketContainer[] getBedChunkPacket(Player player, Location newLoc, Location oldLoc) { public static PacketContainer[] getBedChunkPacket(Player player, Location newLoc, Location oldLoc) {
int i = 0; int i = 0;
PacketContainer[] packets = new PacketContainer[newLoc != null ? 2 + (oldLoc != null ? 1 : 0) : 1]; PacketContainer[] packets = new PacketContainer[newLoc != null ? 2 + (oldLoc != null ? 1 : 0) : 1];
for (Location loc : new Location[] { oldLoc, newLoc }) { for (Location loc : new Location[]{oldLoc, newLoc}) {
if (loc == null) { if (loc == null) {
continue; continue;
} }
@ -360,7 +358,7 @@ public class DisguiseUtilities {
ints.write(1, (int) Math.floor(loc.getX() * 32)); ints.write(1, (int) Math.floor(loc.getX() * 32));
ints.write(2, (int) Math.floor((PacketsManager.getYModifier(disguise.getEntity(), disguise) + loc.getY()) * 32)); ints.write(2, (int) Math.floor((PacketsManager.getYModifier(disguise.getEntity(), disguise) + loc.getY()) * 32));
ints.write(3, (int) Math.floor(loc.getZ() * 32)); ints.write(3, (int) Math.floor(loc.getZ() * 32));
return new PacketContainer[] { setBed, teleport }; return new PacketContainer[]{setBed, teleport};
} }
@ -433,8 +431,9 @@ public class DisguiseUtilities {
/** /**
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise. * Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
*
* @param disguise * @param disguise
* @return * @return
*/ */
public static ArrayList<Player> getPerverts(Disguise disguise) { public static ArrayList<Player> getPerverts(Disguise disguise) {
ArrayList<Player> players = new ArrayList<>(); ArrayList<Player> players = new ArrayList<>();
@ -469,7 +468,7 @@ public class DisguiseUtilities {
if (DisguiseAPI.isDisguiseInUse(disguise) if (DisguiseAPI.isDisguiseInUse(disguise)
&& (!gameProfile.getName().equals( && (!gameProfile.getName().equals(
disguise.getSkin() != null ? disguise.getSkin() : disguise.getName()) disguise.getSkin() != null ? disguise.getSkin() : disguise.getName())
|| !gameProfile.getProperties().isEmpty())) { || !gameProfile.getProperties().isEmpty())) {
disguise.setGameProfile(gameProfile); disguise.setGameProfile(gameProfile);
DisguiseUtilities.refreshTrackers(disguise); DisguiseUtilities.refreshTrackers(disguise);
} }
@ -478,8 +477,7 @@ public class DisguiseUtilities {
} }
/** /**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup * Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/ */
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) { public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
@ -550,8 +548,7 @@ public class DisguiseUtilities {
} }
/** /**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup * Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/ */
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) { public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn); return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
@ -582,14 +579,14 @@ public class DisguiseUtilities {
} }
/** /**
* Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated * Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's version every single packet..
* in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's
* version every single packet..
*/ */
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher, public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
List<WrappedWatchableObject> list) { List<WrappedWatchableObject> list) {
if (true) // Use for future protocol compatibility if (true) // Use for future protocol compatibility
{
return list; return list;
}
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>(); ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>();
ArrayList<WrappedWatchableObject> backups = new ArrayList<>(); ArrayList<WrappedWatchableObject> backups = new ArrayList<>();
for (WrappedWatchableObject obj : list) { for (WrappedWatchableObject obj : list) {
@ -598,7 +595,7 @@ public class DisguiseUtilities {
continue; continue;
} }
switch (obj.getIndex()) { switch (obj.getIndex()) {
// TODO: Future version support // TODO: Future version support
} }
} }
Iterator<WrappedWatchableObject> itel = backups.iterator(); Iterator<WrappedWatchableObject> itel = backups.iterator();
@ -625,8 +622,9 @@ public class DisguiseUtilities {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) { && ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
removeSelfDisguise((Player) disguise.getEntity()); removeSelfDisguise((Player) disguise.getEntity());
if (disguise.isSelfDisguiseVisible()) if (disguise.isSelfDisguiseVisible()) {
selfDisguised.add(disguise.getEntity().getUniqueId()); selfDisguised.add(disguise.getEntity().getUniqueId());
}
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket); ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
@Override @Override
@ -820,10 +818,10 @@ public class DisguiseUtilities {
ProtocolLibrary.getProtocolManager().sendServerPacket( ProtocolLibrary.getProtocolManager().sendServerPacket(
player, player,
ProtocolLibrary ProtocolLibrary
.getProtocolManager() .getProtocolManager()
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(), .createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
WrappedDataWatcher.getEntityWatcher(player), true) WrappedDataWatcher.getEntityWatcher(player), true)
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true)); .createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(System.out); ex.printStackTrace(System.out);
} }
@ -891,11 +889,11 @@ public class DisguiseUtilities {
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) { if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
sendSelfPacket(player, sendSelfPacket(player,
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle()) manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player, player.getVehicle())
.createPacket(0, player, player.getVehicle())); .createPacket(0, player, player.getVehicle()));
} else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) { } else if (player.getPassenger() != null && player.getEntityId() > player.getPassenger().getEntityId()) {
sendSelfPacket(player, sendSelfPacket(player,
manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player) manager.createPacketConstructor(PacketType.Play.Server.ATTACH_ENTITY, 0, player.getPassenger(), player)
.createPacket(0, player.getPassenger(), player)); .createPacket(0, player.getPassenger(), player));
} }
// Resend the armor // Resend the armor
@ -928,7 +926,7 @@ public class DisguiseUtilities {
Object mobEffect = ReflectionManager.createMobEffect(potionEffect); Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
sendSelfPacket(player, sendSelfPacket(player,
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), mobEffect) manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
.createPacket(player.getEntityId(), mobEffect)); .createPacket(player.getEntityId(), mobEffect));
} }
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(System.out); ex.printStackTrace(System.out);
@ -944,7 +942,7 @@ public class DisguiseUtilities {
final PacketContainer[] delayed = transformed == null ? null : transformed[1]; final PacketContainer[] delayed = transformed == null ? null : transformed[1];
try { try {
if (packets == null) { if (packets == null) {
packets = new PacketContainer[] { packet }; packets = new PacketContainer[]{packet};
} }
for (PacketContainer p : packets) { for (PacketContainer p : packets) {
p = p.deepClone(); p = p.deepClone();
@ -972,6 +970,7 @@ public class DisguiseUtilities {
/** /**
* Setup it so he can see himself when disguised * Setup it so he can see himself when disguised
*
* @param disguise * @param disguise
*/ */
public static void setupFakeDisguise(final Disguise disguise) { public static void setupFakeDisguise(final Disguise disguise) {

View File

@ -10,28 +10,28 @@ public class DisguiseValues {
public static DisguiseValues getDisguiseValues(DisguiseType type) { public static DisguiseValues getDisguiseValues(DisguiseType type) {
switch (type) { switch (type) {
case DONKEY: case DONKEY:
case MULE: case MULE:
case UNDEAD_HORSE: case UNDEAD_HORSE:
case SKELETON_HORSE: case SKELETON_HORSE:
type = DisguiseType.HORSE; type = DisguiseType.HORSE;
break; break;
case MINECART_CHEST: case MINECART_CHEST:
case MINECART_COMMAND: case MINECART_COMMAND:
case MINECART_FURNACE: case MINECART_FURNACE:
case MINECART_HOPPER: case MINECART_HOPPER:
case MINECART_TNT: case MINECART_TNT:
case MINECART_MOB_SPAWNER: case MINECART_MOB_SPAWNER:
type = DisguiseType.MINECART; type = DisguiseType.MINECART;
break; break;
case WITHER_SKELETON: case WITHER_SKELETON:
type = DisguiseType.SKELETON; type = DisguiseType.SKELETON;
break; break;
case ZOMBIE_VILLAGER: case ZOMBIE_VILLAGER:
type = DisguiseType.ZOMBIE; type = DisguiseType.ZOMBIE;
break; break;
default: default:
break; break;
} }
return values.get(type); return values.get(type);
} }
@ -76,38 +76,38 @@ public class DisguiseValues {
double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D); double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D);
switch (enumEntitySize) { switch (enumEntitySize) {
case 1: case 1:
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) { if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
return (int) Math.ceil(paramDouble * 32.0D);
}
return (int) Math.floor(paramDouble * 32.0D);
case 2:
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
return (int) Math.floor(paramDouble * 32.0D);
}
return (int) Math.ceil(paramDouble * 32.0D); return (int) Math.ceil(paramDouble * 32.0D);
} case 3:
if (d > 0.0D) {
return (int) Math.floor(paramDouble * 32.0D);
}
return (int) Math.floor(paramDouble * 32.0D);
case 2:
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
return (int) Math.floor(paramDouble * 32.0D);
}
return (int) Math.ceil(paramDouble * 32.0D);
case 3:
if (d > 0.0D) {
return (int) Math.floor(paramDouble * 32.0D);
}
return (int) Math.ceil(paramDouble * 32.0D);
case 4:
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
return (int) Math.ceil(paramDouble * 32.0D); return (int) Math.ceil(paramDouble * 32.0D);
} case 4:
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
return (int) Math.ceil(paramDouble * 32.0D);
}
return (int) Math.floor(paramDouble * 32.0D);
case 5:
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
return (int) Math.floor(paramDouble * 32.0D); return (int) Math.floor(paramDouble * 32.0D);
} case 5:
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
return (int) Math.floor(paramDouble * 32.0D);
}
return (int) Math.ceil(paramDouble * 32.0D); return (int) Math.ceil(paramDouble * 32.0D);
default: default:
break; break;
} }
if (d > 0.0D) { if (d > 0.0D) {
return (int) Math.ceil(paramDouble * 32.0D); return (int) Math.ceil(paramDouble * 32.0D);

View File

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.utilities; package me.libraryaddict.disguise.utilities;
public class FakeBoundingBox { public class FakeBoundingBox {
private double xMod; private double xMod;
private double yMod; private double yMod;
private double zMod; private double zMod;

View File

@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
import com.comphenix.protocol.wrappers.WrappedGameProfile; import com.comphenix.protocol.wrappers.WrappedGameProfile;
public interface LibsProfileLookup { public interface LibsProfileLookup {
public void onLookup(WrappedGameProfile gameProfile); public void onLookup(WrappedGameProfile gameProfile);
} }

View File

@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback; import com.mojang.authlib.ProfileLookupCallback;
public class LibsProfileLookupCaller implements ProfileLookupCallback { public class LibsProfileLookupCaller implements ProfileLookupCallback {
private WrappedGameProfile gameProfile; private WrappedGameProfile gameProfile;
public WrappedGameProfile getGameProfile() { public WrappedGameProfile getGameProfile() {

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,10 @@ import org.bukkit.potion.PotionEffect;
public class ReflectionManager { public class ReflectionManager {
public enum LibVersion { public enum LibVersion {
V1_8; V1_8;
private static LibVersion currentVersion; private static LibVersion currentVersion;
static { static {
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", ""); //String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
currentVersion = V1_8; currentVersion = V1_8;
@ -59,8 +61,7 @@ public class ReflectionManager {
private static Map<String, Map<String, String>> ForgeFieldMappings; private static Map<String, Map<String, String>> ForgeFieldMappings;
/** /**
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method * Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method names.
* names.
*/ */
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings; private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
private static final Method ihmGet; private static final Method ihmGet;
@ -82,7 +83,7 @@ public class ReflectionManager {
final String nameseg_class = "a-zA-Z0-9$_"; final String nameseg_class = "a-zA-Z0-9$_";
final String fqn_class = nameseg_class + "/"; final String fqn_class = nameseg_class + "/";
primitiveTypes = ImmutableMap.<Class<?>, String> builder().put(boolean.class, "Z").put(byte.class, "B") primitiveTypes = ImmutableMap.<Class<?>, String>builder().put(boolean.class, "Z").put(byte.class, "B")
.put(char.class, "C").put(short.class, "S").put(int.class, "I").put(long.class, "J").put(float.class, "F") .put(char.class, "C").put(short.class, "S").put(int.class, "I").put(long.class, "J").put(float.class, "F")
.put(double.class, "D").put(void.class, "V").build(); .put(double.class, "D").put(void.class, "V").build();
@ -191,7 +192,7 @@ public class ReflectionManager {
trackerField = getNmsField("WorldServer", "tracker"); trackerField = getNmsField("WorldServer", "tracker");
entitiesField = getNmsField("EntityTracker", "trackedEntities"); entitiesField = getNmsField("EntityTracker", "trackedEntities");
ihmGet = getNmsMethod("IntHashMap", "get", int.class); ihmGet = getNmsMethod("IntHashMap", "get", int.class);
boundingBoxConstructor = getNmsConstructor("AxisAlignedBB",double.class, double.class, double.class, boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class,
double.class, double.class, double.class); double.class, double.class, double.class);
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB")); setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
} }
@ -208,7 +209,7 @@ public class ReflectionManager {
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises"); WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world, gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
gameProfile.getHandle(), playerinteractmanager); gameProfile.getHandle(), playerinteractmanager);
} else if (entityName.equals("EnderPearl")) { } else if (entityName.equals("EnderPearl")) {
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving")) entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
.newInstance(world, createEntityInstance("Cow")); .newInstance(world, createEntityInstance("Cow"));
@ -249,26 +250,26 @@ public class ReflectionManager {
if (field.getType().getSimpleName().equals("double")) { if (field.getType().getSimpleName().equals("double")) {
stage++; stage++;
switch (stage) { switch (stage) {
case 1: case 1:
x -= field.getDouble(boundingBox); x -= field.getDouble(boundingBox);
break; break;
case 2: case 2:
y -= field.getDouble(boundingBox); y -= field.getDouble(boundingBox);
break; break;
case 3: case 3:
z -= field.getDouble(boundingBox); z -= field.getDouble(boundingBox);
break; break;
case 4: case 4:
x += field.getDouble(boundingBox); x += field.getDouble(boundingBox);
break; break;
case 5: case 5:
y += field.getDouble(boundingBox); y += field.getDouble(boundingBox);
break; break;
case 6: case 6:
z += field.getDouble(boundingBox); z += field.getDouble(boundingBox);
break; break;
default: default:
throw new Exception("Error while setting the bounding box, more doubles than I thought??"); throw new Exception("Error while setting the bounding box, more doubles than I thought??");
} }
} }
} }
@ -382,7 +383,7 @@ public class ReflectionManager {
return null; return null;
} }
public static WrappedGameProfile getGameProfile(Player player) { public static WrappedGameProfile getGameProfile(Player player) {
return WrappedGameProfile.fromPlayer(player); return WrappedGameProfile.fromPlayer(player);
} }
@ -519,7 +520,7 @@ public class ReflectionManager {
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity)); float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity)); float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity)); float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
return new float[] { length, width, height }; return new float[]{length, width, height};
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(System.out); ex.printStackTrace(System.out);
} }
@ -573,7 +574,7 @@ public class ReflectionManager {
.getClass() .getClass()
.getMethod("findProfilesByNames", String[].class, agent.getClass(), .getMethod("findProfilesByNames", String[].class, agent.getClass(),
Class.forName("com.mojang.authlib.ProfileLookupCallback")) Class.forName("com.mojang.authlib.ProfileLookupCallback"))
.invoke(profileRepo, new String[] { playername }, agent, callback); .invoke(profileRepo, new String[]{playername}, agent, callback);
if (callback.getGameProfile() != null) { if (callback.getGameProfile() != null) {
return callback.getGameProfile(); return callback.getGameProfile();
} }
@ -607,10 +608,8 @@ public class ReflectionManager {
public static void setAllowSleep(Player player) { public static void setAllowSleep(Player player) {
try { try {
/** /**
Object nmsEntity = getNmsEntity(player); * Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); */
Field check = getNmsField(connection.getClass(), "checkMovement");
check.setBoolean(connection, true); **/
} catch (Exception ex) { } catch (Exception ex) {
ex.printStackTrace(System.out); ex.printStackTrace(System.out);
} }

View File

@ -7,6 +7,7 @@ import java.net.URL;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class UpdateChecker { public class UpdateChecker {
private String latestVersion; private String latestVersion;
private boolean checkHigher(String currentVersion, String newVersion) { private boolean checkHigher(String currentVersion, String newVersion) {
@ -51,8 +52,9 @@ public class UpdateChecker {
private String toReadable(String version) { private String toReadable(String version) {
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", "")); String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
version = ""; version = "";
for (String s : split) for (String s : split) {
version += String.format("%4s", s); version += String.format("%4s", s);
}
return version; return version;
} }
} }

View File

@ -72,9 +72,9 @@ DisguiseCloneSize: 3
# These disguises, as normal will not persist after a server restart. # These disguises, as normal will not persist after a server restart.
# There is also no EntityDeath option as entities do not revive after death. # There is also no EntityDeath option as entities do not revive after death.
KeepDisguises: KeepDisguises:
EntityDespawn: false EntityDespawn: false
PlayerDeath: false PlayerDeath: false
PlayerLogout: false PlayerLogout: false
# This controls if a entitys max health is determined by the entity, or by the disguise. # This controls if a entitys max health is determined by the entity, or by the disguise.
# Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health. # Wither is 200, a player is 20. With this enabled, a player disguised as a wither will have the boss bar health accurate to the players health.
@ -97,31 +97,31 @@ ContactMojangServers: true
# This will help performance, especially with CPU # This will help performance, especially with CPU
# Due to safety reasons, self disguises can never have their packets disabled. # Due to safety reasons, self disguises can never have their packets disabled.
PacketsEnabled: PacketsEnabled:
# This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash. # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash.
# Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash
Animation: true Animation: true
# Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player
# This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently. # This also sends a chunk packet at key positions else it doesn't work for 1.8. Lazyness means it does it for older versions too currently.
Bed: true Bed: true
# This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it
# This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well
Collect: true Collect: true
# This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching. # This disables a fix for when a disguised entity wearing armor dies, if the disguise can wear armor. It drops unpickupable items to anyone watching.
EntityStatus: true EntityStatus: true
# Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item. # Entity equipment is the packets that are sent to ensure that a disguise has or doesn't have armor, and their held item.
# Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing. # Disabling this means that any disguises which can wear armor or hold items will show the armor/held item that the disguised is wearing.
Equipment: true Equipment: true
# This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data. # This doesn't actually disable the packet. It would introduce problems. Instead it does the next best thing and caches the data.
# This means that entity metadata will not change, and will only be sent in the spawn packet. # This means that entity metadata will not change, and will only be sent in the spawn packet.
# This is good if performance is extremely in need. # This is good if performance is extremely in need.
# This is bad to disable unless you are ONLY going to use the disguises for decorations. # This is bad to disable unless you are ONLY going to use the disguises for decorations.
# To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect. # To be honest. This is basically "Disable entity animations". That option is called 'AddEntityAnimations' in the config but unlike that, this is always in effect.
# Animations set by use of the api or through the disguise command are still in effect. # Animations set by use of the api or through the disguise command are still in effect.
Metadata: true Metadata: true
# Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up. # Movement packets are the biggest cpu hit. These are majorly used to ensure that the disguises facing direction isn't bugged up.
# If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move. # If you are using the Item_Frame disguise, when a packet is sent (Roughly every 2min) the disguise will bug up until they move.
Movement: true Movement: true
# Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity # Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
Riding: true Riding: true
# When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way. # When disguised as a wither skull, it sends a look packet every tick so that the wither skull is facing the right way.
WitherSkull: true WitherSkull: true

View File

@ -1,6 +1,6 @@
name: LibsDisguises name: LibsDisguises
main: me.libraryaddict.disguise.LibsDisguises main: me.libraryaddict.disguise.LibsDisguises
version: 8.6.3 version: 8.6.4
author: libraryaddict author: libraryaddict
authors: [Byteflux, Navid K.] authors: [Byteflux, Navid K.]
depend: [ProtocolLib] depend: [ProtocolLib]
@ -54,6 +54,9 @@ commands:
description: Toggle seeing your own disguise on or off. description: Toggle seeing your own disguise on or off.
permissions: permissions:
libsdisguises.reload:
description: Allows the user to reload LibsDisguises.
default: op
libsdisguises.seethrough: libsdisguises.seethrough:
description: Allows player to see through disguises. description: Allows player to see through disguises.
default: false default: false
@ -97,4 +100,3 @@ permissions:
description: See the /undisguiseradius command in tab-completion description: See the /undisguiseradius command in tab-completion
libsdisguises.seecmd.disguiseclone: libsdisguises.seecmd.disguiseclone:
description: See the /disguiseclone command in tab-completion description: See the /disguiseclone command in tab-completion