fix config crash 2

This commit is contained in:
Bella 2020-03-25 09:54:04 -04:00
parent de670096b1
commit c99a1a041a
No known key found for this signature in database
GPG Key ID: 815562EA23BFE344
4 changed files with 97 additions and 55 deletions

View File

@ -8,19 +8,22 @@ import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.modules.gui.InfoOverlay;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.util.ColourTextFormatting;
import me.zeroeightsix.kami.util.ColourUtils;
import me.zeroeightsix.kami.util.TimeUtil;
import net.minecraft.network.play.server.SPacketChat;
import net.minecraft.util.text.TextFormatting;
import static me.zeroeightsix.kami.util.ColourTextFormatting.toTextMap;
/**
* @author S-B99
* Updated by S-B99 on 06/02/20
* Updated by S-B99 on 25/03/20
*/
@Module.Info(name = "ChatTimestamp", category = Module.Category.CHAT, description = "Shows the time a message was sent beside the message", showOnArray = Module.ShowOnArray.OFF)
public class ChatTimestamp extends Module {
private Setting<TextFormatting> firstColour = register(Settings.e("First Colour", TextFormatting.valueOf("GRAY")));
private Setting<TextFormatting> secondColour = register(Settings.e("Second Colour", TextFormatting.valueOf("WHITE")));
private Setting<ColourTextFormatting.ColourCode> firstColour = register(Settings.e("First Colour", ColourTextFormatting.ColourCode.GRAY));
private Setting<ColourTextFormatting.ColourCode> secondColour = register(Settings.e("Second Colour", ColourTextFormatting.ColourCode.WHITE));
private Setting<TimeUtil.TimeType> timeTypeSetting = register(Settings.e("Time Format", TimeUtil.TimeType.HHMM));
private Setting<TimeUtil.TimeUnit> timeUnitSetting = register(Settings.e("Time Unit", TimeUtil.TimeUnit.H12));
private Setting<Boolean> doLocale = register(Settings.b("Show AMPM", true));
@ -38,7 +41,11 @@ public class ChatTimestamp extends Module {
});
private boolean addTime(String message) {
Command.sendRawChatMessage("<" + TimeUtil.getFinalTime(secondColour.getValue(), firstColour.getValue(), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue()) + TextFormatting.RESET + "> " + message);
Command.sendRawChatMessage("<" + TimeUtil.getFinalTime(setToText(secondColour.getValue()), setToText(firstColour.getValue()), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue()) + TextFormatting.RESET + "> " + message);
return true;
}
private TextFormatting setToText(ColourTextFormatting.ColourCode colourCode) {
return toTextMap.get(colourCode);
}
}

View File

