Skip to content

Commit

Permalink
Merge pull request #245 from sakurawald/dev
Browse files Browse the repository at this point in the history
publish: v6.3.1
  • Loading branch information
sakurawald authored Jan 11, 2025
2 parents 4ad808f + 9b2afdb commit 20eb4c4
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
> The version number of fuji follows `semver` now: https://semver.org/
- (back module): add option `enable_back_on_death` and `enable_back_on_teleport`.
- (anti_build module) fix: the `place_block` anti-type should not throw `NPE` if a non-player (e.g. a dispenser) places a block. (Thanks to @phaldan)
- i18n: new translation for `zh_tw` and `id_id`. (Thanks to @dirtTW)
2 changes: 1 addition & 1 deletion crowdin/id_ID.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"warp.set.success": "<gold>Warp %s diatur.",
"warp.unset.success": "<gold>Warp %s dihapus.",
"warp.gui.title": "<blue>Warp",
"warp.tp.success": "<blue>Teleported to warp %s.",
"warp.tp.success": "<blue>Teleportasi ke warp %s.",
"works.list.add": "<#FFA1F5>Tambah pekerjaan",
"works.list.all_works": "<#FFA1F5>Semua pekerjaan",
"works.list.help.lore": "<green> - Klik kiri -> Kunjungi\n<green> - Klik kanan -> Buka pengaturan umum\n<green> - Shift + Klik kanan -> Buka pengaturan khusus",
Expand Down
2 changes: 1 addition & 1 deletion crowdin/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"warp.set.success": "<gold>傳送點 %s 已設定.",
"warp.unset.success": "<gold>傳送點 %s 已移除.",
"warp.gui.title": "<blue>傳送點",
"warp.tp.success": "<blue>Teleported to warp %s.",
"warp.tp.success": "<blue>已傳送至傳送點 %s。",
"works.list.add": "<#FFA1F5>新增作品",
"works.list.all_works": "<#FFA1F5>所有作品",
"works.list.help.lore": "<green> - 左鍵 -> 參觀\n<green> - 右鍵 -> 開啟通用設定\n<green> - SHIFT + 右鍵 -> 開啟特殊設定",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ org.gradle.parallel=true
# project
maven_group=io.github.sakurawald
mod_id=fuji
mod_version=6.3.0
mod_version=6.3.1

# loader
minecraft_version=1.21.4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,26 @@
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;

public class AntiBuildInitializer extends ModuleInitializer {
public static final BaseConfigurationHandler<AntiBuildConfigModel> config = new ObjectConfigurationHandler<>(BaseConfigurationHandler.CONFIG_JSON, AntiBuildConfigModel.class);

public static <T> void checkAntiBuild(PlayerEntity player, String antiType, Set<String> ids, String id, CallbackInfoReturnable<T> cir, T cancelWithValue, Supplier<Boolean> shouldSendFeedback) {
if ((ids.contains(id) || ids.contains("*"))
&& !PermissionHelper.hasPermission(player.getUuid(), "fuji.anti_build.%s.bypass.%s".formatted(antiType, id))
) {
if ((ids.contains(id) || ids.contains("*")) && !isAllowedByPlayerPermission(player, antiType, id)) {
if (shouldSendFeedback.get()) {
TextHelper.sendMessageByKey(player, "anti_build.disallow");
}

cir.setReturnValue(cancelWithValue);
}
}

private static boolean isAllowedByPlayerPermission(PlayerEntity player, String antiType, String id) {
return Optional.ofNullable(player)
.map(p -> PermissionHelper.hasPermission(player.getUuid(), "fuji.anti_build.%s.bypass.%s".formatted(antiType, id)))
.orElse(true);
}
}

0 comments on commit 20eb4c4

Please sign in to comment.