Merge pull request #38 from ice-mineman/master
Adds .renamemodule command, Optional Arraylist sorting modes
This commit is contained in:
commit
59b192c6cf
|
@ -0,0 +1,50 @@
|
|||
package me.rigamortis.seppuku.impl.command;
|
||||
|
||||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.command.Command;
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
|
||||
|
||||
/**
|
||||
* Author Ice
|
||||
* 5/06/2020 @ 18:14 PM.
|
||||
*/
|
||||
public final class RenameModuleCommand extends Command {
|
||||
|
||||
public RenameModuleCommand() {
|
||||
super("RenameModule", new String[]{"rm", "renamemod", "renamemodule"}, "Rename modules.", "renamemodule <module> <name>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exec(String input) {
|
||||
if (!this.clamp(input, 3, 3)) {
|
||||
this.printUsage();
|
||||
return;
|
||||
}
|
||||
|
||||
final String[] split = input.split(" ");
|
||||
|
||||
final String originalModuleName = split[1];
|
||||
final String newModuleName = split[2];
|
||||
|
||||
if(Seppuku.INSTANCE.getModuleManager().find(originalModuleName) != null) {
|
||||
Module mod = Seppuku.INSTANCE.getModuleManager().find(originalModuleName);
|
||||
|
||||
mod.setDisplayName(newModuleName);
|
||||
|
||||
Seppuku.INSTANCE.getConfigManager().saveAll();
|
||||
Seppuku.INSTANCE.logChat("Set " + originalModuleName + " custom alias to " + newModuleName);
|
||||
} else {
|
||||
Seppuku.INSTANCE.logChat(originalModuleName + " does not exist!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,11 @@ public class ModuleConfig extends Configurable {
|
|||
if (entry.getKey().equalsIgnoreCase("Keybind")) {
|
||||
module.setKey(entry.getValue().getAsString());
|
||||
}
|
||||
|
||||
if (entry.getKey().equalsIgnoreCase("Name")) {
|
||||
module.setDisplayName(entry.getValue().getAsString());
|
||||
}
|
||||
|
||||
// Check if we are already enabled
|
||||
if (entry.getKey().equalsIgnoreCase("Enabled") && !module.isEnabled() && module.getType() != Module.ModuleType.HIDDEN) {
|
||||
if (entry.getValue().getAsBoolean()) {
|
||||
|
|
|
@ -4,12 +4,16 @@ import com.mojang.realmsclient.gui.ChatFormatting;
|
|||
import me.rigamortis.seppuku.Seppuku;
|
||||
import me.rigamortis.seppuku.api.gui.hud.component.DraggableHudComponent;
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.impl.module.render.ArrayListModule;
|
||||
import me.rigamortis.seppuku.impl.module.render.HudModule;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import static me.rigamortis.seppuku.impl.module.render.ArrayListModule.Mode.*;
|
||||
|
||||
/**
|
||||
* Author Seth
|
||||
* 7/25/2019 @ 7:24 AM.
|
||||
|
@ -32,14 +36,26 @@ public final class ArrayListComponent extends DraggableHudComponent {
|
|||
}
|
||||
}
|
||||
|
||||
final Comparator<Module> comparator = (first, second) -> {
|
||||
final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
final float dif = Minecraft.getMinecraft().fontRenderer.getStringWidth(secondName) - Minecraft.getMinecraft().fontRenderer.getStringWidth(firstName);
|
||||
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
|
||||
};
|
||||
|
||||
mods.sort(comparator);
|
||||
Object sorting_mode = Seppuku.INSTANCE.getModuleManager().find(ArrayListModule.class).find("Sorting").getValue();
|
||||
if (sorting_mode.equals(LENGTH)) {
|
||||
final Comparator<Module> lengthComparator = (first, second) -> {
|
||||
final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
final float dif = Minecraft.getMinecraft().fontRenderer.getStringWidth(secondName) - Minecraft.getMinecraft().fontRenderer.getStringWidth(firstName);
|
||||
return dif != 0 ? (int) dif : secondName.compareTo(firstName);
|
||||
};
|
||||
mods.sort(lengthComparator);
|
||||
} else if (sorting_mode.equals(ALPHABET)) {
|
||||
final Comparator<Module> alphabeticalComparator = (first, second) -> {
|
||||
final String firstName = first.getDisplayName() + (first.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + first.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
final String secondName = second.getDisplayName() + (second.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + second.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
return firstName.compareToIgnoreCase(secondName);
|
||||
};
|
||||
mods.sort(alphabeticalComparator);
|
||||
} else if (sorting_mode.equals(UNSORTED)) {
|
||||
|
||||
}
|
||||
|
||||
float xOffset = 0;
|
||||
float yOffset = 0;
|
||||
|
@ -47,6 +63,7 @@ public final class ArrayListComponent extends DraggableHudComponent {
|
|||
|
||||
for (Module mod : mods) {
|
||||
if (mod != null && mod.getType() != Module.ModuleType.HIDDEN && mod.isEnabled() && !mod.isHidden()) {
|
||||
|
||||
final String name = mod.getDisplayName() + (mod.getMetaData() != null ? " " + ChatFormatting.GRAY + "[" + ChatFormatting.WHITE + mod.getMetaData().toLowerCase() + ChatFormatting.GRAY + "]" : "");
|
||||
|
||||
final float width = Minecraft.getMinecraft().fontRenderer.getStringWidth(name);
|
||||
|
|
|
@ -60,6 +60,7 @@ public final class CommandManager {
|
|||
this.commandList.add(new JoinDateCommand());
|
||||
this.commandList.add(new EnchantCommand());
|
||||
this.commandList.add(new RenameCommand());
|
||||
this.commandList.add(new RenameModuleCommand());
|
||||
this.commandList.add(new SpawnEggCommand());
|
||||
this.commandList.add(new StackSizeCommand());
|
||||
this.commandList.add(new CrashSlimeCommand());
|
||||
|
|
|
@ -39,6 +39,7 @@ public final class ModuleManager {
|
|||
add(new KeybindsModule());
|
||||
add(new CommandsModule());
|
||||
add(new HudModule());
|
||||
add(new ArrayListModule());
|
||||
add(new NoOverlayModule());
|
||||
add(new NoPushModule());
|
||||
add(new GodModeModule());
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package me.rigamortis.seppuku.impl.module.render;
|
||||
|
||||
import me.rigamortis.seppuku.api.module.Module;
|
||||
import me.rigamortis.seppuku.api.value.Value;
|
||||
|
||||
/**
|
||||
* Author Ice
|
||||
* 05/06/2020 @ 22:49 PM.
|
||||
*/
|
||||
public class ArrayListModule extends Module {
|
||||
|
||||
public final Value<ArrayListModule.Mode> mode = new Value<ArrayListModule.Mode>("Sorting", new String[]{"Sorting", "sort"}, "Changes arraylist sorting.", ArrayListModule.Mode.LENGTH);
|
||||
|
||||
public ArrayListModule() {
|
||||
super("Arraylist", new String[]{"Arraylist"}, "Sorting", "NONE", -1, ModuleType.RENDER);
|
||||
this.setHidden(true);
|
||||
}
|
||||
|
||||
public enum Mode {
|
||||
LENGTH, ALPHABET, UNSORTED;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import me.rigamortis.seppuku.api.module.Module;
|
|||
import me.rigamortis.seppuku.api.value.Value;
|
||||
import me.rigamortis.seppuku.impl.gui.hud.GuiHudEditor;
|
||||
import me.rigamortis.seppuku.impl.gui.hud.anchor.AnchorPoint;
|
||||
import me.rigamortis.seppuku.impl.module.movement.FlightModule;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import team.stiff.pomelo.impl.annotated.handler.annotation.Listener;
|
||||
|
|
Loading…
Reference in New Issue