Skip to content

Commit

Permalink
Update to 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 3, 2023
1 parent c7e5e1f commit a7c8ac0
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 22 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.+'
id 'fabric-loom' version '1.0.+'
id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
id 'com.matthewprenger.cursegradle' version '1.4.0'
Expand Down Expand Up @@ -43,8 +43,8 @@ dependencies {

modCompileOnly fabricApi.module("fabric-message-api-v1", project.fabric_version)

modImplementation include("eu.pb4:predicate-api:0.1.0+1.19.3")
modImplementation include("eu.pb4:placeholder-api:2.1.0+1.19.4")
modImplementation include("eu.pb4:predicate-api:0.1.2+1.20")
modImplementation include("eu.pb4:placeholder-api:2.1.1+1.20")
modImplementation include("me.lucko:fabric-permissions-api:0.2-SNAPSHOT")
modImplementation include("eu.pb4:player-data-api:0.2.2+1.19.3")

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.14
minecraft_version=1.20-rc1
yarn_mappings=1.20-rc1+build.2
loader_version=0.14.21

#Fabric api
fabric_version=0.75.1+1.19.4
fabric_version=0.83.0+1.20

# Mod Properties

mod_version = 2.1.6+1.19.4
mod_version = 2.2.0+1.20
maven_group = eu.pb4
archives_base_name = styled-chat

Expand Down
31 changes: 31 additions & 0 deletions src/main/java/eu/pb4/styledchat/CardboardWarning.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package eu.pb4.styledchat;

import com.mojang.logging.LogUtils;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import org.slf4j.Logger;

public class CardboardWarning implements PreLaunchEntrypoint {
public static final Logger LOGGER = LogUtils.getLogger();
public static final boolean LOADED = FabricLoader.getInstance().isModLoaded("cardboard") || FabricLoader.getInstance().isModLoaded("banner");

@Override
public void onPreLaunch() {
checkAndAnnounce();
}

public static void checkAndAnnounce() {
if (LOADED) {
LOGGER.error("==============================================");
for (var i = 0; i < 4; i++) {
LOGGER.error("");
LOGGER.error("Cardboard/Banner detected! This mod doesn't work with it!");
LOGGER.error("You won't get any support as long as it's present!");
LOGGER.error("");
LOGGER.error("Read more at: https://gist.github.com/Patbox/e44844294c358b614d347d369b0fc3bf");
LOGGER.error("");
LOGGER.error("==============================================");
}
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/eu/pb4/styledchat/StyledChatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ public static Text formatMessage(SignedMessage message, ServerCommandSource sour
? baseInput
: maybeFormatFor(source, ext.styledChat_getOriginal(), message.getContent());

if (baseInput == null) {
if (baseInput == StyledChatUtils.EMPTY_TEXT) {
ext.styledChat_setArg("base_input", input);
}

Expand Down Expand Up @@ -418,8 +418,8 @@ public static SignedMessage toEventMessage(SignedMessage message, PlaceholderCon
var ext = (ExtSignedMessage) (Object) message;

var baseInput = ext.styledChat_getArg("base_input");
var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY ? baseInput : formatFor(context, ext.styledChat_getOriginal());
if (baseInput == null) {
var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY ? baseInput : formatFor(context, ext.styledChat_getOriginal());
if (baseInput == StyledChatUtils.EMPTY_TEXT) {
ext.styledChat_setArg("base_input", input);
}

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/eu/pb4/styledchat/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ private static int getProperty(CommandContext<ServerCommandSource> context, Chat
var data = StyledChatUtils.getPersonalData(player);

if (data == null) {
context.getSource().sendFeedback(Text.literal("<not set>").formatted(Formatting.ITALIC), false);
context.getSource().sendFeedback(() -> Text.literal("<not set>").formatted(Formatting.ITALIC), false);
return 0;
} else {
var val = propertyGetSet.get(data);

if (val == null) {
context.getSource().sendFeedback(Text.literal("<not set>").formatted(Formatting.ITALIC), false);
context.getSource().sendFeedback(() -> Text.literal("<not set>").formatted(Formatting.ITALIC), false);
return 0;
}

context.getSource().sendFeedback(Text.literal(val), false);
context.getSource().sendFeedback(() -> Text.literal(val), false);
return 1;
}
}
Expand All @@ -126,7 +126,7 @@ private static int setProperty(CommandContext<ServerCommandSource> context, Chat
propertySet.set(StyledChatUtils.getOrCreatePersonalData(player), val);
StyledChatUtils.updateStyle(player);
}
context.getSource().sendFeedback(Text.literal("Changed style of " + players.size() + " player(s)"), false);
context.getSource().sendFeedback(() -> Text.literal("Changed style of " + players.size() + " player(s)"), false);
return players.size();
}

Expand All @@ -140,7 +140,7 @@ private static int clearProperty(CommandContext<ServerCommandSource> context, Ch
}
StyledChatUtils.updateStyle(player);
}
context.getSource().sendFeedback(Text.literal("Cleared style for " + players.size() + " player(s)"), false);
context.getSource().sendFeedback(() -> Text.literal("Cleared style for " + players.size() + " player(s)"), false);
return players.size();
}

Expand Down Expand Up @@ -172,7 +172,7 @@ private static int clearProperty(CommandContext<ServerCommandSource> context, Ch

private static int reloadConfig(CommandContext<ServerCommandSource> context) {
if (ConfigManager.loadConfig()) {
context.getSource().sendFeedback(Text.literal("Reloaded config!"), false);
context.getSource().sendFeedback(() -> Text.literal("Reloaded config!"), false);

for (var player : context.getSource().getServer().getPlayerManager().getPlayerList()) {
StyledChatUtils.sendAutocompliton(player);
Expand All @@ -185,7 +185,7 @@ private static int reloadConfig(CommandContext<ServerCommandSource> context) {

private static int about(CommandContext<ServerCommandSource> context) {
for (var text : context.getSource().getEntity() instanceof ServerPlayerEntity ? GenericModInfo.getAboutFull() : GenericModInfo.getAboutConsole()) {
context.getSource().sendFeedback(text, false);
context.getSource().sendFeedback(() -> text, false);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class TeamMsgCommandMixin {
private static void styledChat_formatOgText(ServerCommandSource serverCommandSource, Entity entity, Team team, List<ServerPlayerEntity> list, SignedMessage signedMessage, CallbackInfo ci) {
var input = ExtSignedMessage.getArg(signedMessage, "base_input");

if (input == null) {
if (input == StyledChatUtils.EMPTY_TEXT) {
input = StyledChatUtils.formatFor(serverCommandSource, ((ExtSignedMessage) (Object) signedMessage).styledChat_getOriginal());
ExtSignedMessage.setArg(signedMessage,"base_input", input);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message
var baseInput = ExtSignedMessage.getArg(signedMessage, "base_input");
var source = ExtSignedMessage.of(signedMessage).styledChat_getSource();

var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY
var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY
? baseInput
: signedMessage.getContent();

Expand Down Expand Up @@ -73,7 +73,7 @@ public void send(ServerPlayerEntity receiver, boolean filterMaskEnabled, Message
var baseInput = ExtSignedMessage.getArg(message, "base_input");
var source = ExtSignedMessage.of(message).styledChat_getSource();

var input = baseInput != null && baseInput.getContent() != TextContent.EMPTY
var input = baseInput != StyledChatUtils.EMPTY_TEXT && baseInput.getContent() != TextContent.EMPTY
? baseInput
: message.getContent();

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@
"entrypoints": {
"main": [
"eu.pb4.styledchat.StyledChatMod"
],
"preLaunch": [
"eu.pb4.styledchat.CardboardWarning"
]
},
"mixins": [
"styledchat.mixins.json"
],

"depends": {
"minecraft": ">=1.19.1-beta.2"
"minecraft": ">=1.20-"
},
"custom": {
"modmenu": {
Expand Down

0 comments on commit a7c8ac0

Please sign in to comment.