-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9cd3f9f
commit aa9ca72
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const pluginGroup = "Balaclava: Auto Champion Select"; | ||
|
||
class SwitchAction { | ||
constructor(id, name, legend, tags, group, callback, toasts) { | ||
this.id = id; | ||
this.name = name; | ||
this.legend = legend; | ||
this.tags = tags; | ||
this.group = group; | ||
this.perform = this.perform.bind(this); | ||
this.callback = callback; | ||
this.toasts = toasts; | ||
} | ||
|
||
perform() { | ||
try { | ||
const currentStatus = this.callback(); | ||
Toast.success(currentStatus ? this.toasts.on : this.toasts.off); | ||
} catch (error) { | ||
Toast.error(this.toasts.error); | ||
console.error(error); | ||
} | ||
} | ||
} | ||
|
||
export class AutoPickSwitchAction extends SwitchAction { | ||
constructor(callback) { | ||
super( | ||
"controladoPickSwitch", | ||
"Auto Pick [ON/OFF]", | ||
"Turn the auto pick ON/OFF", | ||
[pluginGroup, "pick", "switch"], | ||
pluginGroup, | ||
callback, | ||
{ | ||
on: "Auto Pick is ON", | ||
off: "Auto Pick is OFF", | ||
error: "Failed to toggle Auto Pick. Check console." | ||
} | ||
) | ||
} | ||
} | ||
|
||
export class AutoBanSwitchAction extends SwitchAction { | ||
constructor(callback) { | ||
super( | ||
"controladoBanSwitch", | ||
"Auto Ban [ON/OFF]", | ||
"Turn the auto ban ON/OFF", | ||
[pluginGroup, "ban", "switch"], | ||
pluginGroup, | ||
callback, | ||
{ | ||
on: "Auto Ban is ON", | ||
off: "Auto Ban is OFF", | ||
error: "Failed to toggle Auto Ban. Check console." | ||
} | ||
); | ||
} | ||
} | ||
|
||
export function addActions(actions) { | ||
for (let action of actions) { | ||
CommandBar.addAction(action); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters