Skip to content
This repository was archived by the owner on Feb 28, 2021. It is now read-only.

Commit 1c06d93

Browse files
committed
Move feedback methods into their own class
1 parent 3d6d737 commit 1c06d93

File tree

3 files changed

+37
-31
lines changed

3 files changed

+37
-31
lines changed

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ dependencies {
2323
modCompile "net.fabricmc:fabric:0.1.4.71"
2424
}
2525

26-
// TODO: Why doesn't this work?? //just use private.gradle
27-
//apply from: "https://raw.githubusercontent.com/Juuxel/gradle-local-properties/master/loader.gradle.kts"
26+
apply from: "https://raw.githubusercontent.com/Juuxel/gradle-local-properties/master/loader.gradle.kts"
2827

2928
if (rootProject.file("private.gradle").exists()) {
3029
apply from: "private.gradle"

src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22

33
import com.mojang.brigadier.CommandDispatcher;
44
import net.fabricmc.api.EnvType;
5-
import net.fabricmc.api.Environment;
65
import net.fabricmc.api.ModInitializer;
76
import net.fabricmc.loader.FabricLoader;
8-
import net.minecraft.client.MinecraftClient;
97
import net.minecraft.server.command.CommandSource;
10-
import net.minecraft.text.StringTextComponent;
11-
import net.minecraft.text.TextComponent;
12-
import net.minecraft.text.TextFormat;
138

149
import java.util.Collection;
1510
import java.util.Collections;
@@ -36,30 +31,6 @@ public static void registerCommand(Consumer<CommandDispatcher<CommandSource>> co
3631
commands.add(command);
3732
}
3833

39-
// Alternatives for ServerCommandSource.send[Feedback, Error]
40-
41-
/**
42-
* Sends a chat message to the client player. A replacement for ServerCommandSource.sendFeedback().
43-
*
44-
* @param textComponent the message
45-
*/
46-
@Environment(EnvType.CLIENT)
47-
public static void sendFeedback(TextComponent textComponent) {
48-
MinecraftClient.getInstance().player.addChatMessage(textComponent, false);
49-
}
50-
51-
/**
52-
* Sends a error chat message to the client player. A replacement for ServerCommandSource.sendError().
53-
*
54-
* @param textComponent the message
55-
*/
56-
@Environment(EnvType.CLIENT)
57-
public static void sendError(TextComponent textComponent) {
58-
MinecraftClient.getInstance().player.addChatMessage(
59-
new StringTextComponent("").append(textComponent).applyFormat(TextFormat.RED), false
60-
);
61-
}
62-
6334
@Override
6435
public void onInitialize() {
6536

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package io.github.cottonmc.clientcommands;
2+
3+
import net.fabricmc.api.EnvType;
4+
import net.fabricmc.api.Environment;
5+
import net.minecraft.client.MinecraftClient;
6+
import net.minecraft.text.StringTextComponent;
7+
import net.minecraft.text.TextComponent;
8+
import net.minecraft.text.TextFormat;
9+
10+
/**
11+
* Client-side replacements for ServerCommandSource.send[Feedback, Error]
12+
*/
13+
@Environment(EnvType.CLIENT)
14+
public final class Feedback {
15+
private Feedback() {}
16+
17+
/**
18+
* Sends a chat message to the client player. A replacement for ServerCommandSource.sendFeedback().
19+
*
20+
* @param textComponent the message
21+
*/
22+
public static void sendFeedback(TextComponent textComponent) {
23+
MinecraftClient.getInstance().player.addChatMessage(textComponent, false);
24+
}
25+
26+
/**
27+
* Sends a error chat message to the client player. A replacement for ServerCommandSource.sendError().
28+
*
29+
* @param textComponent the message
30+
*/
31+
public static void sendError(TextComponent textComponent) {
32+
MinecraftClient.getInstance().player.addChatMessage(
33+
new StringTextComponent("").append(textComponent).applyFormat(TextFormat.RED), false
34+
);
35+
}
36+
}

0 commit comments

Comments
 (0)