Search in sources :

Example 1 with ColonyViewRemoveCitizenMessage

use of com.minecolonies.coremod.network.messages.ColonyViewRemoveCitizenMessage in project minecolonies by Minecolonies.

the class CitizenManager method removeCitizen.

@Override
public void removeCitizen(@NotNull final CitizenData citizen) {
    // Remove the Citizen
    citizens.remove(citizen.getId());
    if (citizen.getWorkBuilding() != null) {
        citizen.getWorkBuilding().cancelAllRequestsOfCitizen(citizen);
    }
    if (citizen.getHomeBuilding() != null) {
        citizen.getHomeBuilding().cancelAllRequestsOfCitizen(citizen);
    }
    for (@NotNull final AbstractBuilding building : colony.getBuildingManager().getBuildings().values()) {
        building.removeCitizen(citizen);
    }
    colony.getWorkManager().clearWorkForCitizen(citizen);
    // Inform Subscribers of removed citizen
    for (final EntityPlayerMP player : colony.getPackageManager().getSubscribers()) {
        MineColonies.getNetwork().sendTo(new ColonyViewRemoveCitizenMessage(colony, citizen.getId()), player);
    }
    colony.markDirty();
}
Also used : ColonyViewRemoveCitizenMessage(com.minecolonies.coremod.network.messages.ColonyViewRemoveCitizenMessage) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ColonyViewRemoveCitizenMessage (com.minecolonies.coremod.network.messages.ColonyViewRemoveCitizenMessage)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NotNull (org.jetbrains.annotations.NotNull)1