Revert custom disguise api for MM compatibility
This commit is contained in:
parent
daf91304b8
commit
2ff7b7ab3f
@ -27,7 +27,7 @@ public class DisguiseAPI {
|
|||||||
private static int selfDisguiseId = ReflectionManager.getNewEntityId(true);
|
private static int selfDisguiseId = ReflectionManager.getNewEntityId(true);
|
||||||
|
|
||||||
public static String getCustomDisguise(String disguiseName) {
|
public static String getCustomDisguise(String disguiseName) {
|
||||||
Map.Entry<DisguisePerm, String> entry = DisguiseConfig.getCustomDisguise(disguiseName);
|
Map.Entry<DisguisePerm, String> entry = DisguiseConfig.getRawCustomDisguise(disguiseName);
|
||||||
|
|
||||||
if (entry == null)
|
if (entry == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -130,29 +130,48 @@ public class DisguiseConfig {
|
|||||||
explicitDisguisePermissions = explictDisguisePermission;
|
explicitDisguisePermissions = explictDisguisePermission;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry<DisguisePerm, Disguise> getParsedCustomDisguise(
|
public static Entry<DisguisePerm, Disguise> getCustomDisguise(String disguise) {
|
||||||
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||||
Entry<DisguisePerm, String> entry = getCustomDisguise(disguise);
|
|
||||||
|
|
||||||
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(entry.getValue()));
|
if (entry == null) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry<DisguisePerm, Disguise> getParsedCustomDisguise(Entity target,
|
try {
|
||||||
|
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(entry.getValue()));
|
||||||
|
}
|
||||||
|
catch (IllegalAccessException | InvocationTargetException | DisguiseParseException e) {
|
||||||
|
DisguiseUtilities.getLogger().warning("Error when attempting to grab the custom disguise " + disguise);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Entry<DisguisePerm, Disguise> getCustomDisguise(Entity target,
|
||||||
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
||||||
Entry<DisguisePerm, String> entry = getCustomDisguise(disguise);
|
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||||
|
|
||||||
|
if (entry == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new HashMap.SimpleEntry(entry.getKey(),
|
return new HashMap.SimpleEntry(entry.getKey(),
|
||||||
DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry<DisguisePerm, Disguise> getParsedCustomDisguise(CommandSender invoker, Entity target,
|
public static Entry<DisguisePerm, Disguise> getCustomDisguise(CommandSender invoker, Entity target,
|
||||||
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
||||||
Entry<DisguisePerm, String> entry = getCustomDisguise(disguise);
|
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||||
|
|
||||||
|
if (entry == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(invoker, target, entry.getValue()));
|
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(invoker, target, entry.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entry<DisguisePerm, String> getCustomDisguise(String disguise) {
|
public static Entry<DisguisePerm, String> getRawCustomDisguise(String disguise) {
|
||||||
for (Entry<DisguisePerm, String> entry : customDisguises.entrySet()) {
|
for (Entry<DisguisePerm, String> entry : customDisguises.entrySet()) {
|
||||||
String name = entry.getKey().toReadable();
|
String name = entry.getKey().toReadable();
|
||||||
|
|
||||||
@ -383,7 +402,7 @@ public class DisguiseConfig {
|
|||||||
for (String key : section.getKeys(false)) {
|
for (String key : section.getKeys(false)) {
|
||||||
String toParse = section.getString(key);
|
String toParse = section.getString(key);
|
||||||
|
|
||||||
if (getCustomDisguise(toParse) != null) {
|
if (getRawCustomDisguise(toParse) != null) {
|
||||||
DisguiseUtilities.getLogger()
|
DisguiseUtilities.getLogger()
|
||||||
.severe("Cannot create the custom disguise '" + key + "' as there is a name conflict!");
|
.severe("Cannot create the custom disguise '" + key + "' as there is a name conflict!");
|
||||||
continue;
|
continue;
|
||||||
|
@ -336,7 +336,7 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
disguisePerm = getDisguisePerm(args[0]);
|
disguisePerm = getDisguisePerm(args[0]);
|
||||||
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getCustomDisguise(args[0]);
|
Entry<DisguisePerm, String> customDisguise = DisguiseConfig.getRawCustomDisguise(args[0]);
|
||||||
|
|
||||||
if (customDisguise != null) {
|
if (customDisguise != null) {
|
||||||
args = DisguiseUtilities.split(customDisguise.getValue());
|
args = DisguiseUtilities.split(customDisguise.getValue());
|
||||||
|
Loading…
Reference in New Issue
Block a user