Skip to content
This repository has been archived by the owner on Jan 21, 2021. It is now read-only.

Commit

Permalink
new joke comment, add count function
Browse files Browse the repository at this point in the history
  • Loading branch information
hb432 committed Aug 5, 2020
1 parent 310b2d5 commit 391f333
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// you were meant to defeat the sith, not join them!
// server professionals: nooo! you cant just use NMS to parse and serialize data with notch's superior nbt system!!!!!!
// harrix432: haha eval server class name into packages go brrrr
const nms = eval(`Packages.net.minecraft.server.${server.getClass().getCanonicalName().split('.')[3]}`);

const UUID = Java.type('java.util.UUID');
Expand Down Expand Up @@ -126,6 +127,9 @@ const _ = {
color: (string) => {
return string.replace(/(&)/g, '§').replace(/(§§)/g, '&');
},
count: (array) => {
return Object.fromEntries([ ...array.reduce((map, key) => map.set(key, (map.get(key) || 0) + 1), new Map()) ]);
},
def: (object) => {
if ([ undefined, null ].includes(object)) return false;
else if (typeof object === 'number' && object !== object) return false;
Expand Down Expand Up @@ -338,7 +342,7 @@ const _ = {
},
player: (target) => {
let uuid = undefined;
const players = Object.assign({}, core.data('grakkit/players'));
const players = Object.assign({}, core.data('framework/players'));
if (target instanceof UUID) {
uuid = target;
} else if (typeof target === 'string') {
Expand Down Expand Up @@ -632,7 +636,7 @@ core.event('org.bukkit.event.player.PlayerJoinEvent', (event) => {
const name = player.getName();
const uuid = player.getUniqueId().toString();
const info = { address: address, name: name, uuid: uuid };
Object.assign(core.data('grakkit/players'), {
Object.assign(core.data('framework/players'), {
[address]: info,
[name]: info,
[uuid]: info
Expand Down
Loading

0 comments on commit 391f333

Please sign in to comment.