Skip to content

Commit

Permalink
[proxy] check rank
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Apr 18, 2022
1 parent 1b5e8fc commit 517f1eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.io.DataInputStream;
import java.io.IOException;
import java.time.Instant;
import java.util.List;
import java.util.Objects;
import java.util.UUID;

Expand All @@ -45,8 +46,18 @@ public void handle(@NotNull PacketSender sender, @NotNull ProxyboundSetRankMessa
if (!track.containsGroup(msg.getRank())) {
throw new IllegalArgumentException("Group is not in a track: " + msg.getRank());
}
boolean modified = false;
NodeMap nodes = user.getData(DataType.NORMAL);
List<String> groups = track.getGroups();
int rankIndex = groups.indexOf(msg.getRank());
for (String group : groups) {
if (LuckPermsUtil.findNode(nodes, group, msg.getServer()) != null) {
if (groups.indexOf(group) >= rankIndex) {
throw new IllegalArgumentException(msg.getPlayer().getUsernameOrUniqueId() +
" already inherits the same or higher rank in the track: " + msg.getRank());
}
}
}
boolean modified = false;
for (String group : track.getGroups()) {
if (msg.getServer().equals(group)) continue;
Node node = LuckPermsUtil.findNode(nodes, group, msg.getServer());
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "net.azisaba.azipluginmessaging"
version = "2.1.1"
version = "2.1.2"

repositories {
mavenCentral()
Expand Down

0 comments on commit 517f1eb

Please sign in to comment.