This commit is contained in:
Bella 2020-01-26 11:31:04 -05:00
parent 0c96fdc8cc
commit f494e71678
2 changed files with 59 additions and 11 deletions

View File

@ -4,11 +4,13 @@ import me.zeroeightsix.kami.KamiMod;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.util.InfoCalculator;
import me.zeroeightsix.kami.util.ColourUtils;
import me.zeroeightsix.kami.util.InfoCalculator;
import net.minecraft.client.Minecraft;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Locale;
/**
* @author S-B99
@ -20,13 +22,16 @@ public class InfoOverlay extends Module {
public Setting<Boolean> version = register(Settings.b("Version", true));
public Setting<Boolean> username = register(Settings.b("Username", true));
public Setting<Boolean> tps = register(Settings.b("TPS", true));
public Setting<Boolean> fps = register(Settings.b("FPS", true));
public Setting<Boolean> time = register(Settings.b("Time", true));
public Setting<Boolean> tps = register(Settings.b("Ticks Per Second", false));
public Setting<Boolean> fps = register(Settings.b("Frames Per Second", true));
public Setting<Boolean> speed = register(Settings.b("Speed", true));
public Setting<Boolean> ping = register(Settings.b("Ping", false));
public Setting<Boolean> durability = register(Settings.b("Durability", true));
public Setting<Boolean> memory = register(Settings.b("Memory", false));
public Setting<Boolean> ping = register(Settings.b("Latency", false));
public Setting<Boolean> durability = register(Settings.b("Item Damage", false));
public Setting<Boolean> memory = register(Settings.b("Memory Used", false));
public Setting<SpeedUnit> speedUnit = register(Settings.e("Speed Unit", SpeedUnit.KmH));
public Setting<TimeType> timeTypeSetting = register(Settings.e("Time Format", TimeType.HHMMSS));
public Setting<TimeUnit> timeUnitSetting = register(Settings.e("Time Unit", TimeUnit.h12));
public Setting<ColourCode> firstColour = register(Settings.e("First Colour", ColourCode.WHITE));
public Setting<ColourCode> secondColour = register(Settings.e("Second Colour", ColourCode.BLUE));
@ -34,6 +39,14 @@ public class InfoOverlay extends Module {
MpS, KmH
}
public enum TimeType {
HHMM, HHMMSS, HH
}
public enum TimeUnit {
h24, h12
}
private enum ColourCode {
BLACK, DARK_BLUE, DARK_GREEN, DARK_AQUA, DARK_RED, DARK_PURPLE, GOLD, GREY, DARK_GREY, BLUE, GREEN, AQUA, RED, LIGHT_PURPLE, YELLOW, WHITE
}
@ -50,6 +63,32 @@ public class InfoOverlay extends Module {
}
}
public SimpleDateFormat dateFormatter(TimeUnit timeUnit) {
SimpleDateFormat formatter;
switch (timeUnit) {
case h12:
formatter = new SimpleDateFormat("HH" + formatTimeString(timeTypeSetting.getValue()), Locale.UK); break;
case h24:
formatter = new SimpleDateFormat("hh" + formatTimeString(timeTypeSetting.getValue()), Locale.UK); break;
default:
throw new IllegalStateException("Unexpected value: " + timeUnit);
}
return formatter;
}
private static String formatTimeString(TimeType timeType) {
switch (timeType) {
case HHMM: return ":mm";
case HHMMSS: return ":mm:ss";
default: return "";
}
}
private String formatTimeColour() {
String formatted = textColour(secondColour.getValue()) + ":" + textColour(firstColour.getValue());
return InfoCalculator.time().replace(":", formatted);
}
private String textColour(ColourCode c) {
switch (c) {
case BLACK: return ColourUtils.ColourCodesMinecraft.BLACK_CC;
@ -68,7 +107,6 @@ public class InfoOverlay extends Module {
case LIGHT_PURPLE: return ColourUtils.ColourCodesMinecraft.LIGHT_PURPLE_CC;
case YELLOW: return ColourUtils.ColourCodesMinecraft.YELLOW_CC;
case WHITE: return ColourUtils.ColourCodesMinecraft.WHITE_CC;
default: return "";
}
}
@ -81,6 +119,9 @@ public class InfoOverlay extends Module {
if (username.getValue()) {
infoContents.add(textColour(firstColour.getValue()) + "Welcome " + textColour(secondColour.getValue()) + " " + mc.player.getName() + "!");
}
if (time.getValue()) {
infoContents.add(textColour(firstColour.getValue()) + formatTimeColour());
}
if (tps.getValue()) {
infoContents.add(textColour(firstColour.getValue()) + InfoCalculator.tps() + textColour(secondColour.getValue()) + " tps");
}

View File

@ -8,6 +8,8 @@ import net.minecraft.launchwrapper.LogWrapper;
import net.minecraft.util.math.MathHelper;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author S-B99
@ -27,11 +29,8 @@ import java.text.DecimalFormat;
* @author TBM
* Created by TBM on 8/12/19
*
* String:
* @author S-B99
*
* TPS:
* @author S-B99
* @author 086
*/
public class InfoCalculator extends Module {
@ -93,4 +92,12 @@ public class InfoCalculator extends Module {
return "" + Math.round(LagCompensator.INSTANCE.getTickRate());
}
/* End of ticks Per Second */
/* Time */
public static String time() {
SimpleDateFormat formatter = new InfoOverlay().dateFormatter(new InfoOverlay().timeUnitSetting.getValue());
Date date = new Date(System.currentTimeMillis());
return formatter.format(date);
}
/* End of time */
}