Skip to content

Commit

Permalink
fix: Fix visibility being locked to global if defaultVisibility is se…
Browse files Browse the repository at this point in the history
…t to global
  • Loading branch information
BlayTheNinth committed Oct 24, 2024
1 parent 989331d commit 6fdaca0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.blay09.mods.waystones.api;

import net.blay09.mods.waystones.config.WaystonesConfig;
import net.minecraft.resources.ResourceLocation;

public enum WaystoneVisibility {
Expand Down Expand Up @@ -41,12 +40,12 @@ public static WaystoneVisibility fromWaystoneType(ResourceLocation waystoneType)
case "green_sharestone" -> WaystoneVisibility.GREEN_SHARESTONE;
case "red_sharestone" -> WaystoneVisibility.RED_SHARESTONE;
case "black_sharestone" -> WaystoneVisibility.BLACK_SHARESTONE;
default -> WaystonesConfig.getActive().general.defaultVisibility;
default -> WaystoneVisibility.ACTIVATION;
};
} else if (waystoneType.equals(WaystoneTypes.WARP_PLATE)) {
return WaystoneVisibility.SHARD_ONLY;
} else {
return WaystonesConfig.getActive().general.defaultVisibility;
return WaystoneVisibility.ACTIVATION;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.blay09.mods.waystones.api.Waystone;
import net.blay09.mods.waystones.api.WaystoneVisibility;
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.minecraft.world.entity.player.Player;

import java.util.ArrayList;
Expand All @@ -10,11 +11,17 @@
public class WaystoneVisibilities {
public static List<WaystoneVisibility> getVisibilityOptions(Player player, Waystone waystone) {
final var result = new ArrayList<WaystoneVisibility>();
final var defaultVisibility = WaystonesConfig.getActive().general.defaultVisibility;
result.add(defaultVisibility);
final var baseVisibility = WaystoneVisibility.fromWaystoneType(waystone.getWaystoneType());
result.add(baseVisibility);
if (!result.contains(baseVisibility)) {
result.add(baseVisibility);
}
if (baseVisibility == WaystoneVisibility.ACTIVATION) {
if (WaystonePermissionManager.isAllowedVisibility(WaystoneVisibility.GLOBAL) || WaystonePermissionManager.skipsPermissions(player)) {
result.add(WaystoneVisibility.GLOBAL);
if (!result.contains(WaystoneVisibility.GLOBAL)) {
result.add(WaystoneVisibility.GLOBAL);
}
}
}
return result;
Expand Down

0 comments on commit 6fdaca0

Please sign in to comment.