Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanV2 committed Oct 10, 2022
1 parent 4e1d326 commit a38a386
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Minecraft/Components/Used.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { ComponentBehavior } from "./Interfaces";
export function getUsedComponents(data: ComponentBehavior): string[] {
const out: string[] = [];

if (data.components) {
if (data?.components) {
Object.getOwnPropertyNames(data.components).forEach((c) => {
if (!out.includes(c)) out.push(c);
});
}

const groups = data.component_groups;
const groups = data?.component_groups;

if (groups) {
Object.entries(groups).forEach(([name, group]) => {
Expand All @@ -23,7 +23,7 @@ export function getUsedComponents(data: ComponentBehavior): string[] {
}

export function getUsedGroups(data: ComponentBehavior): string[] {
const groups = data.component_groups;
const groups = data?.component_groups;

if (groups) {
return Object.getOwnPropertyNames(groups);
Expand All @@ -39,8 +39,8 @@ export function getUsedGroups(data: ComponentBehavior): string[] {
* @returns
*/
export function hasGroup(data: ComponentBehavior, group: string): boolean {
if (data.component_groups) {
if (data.component_groups[group]) {
if (data?.component_groups) {
if (data?.component_groups[group]) {
return true;
}
}
Expand Down

0 comments on commit a38a386

Please sign in to comment.