Skip to content

Commit

Permalink
Merge pull request #373 from AzureAaron/new-prefix
Browse files Browse the repository at this point in the history
New Message Feedback Prefix
  • Loading branch information
AzureAaron authored Oct 20, 2023
2 parents 5827ef1 + e317764 commit 44f3e52
Show file tree
Hide file tree
Showing 24 changed files with 144 additions and 110 deletions.
5 changes: 3 additions & 2 deletions src/main/java/de/hysky/skyblocker/skyblock/FairySouls.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.NEURepoManager;
import de.hysky.skyblocker.utils.PosUtils;
import de.hysky.skyblocker.utils.Utils;
Expand Down Expand Up @@ -117,12 +118,12 @@ private static void registerCommands(CommandDispatcher<FabricClientCommandSource
.then(literal("fairySouls")
.then(literal("markAllInCurrentIslandFound").executes(context -> {
FairySouls.markAllFairiesOnCurrentIslandFound();
context.getSource().sendFeedback(Text.translatable("skyblocker.fairySouls.markAllFound"));
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.fairySouls.markAllFound")));
return 1;
}))
.then(literal("markAllInCurrentIslandMissing").executes(context -> {
FairySouls.markAllFairiesOnCurrentIslandMissing();
context.getSource().sendFeedback(Text.translatable("skyblocker.fairySouls.markAllMissing"));
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.fairySouls.markAllMissing")));
return 1;
}))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import it.unimi.dsi.fastutil.objects.ObjectIntPair;
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.scheduler.Scheduler;
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
Expand Down Expand Up @@ -214,9 +215,9 @@ private static ArgumentBuilder<FabricClientCommandSource, RequiredArgumentBuilde
return argument("secret", IntegerArgumentType.integer()).executes(context -> {
int secretIndex = IntegerArgumentType.getInteger(context, "secret");
if (markSecrets(secretIndex, found)) {
context.getSource().sendFeedback(Text.translatable(found ? "skyblocker.dungeons.secrets.markSecretFound" : "skyblocker.dungeons.secrets.markSecretMissing", secretIndex));
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable(found ? "skyblocker.dungeons.secrets.markSecretFound" : "skyblocker.dungeons.secrets.markSecretMissing", secretIndex)));
} else {
context.getSource().sendError(Text.translatable(found ? "skyblocker.dungeons.secrets.markSecretFoundUnable" : "skyblocker.dungeons.secrets.markSecretMissingUnable", secretIndex));
context.getSource().sendError(Constants.PREFIX.get().append(Text.translatable(found ? "skyblocker.dungeons.secrets.markSecretFoundUnable" : "skyblocker.dungeons.secrets.markSecretMissingUnable", secretIndex)));
}
return Command.SINGLE_SUCCESS;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
Expand Down Expand Up @@ -34,7 +35,7 @@ private static int customizeDyeColor(FabricClientCommandSource source, String he
ItemStack heldItem = source.getPlayer().getMainHandStack();

if (hex != null && !isHexadecimalColor(hex)) {
source.sendError(Text.translatable("skyblocker.customDyeColors.invalidHex"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.invalidHex")));
return Command.SINGLE_SUCCESS;
}

Expand All @@ -49,24 +50,24 @@ private static int customizeDyeColor(FabricClientCommandSource source, String he
if (customDyeColors.containsKey(itemUuid)) {
customDyeColors.removeInt(itemUuid);
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customDyeColors.removed"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.removed")));
} else {
source.sendFeedback(Text.translatable("skyblocker.customDyeColors.neverHad"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.neverHad")));
}
} else {
customDyeColors.put(itemUuid, Integer.decode("0x" + hex.replace("#", "")).intValue());
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customDyeColors.added"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.added")));
}
} else {
source.sendError(Text.translatable("skyblocker.customDyeColors.noItemUuid"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.noItemUuid")));
}
} else {
source.sendError(Text.translatable("skyblocker.customDyeColors.notDyeable"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.notDyeable")));
return Command.SINGLE_SUCCESS;
}
} else {
source.sendError(Text.translatable("skyblocker.customDyeColors.unableToSetColor"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customDyeColors.unableToSetColor")));
}

return Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.events.SkyblockEvents;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
Expand Down Expand Up @@ -108,32 +109,32 @@ private static int customizeTrim(FabricClientCommandSource source, Identifier ma
if (customArmorTrims.containsKey(itemUuid)) {
customArmorTrims.remove(itemUuid);
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customArmorTrims.removed"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.removed")));
} else {
source.sendFeedback(Text.translatable("skyblocker.customArmorTrims.neverHad"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.neverHad")));
}
} else {
// Ensure that the material & trim are valid
ArmorTrimId trimId = new ArmorTrimId(material, pattern);
if (TRIMS_CACHE.get(trimId) == null) {
source.sendError(Text.translatable("skyblocker.customArmorTrims.invalidMaterialOrPattern"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.invalidMaterialOrPattern")));

return Command.SINGLE_SUCCESS;
}

customArmorTrims.put(itemUuid, trimId);
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customArmorTrims.added"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.added")));
}
} else {
source.sendError(Text.translatable("skyblocker.customArmorTrims.noItemUuid"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.noItemUuid")));
}
} else {
source.sendError(Text.translatable("skyblocker.customArmorTrims.notAnArmorPiece"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.notAnArmorPiece")));
return Command.SINGLE_SUCCESS;
}
} else {
source.sendError(Text.translatable("skyblocker.customArmorTrims.unableToSetTrim"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customArmorTrims.unableToSetTrim")));
}

return Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
Expand Down Expand Up @@ -42,9 +43,9 @@ private static int renameItem(FabricClientCommandSource source, Text text) {
//Remove custom item name when the text argument isn't passed
customItemNames.remove(itemUuid);
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customItemNames.removed"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customItemNames.removed")));
} else {
source.sendFeedback(Text.translatable("skyblocker.customItemNames.neverHad"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customItemNames.neverHad")));
}
} else {
//If the text is provided then set the item's custom name to it
Expand All @@ -55,13 +56,13 @@ private static int renameItem(FabricClientCommandSource source, Text text) {

customItemNames.put(itemUuid, text);
SkyblockerConfigManager.save();
source.sendFeedback(Text.translatable("skyblocker.customItemNames.added"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.customItemNames.added")));
}
} else {
source.sendError(Text.translatable("skyblocker.customItemNames.noItemUuid"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customItemNames.noItemUuid")));
}
} else {
source.sendError(Text.translatable("skyblocker.customItemNames.unableToSetName"));
source.sendError(Constants.PREFIX.get().append(Text.translatable("skyblocker.customItemNames.unableToSetName")));
}

return Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
Expand Down Expand Up @@ -44,18 +45,18 @@ private static int protectMyItem(FabricClientCommandSource source) {
protectedItems.add(itemUuid);
SkyblockerConfigManager.save();

source.sendFeedback(Text.translatable("skyblocker.itemProtection.added", heldItem.getName()));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.added", heldItem.getName())));
} else {
protectedItems.remove(itemUuid);
SkyblockerConfigManager.save();

source.sendFeedback(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName()));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.removed", heldItem.getName())));
}
} else {
source.sendFeedback(Text.translatable("skyblocker.itemProtection.noItemUuid"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.noItemUuid")));
}
} else {
source.sendFeedback(Text.translatable("skyblocker.itemProtection.unableToProtect"));
source.sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemProtection.unableToProtect")));
}

return Command.SINGLE_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gson.JsonObject;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.Http;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.Utils;
Expand Down Expand Up @@ -196,7 +197,7 @@ public static void onInjectTooltip(ItemStack stack, TooltipContext context, List

private static void nullWarning() {
if (!nullMsgSend && client.player != null) {
client.player.sendMessage(Text.translatable("skyblocker.itemTooltip.nullMessage"), false);
client.player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.itemTooltip.nullMessage")), false);
nullMsgSend = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.hysky.skyblocker.skyblock.itemlist;

import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.ItemUtils;
import de.hysky.skyblocker.utils.NEURepoManager;
import io.github.moulberry.repo.data.NEUCraftingRecipe;
Expand Down Expand Up @@ -88,7 +89,7 @@ public static String getWikiLink(String internalName, PlayerEntity player) {

private static void warnNoWikiLink(PlayerEntity player) {
if (player != null) {
player.sendMessage(Text.of("[Skyblocker] Unable to locate a wiki article for this item..."), false);
player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.wikiLookup.noArticleFound")), false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import de.hysky.skyblocker.SkyblockerMod;
import de.hysky.skyblocker.config.SkyblockerConfig;
import de.hysky.skyblocker.config.SkyblockerConfigManager;
import de.hysky.skyblocker.utils.Constants;
import de.hysky.skyblocker.utils.PosUtils;
import de.hysky.skyblocker.utils.Utils;
import de.hysky.skyblocker.utils.render.RenderHelper;
Expand Down Expand Up @@ -105,12 +106,12 @@ private static void registerCommands(CommandDispatcher<FabricClientCommandSource
.then(literal("relics")
.then(literal("markAllFound").executes(context -> {
Relics.markAllFound();
context.getSource().sendFeedback(Text.translatable("skyblocker.relics.markAllFound"));
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.relics.markAllFound")));
return 1;
}))
.then(literal("markAllMissing").executes(context -> {
Relics.markAllMissing();
context.getSource().sendFeedback(Text.translatable("skyblocker.relics.markAllMissing"));
context.getSource().sendFeedback(Constants.PREFIX.get().append(Text.translatable("skyblocker.relics.markAllMissing")));
return 1;
}))));
}
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/de/hysky/skyblocker/utils/Constants.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,31 @@
package de.hysky.skyblocker.utils;

import java.util.function.IntFunction;
import java.util.function.Supplier;
import java.util.function.UnaryOperator;

import net.minecraft.text.MutableText;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

/**
* Holds generic static constants
*/
public interface Constants {
String LEVEL_EMBLEMS = "\u2E15\u273F\u2741\u2E19\u03B1\u270E\u2615\u2616\u2663\u213B\u2694\u27B6\u26A1\u2604\u269A\u2693\u2620\u269B\u2666\u2660\u2764\u2727\u238A\u1360\u262C\u269D\u29C9\uA214\u32D6\u2E0E\u26A0\uA541\u3020\u30C4\u2948\u2622\u2623\u273E\u269C\u0BD0\u0A6D\u2742\u16C3\u3023\u10F6\u0444\u266A\u266B\u04C3\u26C1\u26C3\u16DD\uA03E\u1C6A\u03A3\u09EB\u2603\u2654\u26C2\u12DE";
IntFunction<UnaryOperator<Style>> WITH_COLOR = color -> style -> style.withColor(color);
Supplier<MutableText> PREFIX = () -> Text.empty()
.append(Text.literal("[").formatted(Formatting.GRAY))
.append(Text.literal("S").styled(WITH_COLOR.apply(0x00ff4c)))
.append(Text.literal("k").styled(WITH_COLOR.apply(0x02fa60)))
.append(Text.literal("y").styled(WITH_COLOR.apply(0x04f574)))
.append(Text.literal("b").styled(WITH_COLOR.apply(0x07ef88)))
.append(Text.literal("l").styled(WITH_COLOR.apply(0x09ea9c)))
.append(Text.literal("o").styled(WITH_COLOR.apply(0x0be5af)))
.append(Text.literal("c").styled(WITH_COLOR.apply(0x0de0c3)))
.append(Text.literal("k").styled(WITH_COLOR.apply(0x10dad7)))
.append(Text.literal("e").styled(WITH_COLOR.apply(0x12d5eb)))
.append(Text.literal("r").styled(WITH_COLOR.apply(0x14d0ff)))
.append(Text.literal("] ").formatted(Formatting.GRAY));
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void deleteAndDownloadRepository() {
recursiveDelete(dir);
} catch (Exception ex) {
if (MinecraftClient.getInstance().player != null)
MinecraftClient.getInstance().player.sendMessage(Text.translatable("skyblocker.updaterepository.failed"), false);
MinecraftClient.getInstance().player.sendMessage(Constants.PREFIX.get().append(Text.translatable("skyblocker.updaterepository.failed")), false);
return;
}
loadRepository();
Expand Down
Loading

0 comments on commit 44f3e52

Please sign in to comment.