Skip to content

Refactor #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions commands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"use strict";
const {
hit,
npc,
list,
mode,
show,
hide,
style,
skills,
effects,
summons,
fireworks,
projectile,
} = require("./commands/");

function fpsUtilsCommands(main = "", sub = "", arg = "") {
let f;
switch (main.toLowerCase()) {
case "mode":
case "state":
f = mode; break;

case "hide":
f = hide; break;

case "show":
f = show; break;

case "list":
f = list; break;

case "summons":
f = summons; break;

case "skill":
case "skills":
f = skills; break;

case "npc":
case "npcs":
f = npc; break;

case "hit":
f = hit; break;

case "firework":
case "fireworks":
f = fireworks; break;

case "effects":
case "Abnormalities":
case "abnormalities":
case "fpsbooster9001":
f = effects; break;

case "style":
case "costume":
f = style; break;

case "proj":
case "projectile":
f = projectile; break;

default:
return this.message("Unknown command! Please refer to the readme for more information");
}
f.call(this, sub, arg);
}

module.exports = fpsUtilsCommands;
28 changes: 28 additions & 0 deletions commands/effects.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function effects(arg) {
switch (arg.toLowerCase()) {
case "all":
this.message(`Hiding of ALL abnormality effects on players ${
(config.hideAllAbnormalities = !config.hideAllAbnormalities) ? "en" : "dis"
}abled`);
break;

case "blacklist":
case "black":
this.message(`Hiding of BLACKLISTED abnormality effects ${
(config.blacklistAbnormalities = !config.blacklistAbnormalities) ? "en" : "dis"
}abled`);
break;

default:
return this.message(`Unrecognized subcommand "${arg}"`);
}
saveConfig();
}

module.exports = effects;
14 changes: 14 additions & 0 deletions commands/fireworks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function fireworks() {
this.message(`Hiding of firework effects ${
(config.hideFireworks = !config.hideFireworks) ? "en" : "dis"
}abled`);
saveConfig();
}

module.exports = fireworks;
55 changes: 55 additions & 0 deletions commands/hide.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");
const { entries: objectEntries } = Object;

function hide(sub, arg) {
arg = arg.toLowerCase();
switch (sub.toLowerCase()) {
case "class":
if (!config.classNames.has(arg))
return this.message(`Invalid class "${arg}"`);
if (config.hiddenClasses.has(arg))
return this.message(`Class "${arg}" is already hidden`);
config.hiddenClasses.add(arg);
for (const [model, classObj] of objectEntries(config.classes)) {
if (classObj.name !== arg) continue;
classObj.isHidden = true;
this.emit("hideclass", model);
break;
}
this.message(`Class "${arg}" hidden`);
break;

case "role":
if (!config.roleNames.has(arg))
return this.message(`Invalid role "${arg}"`);
if (config.hiddenRoles.has(arg))
return this.message(`Role "${arg}" is already hidden`);
config.hiddenRoles.add(arg);
for (const [model, classObj] of objectEntries(config.classes)) {
if (!classObj.role.includes(arg)) continue;
config.hiddenClasses.add(classObj.name);
classObj.isHidden = true;
this.emit("hideclass", model);
}
this.message(`Role "${arg}" hidden`);
break;

case "player":
if (config.blacklistedNames.has(arg))
return this.message(`Player "${arg}" already hidden`);
config.blacklistedNames.add(arg);
this.emit("hideplayer", arg);
this.message(`Player "${arg}" hidden`);
break;

default:
return this.message(`Unrecognized subcommand "${sub}"`);
}
saveConfig();
}

module.exports = hide;
33 changes: 33 additions & 0 deletions commands/hit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function hit(arg) {
switch (arg.toLowerCase()) {
case "me":
this.message(`Hiding of the players skill hits ${
(config.hitMe = !config.hitMe) ? "en" : "dis"
}abled`);
break;

case "other":
this.message(`Hiding of other players skill hits ${
(config.hitOther = !config.hitOther) ? "en" : "dis"
}abled`);
break;

case "damage":
this.message(`Hiding of the players skill damage numbers ${
(config.hitDamage = !config.hitDamage) ? "en" : "dis"
}abled`);
break;

default:
return this.message(`Unrecognized subcommand "${arg}"`);
}
saveConfig();
}

module.exports = hit;
16 changes: 16 additions & 0 deletions commands/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

