Skip to content

Commit 77a55fa

Browse files
committed
properly check permissions in guis
1 parent 28586e1 commit 77a55fa

File tree

8 files changed

+14
-15
lines changed

8 files changed

+14
-15
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ yarn_mappings=1.21.4+build.1
66
loader_version=0.16.9
77

88
# Mod Properties
9-
mod_version = 2.7.0
9+
mod_version = 2.7.1
1010
maven_group = io.icker
1111
archives_base_name = factions
1212

src/main/java/io/icker/factions/command/ClaimCommand.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,12 @@ private int addForced(CommandContext<ServerCommandSource> context, int size)
8989
if (existingClaim != null) {
9090
if (size == 1) {
9191
String owner =
92-
existingClaim.getFaction().getID() == faction.getID()
93-
? "Your"
94-
: "Another";
92+
existingClaim.getFaction().equals(faction) ? "Your" : "Another";
9593
new Message(owner + " faction already owns this chunk")
9694
.fail()
9795
.send(player, false);
9896
return 0;
99-
} else if (existingClaim.getFaction().getID() != faction.getID()) {
97+
} else if (!existingClaim.getFaction().equals(faction)) {
10098
new Message("Another faction already owns a chunk")
10199
.fail()
102100
.send(player, false);
@@ -220,7 +218,7 @@ private int removeSize(CommandContext<ServerCommandSource> context)
220218
Claim existingClaim = Claim.get(chunkPos.x, chunkPos.z, dimension);
221219

222220
if (existingClaim != null
223-
&& (user.bypass || existingClaim.getFaction().getID() == faction.getID()))
221+
&& (user.bypass || existingClaim.getFaction().equals(faction)))
224222
existingClaim.remove();
225223
}
226224
}

src/main/java/io/icker/factions/core/InteractionManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ private static ActionResult isInvulnerableTo(Entity source, Entity target) {
190190
Faction sourceFaction = sourceUser.getFaction();
191191
Faction targetFaction = targetUser.getFaction();
192192

193-
if (sourceFaction.getID() == targetFaction.getID()) {
193+
if (sourceFaction.equals(targetFaction)) {
194194
return ActionResult.SUCCESS;
195195
}
196196

@@ -233,7 +233,7 @@ private static ActionResult checkPermissions(
233233

234234
Faction userFaction = user.getFaction();
235235

236-
if (claimFaction == userFaction
236+
if (claimFaction.equals(userFaction)
237237
&& (getRankLevel(claim.accessLevel) <= getRankLevel(user.rank)
238238
|| (user.rank == User.Rank.GUEST
239239
&& claimFaction.guest_permissions.contains(permission)

src/main/java/io/icker/factions/ui/InfoGui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public InfoGui(ServerPlayerEntity player, Faction faction, @Nullable Runnable cl
3838
UserCache cache = server.getUserCache();
3939

4040
User user = User.get(player.getUuid());
41-
boolean isMember = faction == user.getFaction();
41+
boolean isMember = faction.equals(user.getFaction());
4242
List<User> members = faction.getUsers();
4343

4444
String owner =
@@ -243,7 +243,7 @@ public InfoGui(ServerPlayerEntity player, Faction faction, @Nullable Runnable cl
243243
.formatted(Formatting.GREEN)))
244244
.setLore(enemies));
245245

246-
if (Command.Requires.isOwner().test(player.getCommandSource())) {
246+
if (Command.Requires.isOwner().test(player.getCommandSource()) && isMember) {
247247
this.setSlot(
248248
6,
249249
new GuiElementBuilder(Items.PLAYER_HEAD)

src/main/java/io/icker/factions/ui/ListGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected DisplayElement getElement(int id) {
5353
if (this.size > id) {
5454
var faction = this.factions.get(id);
5555

56-
boolean isInFaction = this.user.getFaction() == faction;
56+
boolean isInFaction = this.user.getFaction().equals(faction);
5757
Home home = faction.getHome();
5858

5959
var icon = new GuiElementBuilder(Items.PLAYER_HEAD);

src/main/java/io/icker/factions/ui/MemberGui.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected DisplayElement getElement(int id) {
7777
icon.setComponent(DataComponentTypes.PROFILE, new ProfileComponent(profile));
7878
icon.setName(Text.literal(profile.getName()));
7979

80-
if (profile == unknownPlayer) {
80+
if (profile.equals(unknownPlayer)) {
8181
List<Text> lore =
8282
List.of(
8383
Text.literal("No info available")
@@ -108,7 +108,8 @@ protected DisplayElement getElement(int id) {
108108
if (!profile.getId().equals(player.getUuid())
109109
&& Command.Requires.isLeader().test(player.getCommandSource())
110110
&& Command.Requires.hasPerms("factions.rank.promote", 0)
111-
.test(player.getCommandSource())) {
111+
.test(player.getCommandSource())
112+
&& user.getFaction().equals(faction)) {
112113
lore.add(
113114
Text.literal("Click to promote.")
114115
.setStyle(

src/main/java/io/icker/factions/util/BlueMapWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ private void setHome(Faction faction, Home home) {
164164
}
165165

166166
for (Map.Entry<String, MarkerSet> entry : markerSets.entrySet()) {
167-
if (entry.getKey() == home.level) {
167+
if (entry.getKey().equals(home.level)) {
168168
continue;
169169
}
170170

src/main/java/io/icker/factions/util/SquareMapWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void setHome(Faction faction, Home home) {
158158
}
159159

160160
for (Map.Entry<String, SimpleLayerProvider> entry : layers.entrySet()) {
161-
if (entry.getKey() == home.level) {
161+
if (entry.getKey().equals(home.level)) {
162162
continue;
163163
}
164164

0 commit comments

Comments
 (0)