Skip to content

Commit

Permalink
Version 0.3
Browse files Browse the repository at this point in the history
*add support for version 1.21

*fixed suggestions in commands
  • Loading branch information
I-No-oNe committed Jun 13, 2024
1 parent 52b9dd0 commit 92b6868
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.3
minecraft_version=1.21
yarn_mappings=1.21+build.1
loader_version=0.15.11

# Mod Properties
mod_version=0.2-1.20.6-fabric
mod_version=0.3-1.21-fabric
maven_group=net.i_no_am.attackblocker
archives_base_name=attack-blocker

# Dependencies
fabric_version=0.99.0+1.20.6
fabric_version=0.100.1+1.21
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
// Removing Players from Can't Attack List
.then(ClientCommandManager.literal("remove")
.then(ClientCommandManager.argument("player name", StringArgumentType.word())
.suggests(Utils.playerNameSuggestions())
.suggests(Utils.playersInConfig())
.executes(context -> removeCantAttack(context.getSource(), StringArgumentType.getString(context, "player name")))))
// Color Command
.then(ClientCommandManager.literal("color")
.then(ClientCommandManager.argument("player name", StringArgumentType.word())
.suggests(Utils.playerNameSuggestions())
.suggests(Utils.playersInConfig())
.then(ClientCommandManager.argument("color", StringArgumentType.word())
.suggests(Utils.colorSuggestions())
.executes(context -> setColor(context.getSource(), StringArgumentType.getString(context, "player name"), StringArgumentType.getString(context, "color"))))))
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/net/i_no_am/attackblocker/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,20 @@ public class Utils {
public static void clientMessage(String message, FabricClientCommandSource source) {
source.sendFeedback(Text.of(PREFIX + message));
}

public static void clientMessageWithoutPrefix(String message, FabricClientCommandSource source) {
source.sendFeedback(Text.of(message));
}
public static void playerMessage(String message, ClientPlayNetworkHandler clientPlayNetworkHandler){

public static void playerMessage(String message, ClientPlayNetworkHandler clientPlayNetworkHandler) {
clientPlayNetworkHandler.sendChatMessage(message);
}

public static boolean canAttack(PlayerEntity ignoreattacker, PlayerEntity target) {
String targetName = target.getName().getString();
return Configuration.isEnabled() && !Configuration.getBlockedPlayers().contains(targetName);
}

public static SuggestionProvider<FabricClientCommandSource> colorSuggestions() {
return (context, builder) -> {
for (String color : COLORS) {
Expand All @@ -37,6 +41,13 @@ public static SuggestionProvider<FabricClientCommandSource> colorSuggestions() {
return builder.buildFuture();
};
}

public static SuggestionProvider<FabricClientCommandSource> playersInConfig() {
return (context, builder) -> {
Configuration.getBlockedPlayers().forEach(builder::suggest);
return builder.buildFuture();
};
}
public static SuggestionProvider<FabricClientCommandSource> playerNameSuggestions() {
return (context, builder) -> {
Objects.requireNonNull(MinecraftClient.getInstance().getNetworkHandler()).getPlayerList().forEach(entry -> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
],
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": "~1.20.6",
"minecraft": ">=1.21",
"java": ">=21",
"fabric-api": "*"
},
Expand Down

0 comments on commit 92b6868

Please sign in to comment.