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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
/// <reference types="../../CTAutocomplete" />
/// <reference lib="es2015" />
class Feature {
constructor(){
this.FeatureManager = undefined
this.events = {}
this.customEvents = {}
this.forgeEvents = {}
this.soopyEvents = {}
this.id = undefined
this.enabled = false
}
setId(id){
this.id = id
}
getId(){
return this.id
}
_onDisable(){
Object.values(this.events).forEach(e=>this.FeatureManager.unregisterEvent(e)) //calling parent unregister to avoid the set in unregister event
Object.values(this.customEvents).forEach(e=>this.FeatureManager.unregisterCustom(e)) //calling parent unregister to avoid the set in unregister event
Object.values(this.forgeEvents).forEach(e=>this.FeatureManager.unregisterForge(e)) //calling parent unregister to avoid the set in unregister event
Object.values(this.soopyEvents).forEach(e=>this.FeatureManager.unregisterSoopy(e)) //calling parent unregister to avoid the set in unregister event
this.onDisable()
this.events = {}
this.customEvents = {}
this.enabled = false
}
_onEnable(parent){
this.FeatureManager = parent
this.enabled = true
this.onEnable()
}
onDisable(){}
onEnable(){}
registerEvent(event, func){
let theEvent = this.FeatureManager.registerEvent(event, func, this)
this.events[theEvent.id] = theEvent
return theEvent
}
unregisterEvent(event){
this.FeatureManager.unregisterEvent(event)
delete this.events[event.id]
}
registerSoopy(event, func){
let theEvent = this.FeatureManager.registerSoopy(event, func, this)
this.soopyEvents[theEvent.id] = theEvent
return theEvent
}
unregisterSoopy(event){
this.FeatureManager.unregisterSoopy(event)
delete this.soopyEvents[event.id]
}
registerForge(event, func){
let theEvent = this.FeatureManager.registerForge(event, func, this)
this.forgeEvents[theEvent.id] = theEvent
return theEvent
}
unregisterForge(event){
this.FeatureManager.unregisterForge(event)
delete this.forgeEvents[event.id]
}
registerChat(criteria, func){
let theEvent = this.FeatureManager.registerChat(criteria, func, this)
this.customEvents[theEvent.id] = theEvent
return theEvent
}
registerActionBar(criteria, func){
let theEvent = this.FeatureManager.registerActionBar(criteria, func, this)
this.customEvents[theEvent.id] = theEvent
return theEvent
}
registerStep(isFps, interval, func){
let theEvent = this.FeatureManager.registerStep(isFps, interval, func, this)
this.customEvents[theEvent.id] = theEvent
return theEvent
}
registerCustom(event, func){
let theEvent = this.FeatureManager.registerCustom(event, func, this)
this.customEvents[theEvent.id] = theEvent
return theEvent
}
registerCommand(name, func){
this.FeatureManager.commandFuncs[name] = func
this.FeatureManager.registerCommand(name, (...args)=>{
if(this.FeatureManager.commandFuncs[name]){
this.FeatureManager.commandFuncs[name].call(this, ...(args || []))
}else{
ChatLib.chat(this.FeatureManager.messagePrefix + "This command is not available atm")
}
}, this)
}
unregisterCommand(name){
delete this.FeatureManager.commandFuncs[name]
}
unregisterCustom(event){
this.FeatureManager.unregisterCustom(event)
delete this.customEvents[event.id]
}
createCustomEvent(eventId){
return this.FeatureManager.createCustomEvent(eventId)
}
}
export default Feature
|