use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.
the class WindowWorkOrderPage method updatePriority.
/**
* On Button click update the priority.
*
* @param button the clicked button.
*/
private void updatePriority(@NotNull final Button button) {
final int id = Integer.parseInt(button.getParent().findPaneOfTypeByID("hiddenId", Text.class).getTextAsString());
final String buttonLabel = button.getID();
for (int i = 0; i < workOrders.size(); i++) {
final IWorkOrderView workOrder = workOrders.get(i);
if (workOrder.getId() == id) {
if (buttonLabel.equals(BUTTON_UP) && i > 0) {
workOrder.setPriority(workOrders.get(i - 1).getPriority() + 1);
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
} else if (buttonLabel.equals(BUTTON_DOWN) && i <= workOrders.size()) {
workOrder.setPriority(workOrders.get(i + 1).getPriority() - 1);
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, false, workOrder.getPriority()));
}
sortWorkOrders();
window.findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class).refreshElementPanes();
return;
}
}
}
use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.
the class WorkOrderModuleWindow method selectWorkOrder.
/**
* On click select the clicked work order.
*
* @param button the clicked button.
*/
private void selectWorkOrder(@NotNull final Button button) {
final int row = workOrdersList.getListElementIndexByPane(button);
final IWorkOrderView view = workOrders.get(row);
if (view.getClaimedBy().equals(buildingView.getPosition())) {
view.setClaimedBy(buildingView.getPosition());
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(buildingView, view.getId(), true, 0));
} else {
Network.getNetwork().sendToServer(new BuilderSelectWorkOrderMessage(buildingView, view.getId()));
}
}
use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by Minecolonies.
the class WindowWorkOrderPage method deleteWorkOrder.
/**
* On Button click remove the workOrder.
*
* @param button the clicked button.
*/
private void deleteWorkOrder(@NotNull final Button button) {
final int id = Integer.parseInt(button.getParent().findPaneOfTypeByID("hiddenId", Text.class).getTextAsString());
for (int i = 0; i < workOrders.size(); i++) {
if (workOrders.get(i).getId() == id) {
workOrders.remove(i);
break;
}
}
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(this.building, id, true, 0));
window.findPaneOfTypeByID(LIST_WORKORDER, ScrollingList.class).refreshElementPanes();
}
use of com.minecolonies.coremod.network.messages.server.colony.WorkOrderChangeMessage in project minecolonies by ldtteam.
the class WorkOrderModuleWindow method selectWorkOrder.
/**
* On click select the clicked work order.
*
* @param button the clicked button.
*/
private void selectWorkOrder(@NotNull final Button button) {
final int row = workOrdersList.getListElementIndexByPane(button);
final WorkOrderView view = workOrders.get(row);
if (view.getClaimedBy().equals(buildingView.getPosition())) {
view.setClaimedBy(buildingView.getPosition());
Network.getNetwork().sendToServer(new WorkOrderChangeMessage(buildingView, view.getId(), true, 0));
} else {
Network.getNetwork().sendToServer(new BuilderSelectWorkOrderMessage(buildingView, view.getId()));
}
}
Aggregations