@ -4,6 +4,7 @@ import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.util.ColourTextFormatting;
import net.minecraft.util.text.TextFormatting;
import java.awt.*;
@ -11,13 +12,14 @@ import java.awt.*;
import static me.zeroeightsix.kami.command.Command.sendDisableMessage;
import static me.zeroeightsix.kami.util.ColourConverter.rgbToInt;
import static me.zeroeightsix.kami.util.ColourTextFormatting.colourEnumMap;
import static me.zeroeightsix.kami.util.ColourTextFormatting.toTextMap;
import static me.zeroeightsix.kami.util.InfoCalculator.isNumberEven;
import static me.zeroeightsix.kami.util.InfoCalculator.reverseNumber;
/**
* @author S-B99
* Created by S-B99 on 20/03/20
* Updated by S-B99 on 24/03/20
* Updated by S-B99 on 25/03/20
*/
@Module.Info(name = "ActiveModules", category = Module.Category.GUI, description = "Configures ActiveModules Colour", showOnArray = Module.ShowOnArray.OFF)
public class ActiveModules extends Module {
@ -75,11 +77,15 @@ public class ActiveModules extends Module {
private TextFormatting infoGetSetting(boolean isOne) {
InfoOverlay infoOverlay = (InfoOverlay) ModuleManager.getModuleByName("InfoOverlay");
if (isOne) return infoOverlay.firstColour.getValue();
else return infoOverlay.secondColour.getValue();
if (isOne) return setToText(infoOverlay.firstColour.getValue());
else return setToText(infoOverlay.secondColour.getValue());
}
private TextFormatting setToText(ColourTextFormatting.ColourCode colourCode) {
return toTextMap.get(colourCode);
}
public int getRainbowSpeed() {
int rSpeed = reverseNumber(rainbowSpeed.getValue(), 1, 100);
if (rSpeed == 0) return 1; // can't divide by 0

View File

@ -5,6 +5,7 @@ import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.modules.movement.TimerSpeed;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.util.ColourTextFormatting;
import me.zeroeightsix.kami.util.InfoCalculator;
import me.zeroeightsix.kami.util.TimeUtil;
import net.minecraft.client.Minecraft;
@ -16,12 +17,13 @@ import net.minecraft.util.text.TextFormatting;
import java.util.ArrayList;
import static me.zeroeightsix.kami.command.Command.sendDisableMessage;
import static me.zeroeightsix.kami.util.ColourTextFormatting.toTextMap;
/**
* @author S-B99
* Created by S-B99 on 04/12/19
* Updated by S-B99 on 05/03/20
* PVP Information by Polymer on 04/03/20
* Updated by S-B99 on 25/03/20
*/
@Module.Info(name = "InfoOverlay", category = Module.Category.GUI, description = "Configures the game information overlay", showOnArray = Module.ShowOnArray.OFF)
public class InfoOverlay extends Module {
@ -48,8 +50,52 @@ public class InfoOverlay extends Module {
private Setting<TimeUtil.TimeType> timeTypeSetting = register(Settings.enumBuilder(TimeUtil.TimeType.class).withName("Time Format").withValue(TimeUtil.TimeType.HHMMSS).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
private Setting<TimeUtil.TimeUnit> timeUnitSetting = register(Settings.enumBuilder(TimeUtil.TimeUnit.class).withName("Time Unit").withValue(TimeUtil.TimeUnit.H12).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
private Setting<Boolean> doLocale = register(Settings.booleanBuilder("Time Show AMPM").withValue(true).withVisibility(v -> page.getValue().equals(Page.THREE) && time.getValue()).build());
public Setting<TextFormatting> firstColour = register(Settings.enumBuilder(TextFormatting.class).withName("First Colour").withValue(TextFormatting.valueOf("WHITE")).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<TextFormatting> secondColour = register(Settings.enumBuilder(TextFormatting.class).withName("Second Colour").withValue(TextFormatting.valueOf("BLUE")).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<ColourTextFormatting.ColourCode> firstColour = register(Settings.enumBuilder(ColourTextFormatting.ColourCode.class).withName("First Colour").withValue(ColourTextFormatting.ColourCode.WHITE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public Setting<ColourTextFormatting.ColourCode> secondColour = register(Settings.enumBuilder(ColourTextFormatting.ColourCode.class).withName("Second Colour").withValue(ColourTextFormatting.ColourCode.BLUE).withVisibility(v -> page.getValue().equals(Page.THREE)).build());
public static String getStringColour(TextFormatting c) {
return c.toString();
}
private TextFormatting setToText(ColourTextFormatting.ColourCode colourCode) {
return toTextMap.get(colourCode);
}
public ArrayList<String> infoContents() {
ArrayList<String> infoContents = new ArrayList<>();
if (version.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + KamiMod.KAMI_KANJI + getStringColour(setToText(secondColour.getValue())) + " " + KamiMod.MODVERSMALL);
} if (username.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + "Welcome" + getStringColour(setToText(secondColour.getValue())) + " " + mc.getSession().getUsername() + "!");
} if (time.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + TimeUtil.getFinalTime(setToText(secondColour.getValue()), setToText(firstColour.getValue()), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue()));
} if (tps.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.tps() + getStringColour(setToText(secondColour.getValue())) + " tps");
} if (fps.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + Minecraft.debugFPS + getStringColour(setToText(secondColour.getValue())) + " fps");
} if (speed.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.speed(useUnitKmH()) + getStringColour(setToText(secondColour.getValue())) + " " + unitType(speedUnit.getValue()));
} if (timerSpeed.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + TimerSpeed.returnGui() + getStringColour(setToText(secondColour.getValue())) + "t");
} if (ping.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.ping() + getStringColour(setToText(secondColour.getValue())) + " ms");
} if (durability.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.dura() + getStringColour(setToText(secondColour.getValue())) + " dura");
} if (memory.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + InfoCalculator.memory() + getStringColour(setToText(secondColour.getValue())) + "mB free");
} if (totems.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + getItems(Items.TOTEM_OF_UNDYING) + getStringColour(setToText(secondColour.getValue())) + " Totems");
} if (endCrystals.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + getItems(Items.END_CRYSTAL) + getStringColour(setToText(secondColour.getValue())) + " Crystals");
} if (expBottles.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + getItems(Items.EXPERIENCE_BOTTLE) + getStringColour(setToText(secondColour.getValue())) + " EXP Bottles");
} if (godApples.getValue()) {
infoContents.add(getStringColour(setToText(firstColour.getValue())) + getItems(Items.GOLDEN_APPLE) + getStringColour(setToText(secondColour.getValue())) + " God Apples");
}
return infoContents;
}
public void onDisable() { sendDisableMessage(getName()); }
private enum SpeedUnit { MPS, KMH }
@ -59,6 +105,10 @@ public class InfoOverlay extends Module {
return speedUnit.getValue().equals(SpeedUnit.KMH);
}
public static int getItems(Item i) {
return mc.player.inventory.mainInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum() + mc.player.inventory.offHandInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum();
}
private String unitType(SpeedUnit s) {
switch (s) {
case MPS: return "m/s";
@ -66,48 +116,4 @@ public class InfoOverlay extends Module {
default: return "Invalid unit type (mps or kmh)";
}
}
public static String getStringColour(TextFormatting c) {
return c.toString();
}
public static int getItems(Item i) {
return mc.player.inventory.mainInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum() + mc.player.inventory.offHandInventory.stream().filter(itemStack -> itemStack.getItem() == i).mapToInt(ItemStack::getCount).sum();
}
public ArrayList<String> infoContents() {
ArrayList<String> infoContents = new ArrayList<>();
if (version.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + KamiMod.KAMI_KANJI + getStringColour(secondColour.getValue()) + " " + KamiMod.MODVERSMALL);
} if (username.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + "Welcome" + getStringColour(secondColour.getValue()) + " " + mc.getSession().getUsername() + "!");
} if (time.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + TimeUtil.getFinalTime(secondColour.getValue(), firstColour.getValue(), timeUnitSetting.getValue(), timeTypeSetting.getValue(), doLocale.getValue()));
} if (tps.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + InfoCalculator.tps() + getStringColour(secondColour.getValue()) + " tps");
} if (fps.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + Minecraft.debugFPS + getStringColour(secondColour.getValue()) + " fps");
} if (speed.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + InfoCalculator.speed(useUnitKmH()) + getStringColour(secondColour.getValue()) + " " + unitType(speedUnit.getValue()));
} if (timerSpeed.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + TimerSpeed.returnGui() + getStringColour(secondColour.getValue()) + "t");
} if (ping.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + InfoCalculator.ping() + getStringColour(secondColour.getValue()) + " ms");
} if (durability.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + InfoCalculator.dura() + getStringColour(secondColour.getValue()) + " dura");
} if (memory.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + InfoCalculator.memory() + getStringColour(secondColour.getValue()) + "mB free");
} if (totems.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + getItems(Items.TOTEM_OF_UNDYING) + getStringColour(secondColour.getValue()) + " Totems");
} if (endCrystals.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + getItems(Items.END_CRYSTAL) + getStringColour(secondColour.getValue()) + " Crystals");
} if (expBottles.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + getItems(Items.EXPERIENCE_BOTTLE) + getStringColour(secondColour.getValue()) + " EXP Bottles");
} if (godApples.getValue()) {
infoContents.add(getStringColour(firstColour.getValue()) + getItems(Items.GOLDEN_APPLE) + getStringColour(secondColour.getValue()) + " God Apples");
}
return infoContents;
}
public void onDisable() { sendDisableMessage(getName()); }
}

