Skip to content

Commit

Permalink
Add command to leave the teams
Browse files Browse the repository at this point in the history
1.3.1 release
  • Loading branch information
Ivan-Khar committed Jun 23, 2023
1 parent f902900 commit 2a5913f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loader_version=0.14.21
fabric_version=0.84.0+1.20.1

# Mod Properties
mod_version = 1.3.0
mod_version = 1.3.1
maven_group = cn.noryea
archives_base_name = manhunt-fabric

Expand Down
9 changes: 9 additions & 0 deletions src/main/java/cn/noryea/manhunt/ManhuntCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public static void registerCommands(CommandDispatcher<CommandSourceStack> dis, C
.executes((ctx) -> executeTeamLimit(ctx.getSource(), TeamArgument.getTeam(ctx, "team"), IntegerArgumentType.getInteger(ctx, "limit"))))))
.then(Commands.literal("clearTeams").requires((src) -> src.hasPermission(2))
.executes((ctx) -> executeClearTeams(ctx.getSource())))
.then(Commands.literal("leave")
.executes((ctx) -> executeLeave(ctx.getSource())))
.then(Commands.literal("cure").requires((src) -> src.hasPermission(2))
.then(Commands.argument("targets", EntityArgument.players())
.executes((ctx) -> executeCure(ctx.getSource(), EntityArgument.getPlayers(ctx, "targets")))))
Expand Down Expand Up @@ -139,6 +141,13 @@ private static int executeClearTeams(CommandSourceStack source) {
return 1;
}

private static int executeLeave(CommandSourceStack source) {
Scoreboard scoreboard = source.getServer().getScoreboard();
scoreboard.removePlayerFromTeam(source.getPlayer().getScoreboardName());
source.sendSuccess(() -> Component.translatable("commands.team.leave.success.single", source.getPlayer().getDisplayName()), true);
return 1;
}

private static int executeCompassDelay(CommandSourceStack source, Integer delay) {
config.setDelay(delay);
source.sendSuccess(() -> Component.translatable("manhunt.commands.delay", delay), true);
Expand Down

0 comments on commit 2a5913f

Please sign in to comment.