|
1 | | -let ChatMessage |
2 | 1 | const colors = ['pink', 'blue', 'red', 'green', 'yellow', 'purple', 'white'] |
3 | 2 | const divisions = [0, 6, 10, 12, 20] |
4 | 3 |
|
5 | | -module.exports = loader |
6 | | - |
7 | 4 | function loader (registry) { |
8 | | - ChatMessage = require('prismarine-chat')(registry) |
9 | | - return BossBar |
10 | | -} |
11 | | - |
12 | | -class BossBar { |
13 | | - constructor (uuid, title, health, dividers, color, flags) { |
14 | | - this._entityUUID = uuid |
15 | | - this._title = new ChatMessage(JSON.parse(title)) |
16 | | - this._health = health |
17 | | - this._dividers = divisions[dividers] |
18 | | - this._color = colors[color] |
19 | | - this._shouldDarkenSky = flags & 0x1 |
20 | | - this._isDragonBar = flags & 0x2 |
21 | | - this._createFog = flags & 0x4 |
22 | | - } |
23 | | - |
24 | | - set entityUUID (uuid) { |
25 | | - this._entityUUID = uuid |
26 | | - } |
27 | | - |
28 | | - set title (title) { |
29 | | - this._title = new ChatMessage(JSON.parse(title)) |
30 | | - } |
31 | | - |
32 | | - set health (health) { |
33 | | - this._health = health |
34 | | - } |
35 | | - |
36 | | - set dividers (dividers) { |
37 | | - this._dividers = divisions[dividers] |
38 | | - } |
39 | | - |
40 | | - set color (color) { |
41 | | - this._color = colors[color] |
42 | | - } |
43 | | - |
44 | | - set flags (flags) { |
45 | | - this._shouldDarkenSky = flags & 0x1 |
46 | | - this._isDragonBar = flags & 0x2 |
47 | | - this._createFog = flags & 0x4 |
48 | | - } |
49 | | - |
50 | | - get flags () { |
51 | | - return (this._shouldDarkenSky) | (this._isDragonBar << 1) | (this._createFog << 2) |
52 | | - } |
53 | | - |
54 | | - set shouldDarkenSky (darkenSky) { |
55 | | - this._shouldDarkenSky = darkenSky |
56 | | - } |
57 | | - |
58 | | - set isDragonBar (dragonBar) { |
59 | | - this._isDragonBar = dragonBar |
60 | | - } |
61 | | - |
62 | | - get createFog () { |
63 | | - return this._createFog |
64 | | - } |
65 | | - |
66 | | - set createFog (createFog) { |
67 | | - this._createFog = createFog |
68 | | - } |
69 | | - |
70 | | - get entityUUID () { |
71 | | - return this._entityUUID |
72 | | - } |
73 | | - |
74 | | - get title () { |
75 | | - return this._title |
76 | | - } |
77 | | - |
78 | | - get health () { |
79 | | - return this._health |
80 | | - } |
81 | | - |
82 | | - get dividers () { |
83 | | - return this._dividers |
84 | | - } |
85 | | - |
86 | | - get color () { |
87 | | - return this._color |
88 | | - } |
89 | | - |
90 | | - get shouldDarkenSky () { |
91 | | - return this._shouldDarkenSky |
92 | | - } |
93 | | - |
94 | | - get isDragonBar () { |
95 | | - return this._isDragonBar |
96 | | - } |
97 | | - |
98 | | - get shouldCreateFog () { |
99 | | - return this._createFog |
| 5 | + const ChatMessage = require('prismarine-chat')(registry) |
| 6 | + return class BossBar { |
| 7 | + constructor (uuid, title, health, dividers, color, flags) { |
| 8 | + this._entityUUID = uuid |
| 9 | + this._title = ChatMessage.fromNotch(title) |
| 10 | + this._health = health |
| 11 | + this._dividers = divisions[dividers] |
| 12 | + this._color = colors[color] |
| 13 | + this._shouldDarkenSky = flags & 0x1 |
| 14 | + this._isDragonBar = flags & 0x2 |
| 15 | + this._createFog = flags & 0x4 |
| 16 | + } |
| 17 | + |
| 18 | + set entityUUID (uuid) { |
| 19 | + this._entityUUID = uuid |
| 20 | + } |
| 21 | + |
| 22 | + set title (title) { |
| 23 | + this._title = ChatMessage.fromNotch(title) |
| 24 | + } |
| 25 | + |
| 26 | + set health (health) { |
| 27 | + this._health = health |
| 28 | + } |
| 29 | + |
| 30 | + set dividers (dividers) { |
| 31 | + this._dividers = divisions[dividers] |
| 32 | + } |
| 33 | + |
| 34 | + set color (color) { |
| 35 | + this._color = colors[color] |
| 36 | + } |
| 37 | + |
| 38 | + set flags (flags) { |
| 39 | + this._shouldDarkenSky = flags & 0x1 |
| 40 | + this._isDragonBar = flags & 0x2 |
| 41 | + this._createFog = flags & 0x4 |
| 42 | + } |
| 43 | + |
| 44 | + get flags () { |
| 45 | + return (this._shouldDarkenSky) | (this._isDragonBar << 1) | (this._createFog << 2) |
| 46 | + } |
| 47 | + |
| 48 | + set shouldDarkenSky (darkenSky) { |
| 49 | + this._shouldDarkenSky = darkenSky |
| 50 | + } |
| 51 | + |
| 52 | + set isDragonBar (dragonBar) { |
| 53 | + this._isDragonBar = dragonBar |
| 54 | + } |
| 55 | + |
| 56 | + get createFog () { |
| 57 | + return this._createFog |
| 58 | + } |
| 59 | + |
| 60 | + set createFog (createFog) { |
| 61 | + this._createFog = createFog |
| 62 | + } |
| 63 | + |
| 64 | + get entityUUID () { |
| 65 | + return this._entityUUID |
| 66 | + } |
| 67 | + |
| 68 | + get title () { |
| 69 | + return this._title |
| 70 | + } |
| 71 | + |
| 72 | + get health () { |
| 73 | + return this._health |
| 74 | + } |
| 75 | + |
| 76 | + get dividers () { |
| 77 | + return this._dividers |
| 78 | + } |
| 79 | + |
| 80 | + get color () { |
| 81 | + return this._color |
| 82 | + } |
| 83 | + |
| 84 | + get shouldDarkenSky () { |
| 85 | + return this._shouldDarkenSky |
| 86 | + } |
| 87 | + |
| 88 | + get isDragonBar () { |
| 89 | + return this._isDragonBar |
| 90 | + } |
| 91 | + |
| 92 | + get shouldCreateFog () { |
| 93 | + return this._createFog |
| 94 | + } |
100 | 95 | } |
101 | 96 | } |
| 97 | + |
| 98 | +module.exports = loader |
0 commit comments