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:
parent
3e19045a2c
commit
41cfa8eeaa
@ -13,7 +13,7 @@ println 'Compiling LibsDisguises via Gradle ver. ' + gradle.gradleVersion
|
||||
sourceCompatibility = '1.7'
|
||||
ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT'
|
||||
|
||||
ext.disguisesVersion = '8.6.3'
|
||||
ext.disguisesVersion = '8.6.4'
|
||||
|
||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class DisguiseAPI {
|
||||
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
||||
if (firstCapitalWatcher > 0
|
||||
&& method.getName().substring(firstCapitalMethod)
|
||||
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) {
|
||||
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) {
|
||||
Class methodParam = watcherMethod.getParameterTypes()[0];
|
||||
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
|
||||
methodParam = double.class;
|
||||
@ -143,8 +143,9 @@ public class DisguiseAPI {
|
||||
public static void disguiseEntity(Entity entity, Disguise disguise) {
|
||||
// If they are trying to disguise a null entity or use a null disguise
|
||||
// Just return.
|
||||
if (entity == null || disguise == null)
|
||||
if (entity == null || disguise == null) {
|
||||
return;
|
||||
}
|
||||
// The event wasn't cancelled.
|
||||
// If the disguise entity isn't the same as the one we are disguising
|
||||
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.
|
||||
*
|
||||
* @param disguise
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static int disguiseNextEntity(Disguise disguise) {
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
return -1;
|
||||
}
|
||||
if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
@ -215,6 +218,7 @@ public class DisguiseAPI {
|
||||
|
||||
/**
|
||||
* Disguise this entity with this disguise
|
||||
*
|
||||
* @param entity
|
||||
* @param disguise
|
||||
*/
|
||||
@ -224,8 +228,9 @@ public class DisguiseAPI {
|
||||
}
|
||||
// You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!!
|
||||
((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);
|
||||
}
|
||||
disguiseEntity(entity, disguise);
|
||||
}
|
||||
|
||||
@ -268,42 +273,49 @@ public class DisguiseAPI {
|
||||
|
||||
/**
|
||||
* Get the disguise of a entity
|
||||
*
|
||||
* @param disguised
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static Disguise getDisguise(Entity disguised) {
|
||||
if (disguised == null)
|
||||
if (disguised == null) {
|
||||
return null;
|
||||
}
|
||||
return DisguiseUtilities.getMainDisguise(disguised.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disguise of a entity
|
||||
*
|
||||
* @param observer
|
||||
* @param disguised
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static Disguise getDisguise(Player observer, Entity disguised) {
|
||||
if (disguised == null || observer == null)
|
||||
if (disguised == null || observer == null) {
|
||||
return null;
|
||||
}
|
||||
return DisguiseUtilities.getDisguise(observer, disguised);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the disguises of a entity
|
||||
*
|
||||
* @param disguised
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static Disguise[] getDisguises(Entity disguised) {
|
||||
if (disguised == null)
|
||||
if (disguised == null) {
|
||||
return null;
|
||||
}
|
||||
return DisguiseUtilities.getDisguises(disguised.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a fake disguise for a entityplayer
|
||||
*
|
||||
* @param entityId
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getFakeDisguise(UUID entityId) {
|
||||
@ -316,8 +328,9 @@ public class DisguiseAPI {
|
||||
|
||||
/**
|
||||
* Is this entity disguised
|
||||
*
|
||||
* @param disguised
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDisguised(Entity disguised) {
|
||||
return getDisguise(disguised) != null;
|
||||
@ -325,9 +338,10 @@ public class DisguiseAPI {
|
||||
|
||||
/**
|
||||
* Is this entity disguised
|
||||
*
|
||||
* @param observer
|
||||
* @param disguised
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDisguised(Player observer, Entity disguised) {
|
||||
return getDisguise(observer, disguised) != null;
|
||||
@ -340,20 +354,20 @@ public class DisguiseAPI {
|
||||
public static boolean isSelfDisguised(Player player) {
|
||||
return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if the entitiy has /disguiseviewself toggled
|
||||
* on.
|
||||
* Returns true if the entitiy has /disguiseviewself toggled on.
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static boolean isViewSelfToggled(Entity entity) {
|
||||
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
|
||||
* the world.
|
||||
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from the world.
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public static void undisguiseToAll(Entity entity) {
|
||||
@ -362,12 +376,12 @@ public class DisguiseAPI {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set whether this player can see his
|
||||
* own disguise or not.
|
||||
* Set whether this player can see his own disguise or not.
|
||||
*
|
||||
* @param entity
|
||||
* @param toggled
|
||||
* @param toggled
|
||||
*/
|
||||
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
||||
if (isDisguised(entity)) {
|
||||
@ -375,8 +389,9 @@ public class DisguiseAPI {
|
||||
disguise.setViewSelfDisguise(toggled);
|
||||
}
|
||||
if (toggled) {
|
||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId()))
|
||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||
}
|
||||
} else {
|
||||
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class DisguiseConfig {
|
||||
|
||||
private static boolean animationEnabled;
|
||||
private static boolean bedEnabled;
|
||||
private static boolean blowDisguisesOnAttack;
|
||||
@ -218,7 +219,8 @@ public class DisguiseConfig {
|
||||
|
||||
/**
|
||||
* Is the velocity packets sent
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isVelocitySent() {
|
||||
return sendVelocity;
|
||||
@ -226,7 +228,8 @@ public class DisguiseConfig {
|
||||
|
||||
/**
|
||||
* The default value if a player views his own disguise
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean isViewDisguises() {
|
||||
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?
|
||||
*
|
||||
* @param sendVelocityPackets
|
||||
*/
|
||||
public static void setVelocitySent(boolean sendVelocityPackets) {
|
||||
|
@ -38,6 +38,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class DisguiseListener implements Listener {
|
||||
@ -66,10 +67,12 @@ public class DisguiseListener implements Listener {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player p : Bukkit.getOnlinePlayers())
|
||||
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission()))
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) {
|
||||
p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion,
|
||||
latestVersion));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -81,7 +84,7 @@ public class DisguiseListener implements Listener {
|
||||
// 20 ticks * 60 seconds * 60 minutes * 6 hours
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void cleanup() {
|
||||
for (BukkitRunnable r : disguiseRunnable.values()) {
|
||||
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
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
@ -266,8 +271,9 @@ public class DisguiseListener implements Listener {
|
||||
if (DisguiseAPI.isDisguised(entity)) {
|
||||
DisguiseAPI.undisguiseToAll(entity);
|
||||
p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName);
|
||||
} else
|
||||
} else {
|
||||
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
|
||||
&& DisguiseAPI.isDisguised(event.getTarget())) {
|
||||
switch (event.getReason()) {
|
||||
case TARGET_ATTACKED_ENTITY:
|
||||
case TARGET_ATTACKED_OWNER:
|
||||
case OWNER_ATTACKED_TARGET:
|
||||
case CUSTOM:
|
||||
break;
|
||||
default:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
case TARGET_ATTACKED_ENTITY:
|
||||
case TARGET_ATTACKED_OWNER:
|
||||
case OWNER_ATTACKED_TARGET:
|
||||
case CUSTOM:
|
||||
break;
|
||||
default:
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onTeleport(final PlayerTeleportEvent event) {
|
||||
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
Location to = event.getTo();
|
||||
Location from = event.getFrom();
|
||||
if (DisguiseConfig.isBedPacketsEnabled()) {
|
||||
@ -301,7 +310,7 @@ public class DisguiseListener implements Listener {
|
||||
int z2 = (int) Math.floor(from.getZ() / 16D) - 17;
|
||||
if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) {
|
||||
chunkMove(event.getPlayer(), null, from);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!event.isCancelled()) {
|
||||
@ -318,6 +327,17 @@ public class DisguiseListener implements Listener {
|
||||
for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
|
||||
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)
|
||||
public void onWorldSwitch(final PlayerChangedWorldEvent event) {
|
||||
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
if (DisguiseConfig.isBedPacketsEnabled()) {
|
||||
chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import me.libraryaddict.disguise.utilities.Metrics;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class LibsDisguises extends JavaPlugin {
|
||||
|
||||
|
||||
public static LibsDisguises instance; //I'm sorry Sun MicroSystems and all mighty Java God
|
||||
private DisguiseListener listener;
|
||||
|
||||
@ -69,21 +69,21 @@ public class LibsDisguises extends JavaPlugin {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reloads the config with new config options.
|
||||
*/
|
||||
public void reload() {
|
||||
HandlerList.unregisterAll(listener);
|
||||
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
|
||||
* for mob noises. As well as setting their watcher class and entity size.
|
||||
* 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.
|
||||
*/
|
||||
private void registerValues() {
|
||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||
@ -93,37 +93,37 @@ public class LibsDisguises extends JavaPlugin {
|
||||
Class watcherClass;
|
||||
try {
|
||||
switch (disguiseType) {
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
watcherClass = MinecartWatcher.class;
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
watcherClass = HorseWatcher.class;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
case PIG_ZOMBIE:
|
||||
watcherClass = ZombieWatcher.class;
|
||||
break;
|
||||
case MAGMA_CUBE:
|
||||
watcherClass = SlimeWatcher.class;
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
watcherClass = GuardianWatcher.class;
|
||||
break;
|
||||
case ENDERMITE:
|
||||
watcherClass = LivingWatcher.class;
|
||||
break;
|
||||
default:
|
||||
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
|
||||
+ toReadable(disguiseType.name()) + "Watcher");
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
watcherClass = MinecartWatcher.class;
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
watcherClass = HorseWatcher.class;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
case PIG_ZOMBIE:
|
||||
watcherClass = ZombieWatcher.class;
|
||||
break;
|
||||
case MAGMA_CUBE:
|
||||
watcherClass = SlimeWatcher.class;
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
watcherClass = GuardianWatcher.class;
|
||||
break;
|
||||
case ENDERMITE:
|
||||
watcherClass = LivingWatcher.class;
|
||||
break;
|
||||
default:
|
||||
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
|
||||
+ toReadable(disguiseType.name()) + "Watcher");
|
||||
break;
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
// There is no explicit watcher for this entity.
|
||||
@ -148,45 +148,45 @@ public class LibsDisguises extends JavaPlugin {
|
||||
}
|
||||
String nmsEntityName = toReadable(disguiseType.name());
|
||||
switch (disguiseType) {
|
||||
case WITHER_SKELETON:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
continue;
|
||||
case PRIMED_TNT:
|
||||
nmsEntityName = "TNTPrimed";
|
||||
break;
|
||||
case MINECART_TNT:
|
||||
nmsEntityName = "MinecartTNT";
|
||||
break;
|
||||
case MINECART:
|
||||
nmsEntityName = "MinecartRideable";
|
||||
break;
|
||||
case FIREWORK:
|
||||
nmsEntityName = "Fireworks";
|
||||
break;
|
||||
case SPLASH_POTION:
|
||||
nmsEntityName = "Potion";
|
||||
break;
|
||||
case GIANT:
|
||||
nmsEntityName = "GiantZombie";
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
nmsEntityName = "Item";
|
||||
break;
|
||||
case FIREBALL:
|
||||
nmsEntityName = "LargeFireball";
|
||||
break;
|
||||
case LEASH_HITCH:
|
||||
nmsEntityName = "Leash";
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
nmsEntityName = "Guardian";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
continue;
|
||||
case PRIMED_TNT:
|
||||
nmsEntityName = "TNTPrimed";
|
||||
break;
|
||||
case MINECART_TNT:
|
||||
nmsEntityName = "MinecartTNT";
|
||||
break;
|
||||
case MINECART:
|
||||
nmsEntityName = "MinecartRideable";
|
||||
break;
|
||||
case FIREWORK:
|
||||
nmsEntityName = "Fireworks";
|
||||
break;
|
||||
case SPLASH_POTION:
|
||||
nmsEntityName = "Potion";
|
||||
break;
|
||||
case GIANT:
|
||||
nmsEntityName = "GiantZombie";
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
nmsEntityName = "Item";
|
||||
break;
|
||||
case FIREBALL:
|
||||
nmsEntityName = "LargeFireball";
|
||||
break;
|
||||
case LEASH_HITCH:
|
||||
nmsEntityName = "Leash";
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
nmsEntityName = "Guardian";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
try {
|
||||
if (nmsEntityName.equalsIgnoreCase("Unknown")) {
|
||||
|
@ -43,7 +43,7 @@ public class DisguiseCloneCommand extends BaseDisguiseCommand {
|
||||
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()
|
||||
+ " seconds to grab the disguise reference!");
|
||||
} else {
|
||||
|
@ -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 + "You can use the disguises: " + 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 <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>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
|
||||
|
||||
/**
|
||||
* Send the player the information
|
||||
*
|
||||
* @param sender
|
||||
* @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 + "You can use the disguises: " + 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 <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>");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
|
||||
private class EnumHelp {
|
||||
|
||||
private String enumDescription;
|
||||
private String enumName;
|
||||
private String[] enums;
|
||||
@ -81,38 +83,39 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
try {
|
||||
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(
|
||||
"org.bukkit.entity.Horse$Color").getEnumConstants()));
|
||||
"org.bukkit.entity.Horse$Color").getEnumConstants()));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
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(
|
||||
"org.bukkit.entity.Horse$Style").getEnumConstants()));
|
||||
"org.bukkit.entity.Horse$Style").getEnumConstants()));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
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(
|
||||
"org.bukkit.entity.Ocelot$Type").getEnumConstants()));
|
||||
"org.bukkit.entity.Ocelot$Type").getEnumConstants()));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
ArrayList<String> enumReturns = new ArrayList<>();
|
||||
for (PotionEffectType potionType : PotionEffectType.values()) {
|
||||
if (potionType != null)
|
||||
if (potionType != null) {
|
||||
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
|
||||
+ ChatColor.RED + ")");
|
||||
}
|
||||
}
|
||||
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
|
||||
.size()])));
|
||||
.size()])));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
try {
|
||||
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(
|
||||
"org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
||||
"org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
enumHelp.add(new EnumHelp("Direction", "Directions", ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
|
||||
@ -123,7 +126,7 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
|
||||
@Override
|
||||
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
|
||||
+ ".");
|
||||
if (!permMap.isEmpty()) {
|
||||
@ -273,8 +276,9 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
|
||||
|
||||
public String toReadable(String string) {
|
||||
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();
|
||||
}
|
||||
return StringUtils.join(split, "_");
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +85,13 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + 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> <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 <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DisguiseRadiusCommand extends BaseDisguiseCommand {
|
||||
|
||||
private int maxRadius = 30;
|
||||
private ArrayList<Class> validClasses = new ArrayList<>();
|
||||
|
||||
@ -111,8 +112,9 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
|
||||
int disguisedEntitys = 0;
|
||||
int miscDisguises = 0;
|
||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||
if (entity == sender)
|
||||
if (entity == sender) {
|
||||
continue;
|
||||
}
|
||||
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
|
||||
&& entity instanceof LivingEntity) {
|
||||
@ -165,7 +167,7 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage((ChatColor.DARK_GREEN + "/disguiseradius <EntityType" + optional
|
||||
+ "> <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
|
||||
+ "/disguiseradius EntityTypes");
|
||||
|
@ -11,26 +11,26 @@ public class LibsDisguisesCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN
|
||||
+ "This server is running "
|
||||
+ "Lib's Disguises v."
|
||||
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
|
||||
+ " by libraryaddict, maintained by NavidK0.\n"
|
||||
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
|
||||
} else if (args.length > 0) {
|
||||
if (!sender.hasPermission("libsdisguises.reload")) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
LibsDisguises.instance.reload();
|
||||
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "[LibsDisguises] That command doesn't exist!");
|
||||
}
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN
|
||||
+ "This server is running "
|
||||
+ "Lib's Disguises v."
|
||||
+ Bukkit.getPluginManager().getPlugin("LibsDisguises").getDescription().getVersion()
|
||||
+ " by libraryaddict, maintained by NavidK0.\n"
|
||||
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
|
||||
} else if (args.length > 0) {
|
||||
if (sender.hasPermission("libsdisguises.reload")) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
LibsDisguises.instance.reload();
|
||||
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");
|
||||
return true;
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
@ -21,10 +21,12 @@ public class UndisguiseCommand implements CommandExecutor {
|
||||
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
||||
DisguiseAPI.undisguiseToAll((Player) sender);
|
||||
sender.sendMessage(ChatColor.RED + "You are no longer disguised");
|
||||
} else
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You are not disguised!");
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ public class UndisguiseEntityCommand implements CommandExecutor {
|
||||
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
|
||||
LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), null);
|
||||
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.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -20,14 +20,18 @@ public class UndisguisePlayerCommand implements CommandExecutor {
|
||||
if (DisguiseAPI.isDisguised(p)) {
|
||||
DisguiseAPI.undisguiseToAll(p);
|
||||
sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
|
||||
} else
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "The player is not disguised!");
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Player not found");
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
|
||||
private int maxRadius = 30;
|
||||
|
||||
public UndisguiseRadiusCommand(int maxRadius) {
|
||||
@ -48,16 +49,18 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
}
|
||||
int disguisedEntitys = 0;
|
||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||
if (entity == sender)
|
||||
if (entity == sender) {
|
||||
continue;
|
||||
}
|
||||
if (DisguiseAPI.isDisguised(entity)) {
|
||||
DisguiseAPI.undisguiseToAll(entity);
|
||||
disguisedEntitys++;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
|
||||
} else
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
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(
|
||||
10), RED(14), SILVER(8), WHITE(0), YELLOW(4);
|
||||
|
||||
|
@ -39,6 +39,7 @@ import java.util.Map;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
|
||||
public abstract class Disguise {
|
||||
|
||||
private boolean disguiseInUse;
|
||||
private DisguiseType disguiseType;
|
||||
private Entity entity;
|
||||
@ -56,24 +57,26 @@ public abstract class Disguise {
|
||||
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
|
||||
private FlagWatcher watcher;
|
||||
private boolean showName = false;
|
||||
|
||||
|
||||
private static List<UUID> viewSelf = new ArrayList<>();
|
||||
|
||||
|
||||
@Override
|
||||
public abstract Disguise clone();
|
||||
|
||||
/**
|
||||
* Seems I do this method so I can make cleaner constructors on disguises..
|
||||
*
|
||||
* @param newType
|
||||
*/
|
||||
protected void createDisguise(DisguiseType newType) {
|
||||
if (getWatcher() != null)
|
||||
if (getWatcher() != null) {
|
||||
return;
|
||||
}
|
||||
if (newType.getEntityType() == null) {
|
||||
throw new RuntimeException(
|
||||
"DisguiseType "
|
||||
+ newType
|
||||
+ " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity");
|
||||
+ newType
|
||||
+ " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity");
|
||||
}
|
||||
// Set the disguise type
|
||||
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 (getType() == DisguiseType.WITHER_SKELETON) {
|
||||
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) {
|
||||
getWatcher().setValue(13, (byte) 1);
|
||||
}
|
||||
|
||||
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||
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) {
|
||||
try {
|
||||
// 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;
|
||||
switch (getType()) {
|
||||
case EGG:
|
||||
case ENDER_PEARL:
|
||||
case BAT:
|
||||
case EXPERIENCE_ORB:
|
||||
case FIREBALL:
|
||||
case SMALL_FIREBALL:
|
||||
case SNOWBALL:
|
||||
case SPLASH_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case WITHER_SKULL:
|
||||
case FIREWORK:
|
||||
alwaysSendVelocity = true;
|
||||
break;
|
||||
default:
|
||||
alwaysSendVelocity = false;
|
||||
break;
|
||||
case EGG:
|
||||
case ENDER_PEARL:
|
||||
case BAT:
|
||||
case EXPERIENCE_ORB:
|
||||
case FIREBALL:
|
||||
case SMALL_FIREBALL:
|
||||
case SNOWBALL:
|
||||
case SPLASH_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case WITHER_SKULL:
|
||||
case FIREWORK:
|
||||
alwaysSendVelocity = true;
|
||||
break;
|
||||
default:
|
||||
alwaysSendVelocity = false;
|
||||
break;
|
||||
}
|
||||
double velocitySpeed = 0.0005;
|
||||
switch (getType()) {
|
||||
case FIREWORK:
|
||||
velocitySpeed = -0.040;
|
||||
break;
|
||||
case WITHER_SKULL:
|
||||
velocitySpeed = 0.000001D;
|
||||
break;
|
||||
case ARROW:
|
||||
case BOAT:
|
||||
case ENDER_CRYSTAL:
|
||||
case ENDER_DRAGON:
|
||||
case GHAST:
|
||||
case ITEM_FRAME:
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case PAINTING:
|
||||
case PLAYER:
|
||||
case SQUID:
|
||||
velocitySpeed = 0;
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
case PRIMED_TNT:
|
||||
case WITHER:
|
||||
case FALLING_BLOCK:
|
||||
velocitySpeed = 0.04;
|
||||
break;
|
||||
case EXPERIENCE_ORB:
|
||||
velocitySpeed = 0.0221;
|
||||
break;
|
||||
case SPIDER:
|
||||
case BAT:
|
||||
case CAVE_SPIDER:
|
||||
velocitySpeed = 0.004;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case FIREWORK:
|
||||
velocitySpeed = -0.040;
|
||||
break;
|
||||
case WITHER_SKULL:
|
||||
velocitySpeed = 0.000001D;
|
||||
break;
|
||||
case ARROW:
|
||||
case BOAT:
|
||||
case ENDER_CRYSTAL:
|
||||
case ENDER_DRAGON:
|
||||
case GHAST:
|
||||
case ITEM_FRAME:
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case MINECART_TNT:
|
||||
case PAINTING:
|
||||
case PLAYER:
|
||||
case SQUID:
|
||||
velocitySpeed = 0;
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
case PRIMED_TNT:
|
||||
case WITHER:
|
||||
case FALLING_BLOCK:
|
||||
velocitySpeed = 0.04;
|
||||
break;
|
||||
case EXPERIENCE_ORB:
|
||||
velocitySpeed = 0.0221;
|
||||
break;
|
||||
case SPIDER:
|
||||
case BAT:
|
||||
case CAVE_SPIDER:
|
||||
velocitySpeed = 0.004;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
final double vectorY = velocitySpeed;
|
||||
final TargetedDisguise disguise = (TargetedDisguise) this;
|
||||
@ -328,7 +327,8 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Get the disguised entity
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
@ -336,7 +336,8 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Get the disguise type
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public DisguiseType getType() {
|
||||
return disguiseType;
|
||||
@ -344,16 +345,17 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Get the flag watcher
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public FlagWatcher getWatcher() {
|
||||
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.
|
||||
* getEntity() can still return null if this disguise is active after despawn, logout, etc.
|
||||
* @return
|
||||
* 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.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isDisguiseInUse() {
|
||||
return disguiseInUse;
|
||||
@ -397,17 +399,16 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Internal use
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isRemoveDisguiseOnDeath() {
|
||||
if (getEntity() == null) return true;
|
||||
return getEntity() instanceof Player ?
|
||||
|
||||
(!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
|
||||
|
||||
:
|
||||
|
||||
(!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
|
||||
if (getEntity() == null) {
|
||||
return true;
|
||||
}
|
||||
return getEntity() instanceof Player
|
||||
? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
|
||||
: (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
|
||||
}
|
||||
|
||||
public boolean isSelfDisguiseSoundsReplaced() {
|
||||
@ -416,7 +417,8 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Can the disguised view himself as the disguise
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isSelfDisguiseVisible() {
|
||||
return viewSelfDisguise;
|
||||
@ -432,7 +434,8 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Returns true if the entity's name is showing through the disguise
|
||||
* @return
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isShowName() {
|
||||
return showName;
|
||||
@ -440,7 +443,7 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Removes the disguise and undisguises the entity if its using this disguise.
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean removeDisguise() {
|
||||
@ -503,13 +506,15 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Set the entity of the disguise. Only used for internal things.
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public Disguise setEntity(Entity entity) {
|
||||
if (this.getEntity() != null) {
|
||||
if (getEntity() == entity)
|
||||
if (getEntity() == entity) {
|
||||
return this;
|
||||
}
|
||||
throw new RuntimeException("This disguise is already in use! Try .clone()");
|
||||
}
|
||||
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
|
||||
* datawatcher.
|
||||
* Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the datawatcher.
|
||||
*/
|
||||
private void setupWatcher() {
|
||||
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.
|
||||
// If neither of them touch it
|
||||
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo))
|
||||
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) {
|
||||
continue;
|
||||
}
|
||||
// If the disguise has this, but not the entity. Then better set it!
|
||||
if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) {
|
||||
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
|
||||
@ -626,9 +631,9 @@ public abstract class Disguise {
|
||||
Object eObj = entityValues.get(dataNo);
|
||||
Object dObj = disguiseValues.get(dataNo);
|
||||
if (eObj == null || dObj == null) {
|
||||
if (eObj == null && dObj == null)
|
||||
if (eObj == null && dObj == null) {
|
||||
continue;
|
||||
else {
|
||||
} else {
|
||||
getWatcher().setBackupValue(dataNo, dObj);
|
||||
continue;
|
||||
}
|
||||
@ -645,40 +650,41 @@ public abstract class Disguise {
|
||||
// EntityInsentient is 10 & 11
|
||||
// EntityZombie is 12 & 13 & 14 - But it overrides other values and another check already does this.
|
||||
// EntityLiving is 6 & 7 & 8 & 9
|
||||
|
||||
// Lets use switch
|
||||
Class baseClass = null;
|
||||
switch (dataNo) {
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityLiving");
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityInsentient");
|
||||
break;
|
||||
case 16:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityAgeable");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 9:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityLiving");
|
||||
break;
|
||||
case 10:
|
||||
case 11:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityInsentient");
|
||||
break;
|
||||
case 16:
|
||||
baseClass = ReflectionManager.getNmsClass("EntityAgeable");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass();
|
||||
Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType());
|
||||
if (nmsDisguiseClass != null) {
|
||||
// If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..?
|
||||
if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass)
|
||||
&& baseClass.isAssignableFrom(nmsEntityClass))
|
||||
&& baseClass.isAssignableFrom(nmsEntityClass)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// So they don't extend a basic class.
|
||||
// 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
|
||||
// datawatchers.
|
||||
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass))
|
||||
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// 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!
|
||||
@ -693,7 +699,7 @@ public abstract class Disguise {
|
||||
|
||||
/**
|
||||
* Can the disguised view himself as the disguise
|
||||
*
|
||||
*
|
||||
* @param viewSelfDisguise
|
||||
* @return
|
||||
*/
|
||||
@ -704,8 +710,9 @@ public abstract class Disguise {
|
||||
if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) {
|
||||
if (isSelfDisguiseVisible()) {
|
||||
DisguiseUtilities.setupFakeDisguise(this);
|
||||
} else
|
||||
} else {
|
||||
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -762,9 +769,9 @@ public abstract class Disguise {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of people who have /disguiseViewSelf
|
||||
* toggled on
|
||||
* @return
|
||||
* Returns the list of people who have /disguiseViewSelf toggled on
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<UUID> getViewSelf() {
|
||||
return viewSelf;
|
||||
|
@ -11,146 +11,78 @@ import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
public enum DisguiseType {
|
||||
|
||||
ARMOR_STAND(78),
|
||||
|
||||
ARROW(60),
|
||||
|
||||
BAT,
|
||||
|
||||
BLAZE,
|
||||
|
||||
BOAT(1),
|
||||
|
||||
CAVE_SPIDER,
|
||||
|
||||
CHICKEN,
|
||||
|
||||
COW,
|
||||
|
||||
CREEPER,
|
||||
|
||||
DONKEY,
|
||||
|
||||
DROPPED_ITEM(2, 1),
|
||||
|
||||
EGG(62),
|
||||
|
||||
ELDER_GUARDIAN,
|
||||
|
||||
ENDER_CRYSTAL(51),
|
||||
|
||||
ENDER_DRAGON,
|
||||
|
||||
ENDER_PEARL(65),
|
||||
|
||||
ENDER_SIGNAL(72),
|
||||
|
||||
ENDERMAN,
|
||||
|
||||
ENDERMITE,
|
||||
|
||||
EXPERIENCE_ORB,
|
||||
|
||||
FALLING_BLOCK(70, 1),
|
||||
|
||||
FIREBALL(63, 0),
|
||||
|
||||
FIREWORK(76),
|
||||
|
||||
FISHING_HOOK(90),
|
||||
|
||||
GHAST,
|
||||
|
||||
GIANT,
|
||||
|
||||
GUARDIAN,
|
||||
|
||||
HORSE,
|
||||
|
||||
IRON_GOLEM,
|
||||
|
||||
ITEM_FRAME(71),
|
||||
|
||||
LEASH_HITCH(77),
|
||||
|
||||
MAGMA_CUBE,
|
||||
|
||||
MINECART(10, 0),
|
||||
|
||||
MINECART_CHEST(10, 1),
|
||||
|
||||
MINECART_COMMAND(10, 6),
|
||||
|
||||
MINECART_FURNACE(10, 2),
|
||||
|
||||
MINECART_HOPPER(10, 5),
|
||||
|
||||
MINECART_MOB_SPAWNER(10, 4),
|
||||
|
||||
MINECART_TNT(10, 3),
|
||||
|
||||
MULE,
|
||||
|
||||
MUSHROOM_COW,
|
||||
|
||||
OCELOT,
|
||||
|
||||
PAINTING,
|
||||
|
||||
PIG,
|
||||
|
||||
PIG_ZOMBIE,
|
||||
|
||||
PLAYER,
|
||||
|
||||
PRIMED_TNT(50),
|
||||
|
||||
RABBIT,
|
||||
|
||||
SHEEP,
|
||||
|
||||
SILVERFISH,
|
||||
|
||||
SKELETON,
|
||||
|
||||
SKELETON_HORSE,
|
||||
|
||||
SLIME,
|
||||
|
||||
SMALL_FIREBALL(64, 0),
|
||||
|
||||
SNOWBALL(61),
|
||||
|
||||
SNOWMAN,
|
||||
|
||||
SPIDER,
|
||||
|
||||
SPLASH_POTION(73),
|
||||
|
||||
SQUID,
|
||||
|
||||
THROWN_EXP_BOTTLE(75),
|
||||
|
||||
UNDEAD_HORSE,
|
||||
|
||||
VILLAGER,
|
||||
|
||||
WITCH,
|
||||
|
||||
WITHER,
|
||||
|
||||
WITHER_SKELETON,
|
||||
|
||||
WITHER_SKULL(66),
|
||||
|
||||
WOLF,
|
||||
|
||||
ZOMBIE,
|
||||
|
||||
ZOMBIE_VILLAGER,
|
||||
|
||||
UNKNOWN;
|
||||
|
||||
|
||||
private static Method isVillager, getVariant, getSkeletonType, isElder;
|
||||
|
||||
static {
|
||||
@ -160,27 +92,27 @@ public enum DisguiseType {
|
||||
try {
|
||||
DisguiseType toUse = type;
|
||||
switch (type) {
|
||||
// Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being..
|
||||
// Usable.
|
||||
case ITEM_FRAME:
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
toUse = DisguiseType.HORSE;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
toUse = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
toUse = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
toUse = DisguiseType.GUARDIAN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being..
|
||||
// Usable.
|
||||
case ITEM_FRAME:
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
toUse = DisguiseType.HORSE;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
toUse = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
toUse = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ELDER_GUARDIAN:
|
||||
toUse = DisguiseType.GUARDIAN;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
type.setEntityType(EntityType.valueOf(toUse.name()));
|
||||
} catch (Throwable ex) {
|
||||
@ -209,44 +141,44 @@ public enum DisguiseType {
|
||||
public static DisguiseType getType(Entity entity) {
|
||||
DisguiseType disguiseType = getType(entity.getType());
|
||||
switch (disguiseType) {
|
||||
case ZOMBIE:
|
||||
try {
|
||||
if ((Boolean) isVillager.invoke(entity)) {
|
||||
disguiseType = DisguiseType.ZOMBIE_VILLAGER;
|
||||
case ZOMBIE:
|
||||
try {
|
||||
if ((Boolean) isVillager.invoke(entity)) {
|
||||
disguiseType = DisguiseType.ZOMBIE_VILLAGER;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
break;
|
||||
case HORSE:
|
||||
try {
|
||||
Object variant = getVariant.invoke(entity);
|
||||
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;
|
||||
break;
|
||||
case HORSE:
|
||||
try {
|
||||
Object variant = getVariant.invoke(entity);
|
||||
disguiseType = DisguiseType.valueOf(((Enum) variant).name());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
break;
|
||||
case GUARDIAN:
|
||||
try {
|
||||
if ((Boolean) isElder.invoke(entity)) {
|
||||
disguiseType = DisguiseType.ELDER_GUARDIAN;
|
||||
break;
|
||||
case SKELETON:
|
||||
try {
|
||||
Object type = getSkeletonType.invoke(entity);
|
||||
if (type == Skeleton.SkeletonType.WITHER) {
|
||||
disguiseType = DisguiseType.WITHER_SKELETON;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
case GUARDIAN:
|
||||
try {
|
||||
if ((Boolean) isElder.invoke(entity)) {
|
||||
disguiseType = DisguiseType.ELDER_GUARDIAN;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return disguiseType;
|
||||
}
|
||||
@ -267,14 +199,14 @@ public enum DisguiseType {
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
int value = ints[i];
|
||||
switch (i) {
|
||||
case 0:
|
||||
entityId = value;
|
||||
break;
|
||||
case 1:
|
||||
defaultId = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case 0:
|
||||
entityId = value;
|
||||
break;
|
||||
case 1:
|
||||
defaultId = value;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,7 +249,7 @@ public enum DisguiseType {
|
||||
public boolean isPlayer() {
|
||||
return this == DisguiseType.PLAYER;
|
||||
}
|
||||
|
||||
|
||||
public boolean isUnknown() {
|
||||
return this == DisguiseType.UNKNOWN;
|
||||
}
|
||||
@ -332,8 +264,9 @@ public enum DisguiseType {
|
||||
|
||||
public String toReadable() {
|
||||
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();
|
||||
}
|
||||
return StringUtils.join(split, " ");
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,9 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class FlagWatcher {
|
||||
|
||||
public enum SlotType {
|
||||
|
||||
BOOTS(0), CHESTPLATE(2), HELD_ITEM(4), HELMET(3), LEGGINGS(1);
|
||||
// The ints is for bukkit. Not nms slots.
|
||||
private int slotNo = 0;
|
||||
@ -89,16 +91,19 @@ public class FlagWatcher {
|
||||
sentValues.add(dataType);
|
||||
// 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!
|
||||
if (dataType == 1)
|
||||
if (dataType == 1) {
|
||||
sendAllCustom = true;
|
||||
}
|
||||
Object value = null;
|
||||
if (entityValues.containsKey(dataType)) {
|
||||
if (entityValues.get(dataType) == null)
|
||||
if (entityValues.get(dataType) == null) {
|
||||
continue;
|
||||
}
|
||||
value = entityValues.get(dataType);
|
||||
} else if (backupEntityValues.containsKey(dataType)) {
|
||||
if (backupEntityValues.get(dataType) == null)
|
||||
if (backupEntityValues.get(dataType) == null) {
|
||||
continue;
|
||||
}
|
||||
value = backupEntityValues.get(dataType);
|
||||
}
|
||||
if (value != null) {
|
||||
@ -107,24 +112,28 @@ public class FlagWatcher {
|
||||
}
|
||||
boolean isDirty = watch.getDirtyState();
|
||||
watch = new WrappedWatchableObject(dataType, value);
|
||||
if (!isDirty)
|
||||
if (!isDirty) {
|
||||
watch.setDirtyState(false);
|
||||
}
|
||||
} else {
|
||||
boolean isDirty = watch.getDirtyState();
|
||||
watch = new WrappedWatchableObject(dataType, watch.getValue());
|
||||
if (!isDirty)
|
||||
if (!isDirty) {
|
||||
watch.setDirtyState(false);
|
||||
}
|
||||
}
|
||||
newList.add(watch);
|
||||
}
|
||||
if (sendAllCustom) {
|
||||
// Its sending the entire meta data. Better add the custom meta
|
||||
for (int value : entityValues.keySet()) {
|
||||
if (sentValues.contains(value))
|
||||
if (sentValues.contains(value)) {
|
||||
continue;
|
||||
}
|
||||
Object obj = entityValues.get(value);
|
||||
if (obj == null)
|
||||
if (obj == null) {
|
||||
continue;
|
||||
}
|
||||
WrappedWatchableObject watch = new WrappedWatchableObject(value, obj);
|
||||
newList.add(watch);
|
||||
}
|
||||
@ -182,8 +191,9 @@ public class FlagWatcher {
|
||||
}
|
||||
|
||||
protected Object getValue(int no, Object backup) {
|
||||
if (entityValues.containsKey(no))
|
||||
if (entityValues.containsKey(no)) {
|
||||
return entityValues.get(no);
|
||||
}
|
||||
return backup;
|
||||
}
|
||||
|
||||
@ -246,12 +256,14 @@ public class FlagWatcher {
|
||||
}
|
||||
|
||||
protected void sendData(int... dataValues) {
|
||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this)
|
||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) {
|
||||
return;
|
||||
}
|
||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||
for (int data : dataValues) {
|
||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null) {
|
||||
continue;
|
||||
}
|
||||
Object value = entityValues.get(data);
|
||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) {
|
||||
value = addEntityAnimations((Byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
||||
@ -348,8 +360,9 @@ public class FlagWatcher {
|
||||
items[slot] = itemStack;
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
slot++;
|
||||
if (slot > 4)
|
||||
if (slot > 4) {
|
||||
slot = 0;
|
||||
}
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class MiscDisguise extends TargetedDisguise {
|
||||
|
||||
private int id = -1, data = 0;
|
||||
|
||||
public MiscDisguise(DisguiseType disguiseType) {
|
||||
@ -52,31 +53,31 @@ public class MiscDisguise extends TargetedDisguise {
|
||||
this.id = getType().getEntityId();
|
||||
this.data = getType().getDefaultId();
|
||||
switch (disguiseType) {
|
||||
// The only disguises which should use a custom data.
|
||||
case PAINTING:
|
||||
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, firstParam) % Art.values().length]);
|
||||
break;
|
||||
case FALLING_BLOCK:
|
||||
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, firstParam), 1, (short) Math.max(0,
|
||||
secondParam)));
|
||||
break;
|
||||
case SPLASH_POTION:
|
||||
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, firstParam));
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
if (firstParam > 0) {
|
||||
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(firstParam, Math.max(0, secondParam)));
|
||||
}
|
||||
break;
|
||||
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 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 WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter
|
||||
this.data = firstParam;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// The only disguises which should use a custom data.
|
||||
case PAINTING:
|
||||
((PaintingWatcher) getWatcher()).setArt(Art.values()[Math.max(0, firstParam) % Art.values().length]);
|
||||
break;
|
||||
case FALLING_BLOCK:
|
||||
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(Math.max(1, firstParam), 1, (short) Math.max(0,
|
||||
secondParam)));
|
||||
break;
|
||||
case SPLASH_POTION:
|
||||
((SplashPotionWatcher) getWatcher()).setPotionId(Math.max(0, firstParam));
|
||||
break;
|
||||
case DROPPED_ITEM:
|
||||
if (firstParam > 0) {
|
||||
((DroppedItemWatcher) getWatcher()).setItemStack(new ItemStack(firstParam, Math.max(0, secondParam)));
|
||||
}
|
||||
break;
|
||||
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 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 WITHER_SKULL: // Unknown. Uses entity id of shooter. 0 if no shooter
|
||||
this.data = firstParam;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,14 +135,14 @@ public class MiscDisguise extends TargetedDisguise {
|
||||
*/
|
||||
public int getData() {
|
||||
switch (getType()) {
|
||||
case FALLING_BLOCK:
|
||||
return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
|
||||
case PAINTING:
|
||||
return ((PaintingWatcher) getWatcher()).getArt().getId();
|
||||
case SPLASH_POTION:
|
||||
return ((SplashPotionWatcher) getWatcher()).getPotionId();
|
||||
default:
|
||||
return data;
|
||||
case FALLING_BLOCK:
|
||||
return (int) ((FallingBlockWatcher) getWatcher()).getBlock().getDurability();
|
||||
case PAINTING:
|
||||
return ((PaintingWatcher) getWatcher()).getArt().getId();
|
||||
case SPLASH_POTION:
|
||||
return ((SplashPotionWatcher) getWatcher()).getPotionId();
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,4 +246,4 @@ public class MiscDisguise extends TargetedDisguise {
|
||||
return (MiscDisguise) super.silentlyRemovePlayer(playername);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -184,4 +184,4 @@ public class MobDisguise extends TargetedDisguise {
|
||||
public MobDisguise silentlyRemovePlayer(String playername) {
|
||||
return (MobDisguise) super.silentlyRemovePlayer(playername);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,14 +13,16 @@ import me.libraryaddict.disguise.utilities.LibsProfileLookup;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class PlayerDisguise extends TargetedDisguise {
|
||||
|
||||
private LibsProfileLookup currentLookup;
|
||||
private WrappedGameProfile gameProfile;
|
||||
private String playerName;
|
||||
private String skinToUse;
|
||||
|
||||
public PlayerDisguise(String name) {
|
||||
if (name.length() > 16)
|
||||
if (name.length() > 16) {
|
||||
name = name.substring(0, 16);
|
||||
}
|
||||
playerName = name;
|
||||
createDisguise(DisguiseType.PLAYER);
|
||||
}
|
||||
@ -198,9 +200,8 @@ public class PlayerDisguise extends TargetedDisguise {
|
||||
|
||||
/**
|
||||
* Set the GameProfile, without tampering.
|
||||
*
|
||||
* @param gameProfile
|
||||
* GameProfile
|
||||
*
|
||||
* @param gameProfile GameProfile
|
||||
* @return
|
||||
*/
|
||||
public PlayerDisguise setSkin(WrappedGameProfile gameProfile) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
public enum RabbitType {
|
||||
|
||||
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
|
||||
|
||||
public static RabbitType getType(int id) {
|
||||
|
@ -10,7 +10,9 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class TargetedDisguise extends Disguise {
|
||||
|
||||
public enum TargetType {
|
||||
|
||||
HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS;
|
||||
}
|
||||
|
||||
|
@ -30,9 +30,9 @@ public class ArmorStandWatcher extends LivingWatcher {
|
||||
|
||||
private void set10(int value, boolean isTrue) {
|
||||
byte b1 = (Byte) getValue(10, (byte) 0);
|
||||
if (isTrue)
|
||||
if (isTrue) {
|
||||
b1 = (byte) (b1 | value);
|
||||
else {
|
||||
} else {
|
||||
b1 = (byte) (b1 & value);
|
||||
}
|
||||
setValue(10, b1);
|
||||
|
@ -9,6 +9,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
public class FallingBlockWatcher extends FlagWatcher {
|
||||
|
||||
private ItemStack block;
|
||||
|
||||
public FallingBlockWatcher(Disguise disguise) {
|
||||
|
@ -23,14 +23,14 @@ public class HorseWatcher extends AgeableWatcher {
|
||||
public ItemStack getHorseArmor() {
|
||||
int horseValue = getHorseArmorAsInt();
|
||||
switch (horseValue) {
|
||||
case 1:
|
||||
return new ItemStack(Material.getMaterial("IRON_BARDING"));
|
||||
case 2:
|
||||
return new ItemStack(Material.getMaterial("GOLD_BARDING"));
|
||||
case 3:
|
||||
return new ItemStack(Material.getMaterial("DIAMOND_BARDING"));
|
||||
default:
|
||||
break;
|
||||
case 1:
|
||||
return new ItemStack(Material.getMaterial("IRON_BARDING"));
|
||||
case 2:
|
||||
return new ItemStack(Material.getMaterial("GOLD_BARDING"));
|
||||
case 3:
|
||||
return new ItemStack(Material.getMaterial("DIAMOND_BARDING"));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -11,8 +11,9 @@ public class ItemFrameWatcher extends FlagWatcher {
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
if (getValue(2, null) == null)
|
||||
if (getValue(2, null) == null) {
|
||||
return new ItemStack(0);
|
||||
}
|
||||
return (ItemStack) getValue(8, null);
|
||||
}
|
||||
|
||||
@ -21,8 +22,9 @@ public class ItemFrameWatcher extends FlagWatcher {
|
||||
}
|
||||
|
||||
public void setItem(ItemStack newItem) {
|
||||
if (newItem == null)
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(0);
|
||||
}
|
||||
newItem = newItem.clone();
|
||||
newItem.setAmount(1);
|
||||
setValue(8, newItem);
|
||||
|
@ -23,8 +23,10 @@ import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
||||
|
||||
public class LivingWatcher extends FlagWatcher {
|
||||
|
||||
static Object[] list;
|
||||
static Method potionNo;
|
||||
|
||||
static {
|
||||
try {
|
||||
list = (Object[]) ReflectionManager.getNmsField("MobEffectList", "byId").get(null);
|
||||
|
@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
public class PaintingWatcher extends FlagWatcher {
|
||||
|
||||
private Art painting;
|
||||
|
||||
public PaintingWatcher(Disguise disguise) {
|
||||
|
@ -16,6 +16,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
||||
|
||||
public class PlayerWatcher extends LivingWatcher {
|
||||
|
||||
private boolean isInBed;
|
||||
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.
|
||||
*
|
||||
* @param sleeping
|
||||
* @param sleepingDirection
|
||||
*/
|
||||
|
@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
public class SplashPotionWatcher extends FlagWatcher {
|
||||
|
||||
private int potionId;
|
||||
|
||||
public SplashPotionWatcher(Disguise disguise) {
|
||||
|
@ -17,11 +17,11 @@ public class VillagerWatcher extends AgeableWatcher {
|
||||
return Profession.values()[(Integer) getValue(16, 0)];
|
||||
}
|
||||
|
||||
public void setProfession(int professionId){
|
||||
public void setProfession(int professionId) {
|
||||
setValue(16, professionId % 6);
|
||||
sendData(16);
|
||||
}
|
||||
|
||||
|
||||
public void setProfession(Profession newProfession) {
|
||||
setProfession(newProfession.getId());
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class WitherWatcher extends LivingWatcher {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class DisguiseEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
@ -45,4 +46,4 @@ public class DisguiseEvent extends Event implements Cancellable {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class UndisguiseEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
@ -45,4 +46,4 @@ public class UndisguiseEvent extends Event implements Cancellable {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
isCancelled = cancelled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
public class DisguiseParseException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 1276971370793124510L;
|
||||
|
||||
public DisguiseParseException() {
|
||||
@ -45,7 +46,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
super(string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected ArrayList<String> getAllowedDisguises(HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> hashMap) {
|
||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||
for (DisguiseType type : hashMap.keySet()) {
|
||||
@ -61,30 +62,30 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
protected HashMap<String, Boolean> getDisguisePermission(CommandSender sender, DisguiseType type) {
|
||||
switch (type) {
|
||||
case PLAYER:
|
||||
case FALLING_BLOCK:
|
||||
case PAINTING:
|
||||
case SPLASH_POTION:
|
||||
case FISHING_HOOK:
|
||||
case DROPPED_ITEM:
|
||||
HashMap<String, Boolean> returns = new HashMap<>();
|
||||
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
|
||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||
String lowerPerm = permission.getPermission().toLowerCase();
|
||||
if (lowerPerm.startsWith(beginning)) {
|
||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||
if (split.length > 1) {
|
||||
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
returns.put(split[i], permission.getValue());
|
||||
case PLAYER:
|
||||
case FALLING_BLOCK:
|
||||
case PAINTING:
|
||||
case SPLASH_POTION:
|
||||
case FISHING_HOOK:
|
||||
case DROPPED_ITEM:
|
||||
HashMap<String, Boolean> returns = new HashMap<>();
|
||||
String beginning = "libsdisguises.options." + getClass().getSimpleName().toLowerCase().replace("command", "") + ".";
|
||||
for (PermissionAttachmentInfo permission : sender.getEffectivePermissions()) {
|
||||
String lowerPerm = permission.getPermission().toLowerCase();
|
||||
if (lowerPerm.startsWith(beginning)) {
|
||||
String[] split = lowerPerm.substring(beginning.length()).split("\\.");
|
||||
if (split.length > 1) {
|
||||
if (split[0].replace("_", "").equals(type.name().toLowerCase().replace("_", ""))) {
|
||||
for (int i = 1; i < split.length; i++) {
|
||||
returns.put(split[i], permission.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return returns;
|
||||
default:
|
||||
return new HashMap<>();
|
||||
return returns;
|
||||
default:
|
||||
return new HashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,8 +93,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
Method[] methods = watcherClass.getMethods();
|
||||
methods = Arrays.copyOf(methods, methods.length + 4);
|
||||
int i = 4;
|
||||
for (String methodName : new String[] { "setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
|
||||
"setHearSelfDisguise" }) {
|
||||
for (String methodName : new String[]{"setViewSelfDisguise", "setHideHeldItemFromSelf", "setHideArmorFromSelf",
|
||||
"setHearSelfDisguise"}) {
|
||||
try {
|
||||
methods[methods.length - i--] = Disguise.class.getMethod(methodName, boolean.class);
|
||||
} 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
|
||||
*
|
||||
* @param sender
|
||||
* @param permissionNode
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
protected HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> getPermissions(CommandSender sender, String permissionNode) {
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> singleDisguises = new HashMap<>();
|
||||
@ -265,8 +267,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
option = option.substring(1);
|
||||
isRemove = false;
|
||||
}
|
||||
if (option.equals("baby"))
|
||||
if (option.equals("baby")) {
|
||||
option = "setbaby";
|
||||
}
|
||||
list.add(option);
|
||||
}
|
||||
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
|
||||
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the
|
||||
* disguise has been feed a proper disguisetype.
|
||||
* 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.
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
* @param map
|
||||
* @return
|
||||
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
* @return
|
||||
* @throws me.libraryaddict.disguise.utilities.BaseDisguiseCommand.DisguiseParseException
|
||||
* @throws java.lang.IllegalAccessException
|
||||
* @throws java.lang.reflect.InvocationTargetException
|
||||
*/
|
||||
protected Disguise parseDisguise(CommandSender sender, String[] args, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) throws DisguiseParseException,
|
||||
IllegalAccessException, InvocationTargetException {
|
||||
@ -366,7 +368,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else {
|
||||
if (!disguiseOptions.isEmpty()
|
||||
&& (!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!");
|
||||
}
|
||||
args[1] = args[1].replace("\\_", " ");
|
||||
@ -415,19 +417,19 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
}
|
||||
if (miscId != -1) {
|
||||
switch (disguiseType) {
|
||||
case PAINTING:
|
||||
case FALLING_BLOCK:
|
||||
case SPLASH_POTION:
|
||||
case DROPPED_ITEM:
|
||||
case FISHING_HOOK:
|
||||
case ARROW:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable()
|
||||
+ " doesn't know what to do with " + args[1] + "!");
|
||||
case PAINTING:
|
||||
case FALLING_BLOCK:
|
||||
case SPLASH_POTION:
|
||||
case DROPPED_ITEM:
|
||||
case FISHING_HOOK:
|
||||
case ARROW:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
break;
|
||||
default:
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! " + disguiseType.toReadable()
|
||||
+ " doesn't know what to do with " + args[1] + "!");
|
||||
}
|
||||
toSkip++;
|
||||
// If they also defined a data value
|
||||
@ -577,8 +579,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
if (potionType == null && isNumeric(valueString)) {
|
||||
potionType = PotionEffectType.getById(Integer.parseInt(valueString));
|
||||
}
|
||||
if (potionType == null)
|
||||
if (potionType == null) {
|
||||
throw new DisguiseParseException();
|
||||
}
|
||||
value = potionType;
|
||||
} catch (Exception ex) {
|
||||
throw parseToException("a potioneffect type", valueString, methodName);
|
||||
@ -597,8 +600,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else if (param == BlockFace.class) {
|
||||
try {
|
||||
BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
|
||||
if (face.ordinal() > 4)
|
||||
if (face.ordinal() > 4) {
|
||||
throw new DisguiseParseException();
|
||||
}
|
||||
value = face;
|
||||
} catch (Exception ex) {
|
||||
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());
|
||||
}
|
||||
doCheck(optionPermissions, usedOptions);
|
||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass()))
|
||||
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
|
||||
methodToUse.invoke(disguise.getWatcher(), value);
|
||||
else
|
||||
} else {
|
||||
methodToUse.invoke(disguise, value);
|
||||
}
|
||||
}
|
||||
// Alright. We've constructed our disguise.
|
||||
return disguise;
|
||||
|
@ -13,7 +13,6 @@ import java.util.jar.JarFile;
|
||||
/**
|
||||
* User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester
|
||||
*/
|
||||
|
||||
// Code for this taken and slightly modified from
|
||||
// https://github.com/ddopson/java-class-enumerator
|
||||
public class ClassGetter {
|
||||
@ -59,8 +58,9 @@ public class ClassGetter {
|
||||
}
|
||||
if (className != null) {
|
||||
Class<?> c = loadClass(className);
|
||||
if (c != null)
|
||||
if (c != null) {
|
||||
classes.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
|
@ -11,107 +11,69 @@ import org.bukkit.Sound;
|
||||
* Only living disguises go in here!
|
||||
*/
|
||||
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",
|
||||
"mob.bat.takeoff"),
|
||||
|
||||
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"),
|
||||
|
||||
CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall",
|
||||
"mob.chicken.plop", "damage.fallbig"),
|
||||
|
||||
COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
|
||||
|
||||
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",
|
||||
"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"),
|
||||
|
||||
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",
|
||||
"mob.enderdragon.wings", "damage.fallbig"),
|
||||
|
||||
ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream",
|
||||
"mob.endermen.portal", "mob.endermen.stare"),
|
||||
|
||||
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",
|
||||
"damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"),
|
||||
|
||||
GIANT("damage.hit", "step.grass", null, null),
|
||||
|
||||
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",
|
||||
"mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry",
|
||||
"mob.horse.leather"),
|
||||
|
||||
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"),
|
||||
|
||||
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"),
|
||||
|
||||
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_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
|
||||
|
||||
PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null),
|
||||
|
||||
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"),
|
||||
|
||||
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_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.jump", "mob.horse.angry"),
|
||||
|
||||
SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
|
||||
|
||||
SNOWMAN(),
|
||||
|
||||
SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
|
||||
|
||||
SQUID(),
|
||||
|
||||
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.angry"),
|
||||
|
||||
VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no",
|
||||
"mob.villager.yes"),
|
||||
|
||||
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",
|
||||
"damage.fallbig", "mob.wither.shoot"),
|
||||
|
||||
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",
|
||||
"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",
|
||||
"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",
|
||||
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
|
||||
|
||||
public enum SoundType {
|
||||
|
||||
CANCEL, DEATH, HURT, IDLE, STEP;
|
||||
}
|
||||
|
||||
@ -131,9 +93,9 @@ public enum DisguiseSound {
|
||||
for (int i = 0; i < sounds.length; i++) {
|
||||
Object obj = sounds[i];
|
||||
String s;
|
||||
if (obj == null)
|
||||
if (obj == null) {
|
||||
continue;
|
||||
else if (obj instanceof String) {
|
||||
} else if (obj instanceof String) {
|
||||
s = (String) obj;
|
||||
} else if (obj instanceof Sound) {
|
||||
s = ReflectionManager.getCraftSound((Sound) obj);
|
||||
@ -142,21 +104,21 @@ public enum DisguiseSound {
|
||||
throw new RuntimeException("Was given a unknown object " + obj);
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
disguiseSounds.put(SoundType.HURT, s);
|
||||
break;
|
||||
case 1:
|
||||
disguiseSounds.put(SoundType.STEP, s);
|
||||
break;
|
||||
case 2:
|
||||
disguiseSounds.put(SoundType.DEATH, s);
|
||||
break;
|
||||
case 3:
|
||||
disguiseSounds.put(SoundType.IDLE, s);
|
||||
break;
|
||||
default:
|
||||
cancelSounds.add(s);
|
||||
break;
|
||||
case 0:
|
||||
disguiseSounds.put(SoundType.HURT, s);
|
||||
break;
|
||||
case 1:
|
||||
disguiseSounds.put(SoundType.STEP, s);
|
||||
break;
|
||||
case 2:
|
||||
disguiseSounds.put(SoundType.DEATH, s);
|
||||
break;
|
||||
case 3:
|
||||
disguiseSounds.put(SoundType.IDLE, s);
|
||||
break;
|
||||
default:
|
||||
cancelSounds.add(s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -166,8 +128,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public String getSound(SoundType type) {
|
||||
if (type == null || !disguiseSounds.containsKey(type))
|
||||
if (type == null || !disguiseSounds.containsKey(type)) {
|
||||
return null;
|
||||
}
|
||||
return disguiseSounds.get(type);
|
||||
}
|
||||
|
||||
@ -179,18 +142,22 @@ public enum DisguiseSound {
|
||||
* Used to check if this sound name is owned by this disguise sound.
|
||||
*/
|
||||
public SoundType getType(String sound, boolean ignoreDamage) {
|
||||
if (isCancelSound(sound))
|
||||
if (isCancelSound(sound)) {
|
||||
return SoundType.CANCEL;
|
||||
}
|
||||
if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.")
|
||||
&& sound.startsWith("step."))
|
||||
&& sound.startsWith("step.")) {
|
||||
return SoundType.STEP;
|
||||
}
|
||||
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;
|
||||
}
|
||||
String s = disguiseSounds.get(type);
|
||||
if (s != null) {
|
||||
if (s.equals(sound))
|
||||
if (s.equals(sound)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -205,9 +172,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public void removeSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL)
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.remove(sound);
|
||||
else {
|
||||
} else {
|
||||
disguiseSounds.remove(type);
|
||||
}
|
||||
}
|
||||
@ -221,9 +188,9 @@ public enum DisguiseSound {
|
||||
}
|
||||
|
||||
public void setSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL)
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.add(sound);
|
||||
else {
|
||||
} else {
|
||||
disguiseSounds.put(type, sound);
|
||||
}
|
||||
}
|
||||
|
@ -51,20 +51,20 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
|
||||
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
|
||||
* the plugin to do that.
|
||||
* 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.
|
||||
*/
|
||||
private static HashSet<String> addedByPlugins = new HashSet<>();
|
||||
private static Object bedChunk;
|
||||
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
|
||||
/**
|
||||
* 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<>();
|
||||
/**
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
|
||||
/**
|
||||
@ -99,7 +99,7 @@ public class DisguiseUtilities {
|
||||
ReflectionManager.getNmsClass("IBlockData"));
|
||||
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);
|
||||
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()));
|
||||
setSky.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
|
||||
* observers in the disguise don't see any other disguise.
|
||||
* 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.
|
||||
*/
|
||||
public static void checkConflicts(TargetedDisguise disguise, String name) {
|
||||
// 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
|
||||
// + " on a entity. Removed the old disguise.");
|
||||
|
||||
disguiseItel.remove();
|
||||
d.removeDisguise();
|
||||
}
|
||||
@ -258,7 +256,7 @@ public class DisguiseUtilities {
|
||||
entityTrackerEntry);
|
||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||
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) {
|
||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
if (player == disguise.getEntity() || disguise.canSee(player)) {
|
||||
@ -281,7 +279,7 @@ public class DisguiseUtilities {
|
||||
if (disguiseValues.getBabyBox() != null) {
|
||||
if ((disguise.getWatcher() instanceof AgeableWatcher && ((AgeableWatcher) disguise.getWatcher()).isBaby())
|
||||
|| (disguise.getWatcher() instanceof ZombieWatcher && ((ZombieWatcher) disguise.getWatcher())
|
||||
.isBaby())) {
|
||||
.isBaby())) {
|
||||
disguiseBox = disguiseValues.getBabyBox();
|
||||
}
|
||||
}
|
||||
@ -307,7 +305,7 @@ public class DisguiseUtilities {
|
||||
public static PacketContainer[] getBedChunkPacket(Player player, Location newLoc, Location oldLoc) {
|
||||
int i = 0;
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
@ -360,7 +358,7 @@ public class DisguiseUtilities {
|
||||
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(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.
|
||||
*
|
||||
* @param disguise
|
||||
* @return
|
||||
* @return
|
||||
*/
|
||||
public static ArrayList<Player> getPerverts(Disguise disguise) {
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
@ -469,7 +468,7 @@ public class DisguiseUtilities {
|
||||
if (DisguiseAPI.isDisguiseInUse(disguise)
|
||||
&& (!gameProfile.getName().equals(
|
||||
disguise.getSkin() != null ? disguise.getSkin() : disguise.getName())
|
||||
|| !gameProfile.getProperties().isEmpty())) {
|
||||
|| !gameProfile.getProperties().isEmpty())) {
|
||||
disguise.setGameProfile(gameProfile);
|
||||
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
|
||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
* 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
|
||||
*/
|
||||
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup 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
|
||||
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
|
||||
* 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
|
||||
*/
|
||||
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable 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
|
||||
* 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..
|
||||
* 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..
|
||||
*/
|
||||
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
|
||||
List<WrappedWatchableObject> list) {
|
||||
if (true) // Use for future protocol compatibility
|
||||
{
|
||||
return list;
|
||||
}
|
||||
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>();
|
||||
ArrayList<WrappedWatchableObject> backups = new ArrayList<>();
|
||||
for (WrappedWatchableObject obj : list) {
|
||||
@ -598,7 +595,7 @@ public class DisguiseUtilities {
|
||||
continue;
|
||||
}
|
||||
switch (obj.getIndex()) {
|
||||
// TODO: Future version support
|
||||
// TODO: Future version support
|
||||
}
|
||||
}
|
||||
Iterator<WrappedWatchableObject> itel = backups.iterator();
|
||||
@ -625,8 +622,9 @@ public class DisguiseUtilities {
|
||||
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
|
||||
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
|
||||
removeSelfDisguise((Player) disguise.getEntity());
|
||||
if (disguise.isSelfDisguiseVisible())
|
||||
if (disguise.isSelfDisguiseVisible()) {
|
||||
selfDisguised.add(disguise.getEntity().getUniqueId());
|
||||
}
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
@Override
|
||||
@ -820,10 +818,10 @@ public class DisguiseUtilities {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(
|
||||
player,
|
||||
ProtocolLibrary
|
||||
.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
.getProtocolManager()
|
||||
.createPacketConstructor(PacketType.Play.Server.ENTITY_METADATA, player.getEntityId(),
|
||||
WrappedDataWatcher.getEntityWatcher(player), true)
|
||||
.createPacket(player.getEntityId(), WrappedDataWatcher.getEntityWatcher(player), true));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
@ -891,11 +889,11 @@ public class DisguiseUtilities {
|
||||
if (player.getVehicle() != null && player.getEntityId() > player.getVehicle().getEntityId()) {
|
||||
sendSelfPacket(player,
|
||||
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()) {
|
||||
sendSelfPacket(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
|
||||
@ -928,7 +926,7 @@ public class DisguiseUtilities {
|
||||
Object mobEffect = ReflectionManager.createMobEffect(potionEffect);
|
||||
sendSelfPacket(player,
|
||||
manager.createPacketConstructor(PacketType.Play.Server.ENTITY_EFFECT, player.getEntityId(), mobEffect)
|
||||
.createPacket(player.getEntityId(), mobEffect));
|
||||
.createPacket(player.getEntityId(), mobEffect));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
@ -944,7 +942,7 @@ public class DisguiseUtilities {
|
||||
final PacketContainer[] delayed = transformed == null ? null : transformed[1];
|
||||
try {
|
||||
if (packets == null) {
|
||||
packets = new PacketContainer[] { packet };
|
||||
packets = new PacketContainer[]{packet};
|
||||
}
|
||||
for (PacketContainer p : packets) {
|
||||
p = p.deepClone();
|
||||
@ -972,6 +970,7 @@ public class DisguiseUtilities {
|
||||
|
||||
/**
|
||||
* Setup it so he can see himself when disguised
|
||||
*
|
||||
* @param disguise
|
||||
*/
|
||||
public static void setupFakeDisguise(final Disguise disguise) {
|
||||
|
@ -10,28 +10,28 @@ public class DisguiseValues {
|
||||
|
||||
public static DisguiseValues getDisguiseValues(DisguiseType type) {
|
||||
switch (type) {
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
type = DisguiseType.HORSE;
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_TNT:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
type = DisguiseType.MINECART;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
type = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
type = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
type = DisguiseType.HORSE;
|
||||
break;
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_TNT:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
type = DisguiseType.MINECART;
|
||||
break;
|
||||
case WITHER_SKELETON:
|
||||
type = DisguiseType.SKELETON;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
type = DisguiseType.ZOMBIE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return values.get(type);
|
||||
}
|
||||
@ -76,38 +76,38 @@ public class DisguiseValues {
|
||||
double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D);
|
||||
|
||||
switch (enumEntitySize) {
|
||||
case 1:
|
||||
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
||||
case 1:
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
default:
|
||||
break;
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (d > 0.0D) {
|
||||
return (int) Math.ceil(paramDouble * 32.0D);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.utilities;
|
||||
|
||||
public class FakeBoundingBox {
|
||||
|
||||
private double xMod;
|
||||
private double yMod;
|
||||
private double zMod;
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
|
||||
public interface LibsProfileLookup {
|
||||
|
||||
public void onLookup(WrappedGameProfile gameProfile);
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
|
||||
public class LibsProfileLookupCaller implements ProfileLookupCallback {
|
||||
|
||||
private WrappedGameProfile gameProfile;
|
||||
|
||||
public WrappedGameProfile getGameProfile() {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -31,8 +31,10 @@ import org.bukkit.potion.PotionEffect;
|
||||
public class ReflectionManager {
|
||||
|
||||
public enum LibVersion {
|
||||
|
||||
V1_8;
|
||||
private static LibVersion currentVersion;
|
||||
|
||||
static {
|
||||
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
||||
currentVersion = V1_8;
|
||||
@ -59,8 +61,7 @@ public class ReflectionManager {
|
||||
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
|
||||
* names.
|
||||
* 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.
|
||||
*/
|
||||
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
|
||||
private static final Method ihmGet;
|
||||
@ -82,7 +83,7 @@ public class ReflectionManager {
|
||||
final String nameseg_class = "a-zA-Z0-9$_";
|
||||
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(double.class, "D").put(void.class, "V").build();
|
||||
|
||||
@ -191,7 +192,7 @@ public class ReflectionManager {
|
||||
trackerField = getNmsField("WorldServer", "tracker");
|
||||
entitiesField = getNmsField("EntityTracker", "trackedEntities");
|
||||
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);
|
||||
setBoundingBoxMethod = getNmsMethod("Entity", "a", getNmsClass("AxisAlignedBB"));
|
||||
}
|
||||
@ -208,7 +209,7 @@ public class ReflectionManager {
|
||||
WrappedGameProfile gameProfile = getGameProfile(null, "LibsDisguises");
|
||||
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
|
||||
gameProfile.getHandleType(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
|
||||
gameProfile.getHandle(), playerinteractmanager);
|
||||
gameProfile.getHandle(), playerinteractmanager);
|
||||
} else if (entityName.equals("EnderPearl")) {
|
||||
entityObject = entityClass.getConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
|
||||
.newInstance(world, createEntityInstance("Cow"));
|
||||
@ -249,26 +250,26 @@ public class ReflectionManager {
|
||||
if (field.getType().getSimpleName().equals("double")) {
|
||||
stage++;
|
||||
switch (stage) {
|
||||
case 1:
|
||||
x -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 2:
|
||||
y -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 3:
|
||||
z -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 4:
|
||||
x += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 5:
|
||||
y += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 6:
|
||||
z += field.getDouble(boundingBox);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||
case 1:
|
||||
x -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 2:
|
||||
y -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 3:
|
||||
z -= field.getDouble(boundingBox);
|
||||
break;
|
||||
case 4:
|
||||
x += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 5:
|
||||
y += field.getDouble(boundingBox);
|
||||
break;
|
||||
case 6:
|
||||
z += field.getDouble(boundingBox);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Error while setting the bounding box, more doubles than I thought??");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -382,7 +383,7 @@ public class ReflectionManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static WrappedGameProfile getGameProfile(Player player) {
|
||||
public static WrappedGameProfile getGameProfile(Player player) {
|
||||
return WrappedGameProfile.fromPlayer(player);
|
||||
}
|
||||
|
||||
@ -519,7 +520,7 @@ public class ReflectionManager {
|
||||
float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
|
||||
float width = getNmsField("Entity", "width").getFloat(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) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
@ -573,7 +574,7 @@ public class ReflectionManager {
|
||||
.getClass()
|
||||
.getMethod("findProfilesByNames", String[].class, agent.getClass(),
|
||||
Class.forName("com.mojang.authlib.ProfileLookupCallback"))
|
||||
.invoke(profileRepo, new String[] { playername }, agent, callback);
|
||||
.invoke(profileRepo, new String[]{playername}, agent, callback);
|
||||
if (callback.getGameProfile() != null) {
|
||||
return callback.getGameProfile();
|
||||
}
|
||||
@ -607,10 +608,8 @@ public class ReflectionManager {
|
||||
public static void setAllowSleep(Player player) {
|
||||
try {
|
||||
/**
|
||||
Object nmsEntity = getNmsEntity(player);
|
||||
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity);
|
||||
Field check = getNmsField(connection.getClass(), "checkMovement");
|
||||
check.setBoolean(connection, true); **/
|
||||
* Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
|
||||
*/
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import java.net.URL;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class UpdateChecker {
|
||||
|
||||
private String latestVersion;
|
||||
|
||||
private boolean checkHigher(String currentVersion, String newVersion) {
|
||||
@ -51,8 +52,9 @@ public class UpdateChecker {
|
||||
private String toReadable(String version) {
|
||||
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
|
||||
version = "";
|
||||
for (String s : split)
|
||||
for (String s : split) {
|
||||
version += String.format("%4s", s);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ DisguiseCloneSize: 3
|
||||
# These disguises, as normal will not persist after a server restart.
|
||||
# There is also no EntityDeath option as entities do not revive after death.
|
||||
KeepDisguises:
|
||||
EntityDespawn: false
|
||||
PlayerDeath: false
|
||||
PlayerLogout: false
|
||||
EntityDespawn: false
|
||||
PlayerDeath: false
|
||||
PlayerLogout: false
|
||||
|
||||
# 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.
|
||||
@ -97,31 +97,31 @@ ContactMojangServers: true
|
||||
# This will help performance, especially with CPU
|
||||
# Due to safety reasons, self disguises can never have their packets disabled.
|
||||
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.
|
||||
# Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash
|
||||
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
|
||||
# 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
|
||||
# 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
|
||||
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.
|
||||
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.
|
||||
# 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
|
||||
# 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 is good if performance is extremely in need.
|
||||
# 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.
|
||||
# Animations set by use of the api or through the disguise command are still in effect.
|
||||
Metadata: true
|
||||
# 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.
|
||||
Movement: true
|
||||
# Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
|
||||
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.
|
||||
WitherSkull: true
|
||||
# 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
|
||||
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
|
||||
# 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
|
||||
# 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
|
||||
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.
|
||||
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.
|
||||
# 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
|
||||
# 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 is good if performance is extremely in need.
|
||||
# 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.
|
||||
# Animations set by use of the api or through the disguise command are still in effect.
|
||||
Metadata: true
|
||||
# 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.
|
||||
Movement: true
|
||||
# Disable this if you don't mind crashing everytime you see someone riding something disguised as a non-living entity
|
||||
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.
|
||||
WitherSkull: true
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: LibsDisguises
|
||||
main: me.libraryaddict.disguise.LibsDisguises
|
||||
version: 8.6.3
|
||||
version: 8.6.4
|
||||
author: libraryaddict
|
||||
authors: [Byteflux, Navid K.]
|
||||
depend: [ProtocolLib]
|
||||
@ -54,6 +54,9 @@ commands:
|
||||
description: Toggle seeing your own disguise on or off.
|
||||
|
||||
permissions:
|
||||
libsdisguises.reload:
|
||||
description: Allows the user to reload LibsDisguises.
|
||||
default: op
|
||||
libsdisguises.seethrough:
|
||||
description: Allows player to see through disguises.
|
||||
default: false
|
||||
@ -97,4 +100,3 @@ permissions:
|
||||
description: See the /undisguiseradius command in tab-completion
|
||||
libsdisguises.seecmd.disguiseclone:
|
||||
description: See the /disguiseclone command in tab-completion
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user