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

Commit 789fa4a

Browse files
committed
1.0.0 for 1.15.2
1 parent 9711b56 commit 789fa4a

File tree

11 files changed

+56
-19
lines changed

11 files changed

+56
-19
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[>> Downloads <<](https://github.com/CottonMC/ClientCommands/releases)
88

9-
A Minecraft library for 1.14 that adds support for client-side commands.
9+
A Minecraft library for 1.15 that adds support for client-side commands.
1010

1111
**This mod is open source and under a permissive license.** As such, it can be included in any modpack on any platform without prior permission. We appreciate hearing about people using our mods, but you do not need to ask to use them. See the [LICENSE file](LICENSE) for more details.
1212

@@ -64,10 +64,13 @@ public class MyCommands implements ClientCommandPlugin {
6464
}
6565
```
6666

67-
And register the plugin entrypoint in your `fabric.mod.json`:
67+
And finally, add the dependency and register the plugin entrypoint in your `fabric.mod.json`:
6868

6969
```json
7070
{
71+
"depends": {
72+
"cotton-client-commands": "^1.0.0"
73+
},
7174
"entrypoints": {
7275
"cotton-client-commands": ["path.to.MyCommands"]
7376
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sourceCompatibility = JavaVersion.VERSION_1_8
88
targetCompatibility = JavaVersion.VERSION_1_8
99

1010
archivesBaseName = 'cotton-client-commands'
11-
version = project.mod_version + (project.snapshot ? '-SNAPSHOT' : '')
11+
version = "$project.mod_version+$project.minecraft_version" + (project.snapshot ? '-SNAPSHOT' : '')
1212
group = project.maven_group
1313

1414
minecraft {

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
maven_group = io.github.cottonmc
2-
mod_version = 1.0.0+1.14.4
2+
mod_version = 1.0.0
33
snapshot = false
44

5-
minecraft_version = 1.14.4
6-
yarn_mappings = 1.14.4+build.15
7-
loader_version = 0.7.2+build.174
5+
minecraft_version = 1.15.2
6+
yarn_mappings = 1.15.2+build.14
7+
loader_version = 0.7.8+build.189

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

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

33
import com.mojang.brigadier.CommandDispatcher;
44

5+
/**
6+
* An initializer that registers client-sided commands.
7+
*/
58
public interface ClientCommandPlugin {
9+
/**
10+
* Implementations can use the {@code dispatcher} to register their commands.
11+
*
12+
* @param dispatcher a client-side command dispatcher
13+
*/
614
void registerCommands(CommandDispatcher<CottonClientCommandSource> dispatcher);
715
}

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

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,33 @@
44
import net.minecraft.server.command.CommandSource;
55

66
/**
7-
* Alternative to {@code ServerCommandSource}.
87
* Contains methods for sending messages to the player.
8+
* Alternative to {@code ServerCommandSource}.
99
*
10-
* (since 0.4.1) This interface is implemented on {@code ClientCommandSource} instances.
10+
* <p>(since 0.4.1) This interface is implemented on {@code ClientCommandSource} instances.
1111
*/
1212
public interface CottonClientCommandSource extends CommandSource {
13-
void sendFeedback(Text text);
13+
/**
14+
* Sends a message to the player (mirrors {@link net.minecraft.server.command.ServerCommandSource#sendFeedback}).
15+
* Equivalent of calling {@code sendFeedback(message, false)}.
16+
*
17+
* @param message the message
18+
*/
19+
void sendFeedback(Text message);
20+
21+
/**
22+
* Sends a message to the player (mirrors {@link net.minecraft.server.command.ServerCommandSource#sendFeedback}).
23+
*
24+
* @param message the message
25+
* @param actionBar true, if the message is displayed on the action bar.
26+
* @since 1.0.0
27+
*/
28+
void sendFeedback(Text message, boolean actionBar);
29+
30+
/**
31+
* Sends an error message to the player (mirrors {@link net.minecraft.server.command.ServerCommandSource#sendError}).
32+
*
33+
* @param text the message
34+
*/
1435
void sendError(Text text);
1536
}

src/main/java/io/github/cottonmc/clientcommands/ClientCommands.java renamed to src/main/java/io/github/cottonmc/clientcommands/impl/ClientCommands.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package io.github.cottonmc.clientcommands;
1+
package io.github.cottonmc.clientcommands.impl;
22

33
import com.google.common.collect.ImmutableList;
4+
import io.github.cottonmc.clientcommands.ClientCommandPlugin;
45
import net.fabricmc.loader.api.FabricLoader;
56
import net.minecraft.util.Lazy;
67

src/main/java/io/github/cottonmc/clientcommands/impl/CommandCache.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.mojang.brigadier.CommandDispatcher;
44
import com.mojang.brigadier.exceptions.CommandSyntaxException;
5-
import io.github.cottonmc.clientcommands.ClientCommands;
65
import io.github.cottonmc.clientcommands.CottonClientCommandSource;
76
import net.fabricmc.api.EnvType;
87
import net.fabricmc.api.Environment;

src/main/java/io/github/cottonmc/clientcommands/mixin/ClientCommandSourceMixin.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ public abstract class ClientCommandSourceMixin implements CottonClientCommandSou
1616
private MinecraftClient client;
1717

1818
@Override
19-
public void sendFeedback(Text text) {
20-
client.player.addChatMessage(text, false);
19+
public void sendFeedback(Text message) {
20+
client.player.addChatMessage(message, false);
21+
}
22+
23+
@Override
24+
public void sendFeedback(Text message, boolean actionBar) {
25+
client.player.addChatMessage(message, actionBar);
2126
}
2227

2328
@Override

src/main/java/io/github/cottonmc/clientcommands/mixin/NetworkHandlerMixin.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
import com.mojang.authlib.GameProfile;
44
import com.mojang.brigadier.CommandDispatcher;
5-
import io.github.cottonmc.clientcommands.ClientCommands;
5+
import io.github.cottonmc.clientcommands.impl.ClientCommands;
66
import io.github.cottonmc.clientcommands.impl.CommandCache;
77
import net.minecraft.client.MinecraftClient;
88
import net.minecraft.client.gui.screen.Screen;
99
import net.minecraft.client.network.ClientPlayNetworkHandler;
10-
import net.minecraft.client.network.packet.CommandTreeS2CPacket;
1110
import net.minecraft.network.ClientConnection;
11+
import net.minecraft.network.packet.s2c.play.CommandTreeS2CPacket;
1212
import net.minecraft.server.command.CommandSource;
1313
import org.spongepowered.asm.mixin.Mixin;
1414
import org.spongepowered.asm.mixin.Shadow;

src/main/java/io/github/cottonmc/clientcommands/mixin/PlayerMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private void onChatMessage(String msg, CallbackInfo info) {
4444
// Prevent sending the message
4545
cancel = true;
4646
} catch (CommandException e) {
47-
addChatMessage(e.getMessageText().formatted(Formatting.RED), false);
47+
addChatMessage(e.getTextMessage().formatted(Formatting.RED), false);
4848
cancel = true;
4949
} catch (CommandSyntaxException e) {
5050
addChatMessage(new LiteralText(e.getMessage()).formatted(Formatting.RED), false);

0 commit comments

Comments
 (0)