Improved self disguises toggling to allow commandline to override player preferences, still ignores the commandline users if its a custom or right click disguise.
This commit is contained in:
parent
758f24108b
commit
206207a374
@ -163,10 +163,6 @@ public class DisguiseAPI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
|
||||||
disguise.setViewSelfDisguise(DisguiseAPI.isViewSelfToggled(entity));
|
|
||||||
}
|
|
||||||
|
|
||||||
// The event wasn't cancelled.
|
// The event wasn't cancelled.
|
||||||
// If the disguise entity isn't the same as the one we are disguising
|
// If the disguise entity isn't the same as the one we are disguising
|
||||||
if (disguise.getEntity() != entity) {
|
if (disguise.getEntity() != entity) {
|
||||||
@ -179,8 +175,9 @@ public class DisguiseAPI {
|
|||||||
disguise.setEntity(entity);
|
disguise.setEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
disguise.setViewSelfDisguise(Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId()) !=
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
DisguiseConfig.isViewDisguises());
|
if (hasSelfDisguisePreference(entity) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
|
||||||
disguise.startDisguise();
|
disguise.startDisguise();
|
||||||
}
|
}
|
||||||
@ -382,8 +379,11 @@ public class DisguiseAPI {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static boolean isViewSelfToggled(Entity entity) {
|
public static boolean isViewSelfToggled(Entity entity) {
|
||||||
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible() :
|
return hasSelfDisguisePreference(entity) != DisguiseConfig.isViewDisguises();
|
||||||
!Disguise.getViewSelf().contains(entity.getUniqueId()) == DisguiseConfig.isViewDisguises();
|
}
|
||||||
|
|
||||||
|
public static boolean hasSelfDisguisePreference(Entity entity) {
|
||||||
|
return Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,7 +417,7 @@ public class DisguiseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!canSeeSelfDisguises == DisguiseConfig.isViewDisguises()) {
|
if (!canSeeSelfDisguises == DisguiseConfig.isViewDisguises()) {
|
||||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
if (!hasSelfDisguisePreference(entity)) {
|
||||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -465,7 +465,7 @@ public class DisguiseListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll(entity, disguise);
|
DisguiseAPI.disguiseEntity(entity, disguise);
|
||||||
|
|
||||||
String disguiseName;
|
String disguiseName;
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.commands;
|
package me.libraryaddict.disguise.commands;
|
||||||
|
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
import me.libraryaddict.disguise.utilities.DisguiseParser;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException;
|
import me.libraryaddict.disguise.utilities.DisguiseParser.DisguiseParseException;
|
||||||
@ -13,7 +11,6 @@ import me.libraryaddict.disguise.utilities.DisguiseParser.DisguisePerm;
|
|||||||
import me.libraryaddict.disguise.utilities.LibsMsg;
|
import me.libraryaddict.disguise.utilities.LibsMsg;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
import me.libraryaddict.disguise.utilities.ReflectionFlagWatchers.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.TranslateType;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -45,7 +42,9 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
disguise = DisguiseParser.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(args, " ")), getPermissions(sender));
|
disguise = DisguiseParser
|
||||||
|
.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(args, " ")),
|
||||||
|
getPermissions(sender));
|
||||||
}
|
}
|
||||||
catch (DisguiseParseException ex) {
|
catch (DisguiseParseException ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null) {
|
||||||
@ -69,7 +68,16 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll((Player) sender, disguise);
|
disguise.setEntity((Player) sender);
|
||||||
|
|
||||||
|
if (!setViewDisguise(args)) {
|
||||||
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
disguise.startDisguise();
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse()) {
|
||||||
sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getType().toReadable()));
|
sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getType().toReadable()));
|
||||||
@ -80,6 +88,17 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean setViewDisguise(String[] strings) {
|
||||||
|
for (String string : strings) {
|
||||||
|
if (!string.equalsIgnoreCase("setViewSelfDisguise"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
@ -72,7 +72,8 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
Disguise disguise;
|
Disguise disguise;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
disguise = DisguiseParser.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), map);
|
disguise = DisguiseParser
|
||||||
|
.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), map);
|
||||||
}
|
}
|
||||||
catch (DisguiseParseException ex) {
|
catch (DisguiseParseException ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null) {
|
||||||
@ -100,8 +101,16 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
disguise.setEntity(player);
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll(player, disguise);
|
if (!setViewDisguise(args)) {
|
||||||
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
disguise.startDisguise();
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse()) {
|
||||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG
|
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG
|
||||||
@ -116,6 +125,17 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean setViewDisguise(String[] strings) {
|
||||||
|
for (String string : strings) {
|
||||||
|
if (!string.equalsIgnoreCase("setViewSelfDisguise"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
|
@ -57,8 +57,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) || args[0]
|
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) ||
|
||||||
.equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
||||||
ArrayList<String> classes = new ArrayList<>();
|
ArrayList<String> classes = new ArrayList<>();
|
||||||
|
|
||||||
for (Class c : validClasses) {
|
for (Class c : validClasses) {
|
||||||
@ -130,7 +130,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
disguise = DisguiseParser.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), map);
|
disguise = DisguiseParser
|
||||||
|
.parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), map);
|
||||||
}
|
}
|
||||||
catch (DisguiseParseException ex) {
|
catch (DisguiseParseException ex) {
|
||||||
if (ex.getMessage() != null) {
|
if (ex.getMessage() != null) {
|
||||||
@ -162,8 +163,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
|
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
|
||||||
if (disguise.isMiscDisguise() && !DisguiseConfig
|
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() &&
|
||||||
.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
|
entity instanceof LivingEntity) {
|
||||||
miscDisguises++;
|
miscDisguises++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -179,7 +180,17 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DisguiseAPI.disguiseToAll(entity, disguise);
|
disguise.setEntity(entity);
|
||||||
|
|
||||||
|
if (!setViewDisguise(args)) {
|
||||||
|
// They prefer to have the opposite of whatever the view disguises option is
|
||||||
|
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||||
|
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||||
|
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||||
|
}
|
||||||
|
|
||||||
|
disguise.startDisguise();
|
||||||
|
DisguiseAPI.disguiseEntity(entity, disguise);
|
||||||
|
|
||||||
if (disguise.isDisguiseInUse()) {
|
if (disguise.isDisguiseInUse()) {
|
||||||
disguisedEntitys++;
|
disguisedEntitys++;
|
||||||
@ -200,6 +211,17 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean setViewDisguise(String[] strings) {
|
||||||
|
for (String string : strings) {
|
||||||
|
if (!string.equalsIgnoreCase("setViewSelfDisguise"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||||
ArrayList<String> tabs = new ArrayList<>();
|
ArrayList<String> tabs = new ArrayList<>();
|
||||||
@ -248,8 +270,8 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||||||
ArrayList<String> usedOptions = new ArrayList<>();
|
ArrayList<String> usedOptions = new ArrayList<>();
|
||||||
|
|
||||||
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
for (Method method : ReflectionFlagWatchers.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||||
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? starting + 2 :
|
for (int i = disguiseType.getType() == DisguiseType.PLAYER ? starting + 2 : starting + 1;
|
||||||
starting + 1; i < args.length; i++) {
|
i < args.length; i++) {
|
||||||
String arg = args[i];
|
String arg = args[i];
|
||||||
|
|
||||||
if (!method.getName().equalsIgnoreCase(arg))
|
if (!method.getName().equalsIgnoreCase(arg))
|
||||||
|
Loading…
Reference in New Issue
Block a user