-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
65 lines (53 loc) · 2.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const BLOCK_OPTIONS = { order: 10000 };
const PACKETS_TO_BLOCK = [
'S_PARTY_MEMBER_QUEST_DATA',
'S_UNICAST_FLOATING_CASTLE_INFO',
'S_UNICAST_FLOATING_CASTLE_NAMEPLATE',
'S_UPDATE_ACHIEVEMENT_PROGRESS',
'S_ITEM_CUSTOM_STRING',
'S_INSTANCE_ARROW',
'S_HIT_COMBO'
];
const BLOCK_PACKETS_IF_SAME_AS_PREVIOUS = [
'S_VIEW_PARTY_INVITE',
'S_PLAYER_CHANGE_ALL_PROF',
'S_F2P_PremiumUser_Permission',
'S_WEAK_POINT',
'S_PLAYER_CHANGE_ALL_PROF'
];
class FpsBooster{
constructor(dispatch) {
let enabled = true;
let previous_packets = {};
const library = dispatch.require.library;
function BLOCK_ABNORMALITY_FROM_PLAYERS(e) {
return !(enabled && library.entity.players[e.target.toString()]);
}
function BLOCK_THIS_PACKET() {
return !enabled;
}
const BLOCK_IF_SAME_AS_PREVIOUS = (name, code, data) => {
let ret = !(enabled && previous_packets[name] === data);
previous_packets[name] = data;
return ret;
};
dispatch.command.add('fb', ()=> {
enabled = !enabled;
dispatch.command.message(`FPS-Booster enabled: ${enabled.toString()}`);
});
dispatch.hook('S_ABNORMALITY_BEGIN', mod.majorPatchVersion <= 106 ? 4 : 5, BLOCK_OPTIONS, BLOCK_ABNORMALITY_FROM_PLAYERS);
dispatch.hook('S_ABNORMALITY_REFRESH', 1, BLOCK_OPTIONS, BLOCK_ABNORMALITY_FROM_PLAYERS);
dispatch.hook('S_ABNORMALITY_END', 1, BLOCK_OPTIONS, BLOCK_ABNORMALITY_FROM_PLAYERS);
for(let name of PACKETS_TO_BLOCK) {
try {
dispatch.hook(name, 'raw', BLOCK_OPTIONS, BLOCK_THIS_PACKET);
}catch(e) {}
}
for(let name of BLOCK_PACKETS_IF_SAME_AS_PREVIOUS) {
try {
dispatch.hook(name, 'raw', BLOCK_OPTIONS, BLOCK_IF_SAME_AS_PREVIOUS.bind(null, name));
}catch(e) {}
}
}
}
module.exports = FpsBooster;