Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
add info to CustomName
Browse files Browse the repository at this point in the history
  • Loading branch information
xia-mc committed Aug 5, 2024
1 parent b9b5646 commit 5170bc9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 7 deletions.
14 changes: 14 additions & 0 deletions src/main/java/keystrokesmod/module/Module.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Module {
protected final ArrayList<Setting> settings;
private final String moduleName;
private String prettyName;
private String prettyInfo;
private final Module.category moduleCategory;
@Getter
@Setter
Expand Down Expand Up @@ -145,6 +146,10 @@ public String getInfo() {
return "";
}

public String getPrettyInfo() {
return ModuleManager.customName.isEnabled() && ModuleManager.customName.info.isToggled() ? getRawPrettyInfo() : getInfo();
}

public String getName() {
return this.moduleName;
}
Expand All @@ -157,11 +162,20 @@ public String getRawPrettyName() {
return prettyName;
}

public String getRawPrettyInfo() {
return prettyInfo;
}

public void setPrettyName(String name) {
this.prettyName = name;
ModuleManager.sort();
}

public void setPrettyInfo(String name) {
this.prettyInfo = name;
ModuleManager.sort();
}

public void registerSetting(Setting setting) {
synchronized (settings) {
if (setting instanceof ModeValue) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package keystrokesmod.module.impl.render;

import keystrokesmod.module.Module;
import keystrokesmod.module.setting.impl.ButtonSetting;
import keystrokesmod.module.setting.impl.DescriptionSetting;

public class CustomName extends Module {
public final ButtonSetting info;

public CustomName() {
super("CustomName", category.render);
this.registerSetting(new DescriptionSetting("allow you change module's name."));
this.registerSetting(new DescriptionSetting("Command: rename <module> <name>"));
super("CustomName", category.render, "allow you change module's name.");
this.registerSetting(info = new ButtonSetting("Info", false));
this.registerSetting(new DescriptionSetting("Command: rename [module] [name] <info>"));
}
}
14 changes: 10 additions & 4 deletions src/main/java/keystrokesmod/utility/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,16 +253,22 @@ public static void rCMD(@NotNull String c) {
return;
}

if (args.size() != 3) {
if (args.size() != 3 && args.size() != 4) {
print(invSyn, 1);
return;
}

for (Module module : Raven.getModuleManager().getModules()) {
String name = module.getName().toLowerCase().replace(" ", "");
if (name.equals(args.get(1).toLowerCase())) {
module.setPrettyName(args.get(2));
print("&a" + module.getName() + " is now called " + module.getRawPrettyName(), 1);
if (args.size() == 3) {
module.setPrettyName(args.get(2));
print("&a" + module.getName() + " is now called " + module.getRawPrettyName(), 1);
} else {
module.setPrettyName(args.get(2));
module.setPrettyInfo(args.get(3));
print("&a'" + module.getName() + " " + module.getInfo() + "' is now called '" + module.getRawPrettyName() + module.getRawPrettyInfo() + "'", 1);
}
}
}
} else if (firstArg.equals("resetgui")) {
Expand Down Expand Up @@ -462,7 +468,7 @@ public static void rCMD(@NotNull String c) {
print("4 nick [name/reset]", 0);
print("5 ping", 0);
print("6 hide/show [module]", 0);
print("7 rename [module] [name]", 0);
print("7 rename [module] [name] <info>", 0);
print("8 say [message]", 0);
print("9 panic", 0);
print("10 resetGUI", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void saveProfile(Profile profile) {
JsonObject moduleInformation = new JsonObject();
moduleInformation.addProperty("name", (module.moduleCategory() == Module.category.scripts && !(module instanceof Manager)) ? "sc-" + module.getName() : module.getName());
moduleInformation.addProperty("prettyName", module.getRawPrettyName());
moduleInformation.addProperty("prettyInfo", module.getRawPrettyInfo());
if (module.canBeEnabled) {
moduleInformation.addProperty("enabled", module.isEnabled());
moduleInformation.addProperty("hidden", module.isHidden());
Expand Down

0 comments on commit 5170bc9

Please sign in to comment.