Add modifyDisguise to DisguiseParser for api usage, deprecate 'constructDisguise'

This commit is contained in:
libraryaddict 2020-02-25 15:20:44 +13:00
parent 897f0fc599
commit 061161dad7
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4
2 changed files with 29 additions and 0 deletions

View File

@ -87,10 +87,12 @@ public class DisguiseAPI {
return disguise.getValue(); return disguise.getValue();
} }
@Deprecated
public static Disguise constructDisguise(Entity entity) { public static Disguise constructDisguise(Entity entity) {
return constructDisguise(entity, true, true, true); return constructDisguise(entity, true, true, true);
} }
@Deprecated
public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) { public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) {
DisguiseType disguiseType = DisguiseType.getType(entity); DisguiseType disguiseType = DisguiseType.getType(entity);
Disguise disguise; Disguise disguise;

View File

@ -9,6 +9,7 @@ import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
import me.libraryaddict.disguise.utilities.translations.LibsMsg; import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import me.libraryaddict.disguise.utilities.translations.TranslateType; import me.libraryaddict.disguise.utilities.translations.TranslateType;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -508,6 +509,32 @@ public class DisguiseParser {
return parseDisguise(sender, null, permNode, args, permissions); return parseDisguise(sender, null, permNode, args, permissions);
} }
public static void modifyDisguise(Disguise disguise, Entity target,
String[] params) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
if (target != null) {
params = DisguiseParser.parsePlaceholders(params, target, target);
}
DisguiseParser.callMethods(Bukkit.getConsoleSender(), disguise,
new DisguisePermissions(Bukkit.getConsoleSender(), "disguise"), new DisguisePerm(disguise.getType()),
new ArrayList<>(), params, "Disguise");
}
public static void modifyDisguise(Disguise disguise,
String[] params) throws IllegalAccessException, InvocationTargetException, DisguiseParseException {
modifyDisguise(disguise, null, params);
}
public static void modifyDisguise(Disguise disguise,
String params) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
modifyDisguise(disguise, DisguiseUtilities.split(params));
}
public static void modifyDisguise(Disguise disguise, Entity target,
String params) throws IllegalAccessException, InvocationTargetException, DisguiseParseException {
modifyDisguise(disguise, target, DisguiseUtilities.split(params));
}
public static Disguise parseDisguise( public static Disguise parseDisguise(
String disguise) throws IllegalAccessException, InvocationTargetException, DisguiseParseException { String disguise) throws IllegalAccessException, InvocationTargetException, DisguiseParseException {
return parseDisguise(Bukkit.getConsoleSender(), null, disguise); return parseDisguise(Bukkit.getConsoleSender(), null, disguise);