Enderman can't hold non-blocks, fixes #606

This commit is contained in:
libraryaddict 2021-08-08 03:02:25 +12:00
parent d20a8e5266
commit 69f3494633
4 changed files with 20 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.LibsPremium;
import me.libraryaddict.disguise.utilities.params.ParamInfo;
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemStack;
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
@ -181,6 +182,11 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
if (info != null && !info.isParam(boolean.class)) {
addMethods = false;
}
// Enderman can't hold non-blocks
if (disguisePerm.getType() == DisguiseType.ENDERMAN && prevArg.equalsIgnoreCase("setItemInMainHand")) {
info = ParamInfoManager.getParamInfoItemBlock();
}
}
// If the previous argument is a method

View File

@ -32,12 +32,17 @@ public class EndermanWatcher extends InsentientWatcher {
}
public void setItemInMainHand(Material type) {
if (!type.isBlock()) {
return;
}
Optional<WrappedBlockData> optional;
if (type == null)
if (type == null) {
optional = Optional.empty();
else
} else {
optional = Optional.of(WrappedBlockData.createData(type));
}
setData(MetaIndex.ENDERMAN_ITEM, optional);
sendData(MetaIndex.ENDERMAN_ITEM);

View File

@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities.params;
import lombok.Getter;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.params.types.custom.ParamInfoItemBlock;
@ -50,6 +51,11 @@ public class ParamInfoManager {
return getParamInfoSoundGroup();
}
// Enderman can't hold non-blocks
if (method.getWatcherClass() == EndermanWatcher.class && method.getName().equalsIgnoreCase("setItemInMainHand")) {
return getParamInfoItemBlock();
}
if (method.getWatcherClass() == FallingBlockWatcher.class && (method.getParam() == Material.class || method.getParam() == ItemStack.class)) {
return getParamInfoItemBlock();
}

View File

@ -31,8 +31,7 @@ import java.util.*;
*/
public class ParamInfoTypes {
public ParamInfoItemBlock getParamInfoBlock() {
return new ParamInfoItemBlock(ItemStack.class, "ItemStack", "ItemStack (Material,Amount?,Glow?)",
"An ItemStack compromised of Material,Amount,Glow. Only requires Material", getMaterials());
return new ParamInfoItemBlock(ItemStack.class, "ItemStack", "ItemStack (Material)", "An ItemStack compromised of Material", getMaterials());
}
public ParamInfoSoundGroup getParamInfoSoundGroup() {