Skip to content

Commit 7c5ef86

Browse files
committed
fixed permission check to change other player's tags
1 parent b80a9e5 commit 7c5ef86

File tree

4 files changed

+9
-123
lines changed

4 files changed

+9
-123
lines changed

LICENSE_FABRIC

Lines changed: 0 additions & 121 deletions
This file was deleted.

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ yarn_mappings=1.21.4+build.8
99
loader_version=0.16.10
1010

1111
# Mod Properties
12-
mod_version=1.0.0
12+
mod_version=1.0.1
1313
maven_group=maloschnikow.playertags
1414
archives_base_name=player-tags
1515

src/main/java/maloschnikow/playertags/commands/CommandCustomPlayerTagRemove.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.mojang.brigadier.context.CommandContext;
55
import com.mojang.brigadier.exceptions.CommandSyntaxException;
66

7+
import maloschnikow.playertags.WrongPermissionLevelMessage;
78
import net.minecraft.command.argument.EntityArgumentType;
89
import net.minecraft.scoreboard.Team;
910
import net.minecraft.server.command.ServerCommandSource;
@@ -17,6 +18,12 @@ public int run(CommandContext<ServerCommandSource> context) throws CommandSyntax
1718

1819
//get arguments
1920
ServerPlayerEntity player = EntityArgumentType.getPlayer(context, "player");
21+
ServerCommandSource commandSource = context.getSource();
22+
23+
//check if player has permission to remove other players tag
24+
if( (!commandSource.hasPermissionLevel(2)) && player != commandSource.getPlayer() ) {
25+
throw new CommandSyntaxException(null, new WrongPermissionLevelMessage(2, "remove another player's tag"));
26+
}
2027

2128
Team playerTeam = player.getServer().getScoreboard().getTeam(player.getUuidAsString());
2229
player.getServer().getScoreboard().removeTeam(playerTeam);

src/main/java/maloschnikow/playertags/commands/CommandCustomPlayerTagSet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public int run(CommandContext<ServerCommandSource> context) throws CommandSyntax
3939

4040

4141
//check if player has permission to change other players tag
42-
if( !commandSource.hasPermissionLevel(2) && player != commandSource.getPlayer() ) {
42+
if( (!commandSource.hasPermissionLevel(2)) && player != commandSource.getPlayer() ) {
4343
throw new CommandSyntaxException(null, new WrongPermissionLevelMessage(2, "change another player's tag"));
4444
}
4545

0 commit comments

Comments
 (0)