Skip to content

Commit

Permalink
Fix some server commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Patbox committed Jun 13, 2022
1 parent e8e792f commit a075b28
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repositories {
maven { url 'https://maven.nucleoid.xyz' }
maven { url 'https://maven.gegy.dev' }

//mavenLocal()
mavenLocal()
}

dependencies {
Expand All @@ -37,7 +37,7 @@ dependencies {
modCompileOnly("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")
modLocalRuntime("net.fabricmc.fabric-api:fabric-api:${project.fabric_version}")

modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.3+1.19")
modImplementation include("eu.pb4:placeholder-api:2.0.0-beta.5+1.19")
modImplementation include("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")

//modRuntime "supercoder79:databreaker:0.2.7"
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ loader_version=0.14.6
fabric_version=0.55.1+1.19

# Mod Properties
mod_version = 1.3.1+1.19
mod_version = 1.3.2+1.19
maven_group = eu.pb4
archives_base_name = styled-chat

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/eu/pb4/styledchat/config/ChatStyle.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public Text getPrivateMessageSent(Text sender, Text receiver, Text message, Obje
);
}

public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, Object placeholderContext) {
public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, PlaceholderContext context) {
if (this.privateMessageReceived == null) {
return null;
} else if (this.privateMessageReceived == StyledChatUtils.IGNORED_TEXT) {
Expand All @@ -306,8 +306,7 @@ public Text getPrivateMessageReceived(Text sender, Text receiver, Text message,

return Placeholders.parseText(
this.privateMessageReceived,
placeholderContext instanceof ServerPlayerEntity player ? PlaceholderContext.of(player) : PlaceholderContext.of((MinecraftServer) placeholderContext),

context,
Placeholders.PREDEFINED_PLACEHOLDER_PATTERN,
Map.of("sender", sender,
"receiver", receiver,
Expand Down
8 changes: 1 addition & 7 deletions src/main/java/eu/pb4/styledchat/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,7 @@ public Text getPrivateMessageSent(Text sender, Text receiver, Text message, Serv
}

public Text getPrivateMessageReceived(Text sender, Text receiver, Text message, ServerCommandSource context) {
Object placeholderContext;

try {
placeholderContext = context.getPlayer();
} catch (Exception e) {
placeholderContext = context.getServer();
}
var placeholderContext = PlaceholderContext.of(context);

for (PermissionStyle entry : this.permissionStyle) {
if (Permissions.check(context, entry.permission, entry.opLevel)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ public class MessageArgumentTypeSignedMessageMixin {
@Redirect(method = "method_44266", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;getMessageDecorator()Lnet/minecraft/network/message/MessageDecorator;"))
private MessageDecorator styledChat_returnCached(MinecraftServer instance) {
return (player, message) -> {
var cached = ((ExtPlayNetworkHandler) player.networkHandler).styledChat_getLastCached();
return CompletableFuture.completedFuture(cached != null ? cached : message);
if (player != null) {
var cached = ((ExtPlayNetworkHandler) player.networkHandler).styledChat_getLastCached();
return CompletableFuture.completedFuture(cached != null ? cached : message);
}
return CompletableFuture.completedFuture(message);
};
}
}

0 comments on commit a075b28

Please sign in to comment.