Skip to content

Commit c71c16b

Browse files
committed
0.8.17
1 parent 3860cf2 commit c71c16b

File tree

6 files changed

+23
-32
lines changed

6 files changed

+23
-32
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ mod_name=Area Control
3434
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
3535
mod_license=BSD-3-Clause
3636
# The mod version. See https://semver.org/
37-
mod_version=0.8.16
37+
mod_version=0.8.17
3838
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
3939
# This should match the base package used for the mod sources.
4040
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

src/main/java/org/teacon/areacontrol/AreaControl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
@Mod("area_control")
3535
@EventBusSubscriber(modid = "area_control")
3636
public final class AreaControl {
37+
public static String VERSION = "<not_initialized>";
3738

3839
private static final Logger LOGGER = LoggerFactory.getLogger("AreaControl");
3940

@@ -42,6 +43,8 @@ public final class AreaControl {
4243
public static Predicate<MinecraftServer> singlePlayerServerChecker;
4344

4445
public AreaControl(ModContainer container, IEventBus modBus) {
46+
VERSION = container.getModInfo().getVersion().toString();
47+
4548
AreaRepositoryManager.init();
4649
container.registerConfig(ModConfig.Type.SERVER, AreaControlConfig.setup(new ModConfigSpec.Builder()));
4750
singlePlayerServerChecker = switch (FMLEnvironment.dist) {

src/main/java/org/teacon/areacontrol/AreaControlCommand.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414
import net.minecraft.core.BlockPos;
1515
import net.minecraft.core.Direction;
1616
import net.minecraft.core.SectionPos;
17-
import net.minecraft.core.registries.BuiltInRegistries;
1817
import net.minecraft.network.chat.ClickEvent;
1918
import net.minecraft.network.chat.Component;
2019
import net.minecraft.network.chat.HoverEvent;
2120
import net.minecraft.network.chat.Style;
2221
import net.minecraft.resources.ResourceKey;
23-
import net.minecraft.resources.ResourceLocation;
2422
import net.minecraft.server.level.ServerPlayer;
25-
import net.minecraft.world.item.ItemStack;
2623
import net.minecraft.world.level.ChunkPos;
2724
import net.minecraft.world.level.Level;
2825
import net.minecraft.world.phys.AABB;
@@ -81,7 +78,6 @@ public AreaControlCommand(CommandDispatcher<CommandSourceStack> dispatcher) {
8178
dispatcher.register(Commands.literal("ac")
8279
.redirect(dispatcher.register(Commands.literal("areacontrol")
8380
.then(Commands.literal("about").executes(AreaControlCommand::about))
84-
.then(Commands.literal("help").executes(AreaControlCommand::help))
8581
.then(Commands.literal("admin").requires(ADMIN)
8682
.then(Commands.literal("rebuild").executes(AreaControlCommand::rebuildAreaModel))
8783
)
@@ -211,21 +207,7 @@ private static int openConfiscatedItemInv(CommandContext<CommandSourceStack> con
211207
}
212208

213209
private static int about(CommandContext<CommandSourceStack> context) {
214-
context.getSource().sendSuccess(() -> Component.literal("AreaControl 0.8.16"), false);
215-
return Command.SINGLE_SUCCESS;
216-
}
217-
218-
private static int help(CommandContext<CommandSourceStack> context) {
219-
var markerTool = new ItemStack(BuiltInRegistries.ITEM.get(ResourceLocation.parse(AreaControlConfig.areaClaimTool.get())));
220-
var markerToolName = markerTool.getDisplayName();
221-
var displayName = markerToolName.copy()
222-
.withStyle(Style.EMPTY
223-
.withColor(ChatFormatting.BLUE)
224-
.withUnderlined(Boolean.TRUE)
225-
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, markerTool.getHoverName().copy()
226-
.append(Component.translatable("area_control.claim.how_to.give_item").withStyle(ChatFormatting.GRAY))))
227-
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/give @s " + AreaControlConfig.areaClaimTool.get())));
228-
context.getSource().sendSuccess(() -> Component.translatable("area_control.claim.how_to", displayName), false);
210+
context.getSource().sendSuccess(() -> Component.literal("AreaControl " + AreaControl.VERSION), false);
229211
return Command.SINGLE_SUCCESS;
230212
}
231213

src/main/java/org/teacon/areacontrol/impl/AreaChecks.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.teacon.areacontrol.impl.seizer.ConfiscationInv;
2525

2626
import java.util.List;
27+
import java.util.Optional;
2728
import java.util.function.Supplier;
2829

2930
public class AreaChecks {
@@ -111,14 +112,17 @@ public static void checkInv(IItemHandler inv, Area currentArea, Player player) {
111112
// This is a separate method because area.allow_possess currently has a different logic
112113
public static boolean checkPossess(Area area, Item item) {
113114
var targetId = BuiltInRegistries.ITEM.getKey(item);
114-
if (targetId != null) {
115-
var objSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId);
116-
if (objSpecific.isPresent()) {
117-
return objSpecific.get();
115+
var objSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId);
116+
if (objSpecific.isPresent()) {
117+
return objSpecific.get();
118+
} else {
119+
var modSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId.getNamespace());
120+
if (modSpecific.isPresent()) {
121+
return modSpecific.get();
118122
} else {
119-
var modSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS + "." + targetId.getNamespace());
120-
if (modSpecific.isPresent()) {
121-
return modSpecific.get();
123+
Optional<Boolean> globalSpecific = AreaProperties.getBoolOptional(area, AreaProperties.ALLOW_POSSESS);
124+
if (globalSpecific.isPresent()) {
125+
return globalSpecific.get();
122126
}
123127
}
124128
}

src/main/java/org/teacon/areacontrol/network/ACNetworking.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import net.minecraft.server.level.ServerPlayer;
77
import net.neoforged.neoforge.network.PacketDistributor;
88
import net.neoforged.neoforge.network.event.RegisterPayloadHandlersEvent;
9+
import net.neoforged.neoforge.network.registration.HandlerThread;
910
import net.neoforged.neoforge.network.registration.PayloadRegistrar;
1011
import org.jetbrains.annotations.Nullable;
12+
import org.teacon.areacontrol.AreaControl;
1113

1214
public class ACNetworking {
1315
public static void init(RegisterPayloadHandlersEvent event) {
14-
PayloadRegistrar registrar = event.registrar("area_control")
15-
.versioned("0.8.16")
16-
.optional();
16+
PayloadRegistrar registrar = event.registrar(AreaControl.VERSION).executesOn(HandlerThread.NETWORK).optional();
1717

1818
registrar.playToServer(ACPingServer.TYPE, ACPingServer.STREAM_CODEC, ACPingServer::handle);
1919
registrar.playToClient(ACSendNearbyArea.TYPE, ACSendNearbyArea.STREAM_CODEC, ACSendNearbyArea::handle);

src/main/java/org/teacon/areacontrol/network/ACPingServer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ public void encode(@NotNull ByteBuf o, @NotNull ACPingServer instance) {
2424
};
2525

2626
public void handle(IPayloadContext context) {
27-
var player = context.player();
28-
AreaControlPlayerTracker.getFrom(player).clientExtensionEnabled = true;
27+
context.enqueueWork(() -> {
28+
var player = context.player();
29+
AreaControlPlayerTracker.getFrom(player).clientExtensionEnabled = true;
30+
});
2931
}
3032

3133
@Override

0 commit comments

Comments
 (0)