Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ version = if (preReleaseNumber == 0) {

dependencies {
minecraft("com.mojang:minecraft:${mcVersion}")
mappings("net.fabricmc:yarn:${mcVersion}+build.${deps["yarn_build"]}:v2")
mappings(loom.officialMojangMappings())
modImplementation("net.fabricmc:fabric-loader:${deps["fabricLoaderVersion"]}")

modImplementation("net.fabricmc.fabric-api:fabric-api:${deps["fabric_api"]}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import net.minecraft.network.chat.Component;

import java.util.ArrayList;
import java.util.List;

public interface BUCommand {
String getCommandName();

default Text getDescription() {
return Text.empty();
default Component getDescription() {
return Component.empty();
}

default List<String> getAliases() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import com.github.mkram17.bazaarutils.config.features.DeveloperConfig;
import com.github.mkram17.bazaarutils.config.util.ConfigUtil;
import com.github.mkram17.bazaarutils.data.UserOrdersStorage;
import com.github.mkram17.bazaarutils.utils.storage.UserOrdersStorage;
import com.github.mkram17.bazaarutils.features.notification.OutbidOrderHandler;
import com.github.mkram17.bazaarutils.misc.NotificationType;
import com.github.mkram17.bazaarutils.utils.PlayerActionUtil;
import com.github.mkram17.bazaarutils.utils.annotations.modules.Module;
import com.github.mkram17.bazaarutils.utils.bazaar.data.BazaarDataManager;
import com.github.mkram17.bazaarutils.utils.bazaar.data.BazaarDataUtil;
import com.github.mkram17.bazaarutils.utils.bazaar.market.order.Order;
import com.github.mkram17.bazaarutils.utils.bazaar.market.order.TransactionType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
Expand All @@ -17,8 +17,8 @@
import lombok.Getter;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;

import java.util.List;

Expand All @@ -28,7 +28,7 @@ public final class DeveloperCommands implements BUCommand {
public final String commandName = "developer";

@Getter
public final Text description = Text.literal("Toggles developer mode.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Toggles developer mode.").withStyle(ChatFormatting.GRAY);

@Getter
private final List<BUCommand> subcommands = List.of(
Expand Down Expand Up @@ -68,7 +68,7 @@ private static final class RemoveCommand implements BUCommand {
public final String commandName = "remove";

@Getter
public final Text description = Text.literal("Removes an order by index.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Removes an order by index.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand All @@ -93,7 +93,7 @@ private static final class InfoCommand implements BUCommand {
public final String commandName = "info";

@Getter
public final Text description = Text.literal("Prints info about an order by index.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Prints info about an order by index.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand All @@ -115,7 +115,7 @@ private static final class OutdatedCommand implements BUCommand {
public final String commandName = "outdated";

@Getter
public final Text description = Text.literal("Lists all outdated orders.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Lists all outdated orders.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand All @@ -139,7 +139,7 @@ private static final class ConvertNameCommand implements BUCommand {
public final String commandName = "convertname";

@Getter
public final Text description = Text.literal("Converts an item name to its product ID.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Converts an item name to its product ID.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(
Expand All @@ -152,7 +152,7 @@ private int convertNameToId(CommandContext<FabricClientCommandSource> context) {
if (!isEnabled()) return 0;

String name = StringArgumentType.getString(context, "item name").replaceAll("_", " ");
BazaarDataManager.findProductIdOptional(name).ifPresentOrElse(
BazaarDataUtil.findProductIdOptional(name).ifPresentOrElse(
id -> PlayerActionUtil.notifyAll(name + ": " + id),
() -> PlayerActionUtil.notifyAll("Could not find product ID for " + name)
);
Expand All @@ -166,7 +166,7 @@ private static final class ListCommand implements BUCommand {
public final String commandName = "list";

@Getter
public final Text description = Text.literal("Lists all watched orders.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Lists all watched orders.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import com.github.mkram17.bazaarutils.utils.annotations.modules.Module;
import lombok.Getter;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.ConfirmLinkScreen;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;

import java.net.URI;
Expand All @@ -19,22 +19,22 @@ public final class DiscordCommand implements BUCommand {
public final String commandName = "discord";

@Getter
public final Text description = Text.literal("Opens the BazaarUtils Discord invite.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Opens the BazaarUtils Discord invite.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
return base.executes(context -> {
MinecraftClient client = MinecraftClient.getInstance();
Minecraft client = Minecraft.getInstance();

client.send(() -> client.setScreen(new ConfirmLinkScreen(confirmed -> {
client.schedule(() -> client.setScreen(new ConfirmLinkScreen(confirmed -> {
if (confirmed) {
try {
net.minecraft.util.Util.getOperatingSystem().open(new URI(Util.DISCORD_LINK));
net.minecraft.util.Util.getPlatform().openUri(new URI(Util.DISCORD_LINK));
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
MinecraftClient.getInstance().setScreen(null);
Minecraft.getInstance().setScreen(null);
}, Util.DISCORD_LINK, true)));

return 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
import com.mojang.brigadier.context.CommandContext;
import lombok.Getter;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;

import java.util.List;

@Module
public final class HelpCommand implements BUCommand {

@Getter public final String commandName = "help";
@Getter public final Text description = Text.literal("Lists all available commands.").formatted(Formatting.GRAY);
@Getter public final Component description = Component.literal("Lists all available commands.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand All @@ -29,26 +29,26 @@ public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(Liter
private int execute(CommandContext<FabricClientCommandSource> context) {
BazaarUtilsCommands root = BazaarUtilsLateInitModules.BazaarUtilsCommands;

MutableText message = Text.literal("BazaarUtils Commands\n").formatted(Formatting.GOLD);
MutableComponent message = Component.literal("BazaarUtils Commands\n").withStyle(ChatFormatting.GOLD);

message.append(Text.literal("---------------------\n").formatted(Formatting.DARK_GRAY));
message.append(Component.literal("---------------------\n").withStyle(ChatFormatting.DARK_GRAY));
for (BUCommand command : root.getSubcommands()) {
appendCommand(message, command, "/bu");
}
message.append(Text.literal("---------------------").formatted(Formatting.DARK_GRAY));
message.append(Component.literal("---------------------").withStyle(ChatFormatting.DARK_GRAY));

PlayerActionUtil.notifyAll(message.getString());

return 1;
}

private void appendCommand(MutableText message, BUCommand command, String path) {
private void appendCommand(MutableComponent message, BUCommand command, String path) {
String fullPath = path + " " + command.getCommandName();

message.append(Text.literal(fullPath).formatted(Formatting.GREEN));
message.append(Text.literal(" - ").formatted(Formatting.DARK_GRAY));
message.append(Component.literal(fullPath).withStyle(ChatFormatting.GREEN));
message.append(Component.literal(" - ").withStyle(ChatFormatting.DARK_GRAY));
message.append(command.getDescription());
message.append(Text.literal("\n"));
message.append(Component.literal("\n"));

for (BUCommand sub : command.getSubcommands()) {
appendCommand(message, sub, fullPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import com.github.mkram17.bazaarutils.utils.annotations.modules.Module;
import lombok.Getter;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.network.chat.Component;
import net.minecraft.ChatFormatting;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;

@Module
Expand All @@ -15,7 +15,7 @@ public final class UpdateResourcesCommand implements BUCommand {
public final String commandName = "updateresources";

@Getter
public final Text description = Text.literal("Checks for and applies resource updates.").formatted(Formatting.GRAY);
public final Component description = Component.literal("Checks for and applies resource updates.").withStyle(ChatFormatting.GRAY);

@Override
public LiteralArgumentBuilder<FabricClientCommandSource> getCommandBuilder(LiteralArgumentBuilder<FabricClientCommandSource> base) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.github.mkram17.bazaarutils.BazaarUtils;
import com.github.mkram17.bazaarutils.features.keybinds.StashHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.util.Identifier;
import net.minecraft.client.KeyMapping;
import com.mojang.blaze3d.platform.InputConstants;
import net.minecraft.resources.Identifier;
import org.lwjgl.glfw.GLFW;

public class KeybindConfig {

public static final KeyBinding.Category CATEGORY = KeyBinding.Category.create(Identifier.of(BazaarUtils.MOD_ID));
public static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(Identifier.parse(BazaarUtils.MOD_ID));

//Keybinds get registered on object creation.
public StashHelper stashHelper = new StashHelper(new KeyBinding(
public StashHelper stashHelper = new StashHelper(new KeyMapping(
"Pick Up Stash",
InputUtil.Type.KEYSYM,
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_V,
CATEGORY
));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.JsonOps;
import lombok.extern.slf4j.Slf4j;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.mkram17.bazaarutils.config.patcher;

import com.google.gson.JsonObject;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import java.util.function.UnaryOperator;

public interface Patch extends UnaryOperator<JsonObject> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import java.util.List;

public record AddListPatch(String path, List<JsonElement> inserts) implements Patch {

public static final Identifier ID = Identifier.of("bazaarutils", "add_list");
public static final Identifier ID = Identifier.fromNamespaceAndPath("bazaarutils", "add_list");
public static final MapCodec<AddListPatch> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
Codec.STRING.fieldOf("path").forGetter(AddListPatch::path),
JsonUtils.JSON_ELEMENT_CODEC.listOf().fieldOf("inserts").forGetter(AddListPatch::inserts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;

public record AddPatch(String path, JsonElement insert) implements Patch {

public static final Identifier ID = Identifier.of("bazaarutils", "add");
public static final Identifier ID = Identifier.fromNamespaceAndPath("bazaarutils", "add");
public static final MapCodec<AddPatch> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
Codec.STRING.fieldOf("path").forGetter(AddPatch::path),
JsonUtils.JSON_ELEMENT_CODEC.fieldOf("insert").forGetter(AddPatch::insert)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import com.google.gson.JsonObject;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;
import java.util.List;

public record CompoundPatch(List<Patch> patches) implements Patch {

public static final Identifier ID = Identifier.of("bazaarutils", "compound");
public static final Identifier ID = Identifier.fromNamespaceAndPath("bazaarutils", "compound");
public static final MapCodec<CompoundPatch> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
ConfigPatches.CODEC.listOf().fieldOf("patches").forGetter(CompoundPatch::patches)
).apply(i, CompoundPatch::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;

public record MovePatch(String from, String to) implements Patch {

public static final Identifier ID = Identifier.of("bazaarutils", "move");
public static final Identifier ID = Identifier.fromNamespaceAndPath("bazaarutils", "move");
public static final MapCodec<MovePatch> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
Codec.STRING.fieldOf("from").forGetter(MovePatch::from),
Codec.STRING.fieldOf("to").forGetter(MovePatch::to)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.util.Identifier;
import net.minecraft.resources.Identifier;

public record RemovePatch(String path) implements Patch {

public static final Identifier ID = Identifier.of("bazaarutils", "remove");
public static final Identifier ID = Identifier.fromNamespaceAndPath("bazaarutils", "remove");
public static final MapCodec<RemovePatch> CODEC = RecordCodecBuilder.mapCodec(i -> i.group(
Codec.STRING.fieldOf("path").forGetter(RemovePatch::path)
).apply(i, RemovePatch::new));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import com.teamresourceful.resourcefulconfig.api.client.ResourcefulConfigScreen;
import com.teamresourceful.resourcefulconfig.api.loader.Configurator;
import com.teamresourceful.resourcefulconfig.api.types.ResourcefulConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.components.AbstractWidget;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -35,9 +35,9 @@ public static Screen createGUI(Screen parent) {
}

public static void openGUI() {
MinecraftClient client = MinecraftClient.getInstance();
Screen parent = client.currentScreen;
client.send(() -> client.setScreen(createGUI(parent)));
Minecraft client = Minecraft.getInstance();
Screen parent = client.screen;
client.schedule(() -> client.setScreen(createGUI(parent)));
}

public static void scheduleConfigSave() {
Expand All @@ -51,8 +51,8 @@ public static void scheduleConfigSave() {
}
}

public static List<ClickableWidget> getWidgets(){
List<ClickableWidget> widgets = new ArrayList<>();
public static List<AbstractWidget> getWidgets(){
List<AbstractWidget> widgets = new ArrayList<>();
//automatically added using @RegisterWidget annotation
return widgets;
}
Expand Down
Loading
Loading