diff --git a/build.gradle b/build.gradle index 212e87c6..f2fb4e79 100644 --- a/build.gradle +++ b/build.gradle @@ -12,11 +12,11 @@ base { repositories { mavenCentral() - maven { url 'https://jitpack.io' } - maven { url 'https://repo.bluecolored.de/releases' } - maven { url 'https://oss.sonatype.org/content/repositories/snapshots' } - maven { url "https://repo.mikeprimm.com/" } - maven { url "https://maven.nucleoid.xyz/" } + maven { url = 'https://jitpack.io' } + maven { url = 'https://repo.bluecolored.de/releases' } + maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } + maven { url = "https://repo.mikeprimm.com/" } + maven { url = "https://maven.nucleoid.xyz/" } exclusiveContent { forRepository { maven { diff --git a/gradle.properties b/gradle.properties index 1703eb32..d53ec8ed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=26.1 -loader_version=0.18.4 +minecraft_version=26.2 +loader_version=0.19.3 # Mod Properties mod_version = 2.9.4 @@ -10,13 +10,13 @@ maven_group = io.icker archives_base_name = factions # Dependencies -fabric_api_version=0.144.1+26.1 +fabric_api_version=0.157.0+26.2 lucko_permissions_version=0.7.0 dynmap_api_version=3.7-SNAPSHOT -papi_version=3.0.0-beta.2+26.1 +papi_version=3.1.0-beta.1+26.2 styled_chat_version=V5imDrbM bluemap_api_version=2.7.1 squaremap_api_version=1.2.3 sgui_version=2.0.0+26.1 -stapi_version=3.0.1+26.1 +stapi_version=3.1.0+26.2 flow_version=1.0.3 diff --git a/src/main/java/io/icker/factions/api/persistents/Faction.java b/src/main/java/io/icker/factions/api/persistents/Faction.java index 93e78f6e..26a307ed 100644 --- a/src/main/java/io/icker/factions/api/persistents/Faction.java +++ b/src/main/java/io/icker/factions/api/persistents/Faction.java @@ -78,7 +78,7 @@ public Faction( this.name = name; this.motd = motd; this.description = description; - this.color = color.getName(); + this.color = color.name(); this.open = open; this.power = power; } @@ -124,7 +124,7 @@ public String getName() { } public ChatFormatting getColor() { - return ChatFormatting.getByName(color); + return ChatFormatting.valueOf(color.toUpperCase()); } public String getDescription() { @@ -169,7 +169,7 @@ public void setMOTD(String motd) { } public void setColor(ChatFormatting color) { - this.color = color.getName(); + this.color = color.name(); FactionEvents.MODIFY.invoker().onModify(this); } diff --git a/src/main/java/io/icker/factions/command/ModifyCommand.java b/src/main/java/io/icker/factions/command/ModifyCommand.java index d9c8dd3b..dbea40e5 100644 --- a/src/main/java/io/icker/factions/command/ModifyCommand.java +++ b/src/main/java/io/icker/factions/command/ModifyCommand.java @@ -15,11 +15,12 @@ import net.minecraft.ChatFormatting; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; -import net.minecraft.commands.arguments.ColorArgument; +import net.minecraft.commands.arguments.TeamColorArgument; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Style; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.scores.TeamColor; import xyz.nucleoid.server.translations.api.Localization; import java.util.Locale; @@ -112,7 +113,8 @@ private int motd(CommandContext context) throws CommandSynta } private int color(CommandContext context) throws CommandSyntaxException { - ChatFormatting color = ColorArgument.getColor(context, "color"); + TeamColor teamColor = TeamColorArgument.getTeamColor(context, "color"); + ChatFormatting color = ChatFormatting.valueOf(teamColor.name()); CommandSourceStack source = context.getSource(); ServerPlayer player = source.getPlayerOrException(); @@ -196,7 +198,7 @@ public LiteralCommandNode getNode() { Commands.literal("color") .requires(Requires.hasPerms("factions.modify.color", 0)) .then( - Commands.argument("color", ColorArgument.color()) + Commands.argument("color", TeamColorArgument.teamColor()) .executes(this::color))) .then( Commands.literal("open") diff --git a/src/main/java/io/icker/factions/ui/AdminGui.java b/src/main/java/io/icker/factions/ui/AdminGui.java index ec432092..c86172f7 100644 --- a/src/main/java/io/icker/factions/ui/AdminGui.java +++ b/src/main/java/io/icker/factions/ui/AdminGui.java @@ -19,6 +19,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Items; import xyz.nucleoid.server.translations.api.Localization; @@ -43,7 +44,7 @@ public AdminGui(ServerPlayer player) { FactionsMod.dynmap == null ? List.of(1, 3, 5, 7) : List.of(0, 2, 4, 6, 8); for (int i = 0; i < 9; i++) - this.setSlot(i, new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).hideTooltip()); + this.setSlot(i, new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)).hideTooltip()); // Bypass icon this.setSlot(indexes.get(0), buildBypassElement(user)); diff --git a/src/main/java/io/icker/factions/ui/InfoGui.java b/src/main/java/io/icker/factions/ui/InfoGui.java index 3dd4be3b..2a73467b 100644 --- a/src/main/java/io/icker/factions/ui/InfoGui.java +++ b/src/main/java/io/icker/factions/ui/InfoGui.java @@ -20,6 +20,7 @@ import net.minecraft.server.players.ProfileResolver; import net.minecraft.util.Util; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; @@ -61,7 +62,7 @@ public InfoGui(ServerPlayer player, Faction faction, @Nullable Runnable closeCal this.setTitle(Component.translatable("factions.gui.info.title")); for (int i = 0; i < 9; i++) - this.setSlot(i, new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).hideTooltip()); + this.setSlot(i, new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)).hideTooltip()); // Faction info this.setSlot( diff --git a/src/main/java/io/icker/factions/ui/MemberGui.java b/src/main/java/io/icker/factions/ui/MemberGui.java index 829cce16..3b5b6be0 100644 --- a/src/main/java/io/icker/factions/ui/MemberGui.java +++ b/src/main/java/io/icker/factions/ui/MemberGui.java @@ -20,6 +20,7 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.ProfileResolver; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; @@ -187,7 +188,7 @@ protected DisplayElement getElement(int id) { for (int i = 0; i < 5; i++) gui.setSlot( i, - new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE) + new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)) .hideTooltip()); gui.setTitle( Component.translatable( diff --git a/src/main/java/io/icker/factions/ui/ModifyGui.java b/src/main/java/io/icker/factions/ui/ModifyGui.java index 5027c1ab..7f5d24f0 100644 --- a/src/main/java/io/icker/factions/ui/ModifyGui.java +++ b/src/main/java/io/icker/factions/ui/ModifyGui.java @@ -14,6 +14,7 @@ import net.minecraft.network.chat.Style; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.MenuType; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.Items; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ public ModifyGui(ServerPlayer player, Faction faction, @Nullable Runnable closeC this.setTitle(Component.translatable("factions.gui.modify.title")); for (int i = 0; i < 9; i++) - this.setSlot(i, new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).hideTooltip()); + this.setSlot(i, new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)).hideTooltip()); this.setSlot( 0, @@ -215,107 +216,107 @@ public ColorGui(ServerPlayer player, Faction faction, @Nullable Runnable returnC Component.translatable( "factions.gui.modify.change_color.select.option.reset")) .setCallback(() -> colorCallback(ChatFormatting.RESET))); - this.addSlot(new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE).hideTooltip()); + this.addSlot(new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)).hideTooltip()); this.addSlot( - new GuiElementBuilder(Items.RED_CONCRETE_POWDER) + new GuiElementBuilder(Items.CONCRETE_POWDER.pick(DyeColor.RED)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.red") .withStyle(ChatFormatting.RED)) .setCallback(() -> colorCallback(ChatFormatting.RED))); this.addSlot( - new GuiElementBuilder(Items.LIGHT_BLUE_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.LIGHT_BLUE)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.aqua") .withStyle(ChatFormatting.AQUA)) .setCallback(() -> colorCallback(ChatFormatting.AQUA))); this.addSlot( - new GuiElementBuilder(Items.BLACK_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.BLACK)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.black") .withStyle(ChatFormatting.BLACK)) .setCallback(() -> colorCallback(ChatFormatting.BLACK))); this.addSlot( - new GuiElementBuilder(Items.BLUE_CONCRETE_POWDER) + new GuiElementBuilder(Items.CONCRETE_POWDER.pick(DyeColor.BLUE)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.blue") .withStyle(ChatFormatting.BLUE)) .setCallback(() -> colorCallback(ChatFormatting.BLUE))); this.addSlot( - new GuiElementBuilder(Items.CYAN_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.CYAN)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_aqua") .withStyle(ChatFormatting.DARK_AQUA)) .setCallback(() -> colorCallback(ChatFormatting.DARK_AQUA))); this.addSlot( - new GuiElementBuilder(Items.BLUE_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.BLUE)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_blue") .withStyle(ChatFormatting.DARK_BLUE)) .setCallback(() -> colorCallback(ChatFormatting.DARK_BLUE))); this.addSlot( - new GuiElementBuilder(Items.GRAY_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.GRAY)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_gray") .withStyle(ChatFormatting.DARK_GRAY)) .setCallback(() -> colorCallback(ChatFormatting.DARK_GRAY))); this.addSlot( - new GuiElementBuilder(Items.LIGHT_GRAY_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.LIGHT_GRAY)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.gray") .withStyle(ChatFormatting.GRAY)) .setCallback(() -> colorCallback(ChatFormatting.GRAY))); this.addSlot( - new GuiElementBuilder(Items.GREEN_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.GREEN)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_green") .withStyle(ChatFormatting.DARK_GREEN)) .setCallback(() -> colorCallback(ChatFormatting.DARK_GREEN))); this.addSlot( - new GuiElementBuilder(Items.LIME_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.LIME)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.green") .withStyle(ChatFormatting.GREEN)) .setCallback(() -> colorCallback(ChatFormatting.GREEN))); this.addSlot( - new GuiElementBuilder(Items.MAGENTA_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.MAGENTA)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_purple") .withStyle(ChatFormatting.DARK_PURPLE)) .setCallback(() -> colorCallback(ChatFormatting.DARK_PURPLE))); this.addSlot( - new GuiElementBuilder(Items.PINK_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.PINK)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.light_purple") .withStyle(ChatFormatting.LIGHT_PURPLE)) .setCallback(() -> colorCallback(ChatFormatting.LIGHT_PURPLE))); this.addSlot( - new GuiElementBuilder(Items.RED_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.RED)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.dark_red") .withStyle(ChatFormatting.DARK_RED)) .setCallback(() -> colorCallback(ChatFormatting.DARK_RED))); this.addSlot( - new GuiElementBuilder(Items.YELLOW_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.YELLOW)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.gold") .withStyle(ChatFormatting.GOLD)) .setCallback(() -> colorCallback(ChatFormatting.GOLD))); this.addSlot( - new GuiElementBuilder(Items.WHITE_CONCRETE) + new GuiElementBuilder(Items.CONCRETE.pick(DyeColor.WHITE)) .setName( Component.translatable( "factions.gui.modify.change_color.select.option.white") diff --git a/src/main/java/io/icker/factions/ui/PagedGui.java b/src/main/java/io/icker/factions/ui/PagedGui.java index 0698ba29..4ca19aca 100644 --- a/src/main/java/io/icker/factions/ui/PagedGui.java +++ b/src/main/java/io/icker/factions/ui/PagedGui.java @@ -13,6 +13,7 @@ import net.minecraft.sounds.SoundEvents; import net.minecraft.world.inventory.MenuType; import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.DyeColor; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -130,7 +131,7 @@ public record DisplayElement(@Nullable GuiElement element, @Nullable Slot slot) DisplayElement.of(GuiElementBuilder.from(ItemStack.EMPTY).build()); private static final DisplayElement FILLER = DisplayElement.of( - new GuiElementBuilder(Items.WHITE_STAINED_GLASS_PANE) + new GuiElementBuilder(Items.STAINED_GLASS_PANE.pick(DyeColor.WHITE)) .setName(Component.empty()) .hideTooltip()); diff --git a/src/main/java/io/icker/factions/util/BlueMapWrapper.java b/src/main/java/io/icker/factions/util/BlueMapWrapper.java index fd7ec69e..a188fa39 100644 --- a/src/main/java/io/icker/factions/util/BlueMapWrapper.java +++ b/src/main/java/io/icker/factions/util/BlueMapWrapper.java @@ -20,6 +20,7 @@ import io.icker.factions.api.persistents.Home; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.scores.TeamColor; import java.util.HashMap; import java.util.List; @@ -133,9 +134,9 @@ private void generateMarkers() { .shape(shapes.removeFirst(), -64, 320) .holes(shapes.toArray(new Shape[0])) .fillColor( - new Color(faction.getColor().getColor() | 0x40000000)) + new Color(TeamColor.byName(faction.getColor().name().toLowerCase()).rgb() | 0x40000000)) .lineColor( - new Color(faction.getColor().getColor() | 0xFF000000)) + new Color(TeamColor.byName(faction.getColor().name().toLowerCase()).rgb() | 0xFF000000)) .label(faction.getName()) .detail(info) .build(); diff --git a/src/main/java/io/icker/factions/util/DynmapWrapper.java b/src/main/java/io/icker/factions/util/DynmapWrapper.java index 7f021ef2..9762a21a 100644 --- a/src/main/java/io/icker/factions/util/DynmapWrapper.java +++ b/src/main/java/io/icker/factions/util/DynmapWrapper.java @@ -14,6 +14,7 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; +import net.minecraft.world.scores.TeamColor; import org.dynmap.DynmapCommonAPI; import org.dynmap.DynmapCommonAPIListener; import org.dynmap.markers.AreaMarker; @@ -116,7 +117,7 @@ private void generateMarkers() { new double[] {pos.getMinBlockZ(), pos.getMaxBlockZ() + 1}, true); if (marker != null) { - marker.setFillStyle(marker.getFillOpacity(), faction.getColor().getColor()); + marker.setFillStyle(marker.getFillOpacity(), TeamColor.byName(faction.getColor().name().toLowerCase()).rgb()); marker.setLineStyle(0, 0, 0); } } @@ -153,7 +154,7 @@ private void generateMarkers() { marker.setLineStyle( marker.getLineWeight(), marker.getLineOpacity(), - faction.getColor().getColor()); + TeamColor.byName(faction.getColor().name().toLowerCase()).rgb()); } } } @@ -167,9 +168,9 @@ private void updateFaction(Faction faction) { for (Claim claim : faction.getClaims()) { AreaMarker marker = markerSet.findAreaMarker(claim.getKey()); - marker.setFillStyle(marker.getFillOpacity(), faction.getColor().getColor()); + marker.setFillStyle(marker.getFillOpacity(), TeamColor.byName(faction.getColor().name().toLowerCase()).rgb()); marker.setLineStyle( - marker.getLineWeight(), marker.getLineOpacity(), faction.getColor().getColor()); + marker.getLineWeight(), marker.getLineOpacity(), TeamColor.byName(faction.getColor().name().toLowerCase()).rgb()); marker.setDescription(info); } } diff --git a/src/main/java/io/icker/factions/util/PlaceholdersWrapper.java b/src/main/java/io/icker/factions/util/PlaceholdersWrapper.java index ca79a21b..e1d06195 100644 --- a/src/main/java/io/icker/factions/util/PlaceholdersWrapper.java +++ b/src/main/java/io/icker/factions/util/PlaceholdersWrapper.java @@ -80,7 +80,7 @@ public static void init() { (member) -> { if (!member.isInFaction()) return Component.nullToEmpty("reset"); - return Component.nullToEmpty(member.getFaction().getColor().getName()); + return Component.nullToEmpty(member.getFaction().getColor().name()); }); register( diff --git a/src/main/java/io/icker/factions/util/SquareMapWrapper.java b/src/main/java/io/icker/factions/util/SquareMapWrapper.java index fe3b2f02..eec2ad48 100644 --- a/src/main/java/io/icker/factions/util/SquareMapWrapper.java +++ b/src/main/java/io/icker/factions/util/SquareMapWrapper.java @@ -10,6 +10,7 @@ import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents; +import net.minecraft.world.scores.TeamColor; import xyz.jpenilla.squaremap.api.Key; import xyz.jpenilla.squaremap.api.MapWorld; import xyz.jpenilla.squaremap.api.Point; @@ -115,10 +116,10 @@ private void generateMarkers() { MarkerOptions.builder() .fillColor( new Color( - faction.getColor().getColor())) + TeamColor.byName(faction.getColor().name().toLowerCase()).rgb())) .strokeColor( new Color( - faction.getColor().getColor())) + TeamColor.byName(faction.getColor().name().toLowerCase()).rgb())) .hoverTooltip(faction.getName()) .clickTooltip(info)); diff --git a/src/main/resources/data/factions/lang/en_us.json b/src/main/resources/data/factions/lang/en_us.json index fab12c2f..092f454b 100644 --- a/src/main/resources/data/factions/lang/en_us.json +++ b/src/main/resources/data/factions/lang/en_us.json @@ -106,6 +106,7 @@ "factions.gui.modify.change_color.select.option.dark_red": "Use Dark Red color", "factions.gui.modify.change_color.select.option.gold": "Use Gold color", "factions.gui.modify.change_color.select.option.white": "Use White color", + "factions.gui.modify.change_color.select.option.yellow": "Use Yellow color", "factions.gui.modify.change_color.result.reset": "Successfully reset faction", "factions.gui.modify.change_color.result.color": "Successfully updated faction color to \"%s\"", "factions.gui.modify.change_color.color.red": "Red", @@ -123,6 +124,7 @@ "factions.gui.modify.change_color.color.dark_red": "Dark Red", "factions.gui.modify.change_color.color.gold": "Gold", "factions.gui.modify.change_color.color.white": "White", + "factions.gui.modify.change_color.color.yellow": "Yellow", "factions.gui.modify.faction_type": "Faction type: %s", "factions.gui.modify.faction_type.public": "Public", "factions.gui.modify.faction_type.invite": "Invite only", diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 987d2ee4..e1f74385 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ "depends": { "fabricloader": ">=0.13.3", - "minecraft": "~26.1", + "minecraft": "~26.2", "java": ">=17", "fabric-api": "*" },