Skip to content

Commit

Permalink
feat: Add defaultVisibility option for newly placed and found waystones
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Oct 24, 2024
1 parent e8a67f3 commit 4c03519
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 @@ -40,12 +41,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 -> WaystoneVisibility.ACTIVATION;
default -> WaystonesConfig.getActive().general.defaultVisibility;
};
} else if (waystoneType.equals(WaystoneTypes.WARP_PLATE)) {
return WaystoneVisibility.SHARD_ONLY;
} else {
return WaystoneVisibility.ACTIVATION;
return WaystonesConfig.getActive().general.defaultVisibility;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public static class General {
public Set<WaystoneOrigin> restrictedWaystones = Set.of(WaystoneOrigin.PLAYER);

@Synced
@Comment("Add GLOBAL to allow every player to create global waystones.")
@Comment("Set to \"GLOBAL\" and change allowedVisibilities to have newly placed or found waystones be global by default.")
public WaystoneVisibility defaultVisibility = WaystoneVisibility.ACTIVATION;

@Synced
@Comment("Add \"GLOBAL\" to allow every player to create global waystones.")
@ExpectedType(WaystoneVisibility.class)
public Set<WaystoneVisibility> allowedVisibilities = Set.of();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.blay09.mods.waystones.block.entity.WaystoneBlockEntityBase;
import net.blay09.mods.waystones.config.InventoryButtonMode;
import net.blay09.mods.waystones.config.WaystonesConfig;
import net.blay09.mods.waystones.config.WaystonesConfigData;
import net.blay09.mods.waystones.worldgen.namegen.NameGenerationMode;
import net.blay09.mods.waystones.worldgen.namegen.NameGeneratorManager;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -36,8 +37,9 @@ public static void activateWaystone(Player player, Waystone waystone) {
((MutableWaystone) waystone).setName(name);
}

if (!waystone.hasOwner() && waystone instanceof MutableWaystone) {
((MutableWaystone) waystone).setOwnerUid(player.getUUID());
if (!waystone.hasOwner() && waystone instanceof MutableWaystone mutableWaystone) {
mutableWaystone.setOwnerUid(player.getUUID());
mutableWaystone.setVisibility(WaystonesConfig.getActive().general.defaultVisibility);
}

if (player.getServer() != null) {
Expand Down Expand Up @@ -163,7 +165,7 @@ public static Collection<Waystone> getTargetsForItem(Player player, ItemStack it
}

public static Collection<Waystone> getTargetsForWaystone(Player player, Waystone waystone) {
final var result = getTargetsForWaystoneType(player, waystone.getWaystoneType());
final var result = getTargetsForWaystoneType(player, waystone.getWaystoneType());

final var blockEntity = player.level().getBlockEntity(waystone.getPos());
if (blockEntity instanceof WaystoneBlockEntityBase waystoneBlockEntity) {
Expand Down

0 comments on commit 4c03519

Please sign in to comment.