Search in sources :

Example 1 with Friend

use of mathax.client.systems.friends.Friend in project Client by MatHax.

the class BetterTab method getPlayerName.

public Text getPlayerName(PlayerListEntry playerListEntry) {
    Text name;
    Color color = null;
    name = playerListEntry.getDisplayName();
    if (name == null) {
        /*if (mc.getSession().getUsername().equals("Matejko06"))
                name = new LiteralText("  " + playerListEntry.getProfile().getName());
            else*/
        name = new LiteralText(playerListEntry.getProfile().getName());
    }
    if (playerListEntry.getProfile().getId().toString().equals(mc.player.getGameProfile().getId().toString()) && self.get()) {
        color = selfColor.get();
    } else if (friends.get() && Friends.get().get(playerListEntry.getProfile().getName()) != null) {
        Friend friend = Friends.get().get(playerListEntry.getProfile().getName());
        if (friend != null)
            color = Friends.get().color;
    } else if (enemies.get() && Enemies.get().get(playerListEntry.getProfile().getName()) != null) {
        Enemy enemy = Enemies.get().get(playerListEntry.getProfile().getName());
        if (enemy != null)
            color = Enemies.get().color;
    }
    if (color != null) {
        String nameString = name.getString();
        for (Formatting format : Formatting.values()) {
            if (format.isColor())
                nameString = nameString.replace(format.toString(), "");
        }
        name = new LiteralText(nameString).setStyle(name.getStyle().withColor(new TextColor(color.getPacked())));
    }
    return name;
}
Also used : Friend(mathax.client.systems.friends.Friend) SettingColor(mathax.client.utils.render.color.SettingColor) TextColor(net.minecraft.text.TextColor) Color(mathax.client.utils.render.color.Color) Enemy(mathax.client.systems.enemies.Enemy) Formatting(net.minecraft.util.Formatting) LiteralText(net.minecraft.text.LiteralText) Text(net.minecraft.text.Text) TextColor(net.minecraft.text.TextColor) LiteralText(net.minecraft.text.LiteralText)

Example 2 with Friend

use of mathax.client.systems.friends.Friend in project Client by MatHax.

the class FriendsCommand method build.

@Override
public void build(LiteralArgumentBuilder<CommandSource> builder) {
    builder.then(literal("add").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
        Friend friend = FriendArgumentType.getFriend(context, "friend");
        if (Friends.get().add(friend)) {
            if (friend.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                info("Added (highlight)%s(default) to friends.", friend.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Added to friends.", Config.get().toastDuration.get()));
        } else {
            if (friend.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                error("(highlight)%s(default) is already your friend.", friend.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.RED + "Already your friend.", Config.get().toastDuration.get()));
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("remove").then(argument("friend", FriendArgumentType.friend()).executes(context -> {
        Friend friend = FriendArgumentType.getFriend(context, "friend");
        if (Friends.get().remove(friend)) {
            if (friend.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                info("Removed (highlight)%s(default) from friends.", friend.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.GRAY + "Removed from friends.", Config.get().toastDuration.get()));
        } else {
            if (friend.name.equals(mc.getSession().getUsername()))
                return SINGLE_SUCCESS;
            if (Config.get().chatFeedback.get())
                error("(highlight)%s(default) is not your friend.", friend.name);
            if (Config.get().toastFeedback.get())
                mc.getToastManager().add(new ToastSystem(Items.EMERALD_BLOCK, Friends.get().color.getPacked(), "Friends " + Formatting.GRAY + "[" + Formatting.WHITE + friend.name + Formatting.GRAY + "]", null, Formatting.RED + "Not your friend.", Config.get().toastDuration.get()));
        }
        return SINGLE_SUCCESS;
    })));
    builder.then(literal("list").executes(context -> {
        info("--- Friends ((highlight)%s(default)) ---", Friends.get().count());
        Friends.get().forEach(friend -> info("(highlight)" + friend.name));
        return SINGLE_SUCCESS;
    }));
}
Also used : Suggestions(com.mojang.brigadier.suggestion.Suggestions) Friends(mathax.client.systems.friends.Friends) CommandContext(com.mojang.brigadier.context.CommandContext) Collection(java.util.Collection) CompletableFuture(java.util.concurrent.CompletableFuture) Items(net.minecraft.item.Items) ArgumentType(com.mojang.brigadier.arguments.ArgumentType) Friend(mathax.client.systems.friends.Friend) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Config(mathax.client.systems.config.Config) CommandSource(net.minecraft.command.CommandSource) SINGLE_SUCCESS(com.mojang.brigadier.Command.SINGLE_SUCCESS) Formatting(net.minecraft.util.Formatting) List(java.util.List) CommandSource.suggestMatching(net.minecraft.command.CommandSource.suggestMatching) Command(mathax.client.systems.commands.Command) StringReader(com.mojang.brigadier.StringReader) ToastSystem(mathax.client.utils.render.ToastSystem) CommandSyntaxException(com.mojang.brigadier.exceptions.CommandSyntaxException) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) Friend(mathax.client.systems.friends.Friend) ToastSystem(mathax.client.utils.render.ToastSystem)

Aggregations

Friend (mathax.client.systems.friends.Friend)2 Formatting (net.minecraft.util.Formatting)2 SINGLE_SUCCESS (com.mojang.brigadier.Command.SINGLE_SUCCESS)1 StringReader (com.mojang.brigadier.StringReader)1 ArgumentType (com.mojang.brigadier.arguments.ArgumentType)1 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)1 CommandContext (com.mojang.brigadier.context.CommandContext)1 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)1 Suggestions (com.mojang.brigadier.suggestion.Suggestions)1 SuggestionsBuilder (com.mojang.brigadier.suggestion.SuggestionsBuilder)1 Collection (java.util.Collection)1 List (java.util.List)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 Command (mathax.client.systems.commands.Command)1 Config (mathax.client.systems.config.Config)1 Enemy (mathax.client.systems.enemies.Enemy)1 Friends (mathax.client.systems.friends.Friends)1 ToastSystem (mathax.client.utils.render.ToastSystem)1 Color (mathax.client.utils.render.color.Color)1