Add BlockData to FALLING_BLOCK command constructing
This commit is contained in:
parent
f530af0ae8
commit
325e73d059
@ -3,17 +3,20 @@ package me.libraryaddict.disguise.utilities.parser;
|
|||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.*;
|
import me.libraryaddict.disguise.disguisetypes.*;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
||||||
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||||
|
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||||
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.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -787,21 +790,36 @@ public class DisguiseParser {
|
|||||||
} else if (disguisePerm.isMisc()) {
|
} else if (disguisePerm.isMisc()) {
|
||||||
// Its a misc, we are going to use the MiscDisguise constructor.
|
// Its a misc, we are going to use the MiscDisguise constructor.
|
||||||
ItemStack itemStack = new ItemStack(Material.STONE);
|
ItemStack itemStack = new ItemStack(Material.STONE);
|
||||||
|
// The steps I go through for 1.12..
|
||||||
|
Object blockData = null;
|
||||||
int miscId = -1;
|
int miscId = -1;
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
switch (disguisePerm.getType()) {
|
switch (disguisePerm.getType()) {
|
||||||
case FALLING_BLOCK:
|
case FALLING_BLOCK:
|
||||||
case DROPPED_ITEM:
|
case DROPPED_ITEM:
|
||||||
ParamInfo info = disguisePerm.getType() == DisguiseType.FALLING_BLOCK ?
|
ParamInfo info;
|
||||||
ParamInfoManager.getParamInfoItemBlock() :
|
|
||||||
ParamInfoManager.getParamInfo(ItemStack.class);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
itemStack = (ItemStack) info
|
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
.fromString(new ArrayList<>(Collections.singletonList(args[1])));
|
if (NmsVersion.v1_13.isSupported()) {
|
||||||
|
info = ParamInfoManager.getParamInfo(BlockData.class);
|
||||||
|
blockData = info
|
||||||
|
.fromString(new ArrayList<>(Collections.singletonList(args[1])));
|
||||||
|
} else {
|
||||||
|
info = ParamInfoManager.getParamInfoItemBlock();
|
||||||
|
|
||||||
|
itemStack = (ItemStack) info
|
||||||
|
.fromString(new ArrayList<>(Collections.singletonList(args[1])));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
||||||
|
|
||||||
|
itemStack = (ItemStack) info
|
||||||
|
.fromString(new ArrayList<>(Collections.singletonList(args[1])));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException ex) {
|
catch (Exception ex) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -862,6 +880,10 @@ public class DisguiseParser {
|
|||||||
if (!customName) {
|
if (!customName) {
|
||||||
name = disguise.getDisguiseName();
|
name = disguise.getDisguiseName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blockData != null && disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
|
((FallingBlockWatcher) disguise.getWatcher()).setBlockData((BlockData) blockData);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
disguise = new MiscDisguise(disguisePerm.getType(), miscId);
|
disguise = new MiscDisguise(disguisePerm.getType(), miscId);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user