VirtualChestItem.java 文件源码

java
阅读 19 收藏 0 点赞 0 评论 0

项目:VirtualChest 作者:
public static VirtualChestItem deserialize(VirtualChestPlugin plugin, DataView data) throws InvalidDataException
{
    DataView serializedStack = data.getView(ITEM).orElseThrow(() -> new InvalidDataException("Expected Item"));

    String requirementString = data.getString(REQUIREMENTS).orElse("");
    Tuple<String, CompiledScript> requirements = plugin.getScriptManager().prepare(requirementString);

    List<DataView> primaryList = getViewListOrSingletonList(PRIMARY_ACTION, data);
    VirtualChestActionDispatcher primaryAction = new VirtualChestActionDispatcher(primaryList);

    List<DataView> secondaryList = getViewListOrSingletonList(SECONDARY_ACTION, data);
    VirtualChestActionDispatcher secondaryAction = new VirtualChestActionDispatcher(secondaryList);

    List<DataView> primaryShiftList = getViewListOrSingletonList(PRIMARY_SHIFT_ACTION, data);
    List<DataView> primaryShiftListFinal = primaryShiftList.isEmpty() ? primaryList : primaryShiftList;
    VirtualChestActionDispatcher primaryShiftAction = new VirtualChestActionDispatcher(primaryShiftListFinal);

    List<DataView> secondaryShiftList = getViewListOrSingletonList(SECONDARY_SHIFT_ACTION, data);
    List<DataView> secondaryShiftListFinal = secondaryShiftList.isEmpty() ? secondaryList : secondaryShiftList;
    VirtualChestActionDispatcher secondaryShiftAction = new VirtualChestActionDispatcher(secondaryShiftListFinal);

    List<String> ignoredPermissions = data.getStringList(IGNORED_PERMISSIONS).orElse(ImmutableList.of());

    return new VirtualChestItem(plugin, serializedStack, requirements,
            primaryAction, secondaryAction, primaryShiftAction, secondaryShiftAction, ignoredPermissions);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号