use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.
the class AbstractBuildingWorker method serializeToView.
@Override
public void serializeToView(@NotNull final ByteBuf buf) {
super.serializeToView(buf);
buf.writeInt(workers.size());
for (final CitizenData data : workers) {
buf.writeInt(data == null ? 0 : data.getId());
}
final List<IRecipeStorage> storages = new ArrayList<>();
for (final IToken token : new ArrayList<>(recipes)) {
final IRecipeStorage storage = ColonyManager.getRecipeManager().getRecipes().get(token);
if (storage == null) {
removeRecipe(token);
} else {
storages.add(storage);
}
}
buf.writeInt(storages.size());
for (final IRecipeStorage storage : storages) {
ByteBufUtils.writeTag(buf, StandardFactoryController.getInstance().serialize(storage));
}
}
use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.
the class AddRemoveRecipeMessage method messageOnServerThread.
/**
* Executes the message on the server thread.
* Only if the player has the permission, toggle message.
*
* @param message the original message.
* @param player the player associated.
*/
@Override
public void messageOnServerThread(final AddRemoveRecipeMessage message, final EntityPlayerMP player) {
final Colony colony = ColonyManager.getColony(message.colonyId);
if (colony == null || !colony.getPermissions().hasPermission(player, Action.MANAGE_HUTS)) {
return;
}
final AbstractBuilding buildingWorker = colony.getBuildingManager().getBuilding(message.building);
if (buildingWorker instanceof AbstractBuildingWorker) {
final IToken token = ColonyManager.getRecipeManager().checkOrAddRecipe(message.storage);
if (message.remove) {
((AbstractBuildingWorker) buildingWorker).removeRecipe(token);
} else {
((AbstractBuildingWorker) buildingWorker).addRecipe(token);
}
buildingWorker.markDirty();
}
}
use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.
the class BuildingRequestResolverFactory method deserialize.
@NotNull
@Override
public BuildingRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final IToken token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
return new BuildingRequestResolver(location, token);
}
use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.
the class StandardPlayerRequestResolverFactory method deserialize.
@NotNull
@Override
public StandardPlayerRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final IToken token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
final Set<IToken<?>> assignedRequests = NBTUtils.streamCompound(nbt.getTagList(NBT_ASSIGNED_REQUESTS, Constants.NBT.TAG_COMPOUND)).map(c -> (IToken<?>) controller.deserialize(c)).collect(Collectors.toSet());
final StandardPlayerRequestResolver resolver = new StandardPlayerRequestResolver(location, token);
resolver.setAllAssignedRequests(assignedRequests);
return resolver;
}
use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.
the class WarehouseRequestResolverFactory method deserialize.
@NotNull
@Override
public WarehouseRequestResolver deserialize(@NotNull final IFactoryController controller, @NotNull final NBTTagCompound nbt) {
final IToken token = controller.deserialize(nbt.getCompoundTag(NBT_TOKEN));
final ILocation location = controller.deserialize(nbt.getCompoundTag(NBT_LOCATION));
return new WarehouseRequestResolver(location, token);
}
Aggregations