Search in sources :

Example 1 with AssignUnassignMessage

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

the class WindowAssignCitizen method onButtonClicked.

/**
 * Called when any button has been clicked.
 *
 * @param button the clicked button.
 */
@Override
public void onButtonClicked(@NotNull final Button button) {
    if (button.getID().equals(BUTTON_DONE)) {
        final int row = citizenList.getListElementIndexByPane(button);
        final CitizenDataView data = citizens.get(row);
        if (building instanceof BuildingHome.View) {
            ((BuildingHome.View) building).addResident(data.getId());
        }
        MineColonies.getNetwork().sendToServer(new AssignUnassignMessage(this.building, true, data.getId()));
    } else if (!button.getID().equals(BUTTON_CANCEL)) {
        return;
    }
    if (colony.getTownHall() != null) {
        building.openGui(false);
    }
}
Also used : AssignUnassignMessage(com.minecolonies.coremod.network.messages.AssignUnassignMessage) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) CitizenDataView(com.minecolonies.coremod.colony.CitizenDataView) ColonyView(com.minecolonies.coremod.colony.ColonyView) AbstractBuildingView(com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)

Example 2 with AssignUnassignMessage

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

the class WindowHomeBuilding method removeClicked.

/**
 * Action when the remove button is clicked.
 *
 * @param button the clicked button.
 */
private void removeClicked(@NotNull final Button button) {
    if (building.getColony().isManualHousing()) {
        final int row = citizen.getListElementIndexByPane(button);
        final int citizenid = home.getResidents().get(row);
        home.removeResident(row);
        MineColonies.getNetwork().sendToServer(new AssignUnassignMessage(building, false, citizenid));
        refreshView();
    }
}
Also used : AssignUnassignMessage(com.minecolonies.coremod.network.messages.AssignUnassignMessage)

Aggregations

AssignUnassignMessage (com.minecolonies.coremod.network.messages.AssignUnassignMessage)2 CitizenDataView (com.minecolonies.coremod.colony.CitizenDataView)1 ColonyView (com.minecolonies.coremod.colony.ColonyView)1 AbstractBuildingView (com.minecolonies.coremod.colony.buildings.views.AbstractBuildingView)1