You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added a basic emit/catch for the add_resource_pack and remove_resource_pack packets
* Fixed a typo in a variable name
* Fixed a misnaming.
* Changed resourcePack event to allow uuid or hash
* Updated to a dictionary for active packs, also updated acceptResourcePack to allow 1.20.3 / 1.20.4 accept pack packets
* Fixed errors in Lint test
* Updated add_resource_pack to use UUID
* Removed test print
* Fixed feature checking
* Sent resource pack loaded packet and now it works
* Fixed coding conventions
Copy file name to clipboardexpand all lines: lib/plugins/resource_pack.js
+51-2
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,51 @@
1
+
constUUID=require('uuid-1345')
2
+
1
3
module.exports=inject
2
4
3
5
functioninject(bot){
6
+
letuuid
4
7
letlatestHash
8
+
letlatestUUID
9
+
letactiveResourcePacks={}
5
10
constTEXTURE_PACK_RESULTS={
6
11
SUCCESSFULLY_LOADED: 0,
7
12
DECLINED: 1,
8
13
FAILED_DOWNLOAD: 2,
9
14
ACCEPTED: 3
10
15
}
11
16
17
+
bot._client.on('add_resource_pack',(data)=>{// Emits the same as resource_pack_send but sends uuid rather than hash because that's how active packs are tracked
18
+
constuuid=newUUID(data.uuid)
19
+
// Adding the pack to a set by uuid
20
+
latestUUID=uuid
21
+
activeResourcePacks[uuid]=data.url
22
+
23
+
bot.emit('resourcePack',data.url,uuid)
24
+
})
25
+
26
+
bot._client.on('remove_resource_pack',(data)=>{// Doesn't emit anything because it is removing rather than adding
27
+
// if uuid isn't provided remove all packs
28
+
if(data.uuid===undefined){
29
+
activeResourcePacks={}
30
+
}else{
31
+
// Try to remove uuid from set
32
+
try{
33
+
deleteactiveResourcePacks[newUUID(data.uuid)]
34
+
}catch(error){
35
+
console.error('Tried to remove UUID but it was not in the active list.')
0 commit comments