|
4 | 4 |
|
5 | 5 | import net.minecraft.network.chat.Component; |
6 | 6 | import net.minecraft.resources.ResourceLocation; |
| 7 | +import net.minecraft.server.MinecraftServer; |
7 | 8 | import net.minecraft.server.level.ServerPlayer; |
8 | 9 | import net.minecraft.world.entity.Entity; |
9 | 10 | import net.minecraft.world.entity.player.Player; |
@@ -141,16 +142,36 @@ public static boolean checkPossess(Area area, Item item) { |
141 | 142 | public static boolean checkPropFor(final @Nullable Area area, final @Nullable Entity actor, |
142 | 143 | final @NotNull String prop, final @Nullable ResourceLocation targetId, |
143 | 144 | final @Nullable Supplier<@NotNull Boolean> defaultValue) { |
| 145 | + return checkPropFor(area, actor, null, prop, targetId, defaultValue); |
| 146 | + } |
| 147 | + |
| 148 | + /** |
| 149 | + * Recursively checks if an action is allowed in given area |
| 150 | + * |
| 151 | + * @param area Area to check |
| 152 | + * @param actor The entity that carries out the action |
| 153 | + * @param currentServer The current server instance we are in |
| 154 | + * @param prop The action, represented by a string property |
| 155 | + * @param targetId The object on which the action is being carried out. |
| 156 | + * @return true if such action is allowed; false otherwise. |
| 157 | + */ |
| 158 | + public static boolean checkPropFor(final @Nullable Area area, final @Nullable Entity actor, |
| 159 | + @Nullable MinecraftServer currentServer, |
| 160 | + final @NotNull String prop, final @Nullable ResourceLocation targetId, |
| 161 | + final @Nullable Supplier<@NotNull Boolean> defaultValue) { |
144 | 162 | if (actor != null) { |
145 | | - // If actor is in single-player (without being published to LAN), then skip all checks. |
146 | | - if (AreaControl.singlePlayerServerChecker.test(actor.getServer())) { |
147 | | - return true; |
| 163 | + if (currentServer == null) { |
| 164 | + currentServer = actor.getServer(); |
148 | 165 | } |
149 | 166 | // If bypass mode is activated, then skip all checks. |
150 | 167 | if (AreaControlPlayerTracker.hasBypassModeOnForArea(actor, area)) { |
151 | 168 | return true; |
152 | 169 | } |
153 | 170 | } |
| 171 | + // If we are in single-player (without being published to LAN), then skip all checks. |
| 172 | + if (AreaControl.singlePlayerServerChecker.test(currentServer)) { |
| 173 | + return true; |
| 174 | + } |
154 | 175 | if (targetId != null) { |
155 | 176 | var objSpecific = AreaProperties.getBoolOptional(area, prop + "." + targetId); |
156 | 177 | if (objSpecific.isPresent()) { |
|
0 commit comments