implement basic help system (closes #1)
This commit is contained in:
parent
0a4f25f244
commit
483a2177e3
4 changed files with 64 additions and 14 deletions
|
@ -4,10 +4,7 @@ import com.baseband.client.module.Feature;
|
|||
import com.baseband.client.module.chat.*;
|
||||
import com.baseband.client.module.client.*;
|
||||
import com.baseband.client.module.combat.AutoTotem;
|
||||
import com.baseband.client.module.command.Say;
|
||||
import com.baseband.client.module.command.Set;
|
||||
import com.baseband.client.module.command.Test;
|
||||
import com.baseband.client.module.command.Trigger;
|
||||
import com.baseband.client.module.command.*;
|
||||
import com.baseband.client.module.movement.*;
|
||||
import com.baseband.client.module.render.*;
|
||||
import com.baseband.client.module.world.*;
|
||||
|
@ -35,6 +32,7 @@ public class Setup {
|
|||
new AutoRespawn(),
|
||||
new AutoSignText(),
|
||||
new Baritone(),
|
||||
new Bind(),
|
||||
new Bright(),
|
||||
new ChatAppend(),
|
||||
new ChatCrypt(),
|
||||
|
@ -44,6 +42,7 @@ public class Setup {
|
|||
new ElytraFly(),
|
||||
new ElytraBot(),
|
||||
new Freecam(),
|
||||
new Help(),
|
||||
new HUD(),
|
||||
new HUD.ShowTPS(),
|
||||
new ISeeYou(),
|
||||
|
|
|
@ -6,7 +6,7 @@ import com.baseband.client.util.misc.GlobalUtil;
|
|||
|
||||
public class ToggleButton extends Component {
|
||||
|
||||
protected ConfigHandle handle;
|
||||
public ConfigHandle handle;
|
||||
protected final String field;
|
||||
private Runnable lambda;
|
||||
|
||||
|
|
|
@ -6,12 +6,22 @@ import com.baseband.client.module.Feature;
|
|||
import com.baseband.client.module.category.Command;
|
||||
import com.baseband.client.module.client.Client;
|
||||
import com.baseband.client.util.interact.ChatUtil;
|
||||
import de.tudbut.obj.TLMap;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
@Command
|
||||
public class Help extends Feature {
|
||||
|
||||
String type;
|
||||
@Override
|
||||
public void onTick() {
|
||||
if(type != null) {
|
||||
ChatUtil.openChat(type);
|
||||
type = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(String[] args) {
|
||||
if(args.length == 0) {
|
||||
|
@ -22,7 +32,7 @@ public class Help extends Feature {
|
|||
ChatUtil.print("- modules");
|
||||
ChatUtil.print("");
|
||||
ChatUtil.print("The beginning of the next command has already been typed out for you!");
|
||||
ChatUtil.openChat(Client.prefix + this + " ");
|
||||
type = (Client.prefix + this + " ");
|
||||
return;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("guide")) {
|
||||
|
@ -31,16 +41,30 @@ public class Help extends Feature {
|
|||
"When you change something with the set command, it automatically changes in the GUI as well.");
|
||||
ChatUtil.print("Everything you can do in the GUI can be done with a command. The help system can give you an " +
|
||||
"overview on what you can change. Just ask it for the §lmodules§r, for example.");
|
||||
ChatUtil.print("To navigate " + Setup.Name + " by commands, you will need the following:" +
|
||||
ChatUtil.print("To navigate " + Setup.Name + " by commands, you will also need the following:" +
|
||||
"- " + Client.prefix + BaseBand.getFeature(Set.class) + ": this allows you to set any setting as if you were in the GUI\n" +
|
||||
"- " + Client.prefix + BaseBand.getFeature(Bind.class) + ": this allows you to bind keys\n" +
|
||||
"- " + Client.prefix + BaseBand.getFeature(Bind.class) + ": this allows you to bind keys (they otherwise appear as numbers)\n" +
|
||||
"- " + Client.prefix + BaseBand.getFeature(Trigger.class) + ": this allows you to trigger things (like a button)");
|
||||
ChatUtil.openChat(Client.prefix + this + " modules");
|
||||
type = (Client.prefix + this + " modules");
|
||||
return;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("commands")) {
|
||||
ChatUtil.print("§c§l" + Setup.Name + " help system: Commands");
|
||||
ChatUtil.print("§7Below you find a list of commands in the client:");
|
||||
for (Feature feature : BaseBand.features) {
|
||||
if(feature.category != Category.COMMAND)
|
||||
continue;
|
||||
TextComponentString comp = new TextComponentString(" " + feature.text);
|
||||
Style style = new Style();
|
||||
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature));
|
||||
comp.setStyle(style);
|
||||
ChatUtil.print(comp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(args[0].equalsIgnoreCase("modules")) {
|
||||
ChatUtil.print("§c§l" + Setup.Name + " help system: Modules");
|
||||
ChatUtil.print("§7Below you find a list of modules in the client.");
|
||||
ChatUtil.print("§7Below you find a list of modules in the client:");
|
||||
for (Category category : Category.values()) {
|
||||
if(category == Category.COMMAND)
|
||||
continue;
|
||||
|
@ -50,14 +74,38 @@ public class Help extends Feature {
|
|||
continue;
|
||||
TextComponentString comp = new TextComponentString(" " + feature.text);
|
||||
Style style = new Style();
|
||||
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " module " + feature));
|
||||
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + this + " feature " + feature));
|
||||
comp.setStyle(style);
|
||||
ChatUtil.print(comp);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
ChatUtil.print("This action is not yet implemented!"); // TODO!
|
||||
if(args[0].equalsIgnoreCase("feature")) {
|
||||
if(args.length != 2) {
|
||||
ChatUtil.print("Invalid syntax.");
|
||||
return;
|
||||
}
|
||||
ChatUtil.print("§c§l" + Setup.Name + " help system: Feature " + args[1]);
|
||||
for (Feature feature : BaseBand.features) {
|
||||
if(feature.toString().replace(' ', '_').equalsIgnoreCase(args[1])) {
|
||||
ChatUtil.print(feature.hover);
|
||||
ChatUtil.print("The feature is " + (feature.enabled ? "§aenabled" : "§cdisabled") + ".");
|
||||
ChatUtil.print("It has " + feature.handle.getContent().map.size() + " config entries:");
|
||||
for (TLMap.Entry<String, Object> entry : feature.handle.getContent().map.entries()) {
|
||||
TextComponentString comp = new TextComponentString(" " + entry.key + " = " + entry.val);
|
||||
Style style = new Style();
|
||||
style.setClickEvent(new net.minecraft.util.text.event.ClickEvent(net.minecraft.util.text.event.ClickEvent.Action.SUGGEST_COMMAND, Client.prefix + BaseBand.getFeature(Set.class) + " " + feature.toString().replace(' ', '_') + " " + entry.key.replace(' ', '_') + " "));
|
||||
comp.setStyle(style);
|
||||
ChatUtil.print(comp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
ChatUtil.print("This feature does not exist.");
|
||||
return;
|
||||
}
|
||||
ChatUtil.print("This action does not exist!");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,10 @@ public class ChatUtil {
|
|||
public static void print(ITextComponent comp) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
if (mc.ingameGUI != null) {
|
||||
mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(Setup.get().Name.toLowerCase() + "~ ").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)).appendSibling(comp), new Random().nextInt());
|
||||
ITextComponent text = new TextComponentString(Setup.get().Name.toLowerCase() + "~ ").setStyle(new Style().setColor(TextFormatting.LIGHT_PURPLE)).appendSibling(comp);
|
||||
//noinspection DataFlowIssue
|
||||
comp.getStyle().setParentStyle(null);
|
||||
mc.ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, new Random().nextInt());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue