Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
arlomcwalter committed Jan 8, 2022
1 parent 8e2ea5e commit ca7b2c0
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
@Mixin(CreativeInventoryScreen.class)
public interface CreativeInventoryScreenAccessor {
@Accessor("selectedTab")
int getSelectedTab();
static int getSelectedTab() {
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ private void onRenderBackground(CallbackInfo info) {
info.cancel();
}

@SuppressWarnings("UnresolvedMixinReference")
@Inject(method = "method_32635", at = @At("HEAD"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private static void onComponentConstruct(List<TooltipComponent> list, TooltipData data, CallbackInfo info) {
if (data instanceof MeteorTooltipData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.systems.commands.Command;
import meteordevelopment.meteorclient.systems.commands.arguments.PlayerListEntryArgumentType;
import meteordevelopment.meteorclient.utils.misc.text.TextUtils;
import meteordevelopment.meteorclient.utils.Utils;
import meteordevelopment.meteorclient.utils.network.Http;
import meteordevelopment.meteorclient.utils.network.MeteorExecutor;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
import meteordevelopment.meteorclient.utils.player.PlayerUtils;
import meteordevelopment.meteorclient.utils.render.color.Color;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.command.CommandSource;
Expand All @@ -24,10 +25,12 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import static com.mojang.brigadier.Command.SINGLE_SUCCESS;

public class NameHistoryCommand extends Command {
private static final Type RESPONSE_TYPE = new TypeToken<List<NameHistoryObject>>() {}.getType();

public NameHistoryCommand() {
super("name-history", "Provides a list of a players previous names from the Mojang api.", "history", "names");
Expand All @@ -38,25 +41,26 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
builder.then(argument("player", PlayerListEntryArgumentType.playerListEntry()).executes(context -> {
MeteorExecutor.execute(() -> {
PlayerListEntry lookUpTarget = PlayerListEntryArgumentType.getPlayerListEntry(context);
UUID uuid = lookUpTarget.getProfile().getId();

Type type = new TypeToken<List<NameHistoryObject>>(){}.getType();
List<NameHistoryObject> nameHistoryObjects = Http.get("https://api.mojang.com/user/profiles/" + lookUpTarget.getProfile().getId().toString().replace("-", "") + "/names").sendJson(type);
List<NameHistoryObject> nameHistoryObjects = Http.get("https://api.mojang.com/user/profiles/" + formatUUID(uuid) + "/names").sendJson(RESPONSE_TYPE);

if (nameHistoryObjects == null || nameHistoryObjects.isEmpty()) {
error("There was an error fetching that users name history.");
return;
}

BaseText initial = new LiteralText(lookUpTarget.getProfile().getName());
initial.append(new LiteralText("'s"));
String name = lookUpTarget.getProfile().getName();
BaseText initial = new LiteralText(name);
initial.append(new LiteralText(name.endsWith("s") ? "'" : "'s"));

Color nameColor = TextUtils.getMostPopularColor(lookUpTarget.getDisplayName());
Color nameColor = PlayerUtils.getPlayerColor(mc.world.getPlayerByUuid(uuid), Utils.WHITE);

initial.setStyle(initial.getStyle()
.withColor(new TextColor(nameColor.getPacked()))
.withClickEvent(new ClickEvent(
ClickEvent.Action.OPEN_URL,
"https://namemc.com/search?q=" + lookUpTarget.getProfile().getName()
"https://namemc.com/search?q=" + name
)
)
.withHoverEvent(new HoverEvent(
Expand Down Expand Up @@ -91,9 +95,13 @@ public void build(LiteralArgumentBuilder<CommandSource> builder) {
return SINGLE_SUCCESS;
}));
}
}

class NameHistoryObject {
String name;
long changedToAt;
private String formatUUID(UUID uuid) {
return uuid.toString().replace("-", "");
}

private static class NameHistoryObject {
String name;
long changedToAt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,24 @@ public class BetterChat extends Module {
private final SettingGroup sgSuffix = settings.createGroup("Suffix");

private final Setting<Boolean> annoy = sgGeneral.add(new BoolSetting.Builder()
.name("annoy")
.description("Makes your messages aNnOyInG.")
.defaultValue(false)
.build()
.name("annoy")
.description("Makes your messages aNnOyInG.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> fancy = sgGeneral.add(new BoolSetting.Builder()
.name("fancy-chat")
.description("Makes your messages ғᴀɴᴄʏ!")
.defaultValue(false)
.build()
.name("fancy-chat")
.description("Makes your messages ғᴀɴᴄʏ!")
.defaultValue(false)
.build()
);

private final Setting<Boolean> timestamps = sgGeneral.add(new BoolSetting.Builder()
.name("timestamps")
.description("Adds client side time stamps to the beginning of chat messages.")
.defaultValue(false)
.build()
.name("timestamps")
.description("Adds client side time stamps to the beginning of chat messages.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> playerHeads = sgGeneral.add(new BoolSetting.Builder()
Expand All @@ -74,10 +74,10 @@ public class BetterChat extends Module {
// Filter

private final Setting<Boolean> antiSpam = sgFilter.add(new BoolSetting.Builder()
.name("anti-spam")
.description("Blocks duplicate messages from filling your chat.")
.defaultValue(true)
.build()
.name("anti-spam")
.description("Blocks duplicate messages from filling your chat.")
.defaultValue(true)
.build()
);

private final Setting<Integer> antiSpamDepth = sgFilter.add(new IntSetting.Builder()
Expand Down Expand Up @@ -108,91 +108,91 @@ public class BetterChat extends Module {
// Longer chat

private final Setting<Boolean> infiniteChatBox = sgLongerChat.add(new BoolSetting.Builder()
.name("infinite-chat-box")
.description("Lets you type infinitely long messages.")
.defaultValue(true)
.build()
.name("infinite-chat-box")
.description("Lets you type infinitely long messages.")
.defaultValue(true)
.build()
);

private final Setting<Boolean> longerChatHistory = sgLongerChat.add(new BoolSetting.Builder()
.name("longer-chat-history")
.description("Extends chat length.")
.defaultValue(true)
.build()
.name("longer-chat-history")
.description("Extends chat length.")
.defaultValue(true)
.build()
);

private final Setting<Integer> longerChatLines = sgLongerChat.add(new IntSetting.Builder()
.name("extra-lines")
.description("The amount of extra chat lines.")
.defaultValue(1000)
.min(100)
.sliderRange(100, 1000)
.visible(longerChatHistory::get)
.build()
.name("extra-lines")
.description("The amount of extra chat lines.")
.defaultValue(1000)
.min(100)
.sliderRange(100, 1000)
.visible(longerChatHistory::get)
.build()
);

// Prefix

private final Setting<Boolean> prefix = sgPrefix.add(new BoolSetting.Builder()
.name("prefix")
.description("Adds a prefix to your chat messages.")
.defaultValue(false)
.build()
.name("prefix")
.description("Adds a prefix to your chat messages.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> prefixRandom = sgPrefix.add(new BoolSetting.Builder()
.name("random")
.description("Uses a random number as your prefix.")
.defaultValue(false)
.build()
.name("random")
.description("Uses a random number as your prefix.")
.defaultValue(false)
.build()
);

private final Setting<String> prefixText = sgPrefix.add(new StringSetting.Builder()
.name("text")
.description("The text to add as your prefix.")
.defaultValue("> ")
.visible(() -> !prefixRandom.get())
.build()
.name("text")
.description("The text to add as your prefix.")
.defaultValue("> ")
.visible(() -> !prefixRandom.get())
.build()
);

private final Setting<Boolean> prefixSmallCaps = sgPrefix.add(new BoolSetting.Builder()
.name("small-caps")
.description("Uses small caps in the prefix.")
.defaultValue(false)
.visible(() -> !prefixRandom.get())
.build()
.name("small-caps")
.description("Uses small caps in the prefix.")
.defaultValue(false)
.visible(() -> !prefixRandom.get())
.build()
);

// Suffix

private final Setting<Boolean> suffix = sgSuffix.add(new BoolSetting.Builder()
.name("suffix")
.description("Adds a suffix to your chat messages.")
.defaultValue(false)
.build()
.name("suffix")
.description("Adds a suffix to your chat messages.")
.defaultValue(false)
.build()
);

private final Setting<Boolean> suffixRandom = sgSuffix.add(new BoolSetting.Builder()
.name("random")
.description("Uses a random number as your suffix.")
.defaultValue(false)
.build()
.name("random")
.description("Uses a random number as your suffix.")
.defaultValue(false)
.build()
);

private final Setting<String> suffixText = sgSuffix.add(new StringSetting.Builder()
.name("text")
.description("The text to add as your suffix.")
.defaultValue(" | meteor on crack!")
.visible(() -> !suffixRandom.get())
.build()
.name("text")
.description("The text to add as your suffix.")
.defaultValue(" | meteor on crack!")
.visible(() -> !suffixRandom.get())
.build()
);

private final Setting<Boolean> suffixSmallCaps = sgSuffix.add(new BoolSetting.Builder()
.name("small-caps")
.description("Uses small caps in the suffix.")
.defaultValue(true)
.visible(() -> !suffixRandom.get())
.build()
.name("small-caps")
.description("Uses small caps in the suffix.")
.defaultValue(true)
.visible(() -> !suffixRandom.get())
.build()
);

private final Char2CharMap SMALL_CAPS = new Char2CharArrayMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,6 @@ private void set(KeyBinding bind, boolean pressed) {
}

public boolean skip() {
return mc.currentScreen == null || (mc.currentScreen instanceof CreativeInventoryScreen && ((CreativeInventoryScreenAccessor) mc.currentScreen).getSelectedTab() == ItemGroup.SEARCH.getIndex()) || mc.currentScreen instanceof ChatScreen || mc.currentScreen instanceof SignEditScreen || mc.currentScreen instanceof AnvilScreen || mc.currentScreen instanceof AbstractCommandBlockScreen || mc.currentScreen instanceof StructureBlockScreen;
return mc.currentScreen == null || (mc.currentScreen instanceof CreativeInventoryScreen && CreativeInventoryScreenAccessor.getSelectedTab() == ItemGroup.SEARCH.getIndex()) || mc.currentScreen instanceof ChatScreen || mc.currentScreen instanceof SignEditScreen || mc.currentScreen instanceof AnvilScreen || mc.currentScreen instanceof AbstractCommandBlockScreen || mc.currentScreen instanceof StructureBlockScreen;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static int survivalInventory(int i) {
}

private static int creativeInventory(int i) {
if (!(mc.currentScreen instanceof CreativeInventoryScreen) || ((CreativeInventoryScreenAccessor) mc.currentScreen).getSelectedTab() != ItemGroup.INVENTORY.getIndex()) return -1;
if (!(mc.currentScreen instanceof CreativeInventoryScreen) || CreativeInventoryScreenAccessor.getSelectedTab() != ItemGroup.INVENTORY.getIndex()) return -1;
return survivalInventory(i);
}

Expand Down

0 comments on commit ca7b2c0

Please sign in to comment.