mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-14 15:26:54 +01:00
Let custom disguises retain their disguise name
This commit is contained in:
parent
884f9471ca
commit
3a2c121f0f
@ -89,6 +89,12 @@ public abstract class Disguise {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String disguiseName;
|
private String disguiseName;
|
||||||
|
/**
|
||||||
|
* Is the name allowed to be changed by Lib's Disguises if they do some option?
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean customName = true;
|
||||||
|
|
||||||
public Disguise(DisguiseType disguiseType) {
|
public Disguise(DisguiseType disguiseType) {
|
||||||
this.disguiseType = disguiseType;
|
this.disguiseType = disguiseType;
|
||||||
@ -112,6 +118,7 @@ public abstract class Disguise {
|
|||||||
|
|
||||||
protected void clone(Disguise disguise) {
|
protected void clone(Disguise disguise) {
|
||||||
disguise.setDisguiseName(getDisguiseName());
|
disguise.setDisguiseName(getDisguiseName());
|
||||||
|
disguise.setCustomName(isCustomName());
|
||||||
|
|
||||||
disguise.setReplaceSounds(isSoundsReplaced());
|
disguise.setReplaceSounds(isSoundsReplaced());
|
||||||
disguise.setViewSelfDisguise(isSelfDisguiseVisible());
|
disguise.setViewSelfDisguise(isSelfDisguiseVisible());
|
||||||
|
@ -22,8 +22,10 @@ public class DroppedItemWatcher extends FlagWatcher {
|
|||||||
setData(MetaIndex.DROPPED_ITEM, item);
|
setData(MetaIndex.DROPPED_ITEM, item);
|
||||||
sendData(MetaIndex.DROPPED_ITEM);
|
sendData(MetaIndex.DROPPED_ITEM);
|
||||||
|
|
||||||
getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " +
|
if (!getDisguise().isCustomName()) {
|
||||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " +
|
||||||
.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name())));
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||||
|
.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,8 +87,11 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||||||
|
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
|
||||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
if (!getDisguise().isCustomName()) {
|
||||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name())));
|
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||||
|
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||||
|
.get(ReflectionManager.toReadable(block.getType().name())));
|
||||||
|
}
|
||||||
|
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||||
|
@ -611,6 +611,7 @@ public class DisguiseParser {
|
|||||||
Disguise disguise = null;
|
Disguise disguise = null;
|
||||||
DisguisePerm disguisePerm;
|
DisguisePerm disguisePerm;
|
||||||
String name;
|
String name;
|
||||||
|
boolean customName = false;
|
||||||
|
|
||||||
if (args[0].startsWith("@")) {
|
if (args[0].startsWith("@")) {
|
||||||
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
if (sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
||||||
@ -625,6 +626,7 @@ public class DisguiseParser {
|
|||||||
|
|
||||||
disguisePerm = new DisguisePerm(disguise.getType());
|
disguisePerm = new DisguisePerm(disguise.getType());
|
||||||
name = disguise.getDisguiseName();
|
name = disguise.getDisguiseName();
|
||||||
|
customName = disguise.isCustomName();
|
||||||
|
|
||||||
if (disguisePerm.isUnknown()) {
|
if (disguisePerm.isUnknown()) {
|
||||||
throw new DisguiseParseException(LibsMsg.PARSE_CANT_DISG_UNKNOWN);
|
throw new DisguiseParseException(LibsMsg.PARSE_CANT_DISG_UNKNOWN);
|
||||||
@ -654,6 +656,7 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disguise = new ModdedDisguise(ent);
|
disguise = new ModdedDisguise(ent);
|
||||||
|
customName = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);
|
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);
|
||||||
@ -661,6 +664,7 @@ public class DisguiseParser {
|
|||||||
if (customDisguise != null) {
|
if (customDisguise != null) {
|
||||||
args = DisguiseUtilities.split(customDisguise.getValue());
|
args = DisguiseUtilities.split(customDisguise.getValue());
|
||||||
name = customDisguise.getKey().toReadable();
|
name = customDisguise.getKey().toReadable();
|
||||||
|
customName = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
args = parsePlaceholders(args, sender, target);
|
args = parsePlaceholders(args, sender, target);
|
||||||
@ -696,7 +700,11 @@ public class DisguiseParser {
|
|||||||
|
|
||||||
// Construct the player disguise
|
// Construct the player disguise
|
||||||
disguise = new PlayerDisguise(ChatColor.translateAlternateColorCodes('&', args[1]));
|
disguise = new PlayerDisguise(ChatColor.translateAlternateColorCodes('&', args[1]));
|
||||||
name = ((PlayerDisguise) disguise).getName();
|
|
||||||
|
if (!customName) {
|
||||||
|
name = ((PlayerDisguise) disguise).getName();
|
||||||
|
}
|
||||||
|
|
||||||
toSkip++;
|
toSkip++;
|
||||||
}
|
}
|
||||||
} else if (disguisePerm.isMob()) { // Its a mob, use the mob constructor
|
} else if (disguisePerm.isMob()) { // Its a mob, use the mob constructor
|
||||||
@ -792,7 +800,10 @@ public class DisguiseParser {
|
|||||||
if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM ||
|
if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM ||
|
||||||
disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
disguise = new MiscDisguise(disguisePerm.getType(), itemStack);
|
disguise = new MiscDisguise(disguisePerm.getType(), itemStack);
|
||||||
name = disguise.getDisguiseName();
|
|
||||||
|
if (!customName) {
|
||||||
|
name = disguise.getDisguiseName();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
disguise = new MiscDisguise(disguisePerm.getType(), miscId);
|
disguise = new MiscDisguise(disguisePerm.getType(), miscId);
|
||||||
}
|
}
|
||||||
@ -801,6 +812,7 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
disguise.setDisguiseName(name);
|
disguise.setDisguiseName(name);
|
||||||
|
disguise.setCustomName(customName);
|
||||||
|
|
||||||
// Copy strings to their new range
|
// Copy strings to their new range
|
||||||
String[] newArgs = new String[args.length - toSkip];
|
String[] newArgs = new String[args.length - toSkip];
|
||||||
|
Loading…
Reference in New Issue
Block a user