Skip to content

Commit 86a916e

Browse files
committed
feat: feedback message to player when interaction prevented
FTBTeam/FTB-Mods-Issues#60
1 parent 1036835 commit 86a916e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

common/src/main/java/dev/ftb/mods/ftbchunks/data/ClaimedChunkManagerImpl.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import dev.ftb.mods.ftbchunks.FTBChunks;
66
import dev.ftb.mods.ftbchunks.FTBChunksExpected;
77
import dev.ftb.mods.ftbchunks.FTBChunksWorldConfig;
8+
import dev.ftb.mods.ftbchunks.PlayerNotifier;
89
import dev.ftb.mods.ftbchunks.api.ClaimedChunk;
910
import dev.ftb.mods.ftbchunks.api.ClaimedChunkManager;
1011
import dev.ftb.mods.ftbchunks.api.Protection;
@@ -16,6 +17,7 @@
1617
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
1718
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
1819
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
20+
import net.minecraft.ChatFormatting;
1921
import net.minecraft.core.BlockPos;
2022
import net.minecraft.nbt.CompoundTag;
2123
import net.minecraft.network.chat.Component;
@@ -213,8 +215,11 @@ public boolean shouldPreventInteraction(@Nullable Entity actor, InteractionHand
213215
boolean prevented = policy.isOverride() ?
214216
policy.shouldPreventInteraction() :
215217
!player.isSpectator() && (isFake || !getBypassProtection(player.getUUID()));
216-
if (prevented && isFake) {
217-
chunk.getTeamData().logPreventedAccess(player, System.currentTimeMillis());
218+
if (prevented) {
219+
PlayerNotifier.notifyWithCooldown(player, Component.translatable("ftbchunks.action_prevented").withStyle(ChatFormatting.GOLD), 2000);
220+
if (isFake) {
221+
chunk.getTeamData().logPreventedAccess(player, System.currentTimeMillis());
222+
}
218223
}
219224
return prevented;
220225
} else if (FTBChunksWorldConfig.noWilderness(player)) {
@@ -224,7 +229,7 @@ public boolean shouldPreventInteraction(@Nullable Entity actor, InteractionHand
224229
} else if (!isFake && (getBypassProtection(player.getUUID()) || player.isSpectator())) {
225230
return false;
226231
}
227-
player.displayClientMessage(Component.translatable("ftbchunks.need_to_claim_chunk"), true);
232+
PlayerNotifier.notifyWithCooldown(player, Component.translatable("ftbchunks.need_to_claim_chunk").withStyle(ChatFormatting.GOLD), 2000);
228233
return true;
229234
}
230235

common/src/main/resources/assets/ftbchunks/lang/en_us.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@
220220
"ftbchunks.claim_result.already_loaded": "Chunk already loaded",
221221
"ftbchunks.claim_result.not_loaded": "Chunk not loaded",
222222
"ftbchunks.need_to_claim_chunk": "You need to claim this chunk to interact with blocks here!",
223+
"ftbchunks.action_prevented": "Interaction prevented here by claim protection!",
223224
"ftbchunks.label.show": "Show",
224225
"ftbchunks.label.hide": "Hide",
225226
"ftbchunks.message.no_pvp": "PvP combat is disabled here",

0 commit comments

Comments
 (0)