View File

@ -8,7 +8,7 @@ import java.util.Map;
/**
* @author S-B99
* Updated by S-B99 on 24/03/20
* Updated by S-B99 on 25/03/20
*/
public class ColourTextFormatting {
public enum ColourEnum {
@ -53,4 +53,27 @@ public class ColourTextFormatting {
put(TextFormatting.WHITE, ColourEnum.WHITE);
}};
public enum ColourCode {
BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GRAY, DARK_GRAY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE
}
public static Map<ColourCode, TextFormatting> toTextMap = new HashMap<ColourCode, TextFormatting>(){{
put(ColourCode.BLACK, TextFormatting.BLACK);
put(ColourCode.DARK_BLUE, TextFormatting.DARK_BLUE);
put(ColourCode.DARK_GREEN, TextFormatting.DARK_GREEN);
put(ColourCode.DARK_AQUA, TextFormatting.DARK_AQUA);
put(ColourCode.DARK_RED, TextFormatting.DARK_RED);
put(ColourCode.DARK_PURPLE, TextFormatting.DARK_PURPLE);
put(ColourCode.GOLD, TextFormatting.GOLD);
put(ColourCode.GRAY, TextFormatting.GRAY);
put(ColourCode.DARK_GRAY, TextFormatting.DARK_GRAY);
put(ColourCode.BLUE, TextFormatting.BLUE);
put(ColourCode.GREEN, TextFormatting.GREEN);
put(ColourCode.AQUA, TextFormatting.AQUA);
put(ColourCode.RED, TextFormatting.RED);
put(ColourCode.LIGHT_PURPLE, TextFormatting.LIGHT_PURPLE);
put(ColourCode.YELLOW, TextFormatting.YELLOW);
put(ColourCode.WHITE, TextFormatting.WHITE);
}};
}