Added 2 config options to show names above disguised players head
This commit is contained in:
parent
8dd604153e
commit
319c987f94
@ -32,3 +32,12 @@ AddEntityAnimations: true
|
||||
# Does the plugin remove that disguise from valid disguises? If your plugin handles this. Then thats good.
|
||||
# Else its a memory leak. This loops through all disguise to see if anyone else is online who can see that disguise.
|
||||
RemoveUnusedDisguises: true
|
||||
# This is only called into action when the disguise is constructed using the commands.
|
||||
# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance.
|
||||
# Such as prophunt. Its also false because its kind of a retarded feature.
|
||||
# This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head.
|
||||
# This also overrides any custom name they have set in their disguise options.
|
||||
ShowNamesAboveDisguises: false
|
||||
# This supports the above option.
|
||||
# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not.
|
||||
NameAboveHeadAlwaysVisible: true
|
@ -24,6 +24,8 @@ public class DisguiseAPI {
|
||||
private static boolean isEntityAnimationsAdded;
|
||||
private static boolean removeUnseenDisguises;
|
||||
private static boolean sendVelocity;
|
||||
private static boolean showNameAboveHead;
|
||||
private static boolean showNameAboveHeadAlwaysVisible;
|
||||
|
||||
@Deprecated
|
||||
public static boolean canHearSelfDisguise() {
|
||||
@ -189,8 +191,12 @@ public class DisguiseAPI {
|
||||
return hidingHeldItem;
|
||||
}
|
||||
|
||||
public static boolean isInventoryListenerEnabled() {
|
||||
return PacketsManager.isInventoryListenerEnabled();
|
||||
public static boolean isNameAboveHeadAlwaysVisible() {
|
||||
return showNameAboveHeadAlwaysVisible;
|
||||
}
|
||||
|
||||
public static boolean isNameOfPlayerShownAboveDisguise() {
|
||||
return showNameAboveHead;
|
||||
}
|
||||
|
||||
public static boolean isSelfDisguisesSoundsReplaced() {
|
||||
@ -241,6 +247,7 @@ public class DisguiseAPI {
|
||||
public static void setHideArmorFromSelf(boolean hideArmor) {
|
||||
if (hidingArmor != hideArmor) {
|
||||
hidingArmor = hideArmor;
|
||||
PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,13 +257,16 @@ public class DisguiseAPI {
|
||||
public static void setHideHeldItemFromSelf(boolean hideHelditem) {
|
||||
if (hidingHeldItem != hideHelditem) {
|
||||
hidingHeldItem = hideHelditem;
|
||||
PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
|
||||
}
|
||||
}
|
||||
|
||||
public static void setInventoryListenerEnabled(boolean inventoryListenerEnabled) {
|
||||
if (PacketsManager.isInventoryListenerEnabled() != inventoryListenerEnabled) {
|
||||
PacketsManager.setInventoryListenerEnabled(inventoryListenerEnabled);
|
||||
}
|
||||
public static void setNameAboveHeadAlwaysVisible(boolean alwaysVisible) {
|
||||
showNameAboveHeadAlwaysVisible = alwaysVisible;
|
||||
}
|
||||
|
||||
public static void setNameOfPlayerShownAboveDisguise(boolean showNames) {
|
||||
showNameAboveHead = showNames;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.UpdateChecker;
|
||||
|
||||
@ -85,6 +86,15 @@ public class DisguiseListener implements Listener {
|
||||
disguiseRunnable.remove(event.getPlayer().getName()).cancel();
|
||||
String entityName = event.getRightClicked().getType().name().toLowerCase().replace("_", " ");
|
||||
if (disguise != null) {
|
||||
if (event.getRightClicked() instanceof Player && DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
((LivingWatcher) disguise.getWatcher())
|
||||
.setCustomName(((Player) event.getRightClicked()).getDisplayName());
|
||||
if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
DisguiseAPI.disguiseToAll(event.getRightClicked(), disguise);
|
||||
event.getPlayer().sendMessage(
|
||||
ChatColor.RED + "Disguised the " + entityName + " as a "
|
||||
|
@ -64,10 +64,8 @@ public class LibsDisguises extends JavaPlugin {
|
||||
DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
|
||||
DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
|
||||
DisguiseAPI.setAddEntityAnimations(getConfig().getBoolean("AddEntityAnimations"));
|
||||
DisguiseAPI.setUnusedDisguisesRemoved(getConfig().getBoolean("RemoveUnusedDisguises"));
|
||||
if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
|
||||
DisguiseAPI.setInventoryListenerEnabled(true);
|
||||
}
|
||||
DisguiseAPI.setNameOfPlayerShownAboveDisguise(getConfig().getBoolean("ShowNamesAboveDisguises"));
|
||||
DisguiseAPI.setNameAboveHeadAlwaysVisible(getConfig().getBoolean("NameAboveHeadAlwaysVisible"));
|
||||
try {
|
||||
// Here I use reflection to set the plugin for Disguise..
|
||||
// Kind of stupid but I don't want open API calls for a commonly used object.
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
|
||||
import java.util.ArrayList;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -30,6 +31,14 @@ public class DisguiseCommand extends BaseDisguiseCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) sender).getDisplayName());
|
||||
if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
||||
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
|
||||
return true;
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
|
||||
import java.util.ArrayList;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -49,6 +50,14 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) player).getDisplayName());
|
||||
if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
DisguiseAPI.disguiseToAll(player, disguise);
|
||||
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
|
||||
+ disguise.getType().toReadable() + "!");
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
|
||||
import java.util.ArrayList;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -66,6 +67,15 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
|
||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||
if (entity == sender)
|
||||
continue;
|
||||
disguise = disguise.clone();
|
||||
if (entity instanceof Player && DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) entity).getDisplayName());
|
||||
if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
|
||||
((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
DisguiseAPI.disguiseToAll(entity, disguise);
|
||||
disguisedEntitys++;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.utilities;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
Loading…
Reference in New Issue
Block a user