mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-15 15:28:36 +01:00
Simplify redundant statements and casts
This commit is contained in:
parent
009df4a0ad
commit
5dce8a22e8
@ -22,7 +22,7 @@ public class DisguiseCommand extends BaseDisguiseCommand {
|
|||||||
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
sender.sendMessage(ChatColor.RED + "You may not use this command from the console!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Disguise disguise = null;
|
Disguise disguise;
|
||||||
try {
|
try {
|
||||||
disguise = parseDisguise(sender, args);
|
disguise = parseDisguise(sender, args);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -57,7 +57,7 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
|
|||||||
}
|
}
|
||||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise()) {
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) player).getDisplayName());
|
((LivingWatcher) disguise.getWatcher()).setCustomName(player.getDisplayName());
|
||||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||||
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
||||||
}
|
}
|
||||||
|
@ -62,11 +62,8 @@ public class MobDisguise extends TargetedDisguise {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean doesDisguiseAge() {
|
public boolean doesDisguiseAge() {
|
||||||
if (getWatcher() != null) {
|
return getWatcher() != null &&
|
||||||
return getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher;
|
(getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||||
}
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdult() {
|
public boolean isAdult() {
|
||||||
|
@ -443,11 +443,8 @@ public class DisguiseUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDisguiseInUse(Disguise disguise) {
|
public static boolean isDisguiseInUse(Disguise disguise) {
|
||||||
if (disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId())
|
return disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId())
|
||||||
&& getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise)) {
|
&& getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -179,7 +179,7 @@ public class PacketsManager {
|
|||||||
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
stringMods.write(i, ((PlayerDisguise) disguise).getName());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Object gameProfile = null;
|
Object gameProfile;
|
||||||
String name = ((PlayerDisguise) disguise).getName();
|
String name = ((PlayerDisguise) disguise).getName();
|
||||||
boolean removeName = false;
|
boolean removeName = false;
|
||||||
if (!DisguiseUtilities.hasGameProfile(name)) {
|
if (!DisguiseUtilities.hasGameProfile(name)) {
|
||||||
@ -529,8 +529,9 @@ public class PacketsManager {
|
|||||||
if (disguise.isSoundsReplaced()) {
|
if (disguise.isSoundsReplaced()) {
|
||||||
String sound = null;
|
String sound = null;
|
||||||
DisguiseSound dSound = DisguiseSound.getType(disguise.getType().name());
|
DisguiseSound dSound = DisguiseSound.getType(disguise.getType().name());
|
||||||
if (dSound != null && soundType != null)
|
if (dSound != null)
|
||||||
sound = dSound.getSound(soundType);
|
sound = dSound.getSound(soundType);
|
||||||
|
|
||||||
if (sound == null) {
|
if (sound == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
} else {
|
} else {
|
||||||
@ -563,7 +564,7 @@ public class PacketsManager {
|
|||||||
if (soundType == SoundType.HURT || soundType == SoundType.DEATH
|
if (soundType == SoundType.HURT || soundType == SoundType.DEATH
|
||||||
|| soundType == SoundType.IDLE) {
|
|| soundType == SoundType.IDLE) {
|
||||||
// If the volume is the default
|
// If the volume is the default
|
||||||
if (((Float) mods.read(4)).equals(entitySound.getDamageAndIdleSoundVolume())) {
|
if (mods.read(4).equals(entitySound.getDamageAndIdleSoundVolume())) {
|
||||||
mods.write(4, dSound.getDamageAndIdleSoundVolume());
|
mods.write(4, dSound.getDamageAndIdleSoundVolume());
|
||||||
}
|
}
|
||||||
// Here I assume its the default pitch as I can't calculate if its real.
|
// Here I assume its the default pitch as I can't calculate if its real.
|
||||||
|
@ -151,8 +151,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static Entity getBukkitEntity(Object nmsEntity) {
|
public static Entity getBukkitEntity(Object nmsEntity) {
|
||||||
try {
|
try {
|
||||||
Entity bukkitEntity = (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity").invoke(nmsEntity);
|
return (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity").invoke(nmsEntity);
|
||||||
return bukkitEntity;
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user