Skip to content

Commit 1c8e9f9

Browse files
committed
getTags and findTag update
1 parent 6e81001 commit 1c8e9f9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

scripts/library/structures/classes/entity.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,25 @@ import Server from "./server.js";
33
class EntityBuilder {
44
findTag(searchTag, target) {
55
const allTags = this.getTags(target);
6-
if(!allTags[0]) return false;
6+
if(!allTags) return false;
77
for(const tag of allTags) if(tag.replace(/§./g, '').match(new RegExp(`^${searchTag.replace(/§./g, '')}$`))) return true;
88
return false;
99
};
1010
getTags(target) {
1111
const data = Server.runCommand(`tag @e${target ? `[${target.replace(/\]|\[/g, '')}]` : ''} list`);
12-
if(data.error) return [];
13-
return data.result.statusMessage.match(/(?<=: ).*$/)[0].split('§r, §a');
12+
if(data.error) return;
13+
let tags = data.statusMessage.match(/(?<=: ).*$/);
14+
if(tags) return tags[0].split('§r, §a');
1415
};
1516
getScore(objective, target, { minimum, maximum } = {}) {
1617
const data = Server.runCommand(`scoreboard players test @e${target ? `[${target.replace(/\]|\[/g, '')}]` : ''} ${objective} ${minimum ? minimum : '*'} ${maximum ? maximum : '*'}`);
1718
if(data.error) return;
18-
return parseInt(data.result.statusMessage.match(/-?\d+/)[0]);
19+
return parseInt(data.statusMessage.match(/-?\d+/)[0]);
1920
};
2021
};
2122

2223
/**
2324
* @type {import('../typings/classes/Enitity').EntityBuilder}
2425
*/
2526
const Entity = new EntityBuilder();
26-
export default Entity;
27+
export default Entity;

0 commit comments

Comments
 (0)