diff --git a/src/main/java/com/minecolonies/core/colony/ColonyManager.java b/src/main/java/com/minecolonies/core/colony/ColonyManager.java index 0f1cdb5359c..2ebab0548dc 100755 --- a/src/main/java/com/minecolonies/core/colony/ColonyManager.java +++ b/src/main/java/com/minecolonies/core/colony/ColonyManager.java @@ -648,7 +648,14 @@ public void onWorldLoad(@NotNull final Level w) c.onWorldLoad(world); } - NeoForge.EVENT_BUS.post(new ColonyManagerLoadedEvent(this)); + try + { + NeoForge.EVENT_BUS.post(new ColonyManagerLoadedEvent(this)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyManagerLoadedEvent", e); + } } } @@ -669,7 +676,14 @@ public void onWorldUnload(@NotNull final Level world) BackUpHelper.backupColonyData(world.registryAccess()); } - NeoForge.EVENT_BUS.post(new ColonyManagerUnloadedEvent(this)); + try + { + NeoForge.EVENT_BUS.post(new ColonyManagerUnloadedEvent(this)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyManagerUnloadedEvent", e); + } } } @@ -697,7 +711,14 @@ public void handleColonyViewMessage( } view.handleColonyViewMessage(colonyData, isNewSubscription); - NeoForge.EVENT_BUS.post(new ColonyViewUpdatedEvent(view)); + try + { + NeoForge.EVENT_BUS.post(new ColonyViewUpdatedEvent(view)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyViewUpdatedEvent", e); + } } @Override diff --git a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java b/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java index 9f8dba73086..fe1393043f0 100644 --- a/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java +++ b/src/main/java/com/minecolonies/core/colony/crafting/CustomRecipeManager.java @@ -423,6 +423,13 @@ public void handleCustomRecipeManagerMessage(final RegistryFriendlyByteBuf buff) lootTables.put(id, drops); } - NeoForge.EVENT_BUS.post(new CustomRecipesReloadedEvent()); + try + { + NeoForge.EVENT_BUS.post(new CustomRecipesReloadedEvent()); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CustomRecipesReloadedEvent", e); + } } } diff --git a/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java b/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java index 2c80bbf0a43..df2cbebb83a 100644 --- a/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java +++ b/src/main/java/com/minecolonies/core/colony/interactionhandling/RecruitmentInteraction.java @@ -12,6 +12,7 @@ import com.minecolonies.api.colony.interactionhandling.IInteractionResponseHandler; import com.minecolonies.api.colony.interactionhandling.ModInteractionResponseHandlers; import com.minecolonies.api.util.InventoryUtils; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.MessageUtils; import com.minecolonies.api.util.Tuple; import com.minecolonies.api.util.constant.Constants; @@ -188,7 +189,14 @@ public void onServerResponseTriggered(final int responseId, final Player player, MessageUtils.format(MESSAGE_RECRUITMENT_SUCCESS, data.getName()).sendTo(colony).forAllPlayers(); } - NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.HIRED)); + try + { + NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.HIRED)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CitizenAddedEvent", e); + } } } else diff --git a/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java b/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java index 9f6dd44cf76..a2ad2af23a3 100755 --- a/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java +++ b/src/main/java/com/minecolonies/core/colony/managers/CitizenManager.java @@ -358,8 +358,14 @@ public ICitizenData resurrectCivilianData(@NotNull final CompoundTag compoundNBT citizens.put(citizenData.getId(), citizenData); spawnOrCreateCitizen(citizenData, world, spawnPos); - NeoForge.EVENT_BUS.post(new CitizenAddedEvent(citizenData, CitizenAddedEvent.Source.RESURRECTED)); - + try + { + NeoForge.EVENT_BUS.post(new CitizenAddedEvent(citizenData, CitizenAddedEvent.Source.RESURRECTED)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CitizenAddedEvent", e); + } return citizenData; } @@ -614,8 +620,14 @@ else if (femaleCount < (getCitizens().size() - 1) / 2.0) spawnOrCreateCivilian(newCitizen, colony.getWorld(), null, true); - NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.INITIAL)); - + try + { + NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.INITIAL)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CitizenAddedEvent", e); + } colony.getEventDescriptionManager().addEventDescription(new CitizenSpawnedEvent(colony.getBuildingManager().getTownHall().getPosition(), newCitizen.getName())); } diff --git a/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java b/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java index 0af1737def1..ad334cf3568 100755 --- a/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java +++ b/src/main/java/com/minecolonies/core/commands/citizencommands/CommandCitizenSpawnNew.java @@ -4,6 +4,7 @@ import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyManager; import com.minecolonies.api.colony.citizens.event.CitizenAddedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.core.commands.commandTypes.IMCCommand; import com.minecolonies.core.commands.commandTypes.IMCOPCommand; import com.mojang.brigadier.arguments.IntegerArgumentType; @@ -42,8 +43,14 @@ public int onExecute(final CommandContext context) final ICitizenData newCitizen = colony.getCitizenManager().spawnOrCreateCivilian(null, colony.getWorld(), null, true); context.getSource().sendSuccess(() -> Component.translatableEscape(COMMAND_CITIZEN_SPAWN_SUCCESS, newCitizen.getName()), true); - NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.COMMANDS)); - + try + { + NeoForge.EVENT_BUS.post(new CitizenAddedEvent(newCitizen, CitizenAddedEvent.Source.COMMANDS)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CitizenAddedEvent", e); + } return 1; } diff --git a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java index bce9b9d84c7..24acee2930d 100755 --- a/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java +++ b/src/main/java/com/minecolonies/core/entity/ai/workers/AbstractEntityAIStructureWithWorkOrder.java @@ -423,7 +423,14 @@ public void executeSpecificCompleteActions() if (wo instanceof WorkOrderBuilding) { final IBuilding building = colony.getBuildingManager().getBuilding(wo.getLocation()); - NeoForge.EVENT_BUS.post(new BuildingConstructionEvent(building, BuildingConstructionEvent.EventType.fromWorkOrderType(wo.getWorkOrderType()))); + try + { + NeoForge.EVENT_BUS.post(new BuildingConstructionEvent(building, BuildingConstructionEvent.EventType.fromWorkOrderType(wo.getWorkOrderType()))); + } + catch (final Exception e) + { + Log.getLogger().error("Error during BuildingConstructionEvent", e); + } switch (wo.getWorkOrderType()) { case BUILD: diff --git a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java index 3ebe0bbfdb5..a30a0b006e6 100755 --- a/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java +++ b/src/main/java/com/minecolonies/core/entity/citizen/EntityCitizen.java @@ -1654,7 +1654,14 @@ public void die(@NotNull final DamageSource damageSource) Component.literal(damageSource.getLocalizedDeathMessage(this).getString()).getString().replaceFirst(this.getDisplayName().getString(), "Citizen"); citizenColonyHandler.getColony().getEventDescriptionManager().addEventDescription(new CitizenDiedEvent(blockPosition(), citizenData.getName(), deathCause)); - NeoForge.EVENT_BUS.post(new CitizenRemovedEvent(citizenData, damageSource)); + try + { + NeoForge.EVENT_BUS.post(new CitizenRemovedEvent(citizenData, damageSource)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during CitizenRemovedEvent", e); + } } super.die(damageSource); } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java index c82066db5af..9221649457c 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/CreateColonyMessage.java @@ -7,6 +7,7 @@ import com.minecolonies.api.colony.IColonyManager; import com.minecolonies.api.colony.buildings.IBuilding; import com.minecolonies.api.colony.event.ColonyCreatedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.core.network.messages.client.colony.OpenBuildingUIMessage; import com.minecolonies.core.tileentities.TileEntityColonyBuilding; import com.minecolonies.api.util.BlockPosUtil; @@ -171,8 +172,14 @@ else if (spawnDistance > MineColonies.getConfig().getServer().maxDistanceFromWor new OpenBuildingUIMessage(building).sendToPlayer(sender);; - - NeoForge.EVENT_BUS.post(new ColonyCreatedEvent(createdColony)); + try + { + NeoForge.EVENT_BUS.post(new ColonyCreatedEvent(createdColony)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyCreatedEvent", e); + } return; } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java index e897235a71c..021e78f717e 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyDeleteOwnMessage.java @@ -5,6 +5,7 @@ import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyManager; import com.minecolonies.api.colony.event.ColonyDeletedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.MessageUtils; import com.minecolonies.api.util.constant.Constants; import net.minecraft.network.RegistryFriendlyByteBuf; @@ -51,7 +52,14 @@ protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player) IColonyManager.getInstance().deleteColonyByDimension(colony.getID(), false, colony.getDimension()); MessageUtils.format(MESSAGE_INFO_COLONY_DESTROY_SUCCESS).sendTo(player); - NeoForge.EVENT_BUS.post(new ColonyDeletedEvent(colony)); + try + { + NeoForge.EVENT_BUS.post(new ColonyDeletedEvent(colony)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyDeletedEvent", e); + } } else { diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java index eb61a4aefba..327fe356308 100644 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/ColonyFlagChangeMessage.java @@ -3,6 +3,7 @@ import com.ldtteam.common.network.PlayMessageType; import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.Utils; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; @@ -37,7 +38,14 @@ public ColonyFlagChangeMessage(final IColony colony, final BannerPatternLayers p protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player, final IColony colony) { colony.setColonyFlag(patterns); - NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.FLAG)); + try + { + NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.FLAG)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyInformationChangedEvent", e); + } } @Override diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java index 4a492597a96..424e7028df3 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/TeamColonyColorChangeMessage.java @@ -4,6 +4,7 @@ import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.buildings.views.IBuildingView; import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.ChatFormatting; @@ -65,6 +66,13 @@ protected void toBytes(@NotNull final RegistryFriendlyByteBuf buf) protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player, final IColony colony) { colony.setColonyColor(ChatFormatting.values()[colorOrdinal]); - NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.TEAM_COLOR)); + try + { + NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.TEAM_COLOR)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyInformationChangedEvent", e); + } } } diff --git a/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java b/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java index 2fa19d301ec..2c577c90150 100755 --- a/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java +++ b/src/main/java/com/minecolonies/core/network/messages/server/colony/TownHallRenameMessage.java @@ -4,6 +4,7 @@ import com.minecolonies.api.colony.IColony; import com.minecolonies.api.colony.IColonyView; import com.minecolonies.api.colony.event.ColonyInformationChangedEvent; +import com.minecolonies.api.util.Log; import com.minecolonies.api.util.constant.Constants; import com.minecolonies.core.network.messages.server.AbstractColonyServerMessage; import net.minecraft.network.RegistryFriendlyByteBuf; @@ -53,6 +54,13 @@ protected void toBytes(@NotNull final RegistryFriendlyByteBuf buf) protected void onExecute(final IPayloadContext ctxIn, final ServerPlayer player, final IColony colony) { colony.setName(name); - NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.NAME)); + try + { + NeoForge.EVENT_BUS.post(new ColonyInformationChangedEvent(colony, ColonyInformationChangedEvent.Type.NAME)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during ColonyInformationChangedEvent", e); + } } } diff --git a/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java b/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java index eb028f851f4..aa9adb93c71 100644 --- a/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java +++ b/src/main/java/com/minecolonies/core/placementhandlers/main/SurvivalHandler.java @@ -173,7 +173,14 @@ public void handle( rotMir, packName, blueprintPath); - NeoForge.EVENT_BUS.post(new BlockEvent.EntityPlaceEvent(BlockSnapshot.create(world.dimension(), world, blockPos), world.getBlockState(blockPos.below()), player)); + try + { + NeoForge.EVENT_BUS.post(new BlockEvent.EntityPlaceEvent(BlockSnapshot.create(world.dimension(), world, blockPos), world.getBlockState(blockPos.below()), player)); + } + catch (final Exception e) + { + Log.getLogger().error("Error during EntityPlaceEvent", e); + } InventoryUtils.reduceStackInItemHandler(new InvWrapper(player.getInventory()), inventoryStack, 1); if (tempColony == null)