Skip to content

Commit

Permalink
getTags and findTag update
Browse files Browse the repository at this point in the history
  • Loading branch information
notbeer committed Aug 22, 2021
1 parent 6e81001 commit 1c8e9f9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/library/structures/classes/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ import Server from "./server.js";
class EntityBuilder {
findTag(searchTag, target) {
const allTags = this.getTags(target);
if(!allTags[0]) return false;
if(!allTags) return false;
for(const tag of allTags) if(tag.replace(/§./g, '').match(new RegExp(`^${searchTag.replace(/§./g, '')}$`))) return true;
return false;
};
getTags(target) {
const data = Server.runCommand(`tag @e${target ? `[${target.replace(/\]|\[/g, '')}]` : ''} list`);
if(data.error) return [];
return data.result.statusMessage.match(/(?<=: ).*$/)[0].split('§r, §a');
if(data.error) return;
let tags = data.statusMessage.match(/(?<=: ).*$/);
if(tags) return tags[0].split('§r, §a');
};
getScore(objective, target, { minimum, maximum } = {}) {
const data = Server.runCommand(`scoreboard players test @e${target ? `[${target.replace(/\]|\[/g, '')}]` : ''} ${objective} ${minimum ? minimum : '*'} ${maximum ? maximum : '*'}`);
if(data.error) return;
return parseInt(data.result.statusMessage.match(/-?\d+/)[0]);
return parseInt(data.statusMessage.match(/-?\d+/)[0]);
};
};

/**
* @type {import('../typings/classes/Enitity').EntityBuilder}
*/
const Entity = new EntityBuilder();
export default Entity;
export default Entity;

0 comments on commit 1c8e9f9

Please sign in to comment.