module.exports = {
effects: require("./effects"),
fireworks: require("./fireworks"),
hide: require("./hide"),
hit: require("./hit"),
list: require("./list"),
mode: require("./mode"),
npc: require("./npc"),
projectile: require("./projectile"),
show: require("./show"),
skills: require("./skills"),
style: require("./style"),
summons: require("./summons")
};
12 changes: 12 additions & 0 deletions commands/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";
const {
config
} = require("../utils");

function list() {
this.message(`Hidden players: ${[...config.blacklistedNames]}`);
this.message(`Hidden classes: ${[...config.hiddenClasses]}`);
this.message(`Hidden roles: ${[...config.hiddenRoles]}`);
}

module.exports = list;
52 changes: 52 additions & 0 deletions commands/mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function mode(arg) {
switch (arg) {
case "0":
case "off":
if (config.mode === 3) {
this.emit("showall");
}
config.mode = 0;
this.message(`All FPS improvements disabled`);
break;

case "1":
if (config.mode === 3) {
this.emit("showall");
}
config.mode = 1;
// config.hideAllAbnormalities = true;
config.hitOther = true;
this.message(`FPS mode set to 1, projectiles hidden and abnormalities disabled`);
break;

case "2":
if (config.mode === 3) {
this.emit("showall");
}
config.mode = 2;
// config.hideAllAbnormalities = true;
config.hitOther = true;
this.message(`FPS mode set to 2, all skill effects disabled`);
break;

case "3":
this.emit("hideall");
config.mode = 3;
config.hideAllAbnormalities = true;
config.hitOther = true;
this.message(`FPS mode set to 3, hiding all players, their effects and their hit effects`);
break;

default:
return this.message(`Invalid mode ${arg}, valid modes are: 0, 1, 2, 3`);
}
saveConfig();
}

module.exports = mode;
14 changes: 14 additions & 0 deletions commands/npc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function npc() {
this.message(`Hiding of blacklisted NPCs ${
(config.blacklistNpcs = !config.blacklistNpcs) ? "en" : "dis"
}abled`);
saveConfig();
}

module.exports = npc;
27 changes: 27 additions & 0 deletions commands/projectile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");

function projectile(arg) {
switch (arg.toLowerCase()) {
case "all":
this.message(`Hiding of ALL projectile effects ${
(config.hideProjectiles = !config.hideProjectiles) ? "en" : "dis"
}abled`);
break;

case "blacklist":
this.message(`Hiding of BLACKLISTED projectile effects ${
(config.blacklistProjectiles = !config.blacklistProjectiles) ? "en" : "dis"
}abled`);
break;

default:
return this.message(`Unrecognized subcommand "${arg}"`);
}
saveConfig();
}

module.exports = projectile;
55 changes: 55 additions & 0 deletions commands/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use strict";
const {
config,
saveConfig
} = require("../utils");
const { entries: objectEntries } = Object;

function show(sub, arg) {
arg = arg.toLowerCase();
switch (sub.toLowerCase()) {
case "class":
if (!config.classNames.has(arg))
return this.message(`Invalid class "${arg}"`);
if (!config.hiddenClasses.has(arg))
return this.message(`Class "${arg}" is not hidden`);
config.hiddenClasses.delete(arg);
for (const [model, classObj] of objectEntries(config.classes)) {
if (classObj.name !== arg) continue;
classObj.isHidden = false;
this.emit("showclass", model);
break;
}
this.message(`Class "${arg}" shown`);
break;

case "role":
if (!config.roleNames.has(arg))
return this.message(`Invalid role "${arg}"`);
if (!config.hiddenRoles.has(arg))
return this.message(`Role "${arg}" is not hidden`);
config.hiddenRoles.delete(arg);
for (const [model, classObj] of objectEntries(config.classes)) {
if (!classObj.role.includes(arg)) continue;
config.hiddenClasses.delete(classObj.name);
classObj.isHidden = false;
this.emit("showclass", model);
}
this.message(`Role "${arg}" shown`);
break;

case "player":
if (!config.blacklistedNames.has(arg))
return this.message(`Player "${arg}" not hidden`);
config.blacklistedNames.delete(arg);
this.emit("showplayer", arg);
this.message(`Player "${arg}" shown`);
break;

default:
return this.message(`Unrecognized subcommand "${sub}"`);
}
saveConfig();
}

module.exports = show;
Loading